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

feat(sol-types): rm validate: bool #863

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

yash-atreya
Copy link
Member

@yash-atreya yash-atreya commented Jan 31, 2025

Motivation

Currently, in abi_decode_* methods of sol type traits (SolEnum, SolType, SolValue, SolCall, SolInterface, SolEvents), we expose a validate: bool arg to bypass type-checking while decoding. We should always resort to type-checking.

This type-checking ensures that bytes conform to expected type limitations and that the decoded values can be re-encoded to an identical byte-string.

Solution

  • Remove the validate: bool from abi_decode_* fns of various sol type traits.
  • Always validate types while decoding
  • Address the consequent breaking changes in the sol! expansions.
  • Fix tests.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@yash-atreya yash-atreya changed the title Yash/rm validate bool feat(sol-types): rm validate: bool Jan 31, 2025
@yash-atreya yash-atreya marked this pull request as draft January 31, 2025 06:57
@yash-atreya yash-atreya marked this pull request as ready for review February 3, 2025 16:39
@yash-atreya yash-atreya added the enhancement New feature or request label Feb 3, 2025
@@ -61,8 +61,8 @@ impl DynSolCall {
}

/// ABI decode the given data as function returns.
pub fn abi_decode_input(&self, data: &[u8], validate: bool) -> Result<Vec<DynSolValue>> {
abi_decode(data, &self.parameters, validate)
pub fn abi_decode_input(&self, data: &[u8], _validate: bool) -> Result<Vec<DynSolValue>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about here?

);
}
// #[test]
// fn decode_solidity_no_interface() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you can see here not all the validations are correct as we're rejecting valid inputs; this needs a bit more investigation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or request
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

2 participants