1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 12:47:14 +01:00
metamask-extension/ui/app/pages/send/send-content/add-recipient/add-recipient.js
Mark Stacey ded43cbcdf
Remove unused code (#9564)
A number of unused parameters and `propTypes` have been merged, along
with an unused function.
2020-10-13 11:18:22 -02:30

32 lines
1012 B
JavaScript

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