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
472d8c3160
commit
ee415058cc
@ -254,6 +254,7 @@ function setupController (initState, initLangCode) {
|
||||
})
|
||||
|
||||
setupEnsIpfsResolver({
|
||||
getCurrentNetwork: controller.getCurrentNetwork,
|
||||
getIpfsGateway: controller.preferencesController.getIpfsGateway.bind(controller.preferencesController),
|
||||
provider: controller.provider,
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user