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: correct encodeType expansion for nested structs #203

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

prestwich
Copy link
Member

@prestwich prestwich commented Jul 20, 2023

Motivation

#201

Solution

  • introduce eip712_root_type and eip712_component_types to get typestrings on the fly
  • sort, dedup, and append typestring in default impl of eip712_encode_type

This is a bit clunky. I don't love it

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@prestwich prestwich added the bug Something isn't working label Jul 20, 2023
@prestwich prestwich self-assigned this Jul 20, 2023
@prestwich prestwich marked this pull request as ready for review July 20, 2023 23:23
crates/sol-types/src/types/struct.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/struct.rs Show resolved Hide resolved
/// Returns component EIP-712 types. These types are used to construct
/// the `encodeType` string. These are the types of the struct's fields,
/// and should not include the root type.
fn eip712_components() -> Vec<Cow<'static, str>>;
Copy link
Member

Choose a reason for hiding this comment

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

should this even be exposed? are there any other use cases

Copy link
Member Author

Choose a reason for hiding this comment

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

unless we go through some extra trait wrangling, we can't both

  • use it in the default impl of eip712_encode_type
  • not expose it

Is there a specific setup you'd prefer?

crates/sol-macro/src/expand/struct.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants