|
|
|
@ -41,15 +41,12 @@ EnsInput.prototype.onChange = function (recipient) { |
|
|
|
|
ensResolution: null, |
|
|
|
|
ensFailure: null, |
|
|
|
|
toError: null, |
|
|
|
|
recipient, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
loadingEns: true, |
|
|
|
|
recipient, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.checkName(recipient) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -59,7 +56,6 @@ EnsInput.prototype.render = function () { |
|
|
|
|
list: 'addresses', |
|
|
|
|
onChange: this.onChange.bind(this), |
|
|
|
|
qrScanner: true, |
|
|
|
|
recipient: (this.state || {}).recipient, |
|
|
|
|
}) |
|
|
|
|
return h('div', { |
|
|
|
|
style: { width: '100%', position: 'relative' }, |
|
|
|
@ -83,21 +79,19 @@ EnsInput.prototype.componentDidMount = function () { |
|
|
|
|
|
|
|
|
|
EnsInput.prototype.lookupEnsName = function (recipient) { |
|
|
|
|
const { ensResolution } = this.state |
|
|
|
|
recipient = recipient.trim() |
|
|
|
|
|
|
|
|
|
log.info(`ENS attempting to resolve name: ${recipient}`) |
|
|
|
|
this.ens.lookup(recipient) |
|
|
|
|
this.ens.lookup(recipient.trim()) |
|
|
|
|
.then((address) => { |
|
|
|
|
if (address === ZERO_ADDRESS) throw new Error(this.context.t('noAddressForName')) |
|
|
|
|
if (address !== ensResolution) { |
|
|
|
|
this.setState({ |
|
|
|
|
loadingEns: false, |
|
|
|
|
ensResolution: address, |
|
|
|
|
nickname: recipient, |
|
|
|
|
nickname: recipient.trim(), |
|
|
|
|
hoverText: address + '\n' + this.context.t('clickCopy'), |
|
|
|
|
ensFailure: false, |
|
|
|
|
toError: null, |
|
|
|
|
recipient, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -107,11 +101,11 @@ EnsInput.prototype.lookupEnsName = function (recipient) { |
|
|
|
|
ensResolution: recipient, |
|
|
|
|
ensFailure: true, |
|
|
|
|
toError: null, |
|
|
|
|
recipient: 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 |
|
|
|
@ -134,7 +128,7 @@ EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) { |
|
|
|
|
} |
|
|
|
|
if (prevState && ensResolution && this.props.onChange && |
|
|
|
|
ensResolution !== prevState.ensResolution) { |
|
|
|
|
this.props.onChange({ toAddress: ensResolution, recipient: state.recipient, nickname, toError: state.toError, toWarning: state.toWarning }) |
|
|
|
|
this.props.onChange({ toAddress: ensResolution, nickname, toError: state.toError, toWarning: state.toWarning }) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|