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

Fix type mismatch in smart contract function signatures #72

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

Conversation

algotables
Copy link

1) What was the problem?

The problem was related to type mismatches in the record_ai_info method signatures of the VerifyMedicalAI smart contract. The method signatures were initially defined using basic Python types such as str, bool, and UInt64. This led to compile-time errors because the ARC4 framework requires using ARC4-specific types (like arc4.String, arc4.Bool, and arc4.UInt64) for both defining data structures and for function parameters to maintain type safety and adhere to ARC4's strict type system. The errors were preventing the smart contract from being built, as ARC4 could not correctly interpret these basic Python types in the context of ARC4's static type checking.

2) How did you solve the problem?

I solved the problem by updating the record_ai_info method's parameter types from Python's built-in types to ARC4-specific types. This involved changing the function signatures to expect arc4.String, arc4.UInt64, and arc4.Bool directly, rather than the standard Python str, bool, and UInt64. By aligning the method signatures with the types used in the AiInfo struct, I ensured type consistency and compatibility across the contract. This change addressed the build errors by satisfying ARC4's type requirements, allowing the contract to compile successfully and ensuring that all operations within the contract adhere to the expected type safety standards of ARC4.

3) Screenshot of your terminal showing the result of running the deploy script.

python-challenge-4-jeff-stein-5-10-24

This commit resolves the type mismatch issues in the VerifyMedicalAI smart contract by aligning the method signatures of `record_ai_info` with ARC4-specific types instead of basic Python types. The update ensures type safety and compatibility with ARC4's static type system, preventing build-time type errors.

Changes:
- Updated parameter types in the `record_ai_info` method from Python builtins to ARC4-specific types, ensuring that the method signatures correctly utilize `arc4.String`, `arc4.UInt64`, and `arc4.Bool` types as defined in the AiInfo struct.
@iskysun96 iskysun96 added the Approved ✅ Successfully completed the challenge! label May 16, 2024
@iskysun96
Copy link
Contributor

🎉 Congrats on solving the 4th Algorand Python Coding Challenge!

I have labeled your PR approved, so you can now claim your certificate.

You can claim your certificate of completion NFT here:
https://goplausible.xyz/claim/ef5704v2qwccdxhczy2q9xrapp23gh3sxm0gqc3gjya321kvqvm3nenmkqagy123nwcmf19q16fkcecs3157qyxd9fzye5pb2579000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved ✅ Successfully completed the challenge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants