Skip to content

solved smart contract errors 'Expression has type "Any"', 'Unsupported operand types', 'Argument 2 to "app_opted_in"' #108

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

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

Conversation

12SohailBlockchain
Copy link

Errors in previous Smart contract:

Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge\smart_contracts_main
.py", line 54, in
main(sys.argv[1])
File "E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge\smart_contracts_main
.py", line 32, in main
build(artifact_path / contract.name, contract.path)
File "E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge\smart_contracts\helpers\build.py", line 34, in build
raise Exception(f"Could not build contract:\n{build_result.stdout}")
Exception: Could not build contract:
info: Found python prefix: E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge.venv
smart_contracts\personal_vault\contract.py:26 error: Expression has type "Any" [misc]
ptxn.receiver == Global.current_application_id
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
smart_contracts\personal_vault\contract.py:26 error: Unsupported operand types for == ("Account" and "Application") [operator]
ptxn.receiver == Global.current_application_id
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
smart_contracts\personal_vault\contract.py:30 error: Argument 2 to "app_opted_in" has incompatible type "Account"; expected "Application | UInt64 | int" [arg-type]
Txn.sender, Global.current_application_address
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An error occurred during compile. Please ensure that any supplied arguments are valid and any files passed are valid Algorand Python code before retrying.

Result after solve the smart contracts errors:

(python-challenge-1-py3.12) E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge>algokit project run build
Running build command in E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge...
Command Executed: 'poetry run python -m smart_contracts build'
Output: 2024-08-20 16:35:43,714 INFO : Loading .env
2024-08-20 16:35:43,717 INFO : Building app at smart_contracts\personal_vault\contract.py
2024-08-20 16:35:43,719 INFO : Exporting smart_contracts\personal_vault\contract.py to E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge\smart_contracts\artifacts\personal_vault

✅ python-challenge-1: 'poetry run python -m smart_contracts build' executed successfully.

(python-challenge-1-py3.12) E:\Coding Side Development\Hardhat Mainnet Fork\python-challenge-1\projects\challenge>algokit project deploy localnet
Using deploy command: c:\users\dell.local\bin\poetry.EXE run python -m smart_contracts deploy
Loading deployment environment variables...
Deploying smart contracts from AlgoKit compliant repository 🚀
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:37:52,042 INFO : Loading .env
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:37:52,044 INFO : Deploying app personal_vault
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:37:55,797 DEBUG : Couldn't find existing account in LocalNet with name 'DEPLOYER'. So created account 22Y5X2DFEQYSH57T27IHN53TK326EHZ6FJPY4JKCFPRMNWYIOJDEIO35WM with keys stored in KMD.
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:37:55,797 DEBUG : Funding account 22Y5X2DFEQYSH57T27IHN53TK326EHZ6FJPY4JKCFPRMNWYIOJDEIO35WM with 0 ALGOs
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:37:57,698 DEBUG : Sent transaction WXEVV3CY6YK25QXBWC3R2WT4CGOTJHERKFMECNIRLXGBHLFXSR2Q type=pay from 5FKQJVHEBA7GW5BL47F3UL7Y73NW3MGPGVQKCQYRCNEIFUCOGLJE6O7AKE
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:38:04,538 INFO : Created App ID: 1002
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:38:06,482 DEBUG : Sent transaction XWCKKMYYORNBZ46FXAJMQU3ARAMH3R2B2CBQ7HH6QP2FBDKJTG3Q type=pay from 5FKQJVHEBA7GW5BL47F3UL7Y73NW3MGPGVQKCQYRCNEIFUCOGLJE6O7AKE
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:38:07,173 INFO : Deposited 1 Algo to the bank contract in transaction CZVOUZX5H4EEBUEGSSM2ZWDWHZCIVQWYYLKSH4GMB2FZFC5LBHWQ.
c:\users\dell.local\bin\poetry.EXE: 2024-08-20 16:38:07,280 INFO : User withdrew 1 Algo from the bank contract in transaction WICBGAMTBKLEOXE5RWMX32ZDIPVJYNOEXPR4J2PLU3GWZ42OODBA.
Screenshot 2024-08-20 165613

…d operand types", 'Argument 2 to "app_opted_in"'
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