Skip to content

Commit

Permalink
fix(evm): improve error handling on prove/finalize bridge withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Dec 19, 2024
1 parent 08f39af commit caca817
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ const WithdrawStatus = ({ data, isExpanded, onProveSuccess, onRelaySuccess }: Wi

const { address } = useAccount();

const handleError = (e: Error) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (((e as unknown as any).shortMessage as string).includes('User rejected the request')) {
toast.error(<Trans>User rejected the request.</Trans>);
} else {
Sentry.captureException(e);

toast.error(
<Trans>
Submission failed. Please disable any wallets other than the one connected to this dApp. If the issue
persists, please contact us.
</Trans>
);
}
};

const proveMutation = useMutation({
mutationKey: bridgeKeys.proveTransaction(address, data.transactionHash),
mutationFn: async () => {
Expand Down Expand Up @@ -62,12 +78,7 @@ const WithdrawStatus = ({ data, isExpanded, onProveSuccess, onRelaySuccess }: Wi
toast.success(<Trans>Successfully submitted ${data?.hash} proof</Trans>);
onProveSuccess?.();
},
onError: (e) => {
Sentry.captureException(e);
// eslint-disable-next-line no-console
console.log('Prove: ', e);
toast.error(<Trans>Failed to submit proof.</Trans>);
}
onError: handleError
});

const relayMutation = useMutation({
Expand Down Expand Up @@ -100,12 +111,7 @@ const WithdrawStatus = ({ data, isExpanded, onProveSuccess, onRelaySuccess }: Wi
toast.success(<Trans>Successfully finalized transaction</Trans>);
onRelaySuccess?.();
},
onError: (e) => {
Sentry.captureException(e);
// eslint-disable-next-line no-console
console.log('Finalize: ', e);
toast.error(<Trans>Failed to finalize.</Trans>);
}
onError: handleError
});

const currentStep = useMemo(
Expand Down
20 changes: 14 additions & 6 deletions apps/evm/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ msgid "Failed to connect to {0}"
msgstr "Failed to connect to {0}"

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:107
msgid "Failed to finalize."
msgstr "Failed to finalize."
#~ msgid "Failed to finalize."
#~ msgstr "Failed to finalize."

#: src/app/[lang]/(bridge)/hooks/useGateway.ts:241
msgid "Failed to get estimated fee"
Expand All @@ -669,8 +669,8 @@ msgstr "Failed to get estimated fee"
#~ msgstr "Failed to send {amount} {0}"

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:69
msgid "Failed to submit proof."
msgstr "Failed to submit proof."
#~ msgid "Failed to submit proof."
#~ msgstr "Failed to submit proof."

#: src/components/WithdrawModal/WithdrawForm.tsx:87
#: src/components/WithdrawModal/WithdrawForm.tsx:113
Expand Down Expand Up @@ -1592,15 +1592,19 @@ msgstr "Steps"
msgid "Strategy"
msgstr "Strategy"

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:100
#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:44
msgid "Submission failed. Please disable any wallets other than the one connected to this dApp. If the issue persists, please contact us."
msgstr "Submission failed. Please disable any wallets other than the one connected to this dApp. If the issue persists, please contact us."

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:111
msgid "Successfully finalized transaction"
msgstr "Successfully finalized transaction"

#: src/app/[lang]/wallet/components/SendTokenModal/SendTokenModal.tsx:150
#~ msgid "Successfully sent {amount} {0}"
#~ msgstr "Successfully sent {amount} {0}"

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:62
#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:78
msgid "Successfully submitted ${0} proof"
msgstr "Successfully submitted ${0} proof"

Expand Down Expand Up @@ -1947,6 +1951,10 @@ msgstr "Use your Spice total to support your favourite BOB builders. Winners wil
msgid "User rejected the request"
msgstr "User rejected the request"

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:39
msgid "User rejected the request."
msgstr "User rejected the request."

#: src/app/[lang]/fusion/components/UserInfo/UserInfo.tsx:163
#~ msgid "user_babylon_points ="
#~ msgstr "user_babylon_points ="
Expand Down
20 changes: 14 additions & 6 deletions apps/evm/src/locales/zh.po
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ msgid "Failed to connect to {0}"
msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:107
msgid "Failed to finalize."
msgstr ""
#~ msgid "Failed to finalize."
#~ msgstr ""

#: src/app/[lang]/(bridge)/hooks/useGateway.ts:241
msgid "Failed to get estimated fee"
Expand All @@ -669,8 +669,8 @@ msgstr ""
#~ msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:69
msgid "Failed to submit proof."
msgstr ""
#~ msgid "Failed to submit proof."
#~ msgstr ""

#: src/components/WithdrawModal/WithdrawForm.tsx:87
#: src/components/WithdrawModal/WithdrawForm.tsx:113
Expand Down Expand Up @@ -1588,15 +1588,19 @@ msgstr ""
msgid "Strategy"
msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:100
#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:44
msgid "Submission failed. Please disable any wallets other than the one connected to this dApp. If the issue persists, please contact us."
msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:111
msgid "Successfully finalized transaction"
msgstr ""

#: src/app/[lang]/wallet/components/SendTokenModal/SendTokenModal.tsx:150
#~ msgid "Successfully sent {amount} {0}"
#~ msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:62
#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:78
msgid "Successfully submitted ${0} proof"
msgstr ""

Expand Down Expand Up @@ -1934,6 +1938,10 @@ msgstr "用你的Spice总数来支持你最喜爱的BOB构建者。获胜者将
msgid "User rejected the request"
msgstr ""

#: src/app/[lang]/(bridge)/components/BridgeStatus/WithdrawStatus.tsx:39
msgid "User rejected the request."
msgstr ""

#: src/app/[lang]/fusion/components/UserInfo/UserInfo.tsx:163
#~ msgid "user_babylon_points ="
#~ msgstr ""
Expand Down

0 comments on commit caca817

Please sign in to comment.