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:
parent
c2499d63aa
commit
257e581d47
@ -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) => {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user