solved smart contract errors 'Expression has type "Any"', 'Unsupported operand types', 'Argument 2 to "app_opted_in"'#108
Open
sohailblockchain wants to merge 1 commit intoalgorand-coding-challenges:mainfrom
Conversation
…d operand types", 'Argument 2 to "app_opted_in"'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
buildcommand 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.