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