Add exclusion for balance check for CollateralFiat

ltyu/cli-collateral-fiat-support
Le Yu 3 months ago
parent c9637f9e27
commit 49f48b7e9a
  1. 14
      src/features/transfer/useTokenTransfer.ts

@ -1,7 +1,7 @@
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { toast } from 'react-toastify'; 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 { toTitleCase, toWei } from '@hyperlane-xyz/utils';
import { toastTxSuccess } from '../../components/toast/TxSuccessToast'; import { toastTxSuccess } from '../../components/toast/TxSuccessToast';
@ -18,6 +18,8 @@ import {
import { TransferContext, TransferFormValues, TransferStatus } from './types'; import { TransferContext, TransferFormValues, TransferStatus } from './types';
import { tryGetMsgIdFromTransferReceipt } from './utils'; import { tryGetMsgIdFromTransferReceipt } from './utils';
const SKIP_DEST_BALANCE_CHECK_STANDARDS = [TokenStandard.EvmHypCollateralFiat];
export function useTokenTransfer(onDone?: () => void) { export function useTokenTransfer(onDone?: () => void) {
const { transfers, addTransfer, updateTransferStatus } = useStore((s) => ({ const { transfers, addTransfer, updateTransferStatus } = useStore((s) => ({
transfers: s.transfers, transfers: s.transfers,
@ -108,10 +110,12 @@ async function executeTransfer({
const warpCore = getWarpCore(); const warpCore = getWarpCore();
const isCollateralSufficient = await warpCore.isDestinationCollateralSufficient({ const isCollateralSufficient = SKIP_DEST_BALANCE_CHECK_STANDARDS.includes(originToken.standard)
originTokenAmount, ? true
destination, : await warpCore.isDestinationCollateralSufficient({
}); originTokenAmount,
destination,
});
if (!isCollateralSufficient) { if (!isCollateralSufficient) {
toast.error('Insufficient collateral on destination for transfer'); toast.error('Insufficient collateral on destination for transfer');
throw new Error('Insufficient destination collateral'); throw new Error('Insufficient destination collateral');

Loading…
Cancel
Save