diff options
author | Jonathan Smirnoff <7558841+jonathansmirnoff@users.noreply.github.com> | 2019-02-14 04:30:46 +0800 |
---|---|---|
committer | Frankie <frankie.diamond@gmail.com> | 2019-02-14 04:30:46 +0800 |
commit | 8dddf48904323d47685516ccc76f9e267dbd188a (patch) | |
tree | 3e1c11920da2be888271e4bc48d8dce61e64b944 /ui/app/components/send | |
parent | f7ab4577f637dd9e96cec0f08848bc70c489f9d3 (diff) | |
download | tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.gz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.bz2 tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.lz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.xz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.zst tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.zip |
Fixed issue #5838 (#6001)
Update changelog file
Diffstat (limited to 'ui/app/components/send')
4 files changed, 11 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' ] ) }) }) diff --git a/ui/app/components/send/send.constants.js b/ui/app/components/send/send.constants.js index e79734a54..490bc6fd2 100644 --- a/ui/app/components/send/send.constants.js +++ b/ui/app/components/send/send.constants.js @@ -26,6 +26,7 @@ const INSUFFICIENT_FUNDS_ERROR = 'insufficientFunds' const INSUFFICIENT_TOKENS_ERROR = 'insufficientTokens' const NEGATIVE_ETH_ERROR = 'negativeETH' const INVALID_RECIPIENT_ADDRESS_ERROR = 'invalidAddressRecipient' +const INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR = 'invalidAddressRecipientNotEthNetwork' const REQUIRED_ERROR = 'required' const KNOWN_RECIPIENT_ADDRESS_ERROR = 'knownAddressRecipient' @@ -44,6 +45,7 @@ module.exports = { INSUFFICIENT_TOKENS_ERROR, INVALID_RECIPIENT_ADDRESS_ERROR, KNOWN_RECIPIENT_ADDRESS_ERROR, + INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR, MIN_GAS_LIMIT_DEC, MIN_GAS_LIMIT_HEX, MIN_GAS_PRICE_DEC, |