Skip to content

Commit

Permalink
fix(mobile): sign-raw when wallet contract is uninit (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
voloshinskii authored Dec 13, 2023
1 parent a21ecdd commit f58a924
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { formatValue, getActionTitle } from '@tonkeeper/shared/utils/signRaw';
import { Buffer } from 'buffer';
import { trackEvent } from '$utils/stats';
import { Events, SendAnalyticsFrom } from '$store/models';
import { getWalletSeqno } from '@tonkeeper/shared/utils/wallet';

interface SignRawModalProps {
consequences?: MessageConsequences;
Expand Down Expand Up @@ -65,10 +66,9 @@ export const SignRawModal = memo<SignRawModalProps>((props) => {
contractVersionsMap[vault.getVersion() ?? 'v4R2'],
Buffer.from(vault.tonPublicKey),
);

const boc = TransactionService.createTransfer(contract, {
messages: TransactionService.parseSignRawMessages(params.messages),
seqno: (await tonapi.wallet.getAccountSeqno(tk.wallet.address.ton.raw)).seqno,
seqno: await getWalletSeqno(),
sendMode: 3,
secretKey: Buffer.from(privateKey),
});
Expand Down Expand Up @@ -254,7 +254,7 @@ export const openSignRawModal = async (
try {
const boc = TransactionService.createTransfer(contract, {
messages: TransactionService.parseSignRawMessages(params.messages),
seqno: (await tonapi.wallet.getAccountSeqno(tk.wallet.address.ton.raw)).seqno,
seqno: await getWalletSeqno(),
secretKey: Buffer.alloc(64),
});
consequences = await tonapi.wallet.emulateMessageToWallet({ boc });
Expand Down
10 changes: 10 additions & 0 deletions packages/shared/utils/wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { tk, tonapi } from '../tonkeeper';

export async function getWalletSeqno() {
try {
const seqno = (await tonapi.wallet.getAccountSeqno(tk.wallet.address.ton.raw)).seqno;
return seqno;
} catch (e) {
return 0;
}
}

0 comments on commit f58a924

Please sign in to comment.