diff --git a/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts b/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts index eb36051df97..eddbab3707b 100644 --- a/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts +++ b/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts @@ -5,6 +5,8 @@ import { TransactionBlock } from '@benfen/bfc.js/transactions'; import { BFC_TYPE_ARG } from '@benfen/bfc.js/utils'; import BigNumber from 'bignumber.js'; +import { OneKeyInternalError } from '@onekeyhq/shared/src/errors'; +import { ETranslations } from '@onekeyhq/shared/src/locale'; import timerUtils from '@onekeyhq/shared/src/utils/timerUtils'; import { normalizeBfcCoinType, objectTypeToCoinType } from './utils'; @@ -94,10 +96,15 @@ async function createTokenTransaction({ new BigNumber(0), ); - if (totalBalance.lt(amount)) { - throw new Error('Insufficient balance'); + if ( + totalBalance.lt(amount) || + (totalBalance.isZero() && allCoins.length === 0) + ) { + throw new OneKeyInternalError({ + key: ETranslations.earn_insufficient_balance, + }); } - + // Max send native token if (maxSendNativeToken && coinType === BFC_TYPE_ARG) { tx.transferObjects([tx.gas], recipient); diff --git a/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts b/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts index 7b799b580d3..5bce2b0f785 100644 --- a/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts +++ b/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts @@ -2,6 +2,8 @@ import { Transaction } from '@mysten/sui/transactions'; import { SUI_TYPE_ARG } from '@mysten/sui/utils'; import BigNumber from 'bignumber.js'; +import { OneKeyInternalError } from '@onekeyhq/shared/src/errors'; +import { ETranslations } from '@onekeyhq/shared/src/locale'; import timerUtils from '@onekeyhq/shared/src/utils/timerUtils'; import { normalizeSuiCoinType } from './utils'; @@ -91,8 +93,13 @@ async function createTokenTransaction({ new BigNumber(0), ); - if (totalBalance.lt(amount)) { - throw new Error('Insufficient balance'); + if ( + totalBalance.lt(amount) || + (totalBalance.isZero() && allCoins.length === 0) + ) { + throw new OneKeyInternalError({ + key: ETranslations.earn_insufficient_balance, + }); } // Max send native token