Checksum the address on addressInput (#1410)

This commit is contained in:
Agustin Pane 2020-09-29 16:07:36 -03:00 committed by GitHub
parent 296a6f62a1
commit f4f90acc22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import { Validator, composeValidators, mustBeEthereumAddress, required } from 's
import { trimSpaces } from 'src/utils/strings'
import { getAddressFromENS } from 'src/logic/wallets/getWeb3'
import { isValidEnsName } from 'src/logic/wallets/ethAddresses'
import { checksumAddress } from 'src/utils/checksumAddress'
// an idea for second field was taken from here
// https://github.com/final-form/react-final-form-listeners/blob/master/src/OnBlur.js
@ -56,11 +57,15 @@ const AddressInput = ({
if (isValidEnsName(address)) {
try {
const resolverAddr = await getAddressFromENS(address)
fieldMutator(resolverAddr)
const formattedAddress = checksumAddress(resolverAddr)
fieldMutator(formattedAddress)
} catch (err) {
console.error('Failed to resolve address for ENS name: ', err)
}
} else fieldMutator(address)
} else {
const formattedAddress = checksumAddress(address)
fieldMutator(formattedAddress)
}
}}
</OnChange>
</>