diff options
Diffstat (limited to 'ui/app/components/send/send-content/send-to-row/send-to-row.utils.js')
-rw-r--r-- | ui/app/components/send/send-content/send-to-row/send-to-row.utils.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js b/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js index 0eeaa3a11..7efd2a772 100644 --- a/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js +++ b/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js @@ -1,16 +1,23 @@ const { REQUIRED_ERROR, INVALID_RECIPIENT_ADDRESS_ERROR, + KNOWN_RECIPIENT_ADDRESS_ERROR, } = require('../../send.constants') const { isValidAddress } = require('../../../../util') +import { checkExistingAddresses } from '../../../pages/add-token/util' -function getToErrorObject (to, toError = null, hasHexData = false) { +const ethUtil = require('ethereumjs-util') +const contractMap = require('eth-contract-metadata') + +function getToErrorObject (to, toError = null, hasHexData = false, tokens = [], selectedToken = null) { if (!to) { if (!hasHexData) { toError = REQUIRED_ERROR } } else if (!isValidAddress(to) && !toError) { toError = INVALID_RECIPIENT_ADDRESS_ERROR + } else if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) { + toError = KNOWN_RECIPIENT_ADDRESS_ERROR } return { to: toError } |