Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V7.7.5 Upstream Changes #124

Merged
merged 12 commits into from Feb 25, 2020

Only resolve ENS on mainnet (#7944)

The ENS resolver will now bail on any network other than mainnet.
  • Loading branch information
Gudahtt authored and ryanml committed Jan 30, 2020
commit 14db5196c8b161657f834ec43e4cdb3b0209ca99
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.