From a891fa36b6d72ca67b66cfede7f4c3c3a11ad036 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Tue, 14 Jan 2020 15:44:12 -0330 Subject: [PATCH] Remove MetaMask Mesh testing client (#7818) --- app/scripts/background.js | 9 ------ .../controllers/network/createInfuraClient.js | 14 ++------- app/scripts/controllers/network/network.js | 1 - app/scripts/lib/setupMetamaskMeshMetrics.js | 31 ------------------- 4 files changed, 2 insertions(+), 53 deletions(-) delete mode 100644 app/scripts/lib/setupMetamaskMeshMetrics.js diff --git a/app/scripts/background.js b/app/scripts/background.js index 2acb3ad66..20e05039a 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -31,7 +31,6 @@ import MetamaskController from './metamask-controller' import rawFirstTimeState from './first-time-state' import setupSentry from './lib/setupSentry' import reportFailedTxToSentry from './lib/reportFailedTxToSentry' -import setupMetamaskMeshMetrics from './lib/setupMetamaskMeshMetrics' import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code' import getObjStructure from './lib/getObjStructure' import setupEnsIpfsResolver from './lib/ens-ipfs/setup' @@ -70,9 +69,6 @@ let versionedData // initialization flow initialize().catch(log.error) -// setup metamask mesh testing container -const { submitMeshMetricsEntry } = setupMetamaskMeshMetrics() - /** * An object representing a transaction, in whatever state it is in. * @typedef TransactionMeta @@ -257,11 +253,6 @@ function setupController (initState, initLangCode) { provider: controller.provider, }) - // submit rpc requests to mesh-metrics - controller.networkController.on('rpc-req', (data) => { - submitMeshMetricsEntry({ type: 'rpc', data }) - }) - // report failed transactions to Sentry controller.txController.on(`tx:status-update`, (txId, status) => { if (status !== 'failed') { diff --git a/app/scripts/controllers/network/createInfuraClient.js b/app/scripts/controllers/network/createInfuraClient.js index 77d60045a..5ab71550d 100644 --- a/app/scripts/controllers/network/createInfuraClient.js +++ b/app/scripts/controllers/network/createInfuraClient.js @@ -11,11 +11,8 @@ import BlockTracker from 'eth-block-tracker' export default createInfuraClient -function createInfuraClient ({ network, onRequest }) { - const infuraMiddleware = mergeMiddleware([ - createRequestHookMiddleware(onRequest), - createInfuraMiddleware({ network, maxAttempts: 5, source: 'metamask' }), - ]) +function createInfuraClient ({ network }) { + const infuraMiddleware = createInfuraMiddleware({ network, maxAttempts: 5, source: 'metamask' }) const infuraProvider = providerFromMiddleware(infuraMiddleware) const blockTracker = new BlockTracker({ provider: infuraProvider }) @@ -65,10 +62,3 @@ function createNetworkAndChainIdMiddleware ({ network }) { net_version: netId, }) } - -function createRequestHookMiddleware (onRequest) { - return (req, _, next) => { - onRequest(req) - next() - } -} diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 9a0ce2ca9..a0c19f1bd 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -189,7 +189,6 @@ export default class NetworkController extends EventEmitter { log.info('NetworkController - configureInfuraProvider', type) const networkClient = createInfuraClient({ network: type, - onRequest: (req) => this.emit('rpc-req', { network: type, req }), }) this._setNetworkClient(networkClient) // setup networkConfig diff --git a/app/scripts/lib/setupMetamaskMeshMetrics.js b/app/scripts/lib/setupMetamaskMeshMetrics.js deleted file mode 100644 index 81e5f5e4f..000000000 --- a/app/scripts/lib/setupMetamaskMeshMetrics.js +++ /dev/null @@ -1,31 +0,0 @@ - -export default setupMetamaskMeshMetrics - -/** - * Injects an iframe into the current document for testing - */ -function setupMetamaskMeshMetrics () { - const testingContainer = document.createElement('iframe') - const targetOrigin = 'https://metamask.github.io' - const targetUrl = `${targetOrigin}/mesh-testing/` - testingContainer.src = targetUrl - - let didLoad = false - testingContainer.addEventListener('load', () => { - didLoad = true - }) - - console.log('Injecting MetaMask Mesh testing client') - document.head.appendChild(testingContainer) - - return { submitMeshMetricsEntry } - - function submitMeshMetricsEntry (message) { - // ignore if we haven't loaded yet - if (!didLoad) { - return - } - // submit the message - testingContainer.contentWindow.postMessage(message, targetOrigin) - } -}