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:
parent
c2499d63aa
commit
257e581d47
@ -251,7 +251,10 @@ function setupController (initState, initLangCode) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const provider = controller.provider
|
const provider = controller.provider
|
||||||
setupEnsIpfsResolver({ provider })
|
setupEnsIpfsResolver({
|
||||||
|
getCurrentNetwork: controller.getCurrentNetwork,
|
||||||
|
provider,
|
||||||
|
})
|
||||||
|
|
||||||
// submit rpc requests to mesh-metrics
|
// submit rpc requests to mesh-metrics
|
||||||
controller.networkController.on('rpc-req', (data) => {
|
controller.networkController.on('rpc-req', (data) => {
|
||||||
|
@ -6,7 +6,7 @@ const supportedTopLevelDomains = ['eth']
|
|||||||
|
|
||||||
module.exports = setupEnsIpfsResolver
|
module.exports = setupEnsIpfsResolver
|
||||||
|
|
||||||
function setupEnsIpfsResolver ({ provider }) {
|
function setupEnsIpfsResolver ({ provider, getCurrentNetwork }) {
|
||||||
|
|
||||||
// install listener
|
// install listener
|
||||||
const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`)
|
const urlPatterns = supportedTopLevelDomains.map(tld => `*://*.${tld}/*`)
|
||||||
@ -23,7 +23,10 @@ function setupEnsIpfsResolver ({ provider }) {
|
|||||||
async function webRequestDidFail (details) {
|
async function webRequestDidFail (details) {
|
||||||
const { tabId, url } = details
|
const { tabId, url } = details
|
||||||
// ignore requests that are not associated with tabs
|
// 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
|
// parse ens name
|
||||||
const urlData = urlUtil.parse(url)
|
const urlData = urlUtil.parse(url)
|
||||||
const { hostname: name, path, search, hash: fragment } = urlData
|
const { hostname: name, path, search, hash: fragment } = urlData
|
||||||
|
@ -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
|
* Collects all the information that we want to share
|
||||||
* with the mobile client for syncing purposes
|
* with the mobile client for syncing purposes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user