cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

Unable to validate an address

Open aka-rider opened this issue 3 years ago • 2 comments

Hey cosmjs team.

I can not find any method to validate string as a wallet address programmatically. There is this function in faucet https://github.com/cosmos/cosmjs/blob/79396bfaa49831127ccbbbfdbb1185df14230c63/packages/faucet/src/addresses.ts#L3 but it can not be imported.

Can you move this function up the package hierarchy or point me to another method?

The goal is to check that user-provided string is a valid cosmos address.

Thank you in advance.

aka-rider avatar Oct 06 '22 12:10 aka-rider

Hey! Yeah, true story.

I think the only tricky part is the expected data length. There are currently 20 byte and 32 byte addresses. So we had to make 2 or even 3 functions for that.

In the meantime I recommend copying the function to your code.

webmaster128 avatar Oct 17 '22 09:10 webmaster128

Ok, clear, thanks for the explanation.

aka-rider avatar Oct 17 '22 09:10 aka-rider