You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When constructing an arc4.Tuple a contract will not compile if the Asset type is included in the Tuple. The error message below says expected ARC4 type: asset but there is no asset exported from algopy.
Error message:
····················· project run 'build' command output: ······················
2024-11-22 14:01:27,885 INFO : Loading .env
2024-11-22 14:01:27,885 INFO : Building app at smart_contracts/hello_world/contract.py
2024-11-22 14:01:27,885 INFO : Exporting smart_contracts/hello_world/contract.py to /Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/artifacts/hello_world
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/main.py", line 70, in
main(sys.argv[1])
~~~~^^^^^^^^^^^^^
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/main.py", line 39, in main
build(artifact_path / contract.name, contract.path)
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/_helpers/build.py", line 41, in build
raise Exception(f"Could not build contract:\n{build_result.stdout}")
Exception: Could not build contract:
info: Found python prefix: /Users/bwhippo/Code/tuple/projects/tuple/.venv
smart_contracts/hello_world/contract.py:6 error: expected ARC4 type: asset
@abimethod
def createBattle(
self,
asset: Asset,
selected_assets: Tuple[Asset, String]
) -> None:
An error occurred during compile. Please ensure that any supplied arguments are valid and any files passed are valid Algorand Python code before retrying.
Your environment
A fresh Python project was initialized from AlgoKit CLI today.
See a successful compilation using Asset outside of a Tuple by compiling this contract, and then uncomment the 10th line to see the compilation failure.
Will address the error message described here to something less confusing. However at present supporting the reference types in ARC4 tuples/structs is unsupported. The main reason for this is due to algosdk also not supporting this use case as it does not correctly pack reference values into foreign arrays unless they are top level arguments.
Recommended workaround is to use the algopy.UInt64 type within the tuple and convert to an Asset as required e.g.
In the future we will introduce Asset / Application / Account equivalents that will be encoded as their underlying values (uint64, byte[32]) instead of the reference encodings.
Subject of the issue
When constructing an
arc4.Tuple
a contract will not compile if theAsset
type is included in the Tuple. The error message below saysexpected ARC4 type: asset
but there is noasset
exported from algopy.Error message:
····················· project run 'build' command output: ······················
2024-11-22 14:01:27,885 INFO : Loading .env
2024-11-22 14:01:27,885 INFO : Building app at smart_contracts/hello_world/contract.py
2024-11-22 14:01:27,885 INFO : Exporting smart_contracts/hello_world/contract.py to /Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/artifacts/hello_world
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/main.py", line 70, in
main(sys.argv[1])
~~~~^^^^^^^^^^^^^
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/main.py", line 39, in main
build(artifact_path / contract.name, contract.path)
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bwhippo/Code/tuple/projects/tuple/smart_contracts/_helpers/build.py", line 41, in build
raise Exception(f"Could not build contract:\n{build_result.stdout}")
Exception: Could not build contract:
info: Found python prefix: /Users/bwhippo/Code/tuple/projects/tuple/.venv
smart_contracts/hello_world/contract.py:6 error: expected ARC4 type: asset
@abimethod
def createBattle(
self,
asset: Asset,
selected_assets: Tuple[Asset, String]
) -> None:
An error occurred during compile. Please ensure that any supplied arguments are valid and any files passed are valid Algorand Python code before retrying.
Your environment
A fresh Python project was initialized from AlgoKit CLI today.
timestamp: 2024-11-22T19:08:56+00:00
AlgoKit: 2.4.3
AlgoKit Python: 3.12.7 (v3.12.7:0b05ead877f, Sep 30 2024, 23:18:00) [Clang 13.0.0 (clang-1300.0.29.30)] (location: /opt/homebrew/Caskroom/algokit/2.4.3/_internal)
OS: macOS-14.6.1-arm64-arm-64bit
docker: 27.3.1
docker compose: 2.29.7-desktop.1
git: 2.39.3
python: 3.13.0 (location: /Users/bwhippo/Code/tuple/projects/tuple/.venv/bin/python)
python3: 3.13.0 (location: /Users/bwhippo/Code/tuple/projects/tuple/.venv/bin/python3)
pipx: 1.7.1
poetry: 1.8.4
node: 23.3.0
npm: 10.9.0
brew: 4.4.6
Steps to reproduce
See a successful compilation using Asset outside of a Tuple by compiling this contract, and then uncomment the 10th line to see the compilation failure.
`from algopy import ARC4Contract, Asset
from algopy.arc4 import abimethod, Tuple, String
class HelloWorld(ARC4Contract):
@abimethod
def createBattle(
self,
asset: Asset,
# selected_assets: Tuple[Asset, String]
) -> None:
return`
The text was updated successfully, but these errors were encountered: