@@ -5,11 +5,9 @@ const extend = require('xtend')
55const debounce = require ( 'debounce' )
66const copyToClipboard = require ( 'copy-to-clipboard' )
77const ENS = require ( 'ethjs-ens' )
8+ const networkMap = require ( 'ethjs-ens/lib/network-map.json' )
89const ensRE = / .+ \. e t h $ /
910
10- const networkResolvers = {
11- '3' : '112234455c3a32fd11230c42e7bccd4a84e02010' ,
12- }
1311
1412module . 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
7472EnsInput . 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