mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-27 09:54:51 +00:00
Checksum the address on addressInput (#1410)
This commit is contained in:
parent
296a6f62a1
commit
f4f90acc22
@ -7,6 +7,7 @@ import { Validator, composeValidators, mustBeEthereumAddress, required } from 's
|
|||||||
import { trimSpaces } from 'src/utils/strings'
|
import { trimSpaces } from 'src/utils/strings'
|
||||||
import { getAddressFromENS } from 'src/logic/wallets/getWeb3'
|
import { getAddressFromENS } from 'src/logic/wallets/getWeb3'
|
||||||
import { isValidEnsName } from 'src/logic/wallets/ethAddresses'
|
import { isValidEnsName } from 'src/logic/wallets/ethAddresses'
|
||||||
|
import { checksumAddress } from 'src/utils/checksumAddress'
|
||||||
|
|
||||||
// an idea for second field was taken from here
|
// an idea for second field was taken from here
|
||||||
// https://github.com/final-form/react-final-form-listeners/blob/master/src/OnBlur.js
|
// https://github.com/final-form/react-final-form-listeners/blob/master/src/OnBlur.js
|
||||||
@ -56,11 +57,15 @@ const AddressInput = ({
|
|||||||
if (isValidEnsName(address)) {
|
if (isValidEnsName(address)) {
|
||||||
try {
|
try {
|
||||||
const resolverAddr = await getAddressFromENS(address)
|
const resolverAddr = await getAddressFromENS(address)
|
||||||
fieldMutator(resolverAddr)
|
const formattedAddress = checksumAddress(resolverAddr)
|
||||||
|
fieldMutator(formattedAddress)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to resolve address for ENS name: ', err)
|
console.error('Failed to resolve address for ENS name: ', err)
|
||||||
}
|
}
|
||||||
} else fieldMutator(address)
|
} else {
|
||||||
|
const formattedAddress = checksumAddress(address)
|
||||||
|
fieldMutator(formattedAddress)
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
</OnChange>
|
</OnChange>
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user