Skip to content

Commit

Permalink
fix(mobile): toNano fix for jetton transfer (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
voloshinskii authored Mar 8, 2024
1 parent 78255f1 commit 4c8a50d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/mobile/src/blockchain/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@tonkeeper/core/src/legacy';

import { tk } from '$wallet';
import { Address, Cell, internal, toNano } from '@ton/core';
import { Address, Cell, internal } from '@ton/core';
import {
emulateWithBattery,
sendBocWithBattery,
Expand All @@ -35,6 +35,7 @@ import { setBalanceForEmulation } from '@tonkeeper/shared/utils/wallet';
import { WalletNetwork } from '$wallet/WalletTypes';
import { createTonApiInstance } from '$wallet/utils';
import { config } from '$config';
import { toNano } from '$utils';

const TonWeb = require('tonweb');

Expand Down Expand Up @@ -459,7 +460,9 @@ export class TonWallet {

if (
!balance ||
new BigNumber(Ton.toNano(balance.balance)).lt(new BigNumber(amountNano))
new BigNumber(toNano(balance.balance, balance.metadata.decimals ?? 9)).lt(
new BigNumber(amountNano),
)
) {
throw new Error(t('send_insufficient_funds'));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export async function getWalletSeqno(wallet?: Wallet) {
}
}

export function setBalanceForEmulation(balance: bigint) {
export function setBalanceForEmulation(balance: bigint | number | string) {
return { balance: Number(balance), address: tk.wallet.address.ton.raw };
}

0 comments on commit 4c8a50d

Please sign in to comment.