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

Contract interfaces generated by "moonworm generate" should coerce types before web3 calls #88

Open
zomglings opened this issue Aug 9, 2022 · 1 comment

Comments

@zomglings
Copy link
Contributor

zomglings commented Aug 9, 2022

An example error we saw in Moonstream Engine API:

Before:

            message_hash = dropper_contract.claimMessageHash(
                claimant_drop.claim_id,
                claimant_drop.address,
                claimant_drop.claim_block_deadline,
                transformed_amount,
            ).call()

Error:

web3.exceptions.ValidationError:                                                                                                                                                    
Could not identify the intended function with name `claimMessageHash`, positional argument(s) of type `(<class 'int'>, <class 'str'>, <class 'int'>, <class 'str'>)` and keyword argument(s) of type `{}`.                                                                                                                                                              
Found 1 function(s) with the name `claimMessageHash`: ['claimMessageHash(uint256,address,uint256,uint256)']                                                                         
Function invocation failed due to no matching argument types.

After:

            message_hash = dropper_contract.claimMessageHash(
                claimant_drop.claim_id,
                claimant_drop.address,
                claimant_drop.claim_block_deadline,
                int(transformed_amount),
            ).call()

This is not an issue with the moonworm generate-brownie interfaces because I believe brownie does the type coercion before making the web3 call.

It would be useful if we did this ourselves in the generated classes for moonworm generate.

@zomglings
Copy link
Contributor Author

Maybe there is a way to configure web3 client to coerce to ABI types without us having to do it ourselves?

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

No branches or pull requests

1 participant