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(dyn-abi): allow T: Into<Cow<str>> in eip712_domain! #222

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Aug 2, 2023

Motivation

Minor improvement to the eip712_domain! macro.

Solution

If an expr is a literal, then use Cow::Borrowed, else use Cow::from.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

/// According to the MetaMask implementation,
/// the message parameter may be JSON stringified in versions later than V1
/// See <https://github.com/MetaMask/metamask-extension/blob/0dfdd44ae7728ed02cbf32c564c75b74f37acf77/app/scripts/metamask-controller.js#L1736>
/// In fact, ethers.js JSON stringifies the message at the time of writing.
/// `TypedData` is most likely going to be a stringified JSON object, so we have
/// to implement Deserialize manually to parse the string first.
///
/// See:
/// - Ethers.js: <https://github.com/ethers-io/ethers.js/blob/17969fe4169b44389dbd4da1dd85682eb3284d6f/src.ts/providers/provider-jsonrpc.ts#L415>
/// - Viem: <https://github.com/wagmi-dev/viem/blob/9aba19289832b22422e57265258fdf4beba83570/src/actions/wallet/signTypedData.ts#L178-L185>
Copy link
Member Author

Choose a reason for hiding this comment

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

This link points to a 3 year old commit in Metamask which very hard to trace to today's implementations, so I updated this doc

@DaniPopes DaniPopes force-pushed the dani/runtime-eip712-domain branch 2 times, most recently from 0fa5215 to 67a4dc4 Compare August 2, 2023 15:23
@DaniPopes
Copy link
Member Author

Clippy fixed in #218

@DaniPopes DaniPopes merged commit 7d7621f into main Aug 3, 2023
18 checks passed
@DaniPopes DaniPopes deleted the dani/runtime-eip712-domain branch August 3, 2023 18:52
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