1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-24 12:23:39 +02:00
metamask-extension/ui/app/pages/send/send-content/add-recipient/add-recipient.js
Mark Stacey 1972adad76
Remove unused parameters (#8216)
These two parameters were never used in practice - a `null` was being
passed in explicitly.
2020-03-19 14:32:38 -03:00

34 lines
1.1 KiB
JavaScript

import {
REQUIRED_ERROR,
INVALID_RECIPIENT_ADDRESS_ERROR,
KNOWN_RECIPIENT_ADDRESS_ERROR,
INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
} from '../../send.constants'
import { isValidAddress, isEthNetwork } from '../../../../helpers/utils/util'
import { checkExistingAddresses } from '../../../add-token/util'
import ethUtil from 'ethereumjs-util'
import contractMap from 'eth-contract-metadata'
export function getToErrorObject (to, hasHexData = false, _, __, network) {
let toError = null
if (!to) {
if (!hasHexData) {
toError = REQUIRED_ERROR
}
} else if (!isValidAddress(to, network) && !toError) {
toError = isEthNetwork(network) ? INVALID_RECIPIENT_ADDRESS_ERROR : INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR
}
return { to: toError }
}
export function getToWarningObject (to, tokens = [], selectedToken = null) {
let toWarning = null
if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) {
toWarning = KNOWN_RECIPIENT_ADDRESS_ERROR
}
return { to: toWarning }
}