Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OK-34450: Prevent zero amount transfer on SUI #6375

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: prevent zero amount transfer on SUI
  • Loading branch information
originalix committed Dec 19, 2024
commit 86e72c94ce29fe26244ca5b931e8f21c8b2bab22
8 changes: 6 additions & 2 deletions packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -91,8 +93,10 @@ async function createTokenTransaction({
new BigNumber(0),
);

if (totalBalance.lt(amount)) {
throw new Error('Insufficient balance');
if (totalBalance.lt(amount) || totalBalance.isZero()) {
throw new OneKeyInternalError({
key: ETranslations.earn_insufficient_balance,
});
}

// Max send native token
Expand Down
Loading