aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send/send-content
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components/send/send-content')
-rw-r--r--ui/app/components/send/send-content/send-to-row/send-to-row.component.js6
-rw-r--r--ui/app/components/send/send-content/send-to-row/send-to-row.utils.js9
-rw-r--r--ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js2
3 files changed, 9 insertions, 8 deletions
diff --git a/ui/app/components/send/send-content/send-to-row/send-to-row.component.js b/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
index 0f26dd55c..3fbf9a76b 100644
--- a/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
+++ b/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
@@ -29,9 +29,9 @@ export default class SendToRow extends Component {
t: PropTypes.func,
}
- handleToChange (to, nickname = '', toError, toWarning) {
+ handleToChange (to, nickname = '', toError, toWarning, network) {
const { hasHexData, updateSendTo, updateSendToError, updateGas, tokens, selectedToken, updateSendToWarning } = this.props
- const toErrorObject = getToErrorObject(to, toError, hasHexData)
+ const toErrorObject = getToErrorObject(to, toError, hasHexData, tokens, selectedToken, network)
const toWarningObject = getToWarningObject(to, toWarning, tokens, selectedToken)
updateSendTo(to, nickname)
updateSendToError(toErrorObject)
@@ -69,7 +69,7 @@ export default class SendToRow extends Component {
inError={inError}
name={'address'}
network={network}
- onChange={({ toAddress, nickname, toError, toWarning }) => this.handleToChange(toAddress, nickname, toError, toWarning)}
+ onChange={({ toAddress, nickname, toError, toWarning }) => this.handleToChange(toAddress, nickname, toError, toWarning, this.props.network)}
openDropdown={() => openToDropdown()}
placeholder={this.context.t('recipientAddress')}
to={to}
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 4a8add42e..2bd3ea45e 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
@@ -2,20 +2,21 @@ const {
REQUIRED_ERROR,
INVALID_RECIPIENT_ADDRESS_ERROR,
KNOWN_RECIPIENT_ADDRESS_ERROR,
+ INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
} = require('../../send.constants')
-const { isValidAddress } = require('../../../../util')
+const { isValidAddress, isEthNetwork } = require('../../../../util')
import { checkExistingAddresses } from '../../../pages/add-token/util'
const ethUtil = require('ethereumjs-util')
const contractMap = require('eth-contract-metadata')
-function getToErrorObject (to, toError = null, hasHexData = false, tokens = [], selectedToken = null) {
+function getToErrorObject (to, toError = null, hasHexData = false, tokens = [], selectedToken = null, network) {
if (!to) {
if (!hasHexData) {
toError = REQUIRED_ERROR
}
- } else if (!isValidAddress(to) && !toError) {
- toError = INVALID_RECIPIENT_ADDRESS_ERROR
+ } else if (!isValidAddress(to, network) && !toError) {
+ toError = isEthNetwork(network) ? INVALID_RECIPIENT_ADDRESS_ERROR : INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR
} else if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) {
toError = KNOWN_RECIPIENT_ADDRESS_ERROR
}
diff --git a/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
index d3732307f..d4d054057 100644
--- a/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
+++ b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
@@ -159,7 +159,7 @@ describe('SendToRow Component', function () {
assert.equal(SendToRow.prototype.handleToChange.callCount, 1)
assert.deepEqual(
SendToRow.prototype.handleToChange.getCall(0).args,
- ['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning']
+ ['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning', 'mockNetwork' ]
)
})
})