From 49f48b7e9aec5478818107bfe350629886f23a2d Mon Sep 17 00:00:00 2001 From: Le Yu <6251863+ltyu@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:58:22 -0400 Subject: [PATCH] Add exclusion for balance check for CollateralFiat --- src/features/transfer/useTokenTransfer.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/features/transfer/useTokenTransfer.ts b/src/features/transfer/useTokenTransfer.ts index cc233e8..83c3fbe 100644 --- a/src/features/transfer/useTokenTransfer.ts +++ b/src/features/transfer/useTokenTransfer.ts @@ -1,7 +1,7 @@ import { useCallback, useState } from 'react'; import { toast } from 'react-toastify'; -import { TypedTransactionReceipt, WarpTxCategory } from '@hyperlane-xyz/sdk'; +import { TokenStandard, TypedTransactionReceipt, WarpTxCategory } from '@hyperlane-xyz/sdk'; import { toTitleCase, toWei } from '@hyperlane-xyz/utils'; import { toastTxSuccess } from '../../components/toast/TxSuccessToast'; @@ -18,6 +18,8 @@ import { import { TransferContext, TransferFormValues, TransferStatus } from './types'; import { tryGetMsgIdFromTransferReceipt } from './utils'; +const SKIP_DEST_BALANCE_CHECK_STANDARDS = [TokenStandard.EvmHypCollateralFiat]; + export function useTokenTransfer(onDone?: () => void) { const { transfers, addTransfer, updateTransferStatus } = useStore((s) => ({ transfers: s.transfers, @@ -108,10 +110,12 @@ async function executeTransfer({ const warpCore = getWarpCore(); - const isCollateralSufficient = await warpCore.isDestinationCollateralSufficient({ - originTokenAmount, - destination, - }); + const isCollateralSufficient = SKIP_DEST_BALANCE_CHECK_STANDARDS.includes(originToken.standard) + ? true + : await warpCore.isDestinationCollateralSufficient({ + originTokenAmount, + destination, + }); if (!isCollateralSufficient) { toast.error('Insufficient collateral on destination for transfer'); throw new Error('Insufficient destination collateral');