Skip to content

Commit e6c2112

Browse files
authored
Add retryable fields to notion (#79)
* add feeRefundAddress, beneficiary and l2CallValue to retryable report * add feeRefundAddress, beneficiary, retryTo and retryData to failed retryable sync * update notion sync to add new retryable fields and drop TotalRetryableDeposit * use L2CallValue and TokensDeposited for total deposit in alerts * truncate long Notion rich_text fields
1 parent fad3851 commit e6c2112

File tree

5 files changed

+64
-16
lines changed

5 files changed

+64
-16
lines changed

packages/retryable-monitor/core/reportGenerator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export const getChildChainRetryableReport = async ({
5454
retryData: retryableMessage.messageData.data,
5555
gasFeeCap: (childChainTx.maxFeePerGas ?? BigNumber.from(0)).toNumber(),
5656
gasLimit: childChainTx.gasLimit.toNumber(),
57+
feeRefundAddress: retryableMessage.messageData.excessFeeRefundAddress,
58+
beneficiary: retryableMessage.messageData.callValueRefundAddress,
59+
l2CallValue: retryableMessage.messageData.l2CallValue.toString(),
5760
}
5861

5962
return childChainTicketReport

packages/retryable-monitor/core/types.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export interface ChildChainTicketReport {
4747
retryData: string
4848
gasFeeCap: number
4949
gasLimit: number
50+
l2CallValue?: string
51+
feeRefundAddress?: string
52+
beneficiary?: string
5053
}
5154

5255
export interface TokenDepositData {
@@ -75,9 +78,11 @@ export interface OnRetryableFoundParams {
7578
gasPriceProvided: string
7679
gasPriceAtCreation?: string
7780
gasPriceNow: string
78-
l2CallValue: string
79-
createdAt?: number
80-
decision?: string
81+
l2CallValue?: string
82+
feeRefundAddress?: string
83+
beneficiary?: string
84+
retryTo?: string
85+
retryData?: string
8186
botRedemptionStatus?: string
8287

8388
}

packages/retryable-monitor/handlers/handleFailedRetryablesFound.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ export const handleFailedRetryablesFound = async (
8585
status: childChainRetryableReport.status,
8686
chainId: childChain.chainId,
8787
chain: childChain.name,
88+
decision: 'Triage',
8889
metadata: {
8990
tokensDeposited: formattedTokenString,
9091
gasPriceProvided,
9192
gasPriceAtCreation,
9293
gasPriceNow,
9394
l2CallValue: l2CallValueFormatted,
94-
decision: 'Triage',
95+
feeRefundAddress: childChainRetryableReport.feeRefundAddress,
96+
beneficiary: childChainRetryableReport.beneficiary,
97+
retryTo: childChainRetryableReport.retryTo,
98+
retryData: childChainRetryableReport.retryData,
9599
},
96100
})
97101
}

packages/retryable-monitor/handlers/notion/alertUntriagedRetraybles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ export const alertUntriagedNotionRetryables = async (
6969
const parentTx =
7070
props?.ParentTx?.rich_text?.[0]?.text?.content || '(unknown)'
7171

72-
const ethDeposit =
73-
props?.TotalRetryableDeposit?.rich_text?.[0]?.text?.content || ''
72+
const l2CallValue = props?.L2CallValue?.rich_text?.[0]?.text?.content || ''
7473
const tokenDeposit =
7574
props?.TokensDeposited?.rich_text?.[0]?.text?.content || ''
75+
7676
const deposit =
77-
[ethDeposit, tokenDeposit]
77+
[l2CallValue, tokenDeposit]
7878
.filter(s => s && s !== '0.0 ETH ($0.00)')
7979
.join(' and ') || '(unknown)'
8080

packages/retryable-monitor/handlers/notion/syncRetryableToNotion.ts

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ import { getTokenPrice } from '../slack/slackMessageFormattingUtils'
77
import { parseAmount } from '../../../utils/amountUtils'
88

99
const databaseId = process.env.RETRYABLE_MONITORING_NOTION_DB_ID!
10+
const NOTION_RICH_TEXT_MAX = 2000
11+
function truncateForNotion(
12+
s: string,
13+
max = NOTION_RICH_TEXT_MAX,
14+
suffix = '...[truncated]'
15+
) {
16+
if (!s) return s
17+
const hard = max - suffix.length
18+
return s.length > hard ? s.slice(0, hard) + suffix : s
19+
}
1020

1121
async function buildTokensDepositedDisplay(metadata: any): Promise<string> {
1222
if (
@@ -61,7 +71,7 @@ export async function syncRetryableToNotion(
6171

6272
const isRetryableFoundInNotion = search.results.length > 0
6373

64-
const rawCreatedAt = metadata?.createdAt ?? createdAt
74+
const rawCreatedAt = createdAt
6575
const createdAtMs =
6676
rawCreatedAt > 1e14
6777
? Math.floor(rawCreatedAt / 1000)
@@ -99,8 +109,34 @@ export async function syncRetryableToNotion(
99109
notionProps['GasPriceNow'] = {
100110
rich_text: [{ text: { content: metadata.gasPriceNow } }],
101111
}
102-
notionProps['TotalRetryableDeposit'] = {
103-
rich_text: [{ text: { content: metadata.l2CallValue } }],
112+
113+
if (metadata.l2CallValue) {
114+
notionProps['L2CallValue'] = {
115+
rich_text: [{ text: { content: metadata.l2CallValue } }],
116+
}
117+
}
118+
119+
if (metadata.feeRefundAddress) {
120+
notionProps['FeeRefundAddress'] = {
121+
rich_text: [{ text: { content: metadata.feeRefundAddress } }],
122+
}
123+
}
124+
if (metadata.beneficiary) {
125+
notionProps['Beneficiary'] = {
126+
rich_text: [{ text: { content: metadata.beneficiary } }],
127+
}
128+
}
129+
if (metadata.retryTo) {
130+
notionProps['RetryTo'] = {
131+
rich_text: [{ text: { content: metadata.retryTo } }],
132+
}
133+
}
134+
if (metadata.retryData) {
135+
notionProps['RetryData'] = {
136+
rich_text: [
137+
{ text: { content: truncateForNotion(metadata.retryData, 1950) } },
138+
],
139+
}
104140
}
105141

106142
const tokensDepositedDisplay = await buildTokensDepositedDisplay(metadata)
@@ -151,9 +187,9 @@ export async function syncRetryableToNotion(
151187
}
152188
}
153189

154-
if (!currentDecision && metadata?.decision) {
190+
if (!currentDecision && input.decision) {
155191
executedProps['Decision'] = {
156-
select: { name: metadata.decision },
192+
select: { name: input.decision },
157193
}
158194
}
159195

@@ -175,9 +211,9 @@ export async function syncRetryableToNotion(
175211
notionProps['Status'] = { select: { name: status } }
176212

177213
// Only set Decision if it's missing
178-
if (!currentDecision && metadata?.decision) {
214+
if (!currentDecision && input.decision) {
179215
notionProps['Decision'] = {
180-
select: { name: metadata.decision },
216+
select: { name: input.decision },
181217
}
182218
}
183219

@@ -199,8 +235,8 @@ export async function syncRetryableToNotion(
199235
properties: {
200236
ChildTx: { title: [{ text: { content: ChildTx } }] },
201237
Status: { select: { name: status } },
202-
...(metadata?.decision
203-
? { Decision: { select: { name: metadata.decision } } }
238+
...(input.decision
239+
? { Decision: { select: { name: input.decision } } }
204240
: {}),
205241
...(metadata?.botRedemptionStatus
206242
? {

0 commit comments

Comments
 (0)