1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Only resolve ENS on mainnet (#7944)

The ENS resolver will now bail on any network other than mainnet.
This commit is contained in:
Mark Stacey 2020-01-29 20:57:14 -04:00 committed by GitHub
parent 472d8c3160
commit ee415058cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -254,6 +254,7 @@ function setupController (initState, initLangCode) {
})
setupEnsIpfsResolver({
getCurrentNetwork: controller.getCurrentNetwork,
getIpfsGateway: controller.preferencesController.getIpfsGateway.bind(controller.preferencesController),
provider: controller.provider,
})

View File

@ -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}/*`)
@ -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

View File

@ -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