-
Notifications
You must be signed in to change notification settings - Fork 40
Add command to convert from/to Ethereum addresses #592
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
Conversation
AlexD10S
left a comment
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.
Excellent job! I really like the feature, I believe it will be widely used. The DevEx is very smooth, the user doesn’t have to specify the input format, the CLI already recognizes it.
The code is solid and is well tested. The only comment I left was about the new library that was imported, which might not be necessary.
I do have one question from testing: when I try with Alice’s address
pop convert address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
I get the following error:
Error: Invalid address: last 12 bytes must be 0xEE
The reason it does not work with Alice's public key is because the operation is not reversible. If you recalculate the Polkadot address out of the resulting 20 bytes the account would be different, since Alice's public key bytes does not end in We could threat this differently, of course. I have no strong opinion on this, so up to you to decide. |
|
@AlexD10S some minor detail regarding this development:
The output, as you can see, is not purely the resulting address (meaning that it contains the formatting sugar of the I didn't do it here, as I wanted to respect the similar development for hashing, but it might be worth creating an issue so that this does not get forgotten. |
Good point, it makes sense to keep the Another option would be to move the address conversion method into the |
Absolutely! Moving utility stuff to a library seems like a very good idea. |
b66c9ea to
bdde384
Compare
12d6a04 to
4434dc6
Compare
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #592 +/- ##
==========================================
- Coverage 79.36% 77.08% -2.29%
==========================================
Files 106 109 +3
Lines 25979 24854 -1125
Branches 25979 24854 -1125
==========================================
- Hits 20619 19158 -1461
- Misses 3073 3697 +624
+ Partials 2287 1999 -288
... and 27 files with indirect coverage changes 🚀 New features to boost your workflow:
|
AlexD10S
left a comment
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.
LGTM! 🚀
One follow-up: we’ll also need to document this new command in the docs repo: https://github.com/r0gue-io/pop-docs

Closes #566
This PR adds the
convertcommand to initially convert from Ethereum address format to Substrate address format and viceversa.However, and merely as a proposal, I think this command should be a gateway to the same (or more!) functionality as the one we can find in the Substrate js-utilities.
Also, thisconvertcommand could be perfectly isolated as a separate feature. Would be fine for me to address that, but firstly it'd be good go have some feedback.EDIT: the command has been isolated in a separate feature called
convert, which has been included under theexperimentalfeature's umbrella.Usage
# Convert from Substrate address to Ethereum address: pop convert address 13dKz82CEiU7fKfhfQ5aLpdbXHApLfJH5Z6y2RTZpRwKiNhX 0x742d35cc6634c0532925a3b844bc454e4438f44e# Convert from Ethereum address to Substrate address with prefix 0 (Polkadot). pop convert address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e 13dKz82CEiU7fKfhfQ5aLpdbXHApLfJH5Z6y2RTZpRwKiNhX# Convert from Ethereum address to Substrate address with prefix 42 (Generic). pop convert address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e 42 5Eh2qnm8NwCeDnfBhm2aCfoSffBAeMk914NUs8UDGLuoY6qg