From d826e886eba989c35b3f28145f815642684f84d7 Mon Sep 17 00:00:00 2001 From: Korbinian Date: Tue, 26 Mar 2024 01:15:00 +0100 Subject: [PATCH 1/3] fix(bridge-ui): canonical check can use wrong chain, incorrect supported chain check (#16526) --- .../Transactions/Dialogs/Claim.svelte | 45 +----------- .../Dialogs/ClaimDialog/ClaimDialog.svelte | 73 +++++++++++++++---- packages/bridge-ui/src/i18n/en.json | 8 +- .../libs/token/getCanonicalInfoForToken.ts | 13 +++- .../src/libs/token/getTokenAddresses.ts | 2 + packages/bridge-ui/src/libs/wagmi/watcher.ts | 10 +-- 6 files changed, 83 insertions(+), 68 deletions(-) diff --git a/packages/bridge-ui/src/components/Transactions/Dialogs/Claim.svelte b/packages/bridge-ui/src/components/Transactions/Dialogs/Claim.svelte index 03484e7f50..db38f7d7b3 100644 --- a/packages/bridge-ui/src/components/Transactions/Dialogs/Claim.svelte +++ b/packages/bridge-ui/src/components/Transactions/Dialogs/Claim.svelte @@ -2,18 +2,9 @@ import { switchChain } from '@wagmi/core'; import { log } from 'debug'; import { createEventDispatcher } from 'svelte'; - import { t } from 'svelte-i18n'; - import { ContractFunctionExecutionError, UserRejectedRequestError } from 'viem'; - import { errorToast, warningToast } from '$components/NotificationToast/NotificationToast.svelte'; import { bridges, type BridgeTransaction } from '$libs/bridge'; - import { - InsufficientBalanceError, - InvalidProofError, - NotConnectedError, - ProcessMessageError, - RetryError, - } from '$libs/error'; + import { NotConnectedError } from '$libs/error'; import { getConnectedWallet } from '$libs/util/getConnectedWallet'; import { config } from '$libs/wagmi'; import { account } from '$stores/account'; @@ -62,41 +53,7 @@ dispatch('claimingTxSent', { txHash, type: 'claim' }); } catch (err) { - handleClaimError(err); - dispatch('error', { error: err, action: 'claim' }); } }; - - const handleClaimError = (err: unknown) => { - switch (true) { - case err instanceof NotConnectedError: - warningToast({ title: $t('messages.account.required') }); - break; - case err instanceof UserRejectedRequestError: - warningToast({ title: $t('transactions.actions.claim.rejected.title') }); - break; - case err instanceof InsufficientBalanceError: - dispatch('insufficientFunds', { tx: bridgeTx }); - break; - case err instanceof InvalidProofError: - errorToast({ title: $t('common.error'), message: $t('bridge.errors.invalid_proof_provided') }); - break; - case err instanceof ProcessMessageError: - errorToast({ title: $t('bridge.errors.process_message_error') }); - break; - case err instanceof RetryError: - errorToast({ title: $t('bridge.errors.retry_error') }); - break; - case err instanceof ContractFunctionExecutionError: - console.error('!========= ContractFunctionExecutionError', err); - break; - default: - errorToast({ - title: $t('bridge.errors.unknown_error.title'), - message: $t('bridge.errors.unknown_error.message'), - }); - break; - } - }; diff --git a/packages/bridge-ui/src/components/Transactions/Dialogs/ClaimDialog/ClaimDialog.svelte b/packages/bridge-ui/src/components/Transactions/Dialogs/ClaimDialog/ClaimDialog.svelte index ba3fcb1228..a5c9405fef 100644 --- a/packages/bridge-ui/src/components/Transactions/Dialogs/ClaimDialog/ClaimDialog.svelte +++ b/packages/bridge-ui/src/components/Transactions/Dialogs/ClaimDialog/ClaimDialog.svelte @@ -1,16 +1,28 @@