Skip to content

Commit 66fcf35

Browse files
authored
Merge pull request #1402 from MetaMask/ens-fix
ens - add mainnet ens support
2 parents 03d454f + ac54c7d commit 66fcf35

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ui/app/components/ens-input.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ const extend = require('xtend')
55
const debounce = require('debounce')
66
const copyToClipboard = require('copy-to-clipboard')
77
const ENS = require('ethjs-ens')
8+
const networkMap = require('ethjs-ens/lib/network-map.json')
89
const ensRE = /.+\.eth$/
910

10-
const networkResolvers = {
11-
'3': '112234455c3a32fd11230c42e7bccd4a84e02010',
12-
}
1311

1412
module.exports = EnsInput
1513

@@ -24,8 +22,8 @@ EnsInput.prototype.render = function () {
2422
list: 'addresses',
2523
onChange: () => {
2624
const network = this.props.network
27-
const resolverAddress = networkResolvers[network]
28-
if (!resolverAddress) return
25+
const networkHasEnsSupport = getNetworkEnsSupport(network)
26+
if (!networkHasEnsSupport) return
2927

3028
const recipient = document.querySelector('input[name="address"]').value
3129
if (recipient.match(ensRE) === null) {
@@ -73,9 +71,9 @@ EnsInput.prototype.render = function () {
7371

7472
EnsInput.prototype.componentDidMount = function () {
7573
const network = this.props.network
76-
const resolverAddress = networkResolvers[network]
74+
const networkHasEnsSupport = getNetworkEnsSupport(network)
7775

78-
if (resolverAddress) {
76+
if (networkHasEnsSupport) {
7977
const provider = global.ethereumProvider
8078
this.ens = new ENS({ provider, network })
8179
this.checkName = debounce(this.lookupEnsName.bind(this), 200)
@@ -169,3 +167,7 @@ EnsInput.prototype.ensIconContents = function (recipient) {
169167
})
170168
}
171169
}
170+
171+
function getNetworkEnsSupport(network) {
172+
return Boolean(networkMap[network])
173+
}

0 commit comments

Comments
 (0)