Skip to content

Commit

Permalink
fix: benfen zero amount transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
wabicai committed Dec 19, 2024
1 parent 07d933f commit 6547115
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6547115

Please sign in to comment.