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

Cannot set asset_sender on an inner transaction AssetTransfer to do a clawback operation #200

Closed
SilentRhetoric opened this issue Apr 21, 2024 · 2 comments · Fixed by #201
Assignees
Labels
bug Something isn't working

Comments

@SilentRhetoric
Copy link

Subject of the issue

It is not possible to set the asset_sender transaction field when building an inner transaction asset transfer. This is required to perform a clawback operation on an asset.

Your environment

AlgoKit: 2.0.3
AlgoKit Python: 3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (location: /Users/brianwhippo/.local/pipx/venvs/algokit)
OS: macOS-14.4.1-arm64-arm-64bit
docker: 26.0.0
docker compose: 2.26.1-desktop.1
git: 2.39.3
python: Command not found!
python3: 3.12.3 (location: /opt/homebrew/bin/python3)
pipx: 1.5.0
poetry: 1.5.1
node: 21.7.3
npm: 10.5.0
brew: 4.2.18

[tool.poetry.dependencies]
python = "^3.12"
algokit-utils = "^2.2.0"
python-dotenv = "^1.0.0"
algorand-python = "^1.0.0"

Steps to reproduce

        itxn.AssetTransfer(
            xfer_asset=self.token_asset_id,
            asset_amount=1,
            sender=Global.current_application_address,
            asset_sender=Global.current_application_address,  # Unexpected keyword argument "asset_sender" for "AssetTransfer"
            asset_receiver=Txn.sender,
            fee=0,
        ).submit()

Expected behaviour

The AssetTransfer class, as well as the more generic InnerTransaction class, should provide a way to set asset sender per the clawback transaction specification at https://developer.algorand.org/docs/get-details/transactions/transactions/#asset-clawback-transaction.

Actual behaviour

Mypy identifies the missing kwarg (Unexpected keyword argument "asset_sender" for "AssetTransfer"). The contract will also fail to move a frozen asset because it needs the inner transaction to have this field set.

@SilentRhetoric SilentRhetoric added the bug Something isn't working label Apr 21, 2024
@achidlow
Copy link
Collaborator

This should be fixed in the next release which will be out this week, in the mean time, since in this case the compiler actually supports this and it's just missing from the stubs, the following is a viable workaround:

        itxn.AssetTransfer(
            xfer_asset=self.token_asset_id,
            asset_amount=1,
            sender=Global.current_application_address,
            asset_sender=Global.current_application_address,  # type: ignore[call-arg]
            asset_receiver=Txn.sender,
            fee=0,
        ).submit()

@daniel-makerx daniel-makerx linked a pull request Apr 22, 2024 that will close this issue
@SilentRhetoric
Copy link
Author

Thank you, guys!

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