diff --git a/app/scripts/background.js b/app/scripts/background.js index b2ed07e8b..6a1ca37d8 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -79,7 +79,7 @@ const localStore = inTest ? new ReadOnlyNetworkStore() : new LocalStore(); let versionedData; if (inTest || process.env.METAMASK_DEBUG) { - global.metamaskGetState = localStore.get.bind(localStore); + global.stateHooks.metamaskGetState = localStore.get.bind(localStore); } const phishingPageUrl = new URL(process.env.PHISHING_WARNING_PAGE_URL); @@ -753,7 +753,7 @@ browser.runtime.onInstalled.addListener(({ reason }) => { }); function setupSentryGetStateGlobal(store) { - global.sentryHooks.getSentryState = function () { + global.stateHooks.getSentryState = function () { const fullState = store.getState(); const debugState = maskObject({ metamask: fullState }, SENTRY_STATE); return { diff --git a/app/scripts/sentry-install.js b/app/scripts/sentry-install.js index 1f0b87bd5..fc654371b 100644 --- a/app/scripts/sentry-install.js +++ b/app/scripts/sentry-install.js @@ -1,10 +1,10 @@ import setupSentry from './lib/setupSentry'; // The root compartment will populate this with hooks -global.sentryHooks = {}; +global.stateHooks = {}; // setup sentry error reporting global.sentry = setupSentry({ release: process.env.METAMASK_VERSION, - getState: () => global.sentryHooks?.getSentryState?.() || {}, + getState: () => global.stateHooks?.getSentryState?.() || {}, }); diff --git a/docs/generating-fixture-data.md b/docs/generating-fixture-data.md index 77b90f3c2..274945765 100644 --- a/docs/generating-fixture-data.md +++ b/docs/generating-fixture-data.md @@ -4,12 +4,12 @@ Fixture data can be generated by following these steps: 1. Load the unpacked extension in development or test mode 2. Inspecting the background context of the extension -3. Call `metamaskGetState`, then call [`copy`][1] on the results +3. Call `stateHooks.metamaskGetState`, then call [`copy`][1] on the results You can then paste the contents directly in your fixture file. ```js -copy(await metamaskGetState()) +copy(await stateHooks.metamaskGetState()) ``` diff --git a/test/e2e/webdriver/driver.js b/test/e2e/webdriver/driver.js index 1df5dfd4c..1969ddfcf 100644 --- a/test/e2e/webdriver/driver.js +++ b/test/e2e/webdriver/driver.js @@ -405,7 +405,9 @@ class Driver { const htmlSource = await this.driver.getPageSource(); await fs.writeFile(`${filepathBase}-dom.html`, htmlSource); const uiState = await this.driver.executeScript( - () => window.getCleanAppState && window.getCleanAppState(), + () => + window.stateHooks.getCleanAppState && + window.stateHooks.getCleanAppState(), ); await fs.writeFile( `${filepathBase}-state.json`, diff --git a/ui/index.js b/ui/index.js index 0d7a09e31..643bc9760 100644 --- a/ui/index.js +++ b/ui/index.js @@ -164,7 +164,7 @@ async function startApp(metamaskState, backgroundConnection, opts) { } function setupDebuggingHelpers(store) { - window.getCleanAppState = async function () { + window.stateHooks.getCleanAppState = async function () { const state = clone(store.getState()); state.version = global.platform.getVersion(); state.browser = window.navigator.userAgent; @@ -173,7 +173,7 @@ function setupDebuggingHelpers(store) { }); return state; }; - window.sentryHooks.getSentryState = function () { + window.stateHooks.getSentryState = function () { const fullState = store.getState(); const debugState = maskObject(fullState, SENTRY_STATE); return { @@ -185,7 +185,7 @@ function setupDebuggingHelpers(store) { } window.logStateString = async function (cb) { - const state = await window.getCleanAppState(); + const state = await window.stateHooks.getCleanAppState(); browser.runtime .getPlatformInfo() .then((platform) => {