aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/ens-input.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-13 19:56:21 +0800
committerDan <danjm.com@gmail.com>2018-06-13 19:56:21 +0800
commit5995b6d68dccb8d45a14b0665664717b21be5b8b (patch)
treeacc115b13121e76d7ae56c8983f8452150ff8d08 /ui/app/components/ens-input.js
parentb7a469681bdadd77f8c09da254db91dad820a7a1 (diff)
downloadtangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar.gz
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar.bz2
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar.lz
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar.xz
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.tar.zst
tangerine-wallet-browser-5995b6d68dccb8d45a14b0665664717b21be5b8b.zip
ENS name revalidates on network change.
Diffstat (limited to 'ui/app/components/ens-input.js')
-rw-r--r--ui/app/components/ens-input.js56
1 files changed, 33 insertions, 23 deletions
diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js
index aff4b6ef6..1be6d798a 100644
--- a/ui/app/components/ens-input.js
+++ b/ui/app/components/ens-input.js
@@ -25,31 +25,33 @@ function EnsInput () {
Component.call(this)
}
-EnsInput.prototype.render = function () {
- const props = this.props
- const opts = extend(props, {
- list: 'addresses',
- onChange: (recipient) => {
- const network = this.props.network
- const networkHasEnsSupport = getNetworkEnsSupport(network)
+EnsInput.prototype.onChange = function (recipient) {
+ const network = this.props.network
+ const networkHasEnsSupport = getNetworkEnsSupport(network)
- props.onChange(recipient)
+ this.props.onChange(recipient)
- if (!networkHasEnsSupport) return
+ if (!networkHasEnsSupport) return
- if (recipient.match(ensRE) === null) {
- return this.setState({
- loadingEns: false,
- ensResolution: null,
- ensFailure: null,
- })
- }
+ if (recipient.match(ensRE) === null) {
+ return this.setState({
+ loadingEns: false,
+ ensResolution: null,
+ ensFailure: null,
+ })
+ }
- this.setState({
- loadingEns: true,
- })
- this.checkName(recipient)
- },
+ this.setState({
+ loadingEns: true,
+ })
+ this.checkName(recipient)
+}
+
+EnsInput.prototype.render = function () {
+ const props = this.props
+ const opts = extend(props, {
+ list: 'addresses',
+ onChange: this.onChange.bind(this),
})
return h('div', {
style: { width: '100%', position: 'relative' },
@@ -89,10 +91,13 @@ EnsInput.prototype.lookupEnsName = function (recipient) {
}
})
.catch((reason) => {
- log.error(reason)
+ // log.error(reason)
+ if (reason.message !== 'ENS name not defined.') {
+ log.error(reason)
+ }
return this.setState({
loadingEns: false,
- ensResolution: ZERO_ADDRESS,
+ ensResolution: recipient,
ensFailure: true,
hoverText: reason.message,
})
@@ -105,6 +110,11 @@ EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) {
// If an address is sent without a nickname, meaning not from ENS or from
// the user's own accounts, a default of a one-space string is used.
const nickname = state.nickname || ' '
+ if (prevProps.network !== this.props.network) {
+ const provider = global.ethereumProvider
+ this.ens = new ENS({ provider, network: this.props.network })
+ this.onChange(ensResolution)
+ }
if (prevState && ensResolution && this.props.onChange &&
ensResolution !== prevState.ensResolution) {
this.props.onChange(ensResolution, nickname)