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): introduce SolValue, make Encodable an impl detail #333

Merged
merged 20 commits into from
Oct 7, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Oct 5, 2023

  • Renamed existing Encodable to SolTypeValue and make it clear that it and SolType should not be implemented manually
  • Add a new SolValue trait with the useful methods from SolType, but instead of rust : &Self::RustType they take receiver self
  • SolValue is implemented for all ABI Rust types and just delegates everything to SolTypeEncodable when Self: SolTypeEncodable
  • Moved implementations of previous &Self::RustType methods to SolTypeEncodable so they can be used in Encodable

@DaniPopes DaniPopes marked this pull request as ready for review October 5, 2023 07:34
crates/sol-types/src/types/encodable.rs Outdated Show resolved Hide resolved
crates/sol-types/src/types/encodable.rs Outdated Show resolved Hide resolved
@DaniPopes
Copy link
Member Author

Also is there a better name than Encodable? This trait is a helper for everything SolType does, not just encoding

@DaniPopes DaniPopes changed the title feat(sol-types): make Encodable actually work feat(sol-types): introduce SolValue, make Encodable an impl detail Oct 7, 2023
encode_opt::<sol_data::Uint<256>, _>(self.chain_id.as_ref(), out);
encode_opt::<sol_data::Address, _>(self.verifying_contract.as_ref(), out);
encode_opt::<sol_data::FixedBytes<32>, _>(self.salt.as_ref(), out);
encode_opt!(self.name.as_ref().map(cow_keccak256));
Copy link
Member

Choose a reason for hiding this comment

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

so clean 👀

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

🤩

@DaniPopes DaniPopes merged commit 88ef37f into main Oct 7, 2023
20 checks passed
@DaniPopes DaniPopes deleted the dani/better-soltype branch October 7, 2023 20:14
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

Successfully merging this pull request may close these issues.

2 participants