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

Txn.asset_sender() gives different values in runtime and TestNet #729

Closed
kashishkhullar opened this issue Jul 1, 2022 · 4 comments · Fixed by #737
Closed

Txn.asset_sender() gives different values in runtime and TestNet #729

kashishkhullar opened this issue Jul 1, 2022 · 4 comments · Fixed by #737
Assignees
Labels
bug Something isn't working

Comments

@kashishkhullar
Copy link

kashishkhullar commented Jul 1, 2022

Describe the bug

I have a smart contract in which I verify the amount, ID and sender of the asset received in a group transaction. I am sending the NFT in the second transaction and the function call is the first transaction.

While unit testing I am using the runtime and I am able to verify the value of Gtxn[1].asset_sender() to the stored address in the smart contract. However I was getting an assertion error for this when I deployed it on the TestNet and called the same function.

Note that in both cases clawback address was not set.

After some debugging I found that in the TestNet, the same smart contract was comparing the stored address of the sender to Global.zero_address() whose value is AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ.
This address was getting returned from Gtxn[1].asset_sender() however, while using AlgoBuilder runtime, I was getting the actual address of the sender instead.

I created the NFT like this:

nft_id = runtime.deployASADef(
                    "ABC",
                    {
                        total: 1,
                        decimals: 0,
                    },
                    {
                        creator: user.account,
                    }
                ).assetIndex;

If I print the asset details using runtime.getAssetDef(nft_id) I get the following:

 {
  attribute_map: {},
  name: 'ABC',
  creator: 'NWAMR6YPAGXXMFYEGIJAK3L2PQORKHF2RZDCGYIVGXRNUP35EO64TT7CZI',
  total: 1n,
  decimals: 0,
  defaultFrozen: false,
  unitName: undefined,
  url: undefined,
  metadataHash: undefined,
  manager: undefined,
  reserve: undefined,
  freeze: undefined,
  clawback: undefined
}

Expected Behavior

As mentioned here https://developer.algorand.org/docs/get-details/transactions/transactions/#assetsender it is supposed to return ZeroAddress

Current Behavior

Gtxn[1].asset_sender() returning Global.zero_address() in TestNet
Gtxn[1].asset_sender() returning Sender's address in Algobuilder Runtime

Possible Solution

Steps to Reproduce

  1. Create a smart contract with a function that can take a group transaction and has a sender's address stored in a global variable
  2. In the function assert the value of Gtxn[1].asset_sender() with stored_sender_address
  3. Try calling the function with algobuilder runtim - this should pass
  4. Try calling the function after deploying on TestNet (AlgoSigner) - this will fail

Environment

  • OS: [e.g. iOS]
  • Node.js version:
  • algob version:
@kashishkhullar kashishkhullar added the bug Something isn't working label Jul 1, 2022
@kashishkhullar kashishkhullar changed the title Txn.asset_sender() gives different values Txn.asset_sender() gives different values in runtime and TestNet Jul 1, 2022
@robert-zaremba
Copy link
Member

Thanks for reporting. We are going to fix it next week and include it in the next release, hopefully end of the next week.

@vuvoth vuvoth self-assigned this Jul 11, 2022
@vuvoth vuvoth mentioned this issue Jul 12, 2022
1 task
@vuvoth vuvoth linked a pull request Jul 12, 2022 that will close this issue
1 task
@vuvoth
Copy link
Contributor

vuvoth commented Jul 19, 2022

Resolved in #737.

@vuvoth vuvoth closed this as completed Jul 19, 2022
@kashishkhullar
Copy link
Author

kashishkhullar commented Aug 7, 2022

This issue is still present in v5.0.1

The changes in #737 are not present in the module available on npm.

I went through the node_modules folder and opened the changes but couldn't find them.

Take a look at this screenshot

image

I can confirm that the package version is latest

image

I have tried deleting the node_modules folder and also tried deleting the package-lock.json but it didn't work.
The issue about renaming optIntoASA to optInToASA is fixed in this build so it is possible that during shipping these changes are missed. I recommend using GitHub actions to publish to NPM.

@kashishkhullar
Copy link
Author

@vuvoth any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants