aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/ens-input.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-03-09 07:19:33 +0800
committerDan Finlay <dan@danfinlay.com>2017-03-09 07:19:33 +0800
commite3f6c010abb5cec35910dc4ea83f451287d25f11 (patch)
treebcc8f6b5e70b136d45644ae56024b253086e8b64 /ui/app/components/ens-input.js
parent69d4aafc3e8fd62875e5da2c2c6c7b3bdac5bf9f (diff)
parent1fbe4a801a05523cbdf97f7d8491affb49ed9bc6 (diff)
downloadtangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar.gz
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar.bz2
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar.lz
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar.xz
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.tar.zst
tangerine-wallet-browser-e3f6c010abb5cec35910dc4ea83f451287d25f11.zip
Get basic ENS working
& merge master into ENS branch.
Diffstat (limited to 'ui/app/components/ens-input.js')
-rw-r--r--ui/app/components/ens-input.js37
1 files changed, 26 insertions, 11 deletions
diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js
index f5edab9fd..f018cc632 100644
--- a/ui/app/components/ens-input.js
+++ b/ui/app/components/ens-input.js
@@ -3,7 +3,7 @@ const h = require('react-hyperscript')
const inherits = require('util').inherits
const extend = require('xtend')
const debounce = require('debounce')
-const ENS = require('ethereum-ens')
+const ENS = require('ethjs-ens')
const ensRE = /.+\.eth$/
const networkResolvers = {
@@ -30,6 +30,8 @@ EnsInput.prototype.render = function () {
console.dir(recipient)
return this.setState({
loadingEns: false,
+ ensResolution: null,
+ ensFailure: null,
})
}
@@ -53,12 +55,16 @@ EnsInput.prototype.componentDidMount = function () {
let resolverAddress = networkResolvers[network]
if (resolverAddress) {
- this.ens = new ENS(web3, resolverAddress)
+ const provider = web3.currentProvider
+ this.ens = new ENS({ provider, network })
this.checkName = debounce(this.lookupEnsName.bind(this), 200)
}
}
EnsInput.prototype.lookupEnsName = function () {
+ const recipient = document.querySelector('input[name="address"]').value
+ const { ensResolution } = this.state
+
if (!this.ens) {
return this.setState({
loadingEns: false,
@@ -67,17 +73,23 @@ EnsInput.prototype.lookupEnsName = function () {
})
}
- const recipient = document.querySelector('input[name="address"]').value
log.info(`ENS attempting to resolve name: ${recipient}`)
- this.ens.resolver(recipient).addr()
+ this.ens.lookup(recipient.trim())
.then((address) => {
- this.setState({
- loadingEns: false,
- ensResolution: address,
- hoverText: address,
- })
+ console.log('ens called back with ' + address)
+
+ if (address !== ensResolution) {
+ this.setState({
+ loadingEns: false,
+ ensResolution: address,
+ hoverText: address,
+ })
+ }
})
.catch((reason) => {
+ console.log('ens threw error: ' + reason.message)
+ console.trace(reason)
+ debugger
return this.setState({
loadingEns: false,
ensFailure: true,
@@ -86,10 +98,12 @@ EnsInput.prototype.lookupEnsName = function () {
})
}
-EnsInput.prototype.componentDidUpdate = function () {
+EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) {
const state = this.state || {}
const { ensResolution } = state
- if (ensResolution && this.props.onChange) {
+ if (ensResolution && this.props.onChange &&
+ ensResolution !== prevState.ensResolution) {
+ console.log('Firing on change to parent')
this.props.onChange(ensResolution)
}
}
@@ -115,6 +129,7 @@ EnsInput.prototype.ensIconContents = function (recipient) {
style: {
width: '30px',
height: '30px',
+ transform: 'translateY(-6px)',
},
})
}