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

Challenge 4 Solution #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

algotables
Copy link

What was the bug?

The application was encountering a TypeError: signer is not a function during the execution of atomic transactions using the Algorand SDK's AtomicTransactionComposer. This error was triggered when trying to gather signatures for the transactions. The bug stemmed from improperly passing the sender account object as a signer directly into the AtomicTransactionComposer, which expects a function capable of signing transactions.

How did you fix the bug?

To fix the bug, I implemented the following steps:

  1. Identified the Misuse of Signer: Reviewed the existing implementation where the sender account object was being passed directly as a signer. Recognized that the AtomicTransactionComposer requires a function to handle the signing process.
  2. Implemented Correct Signer Handling: Utilized the algosdk.makeBasicAccountTransactionSigner function to create a signer function from the sender's secret key. This function encapsulates the correct signing logic required by the AtomicTransactionComposer.
  3. Updated Transaction Addition to Composer: Modified the code to pass the newly created signer function instead of the account object when adding transactions to the composer.
  4. Tested the Fix: Ran the application to ensure that the transactions were processed without errors. Confirmed that the atomic transactions were executed successfully, transferring the specified amounts of microAlgos between accounts as intended.
  5. Code Clean-Up and Documentation: Added comments and cleaned up the code for better readability and maintainability. Documented the changes in the code to help future developers understand the use of the signer function.

By implementing these steps, I was able to successfully resolve the bug, allowing for the correct execution of atomic transactions in the application.

Console Screenshot:

algorand-volume-1-challenge-4-AtomicTransactionComposer-5-11-24

Resolved the TypeError by correctly implementing the signer function using algosdk.makeBasicAccountTransactionSigner. This change ensures that the AtomicTransactionComposer correctly processes the signing of transactions, enabling successful atomic transfers of ALGOs between accounts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant