aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/ens-input.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-14 21:55:55 +0800
committerDan <danjm.com@gmail.com>2018-06-15 02:13:14 +0800
commitbb855707efbcb754f5e4ee4e124f69308bca037d (patch)
tree56b4c0e9f98f8efd8e8e6cd20d726bd4acc72e2e /ui/app/components/ens-input.js
parent5995b6d68dccb8d45a14b0665664717b21be5b8b (diff)
downloadtangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar.gz
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar.bz2
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar.lz
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar.xz
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.tar.zst
tangerine-wallet-browser-bb855707efbcb754f5e4ee4e124f69308bca037d.zip
ENS input in send form shows distinct errors for invalid addresses and non-existent addresses.
Diffstat (limited to 'ui/app/components/ens-input.js')
-rw-r--r--ui/app/components/ens-input.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js
index 1be6d798a..7873e81e0 100644
--- a/ui/app/components/ens-input.js
+++ b/ui/app/components/ens-input.js
@@ -12,6 +12,7 @@ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
const connect = require('react-redux').connect
const ToAutoComplete = require('./send/to-autocomplete')
const log = require('loglevel')
+const { isValidENSAddress } = require('../util')
EnsInput.contextTypes = {
t: PropTypes.func,
@@ -29,7 +30,7 @@ EnsInput.prototype.onChange = function (recipient) {
const network = this.props.network
const networkHasEnsSupport = getNetworkEnsSupport(network)
- this.props.onChange(recipient)
+ this.props.onChange({ toAddress: recipient })
if (!networkHasEnsSupport) return
@@ -38,6 +39,7 @@ EnsInput.prototype.onChange = function (recipient) {
loadingEns: false,
ensResolution: null,
ensFailure: null,
+ toError: null,
})
}
@@ -87,20 +89,28 @@ EnsInput.prototype.lookupEnsName = function (recipient) {
nickname: recipient.trim(),
hoverText: address + '\n' + this.context.t('clickCopy'),
ensFailure: false,
+ toError: null,
})
}
})
.catch((reason) => {
// log.error(reason)
- if (reason.message !== 'ENS name not defined.') {
- log.error(reason)
- }
- return this.setState({
+ const setStateObj = {
loadingEns: false,
ensResolution: recipient,
ensFailure: true,
- hoverText: reason.message,
- })
+ toError: null,
+ }
+ if (isValidENSAddress(recipient) && reason.message === 'ENS name not defined.') {
+ setStateObj.hoverText = this.context.t('ensNameNotFound')
+ setStateObj.toError = 'ensNameNotFound'
+ setStateObj.ensFailure = false
+ } else {
+ log.error(reason)
+ setStateObj.hoverText = reason.message
+ }
+
+ return this.setState(setStateObj)
})
}
@@ -117,7 +127,7 @@ EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) {
}
if (prevState && ensResolution && this.props.onChange &&
ensResolution !== prevState.ensResolution) {
- this.props.onChange(ensResolution, nickname)
+ this.props.onChange({ toAddress: ensResolution, nickname, toError: state.toError })
}
}
@@ -134,7 +144,9 @@ EnsInput.prototype.ensIcon = function (recipient) {
}
EnsInput.prototype.ensIconContents = function (recipient) {
- const { loadingEns, ensFailure, ensResolution } = this.state || { ensResolution: ZERO_ADDRESS}
+ const { loadingEns, ensFailure, ensResolution, toError } = this.state || { ensResolution: ZERO_ADDRESS }
+
+ if (toError) return
if (loadingEns) {
return h('img', {