mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add ENS click to copy
Also bump ethjs-ens version to get proper error for unregistered names.
This commit is contained in:
parent
e3f6c010ab
commit
42e4a0621b
@ -60,7 +60,7 @@
|
|||||||
"ethereumjs-tx": "^1.0.0",
|
"ethereumjs-tx": "^1.0.0",
|
||||||
"ethereumjs-util": "ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
|
"ethereumjs-util": "ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
|
||||||
"ethereumjs-wallet": "^0.6.0",
|
"ethereumjs-wallet": "^0.6.0",
|
||||||
"ethjs-ens": "^1.0.1",
|
"ethjs-ens": "^1.0.2",
|
||||||
"express": "^4.14.0",
|
"express": "^4.14.0",
|
||||||
"extension-link-enabler": "^1.0.0",
|
"extension-link-enabler": "^1.0.0",
|
||||||
"extensionizer": "^1.0.0",
|
"extensionizer": "^1.0.0",
|
||||||
|
@ -3,6 +3,7 @@ const h = require('react-hyperscript')
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const debounce = require('debounce')
|
const debounce = require('debounce')
|
||||||
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
const ENS = require('ethjs-ens')
|
const ENS = require('ethjs-ens')
|
||||||
const ensRE = /.+\.eth$/
|
const ensRE = /.+\.eth$/
|
||||||
|
|
||||||
@ -27,7 +28,6 @@ EnsInput.prototype.render = function () {
|
|||||||
|
|
||||||
const recipient = document.querySelector('input[name="address"]').value
|
const recipient = document.querySelector('input[name="address"]').value
|
||||||
if (recipient.match(ensRE) === null) {
|
if (recipient.match(ensRE) === null) {
|
||||||
console.dir(recipient)
|
|
||||||
return this.setState({
|
return this.setState({
|
||||||
loadingEns: false,
|
loadingEns: false,
|
||||||
ensResolution: null,
|
ensResolution: null,
|
||||||
@ -76,20 +76,15 @@ EnsInput.prototype.lookupEnsName = function () {
|
|||||||
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.trim())
|
||||||
.then((address) => {
|
.then((address) => {
|
||||||
console.log('ens called back with ' + address)
|
|
||||||
|
|
||||||
if (address !== ensResolution) {
|
if (address !== ensResolution) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loadingEns: false,
|
loadingEns: false,
|
||||||
ensResolution: address,
|
ensResolution: address,
|
||||||
hoverText: address,
|
hoverText: address + '\nClick to Copy',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
console.log('ens threw error: ' + reason.message)
|
|
||||||
console.trace(reason)
|
|
||||||
debugger
|
|
||||||
return this.setState({
|
return this.setState({
|
||||||
loadingEns: false,
|
loadingEns: false,
|
||||||
ensFailure: true,
|
ensFailure: true,
|
||||||
@ -103,7 +98,6 @@ EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|||||||
const { ensResolution } = state
|
const { ensResolution } = state
|
||||||
if (ensResolution && this.props.onChange &&
|
if (ensResolution && this.props.onChange &&
|
||||||
ensResolution !== prevState.ensResolution) {
|
ensResolution !== prevState.ensResolution) {
|
||||||
console.log('Firing on change to parent')
|
|
||||||
this.props.onChange(ensResolution)
|
this.props.onChange(ensResolution)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,8 +133,13 @@ EnsInput.prototype.ensIconContents = function (recipient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ensResolution) {
|
if (ensResolution) {
|
||||||
return h('i.fa.fa-check-circle.fa-lg', {
|
return h('i.fa.fa-check-circle.fa-lg.cursor-pointer', {
|
||||||
style: { color: 'green' },
|
style: { color: 'green' },
|
||||||
|
onClick: (event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
copyToClipboard(ensResolution)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user