67P / kredits-web

Kredits Web UI
https://kredits.kosmos.org
6 stars 2 forks source link

Validate Ethereum addresses in input fields #144

Closed raucao closed 4 years ago

raucao commented 4 years ago

Adds address validation to the address inputs.

Importing the function from web3-utils, because ethers.js doesn't have any such utility function. :slightly_frowning_face:

bumi commented 4 years ago

ethers has that getchcksumaddress function that does some check: https://github.com/ethers-io/ethers.js/blob/061b0eae1d4c570aedd9bee1971afa43fcdae1a6/src.ts/utils/address.ts#L22

I guess that duplication of isValidAccount can not be prevented as we need that method in both files?

raucao commented 4 years ago

ethers has that getchcksumaddress function that does some check: https://github.com/ethers-io/ethers.js/blob/061b0eae1d4c570aedd9bee1971afa43fcdae1a6/src.ts/utils/address.ts#L22

That's not a check, that's actually creating a checksum address from a non-checksum one.

raucao commented 4 years ago

I guess that duplication of isValidAccount can not be prevented as we need that method in both files?

It can, but that would be way more complex and require more code than the de-duplication is worth. In essence, isAddress is what's already de-duplicated here, and using it on this or that property is just a declarative action.

raucao commented 4 years ago

Good to merge.