-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add Address w/ checksum support to primitives
#19
Conversation
7a08fd8
to
34d5d40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, but I don't understand why Address should be its own fixed-hash type when we already have B160? Can't we implement address methods on B160 and export a type alias?
I've gone back and forth on this a bit, but i think that they ought to be separate. For one thing, there is a type-level distinction, as only some 20-byte hashes are Addresses I also don't want to clutter the B160 impl space with address-specific behavior (like checksumming) or do floating util functions the way ethers currently does @gakonst any strong opinion here? |
How are not 20 byte hashes addresses? Where else is a B160 used in Ethereum other than addresses? The |
Ethereum does support the Ripemd160 hash function via precompile 3. Nobody uses it really tho and it would be returned from solidity as TBH, my hot take is that it's probably not ideal to even have B type aliases. Instead just use named distinct hashes OR just
just because type-confusion is standard in representation of strings doesn't mean we need to embrace it for our types. It should be illegal at compile-time to use EIP-55 to checksum encode a Ripemd160 output or a non-address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some methods that can panic are missing #[track_caller]
, while others that can't have it
this PR ended up being much larger than expected 😅 |
closes #16