Skip to content

Commit

Permalink
fix(mnemonic): ensure account is initialized when signing transactions
Browse files Browse the repository at this point in the history
This fixes the bug where signing transactions with the mnemonic wallet fails under certain
circumstances because the account is not initialized despite being in a valid connection session.
  • Loading branch information
No-Cash-7970 committed Oct 12, 2024
1 parent 85700c0 commit c9d1cb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/use-wallet/src/wallets/mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export class MnemonicWallet extends BaseWallet {
this.logger.debug('Signing transactions...', { txnGroup, indexesToSign })
let txnsToSign: algosdk.Transaction[] = []

const account = this.account || this.initializeAccount()

// Determine type and process transactions for signing
if (isTransactionArray(txnGroup)) {
const flatTxns: algosdk.Transaction[] = flattenTxnGroup(txnGroup)
Expand All @@ -236,7 +238,7 @@ export class MnemonicWallet extends BaseWallet {
}

// Sign transactions
const signedTxns = txnsToSign.map((txn) => txn.signTxn(this.account!.sk))
const signedTxns = txnsToSign.map((txn) => txn.signTxn(account.sk))
this.logger.debug('Transactions signed successfully', { signedTxns })
return signedTxns
} catch (error: any) {
Expand Down

0 comments on commit c9d1cb0

Please sign in to comment.