diff options
author | Dan J Miller <danjm.com@gmail.com> | 2019-08-03 07:00:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-03 07:00:50 +0800 |
commit | 165f44d3a487adc580cc4b68580d3ac42a34bcd0 (patch) | |
tree | ccc14f04f635fb35ca87e8349c88b2fa20531f94 /ui | |
parent | 9d5be5d29fcdab1273e30810f87de4624b8622a1 (diff) | |
download | tangerine-wallet-browser-165f44d3a487adc580cc4b68580d3ac42a34bcd0.tar.gz tangerine-wallet-browser-165f44d3a487adc580cc4b68580d3ac42a34bcd0.tar.zst tangerine-wallet-browser-165f44d3a487adc580cc4b68580d3ac42a34bcd0.zip |
Address book name save fix (#6945)
* Fix address book name saving and ens input errors on good inputs on unsupported networks
* Add initial e2e test for address book send flow.
* No longer need to click recipient row in e2e tests
* Click write button in address book e2e test on seed confirm screen
* Use correct seed phrase and private key in address-book.spec tests
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/helpers/utils/util.js | 8 | ||||
-rw-r--r-- | ui/app/pages/send/send-content/add-recipient/ens-input.component.js | 10 | ||||
-rw-r--r-- | ui/app/pages/send/send-footer/send-footer.utils.js | 2 | ||||
-rw-r--r-- | ui/app/pages/send/send.component.js | 1 |
4 files changed, 17 insertions, 4 deletions
diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index 94fa9ad42..b9e8e83c5 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -61,6 +61,7 @@ module.exports = { checksumAddress, addressSlicer, isEthNetwork, + isValidAddressHead, } function isEthNetwork (netId) { @@ -323,3 +324,10 @@ function addressSlicer (address = '') { return `${address.slice(0, 6)}...${address.slice(-4)}` } + +function isValidAddressHead (address) { + const addressLengthIsLessThanFull = address.length < 42 + const addressIsHex = isHex(address) + + return addressLengthIsLessThanFull && addressIsHex +} diff --git a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js index c8d022079..498d72605 100644 --- a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import c from 'classnames' -import { isValidENSAddress, isValidAddress } from '../../../../helpers/utils/util' +import { isValidENSAddress, isValidAddress, isValidAddressHead } from '../../../../helpers/utils/util' import {ellipsify} from '../../send.utils' import debounce from 'debounce' @@ -33,6 +33,7 @@ export default class EnsInput extends Component { addressBook: PropTypes.array, onPaste: PropTypes.func, onReset: PropTypes.func, + onValidAddressTyped: PropTypes.func, } state = { @@ -108,7 +109,7 @@ export default class EnsInput extends Component { } onChange = e => { - const { network, onChange, updateEnsResolution, updateEnsResolutionError } = this.props + const { network, onChange, updateEnsResolution, updateEnsResolutionError, onValidAddressTyped } = this.props const input = e.target.value const networkHasEnsSupport = getNetworkEnsSupport(network) @@ -116,7 +117,8 @@ export default class EnsInput extends Component { // Empty ENS state if input is empty // maybe scan ENS - if (!input || isValidAddress(input) || !networkHasEnsSupport) { + + if (!networkHasEnsSupport && !isValidAddress(input) && !isValidAddressHead(input)) { updateEnsResolution('') updateEnsResolutionError(!networkHasEnsSupport ? 'Network does not support ENS' : '') return @@ -124,6 +126,8 @@ export default class EnsInput extends Component { if (isValidENSAddress(input)) { this.lookupEnsName(input) + } else if (onValidAddressTyped && isValidAddress(input)) { + onValidAddressTyped(input) } else { updateEnsResolution('') updateEnsResolutionError('') diff --git a/ui/app/pages/send/send-footer/send-footer.utils.js b/ui/app/pages/send/send-footer/send-footer.utils.js index 91ac29014..ce65535a6 100644 --- a/ui/app/pages/send/send-footer/send-footer.utils.js +++ b/ui/app/pages/send/send-footer/send-footer.utils.js @@ -76,7 +76,7 @@ function constructUpdatedTx ({ function addressIsNew (toAccounts, newAddress) { const newAddressNormalized = newAddress.toLowerCase() - const foundMatching = toAccounts.some(({ address }) => address === newAddressNormalized) + const foundMatching = toAccounts.some(({ address }) => address.toLowerCase() === newAddressNormalized) return !foundMatching } diff --git a/ui/app/pages/send/send.component.js b/ui/app/pages/send/send.component.js index 9cdf75536..cb07dcb59 100644 --- a/ui/app/pages/send/send.component.js +++ b/ui/app/pages/send/send.component.js @@ -303,6 +303,7 @@ export default class SendTransactionScreen extends PersistentForm { this.props.scanQrCode() }} onChange={this.onRecipientInputChange} + onValidAddressTyped={(address) => this.props.updateSendTo(address, '')} onPaste={text => this.props.updateSendTo(text)} onReset={() => this.props.updateSendTo('', '')} updateEnsResolution={this.props.updateSendEnsResolution} |