Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Don't truncate ToString for H160 #2175

Closed
hexcowboy opened this issue Feb 21, 2023 · 3 comments
Closed

Don't truncate ToString for H160 #2175

hexcowboy opened this issue Feb 21, 2023 · 3 comments

Comments

@hexcowboy
Copy link

Is your feature request related to a problem? Please describe.
When using the implementation of H160, using the to_string method, the hex string is truncated like so: 0x3712…99d8.

Describe the solution you'd like
It would make much more sense to me to have it display the full hexstring address like: 0x37121F74d25262011ABBBcc8D13E6923AEb699d8.

Describe alternatives you've considered
https://stackoverflow.com/a/75509511/16245971 this is the alternative I'm using right now, which doesn't feel intuitive.

Additional Context
This is just my opinion but I think users should define their own logic for truncating an H160 if they want to, since there isn't a standard AFAIK. The path for converting H160 -> String is not clear to people without knowledge of UpperHex and LowerHex traits.

@mattsse
Copy link
Collaborator

mattsse commented Feb 21, 2023

this also caused me some grief, but I think the argument for it is that the debug impl already outputs the entire address so display impl can truncate.

but this is implemented via the uint crate in the primitive-types crates. so nothing we can do here.

@hexcowboy
Copy link
Author

this is implemented via the uint crate in the primitive-types crates.

good to know, i'll bring the discussion over there. ty

@jorgeavaldez
Copy link

jorgeavaldez commented Apr 15, 2023

I ran into the same issue, but for addresses in particular I found this function to get a checksum address string!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants