Skip to content

Conversation

@algorambo
Copy link

Fix the Bug Submission Pull Request

What was the bug?

When composing the atomic transaction group, the transactions' signer parameters were incorrectly assigned to a standard Account object instead of a TransactionSigner object, which would had the capability to authorize the transactions.

This caused the following error to be thrown on npm run start:

> start
> tsx -r dotenv/config index.ts

LocalNet account 'RECEIVER' doesn't yet exist; created account 4DWMOO27DOLO53QKA43L46QIOOU6NOGQ6L23G5CNWNGY73VQZ6RFO542DI with keys stored in KMD and funding with 100 ALGOs
Transferring 100000000µALGOs from DASLV3YQ5M7F4APL3LJG5DWWTREJJRZIEE72W2TKPNLGD42AVVN3OHXY7Q to 4DWMOO27DOLO53QKA43L46QIOOU6NOGQ6L23G5CNWNGY73VQZ6RFO542DI
Received error executing Atomic Transaction Composer, for more information enable the debug flag TypeError: signer is not a function
    at <anonymous> (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:542:49)
    at Array.map (<anonymous>)
    at AtomicTransactionComposer.gatherSignatures (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:542:22)
    at AtomicTransactionComposer.submit (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:601:30)
    at AtomicTransactionComposer.execute (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:713:30)
    at Module.sendAtomicTransactionComposer (/developments/algorand-challenges/challenge-4/challenge/node_modules/@algorandfoundation/src/transaction/transaction.ts:557:30)
    at <anonymous> (/developments/algorand-challenges/challenge-4/challenge/index.ts:49:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

TypeError: signer is not a function
    at <anonymous> (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:542:49)
    at Array.map (<anonymous>)
    at AtomicTransactionComposer.gatherSignatures (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:542:22)
    at AtomicTransactionComposer.submit (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:601:30)
    at AtomicTransactionComposer.execute (/developments/algorand-challenges/challenge-4/challenge/node_modules/algosdk/src/composer.ts:713:30)
    at Module.sendAtomicTransactionComposer (/developments/algorand-challenges/challenge-4/challenge/node_modules/@algorandfoundation/src/transaction/transaction.ts:557:30)
    at <anonymous> (/developments/algorand-challenges/challenge-4/challenge/index.ts:49:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

How did you fix the bug?

Before composing the atomic transaction group, a TransactionSigner object had to be initialized.
Subsequently, this newly created signer had to be passed to sign both transactions.

// Create signer for the Atomic Transaction
const signer = algosdk.makeBasicAccountTransactionSigner(sender)

// Compose the Atomic Transaction
const atc = new algosdk.AtomicTransactionComposer()
atc.addTransaction({ txn: ptxn1, signer: signer })
atc.addTransaction({ txn: ptxn2, signer: signer })

Console Screenshot:

image

@algorambo algorambo changed the title Replace sender with signer object Fix: Sign transactions with a TransactionSigner object Mar 27, 2024
@iskysun96 iskysun96 added the Approved ✅ Successfully completed the challenge! label Apr 1, 2024
@iskysun96
Copy link
Contributor

🎉 Congrats on solving the 4th Algorand Coding Challenge!

I have labeled your PR approved, so you can now claim your certificate.

You can claim your certificate of completion NFT here:
https://goplausible.xyz/claim/8x3aqnmh7p2wf25dvmxz7ksvjs3gr02d6648tf31ny90wwtams53jvssjwcj2bgfs7qr425958h3abw83a33t3tdbqb0sjtntmta82r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved ✅ Successfully completed the challenge!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants