1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +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
parent c2499d63aa
commit 257e581d47
3 changed files with 13 additions and 3 deletions

View File

@ -251,7 +251,10 @@ function setupController (initState, initLangCode) {
})
const provider = controller.provider
setupEnsIpfsResolver({ provider })
setupEnsIpfsResolver({
getCurrentNetwork: controller.getCurrentNetwork,
provider,
})
// submit rpc requests to mesh-metrics
controller.networkController.on('rpc-req', (data) => {

View File

@ -6,7 +6,7 @@ const supportedTopLevelDomains = ['eth']
module.exports = setupEnsIpfsResolver
function setupEnsIpfsResolver ({ provider }) {
function setupEnsIpfsResolver ({ provider, getCurrentNetwork }) {
// install listener
const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`)
@ -23,7 +23,10 @@ function setupEnsIpfsResolver ({ provider }) {
async function webRequestDidFail (details) {
const { tabId, url } = details
// ignore requests that are not associated with tabs
if (tabId === -1) return
// only attempt ENS resolution on mainnet
if (tabId === -1 || getCurrentNetwork() !== '1') {
return
}
// parse ens name
const urlData = urlUtil.parse(url)
const { hostname: name, path, search, hash: fragment } = urlData

View File

@ -675,6 +675,10 @@ module.exports = 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