feat: derive Hash for evm_rpc_types hex wrappers#596
Conversation
|
Dear @sueun-dev, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA. If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged. — The DFINITY Foundation |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR enables Ethereum hex-string wrapper types to be used as keys in hash-based collections by deriving Hash, and adds a unit test that exercises HashMap/HashSet usage for several hex types.
Changes:
- Derive
Hashfor all hex-string wrapper types generated byimpl_hex_string!. - Derive
HashforByte. - Add a test validating
Hex20,Hex32,HexByte,Hex, andHex256can be used inHashMap/HashSet.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| evm_rpc_types/src/tests.rs | Adds a new unit test that checks hex wrapper types work as hash keys/values in HashMap/HashSet. |
| evm_rpc_types/src/lib.rs | Adds Hash derives to hex wrapper types and Byte to support usage in hash-based collections. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb4fad4 to
455ba3c
Compare
gregorydemay
left a comment
There was a problem hiding this comment.
Thanks for this PR @sueun-dev !
Fixes #393.
What changed:
Hashfor theevm_rpc_typeshex wrappers generated byimpl_hex_string!.Hashfor the internalBytewrapper soHexByteis covered too.Hex20as aHashMapkey andHexByte,Hex32,Hex256, andHexinHashSets.Why:
These wrappers already compare by decoded bytes through
Eq, so hashing the same inner values is consistent with their equality behavior. This lets callers use hash-based collections when they need them without changing Candid, serde, display, or parsing behavior.Checked:
cargo test -p evm_rpc_typescargo test -p evm_rpc_types --all-features