mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Remove unused function (#14423)
* Remove unused function * Removed fetch mocks file as it's no longer used
This commit is contained in:
parent
d642dbc111
commit
8eb8fc1591
@ -1,73 +0,0 @@
|
|||||||
{
|
|
||||||
"gasPricesBasic": {
|
|
||||||
"average": 85,
|
|
||||||
"fast": 200,
|
|
||||||
"safeLow": 80
|
|
||||||
},
|
|
||||||
"metametrics": {
|
|
||||||
"mockMetaMetricsResponse": true
|
|
||||||
},
|
|
||||||
"swaps": {
|
|
||||||
"featureFlags": {
|
|
||||||
"bsc": {
|
|
||||||
"mobile_active": false,
|
|
||||||
"extension_active": true,
|
|
||||||
"fallback_to_v1": true
|
|
||||||
},
|
|
||||||
"ethereum": {
|
|
||||||
"mobile_active": false,
|
|
||||||
"extension_active": true,
|
|
||||||
"fallback_to_v1": true
|
|
||||||
},
|
|
||||||
"polygon": {
|
|
||||||
"mobile_active": false,
|
|
||||||
"extension_active": true,
|
|
||||||
"fallback_to_v1": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tokenList": {
|
|
||||||
"0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0": {
|
|
||||||
"address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0",
|
|
||||||
"symbol": "MATIC",
|
|
||||||
"decimals": 18,
|
|
||||||
"name": "Polygon",
|
|
||||||
"iconUrl": "https://raw.githubusercontent.com/MetaMask/eth-contract-metadata/master/images/matic-network-logo.svg",
|
|
||||||
"aggregators": [
|
|
||||||
"airswapLight",
|
|
||||||
"bancor",
|
|
||||||
"coinGecko",
|
|
||||||
"kleros",
|
|
||||||
"oneInch",
|
|
||||||
"paraswap",
|
|
||||||
"pmm",
|
|
||||||
"totle",
|
|
||||||
"zapper",
|
|
||||||
"zerion",
|
|
||||||
"zeroEx"
|
|
||||||
],
|
|
||||||
"occurrences": 11
|
|
||||||
},
|
|
||||||
"0x0d8775f648430679a709e98d2b0cb6250d2887ef": {
|
|
||||||
"address": "0x0d8775f648430679a709e98d2b0cb6250d2887ef",
|
|
||||||
"symbol": "BAT",
|
|
||||||
"decimals": 18,
|
|
||||||
"name": "Basic Attention Tok",
|
|
||||||
"iconUrl": "https://s3.amazonaws.com/airswap-token-images/BAT.png",
|
|
||||||
"aggregators": [
|
|
||||||
"airswapLight",
|
|
||||||
"bancor",
|
|
||||||
"coinGecko",
|
|
||||||
"kleros",
|
|
||||||
"oneInch",
|
|
||||||
"paraswap",
|
|
||||||
"pmm",
|
|
||||||
"totle",
|
|
||||||
"zapper",
|
|
||||||
"zerion",
|
|
||||||
"zeroEx"
|
|
||||||
],
|
|
||||||
"occurrences": 11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
const { Browser } = require('selenium-webdriver');
|
const { Browser } = require('selenium-webdriver');
|
||||||
const fetchMockResponses = require('../../data/fetch-mocks.json');
|
|
||||||
const Driver = require('./driver');
|
const Driver = require('./driver');
|
||||||
const ChromeDriver = require('./chrome');
|
const ChromeDriver = require('./chrome');
|
||||||
const FirefoxDriver = require('./firefox');
|
const FirefoxDriver = require('./firefox');
|
||||||
@ -12,7 +11,6 @@ async function buildWebDriver({ responsive, port, type } = {}) {
|
|||||||
extensionId,
|
extensionId,
|
||||||
extensionUrl,
|
extensionUrl,
|
||||||
} = await buildBrowserWebDriver(browser, { responsive, port, type });
|
} = await buildBrowserWebDriver(browser, { responsive, port, type });
|
||||||
await setupFetchMocking(seleniumDriver);
|
|
||||||
const driver = new Driver(seleniumDriver, browser, extensionUrl);
|
const driver = new Driver(seleniumDriver, browser, extensionUrl);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -35,53 +33,6 @@ async function buildBrowserWebDriver(browser, webDriverOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupFetchMocking(driver) {
|
|
||||||
// define fetchMocking script, to be evaluated in the browser
|
|
||||||
function fetchMocking(mockResponses) {
|
|
||||||
window.origFetch = window.fetch.bind(window);
|
|
||||||
window.fetch = async (...args) => {
|
|
||||||
const url = args[0];
|
|
||||||
// api.metaswap.codefi.network/gasPrices
|
|
||||||
if (
|
|
||||||
url.match(/^http(s)?:\/\/api\.metaswap\.codefi\.network\/gasPrices/u)
|
|
||||||
) {
|
|
||||||
return { json: async () => clone(mockResponses.gasPricesBasic) };
|
|
||||||
} else if (url.match(/chromeextensionmm/u)) {
|
|
||||||
return { json: async () => clone(mockResponses.metametrics) };
|
|
||||||
} else if (url.match(/^https:\/\/(swap\.metaswap\.codefi\.network)/u)) {
|
|
||||||
if (url.match(/featureFlags$/u)) {
|
|
||||||
return { json: async () => clone(mockResponses.swaps.featureFlags) };
|
|
||||||
}
|
|
||||||
} else if (
|
|
||||||
url.match(/^https:\/\/(token-api\.airswap-prod\.codefi\.network)/u)
|
|
||||||
) {
|
|
||||||
if (url.match(/tokens\/1337$/u)) {
|
|
||||||
return { json: async () => clone(mockResponses.tokenList) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return window.origFetch(...args);
|
|
||||||
};
|
|
||||||
if (window.chrome && window.chrome.webRequest) {
|
|
||||||
window.chrome.webRequest.onBeforeRequest.addListener(
|
|
||||||
cancelInfuraRequest,
|
|
||||||
{ urls: ['https://*.infura.io/*'] },
|
|
||||||
['blocking'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
function cancelInfuraRequest(requestDetails) {
|
|
||||||
console.log(`fetchMocking - Canceling request: "${requestDetails.url}"`);
|
|
||||||
return { cancel: true };
|
|
||||||
}
|
|
||||||
function clone(obj) {
|
|
||||||
return JSON.parse(JSON.stringify(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// fetchMockResponses are parsed last minute to ensure that objects are uniquely instantiated
|
|
||||||
const fetchMockResponsesJson = JSON.stringify(fetchMockResponses);
|
|
||||||
// eval the fetchMocking script in the browser
|
|
||||||
await driver.executeScript(`(${fetchMocking})(${fetchMockResponsesJson})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
buildWebDriver,
|
buildWebDriver,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user