Skip to content
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

utils functions for validating address of a chain and convert address between chains #27

Open
kombos opened this issue Jan 15, 2023 · 2 comments

Comments

@kombos
Copy link

kombos commented Jan 15, 2023

we require some crucial functions to be made part of the utils library of chain-registry, such as validating an address of a particular chain. This should be a functions to verify if an address is a valid bech32 address for a particular chain, in chain-registry ? this should ideally be under @chain-registry/utils or @chain-registry/assets.. for each asset, we could provide a verifyAddress() function, where we pass the complete address (human readable prefix + control digit + remaining hash value) and it will return a boolean value.
for e.g. verifyAddress("osmosis", "osmo1egdwq4khcmsyd0tk6mpq28r7eawjpe6nzd9kjd") could give return value - true - since it is a valid address.

Also, a function to convert an address represented in one chain to address represented in another chain.. for eg. convertAddress("cosmoshub", "osmosis", "cosmos1egdwq4khcmsyd0tk6mpq28r7eawjpe6n2kkxyl") could give back - "osmo1egdwq4khcmsyd0tk6mpq28r7eawjpe6nzd9kjd"

@pyramation
Copy link
Contributor

hey — I think we can put this under @chain-registry/utils for verifyAddress

however, I don't see how we can do convertAddress unless they share a coin type. e.g. you cannot create secret to osmo since they don't share a cointype, so this convert address is not really a safe method to provide. If we did this we'd have to throw errors for incompatible coin types.

@pyramation
Copy link
Contributor

verify address — it was mentioned maybe folks should use these libraries and info to do validation, we'll take a look and see if we can do it in a minimal way that doesn't use much dependencies, if any.

https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki

https://github.com/bitcoinjs/bech32

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

No branches or pull requests

2 participants