Skip to content

Commit

Permalink
Only resolve ENS on mainnet (#7944)
Browse files Browse the repository at this point in the history
The ENS resolver will now bail on any network other than mainnet.
  • Loading branch information
Gudahtt authored Jan 30, 2020
1 parent 472d8c3 commit ee41505
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function setupController (initState, initLangCode) {
})

setupEnsIpfsResolver({
getCurrentNetwork: controller.getCurrentNetwork,
getIpfsGateway: controller.preferencesController.getIpfsGateway.bind(controller.preferencesController),
provider: controller.provider,
})
Expand Down
5 changes: 3 additions & 2 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const supportedTopLevelDomains = ['eth']

export default setupEnsIpfsResolver

function setupEnsIpfsResolver ({ provider, getIpfsGateway }) {
function setupEnsIpfsResolver ({ provider, getCurrentNetwork, getIpfsGateway }) {

// install listener
const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`)
Expand All @@ -23,7 +23,8 @@ function setupEnsIpfsResolver ({ provider, getIpfsGateway }) {
async function webRequestDidFail (details) {
const { tabId, url } = details
// ignore requests that are not associated with tabs
if (tabId === -1) {
// only attempt ENS resolution on mainnet
if (tabId === -1 || getCurrentNetwork() !== '1') {
return
}
// parse ens name
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ export default class MetamaskController extends EventEmitter {
})
}

getCurrentNetwork = () => {
return this.networkController.store.getState().network
}

/**
* Collects all the information that we want to share
* with the mobile client for syncing purposes
Expand Down

0 comments on commit ee41505

Please sign in to comment.