diff --git a/src/components/forms/AddressInput/index.tsx b/src/components/forms/AddressInput/index.tsx index cc54b754..9ffcc47a 100644 --- a/src/components/forms/AddressInput/index.tsx +++ b/src/components/forms/AddressInput/index.tsx @@ -5,8 +5,7 @@ import { OnChange } from 'react-final-form-listeners' import TextField from 'src/components/forms/TextField' import { composeValidators, mustBeEthereumAddress, required } from 'src/components/forms/validator' import { getAddressFromENS } from 'src/logic/wallets/getWeb3' - -const isValidEnsName = (name) => /^([\w-]+\.)+(eth|test|xyz|luxe)$/.test(name) +import { isValidEnsName } from 'src/logic/wallets/ethAddresses' // an idea for second field was taken from here // https://github.com/final-form/react-final-form-listeners/blob/master/src/OnBlur.js diff --git a/src/logic/wallets/ethAddresses.ts b/src/logic/wallets/ethAddresses.ts index e0b0a3cb..b6ad3a75 100644 --- a/src/logic/wallets/ethAddresses.ts +++ b/src/logic/wallets/ethAddresses.ts @@ -43,3 +43,5 @@ export const isUserOwner = (safe, userAccount) => { } export const isUserOwnerOnAnySafe = (safes, userAccount) => safes.some((safe) => isUserOwner(safe, userAccount)) + +export const isValidEnsName = (name) => /^([\w-]+\.)+(eth|test|xyz|luxe)$/.test(name) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index 89fcc25e..e3a50f57 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -12,6 +12,7 @@ import Identicon from 'src/components/Identicon' import { mustBeEthereumAddress, mustBeEthereumContractAddress } from 'src/components/forms/validator' import { getAddressBookListSelector } from 'src/logic/addressBook/store/selectors' import { getAddressFromENS } from 'src/logic/wallets/getWeb3' +import { isValidEnsName } from 'src/logic/wallets/ethAddresses' const textFieldLabelStyle = makeStyles(() => ({ root: { @@ -38,8 +39,6 @@ const filterAddressBookWithContractAddresses = async (addressBook) => { return addressBook.filter((adbkEntry, index) => abFlags[index]) } -const isValidEnsName = (name) => /^([\w-]+\.)+(eth|test|xyz|luxe)$/.test(name) - const AddressBookInput = ({ classes, fieldMutator,