move-language / move

Apache License 2.0
2.25k stars 684 forks source link

[account address] Cleanup multiple to string & from string implementations #53

Open gregnazario opened 2 years ago

gregnazario commented 2 years ago

I made the previous change to make 0x more prevalent in the account address outputs, but it's clear to me that there are too many ways to display the account addresses and it adds a lot of confusion.

I'm going to clean it up so that there are less implementations and that it's straightforward at that point.

gregnazario commented 2 years ago

cc @areshand I'm working on this right now

gregnazario commented 2 years ago

Seems to me there are currently 3 use cases:

for 0x00000000abcd

(to & from hex_literal and also display/debug) To & From Hex -> 0xabcd (short_str_lossless) To short str as identifier -> abcd (a currently non existent function) And for some time fuzzy matching back to address without 0x -> abcd

One I want to remove which is confusing is (to_hex, from_hex), which doesn't take a 0x, and has to be exactly the right length number of bytes

@tnowacki would you agree with me? So, I can move forward on this?

Also, what's your opinion on lowercase vs uppercase, since short_str_lossless is lowercase and display is uppercase

tnowacki commented 2 years ago

Thanks for looking at this! It has always annoyed me, which is partially why the source language's parsing/rendering is its own thing :P

I think I agree with the setup you have described with to/from hex and short_str_lossless and maybe this "fuzzy" matching back. But it will be easier for me to know for sure when I see the code.

And I would love to do uppercase by default if we don't already! I think both @sblackshear and myself tried to do that on separate occasions but got frustrated with the amount of breakages