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

Check ABI is in correct format #160

Open
BellringerQuinn opened this issue Sep 24, 2024 · 2 comments
Open

Check ABI is in correct format #160

BellringerQuinn opened this issue Sep 24, 2024 · 2 comments

Comments

@BellringerQuinn
Copy link
Collaborator

There are multiple places in the SDK where we may pass a portion of an ABI
e.g.
burn(uint256,uint256)

This is done when using a Contract that wasn't created with a full abi as an argument (client-side encoding) or when making a DelayedEncode transaction (server-side encoding)

A common user error is to paste the contract function definition
e.g.
burn(uint256 tokenId, uint256 amount)

This can easily go unnoticed and can be a pain to debug.

Before attempting to encode or hit the WaaS API, we should validate that the ABI is in the correct format and throw an ArgumentException (or similar)

@BellringerQuinn
Copy link
Collaborator Author

https://github.com/0xsequence/ethkit/blob/master/ethcoder/events_parser.go

Bonus points: translate the above ABI parser (it is poorly titled events_parser, it should be useable for any ABI) into C++ and use it to attempt to recover from an ABI provided in the wrong format; if unable to parse, we should still throw an ArgumentException

@BellringerQuinn
Copy link
Collaborator Author

Some Regex you can use to validate the expected format

FunctionNameRegex = @"^[A-Z|a-z|,-|0-9]+$"
FunctionABIRegex = @"^[A-Z|a-z|
,-|0-9]+(([A-Z|a-z|0-9]+(, [A-Z|a-z|0-9]+))?)$"

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