|
|
@ -1,4 +1,4 @@ |
|
|
|
/* |
|
|
|
/** |
|
|
|
* @file The entry point for the web extension singleton process. |
|
|
|
* @file The entry point for the web extension singleton process. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ setupMetamaskMeshMetrics() |
|
|
|
* @property {number} submittedTime - The time the transaction was submitted to the network, in Unix epoch time (ms). |
|
|
|
* @property {number} submittedTime - The time the transaction was submitted to the network, in Unix epoch time (ms). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* The data emitted from the MetaMaskController.store EventEmitter, also used to initialize the MetaMaskController. |
|
|
|
* The data emitted from the MetaMaskController.store EventEmitter, also used to initialize the MetaMaskController. |
|
|
|
* @typedef MetaMaskState |
|
|
|
* @typedef MetaMaskState |
|
|
|
* @property {boolean} isInitialized - Whether the first vault has been created. |
|
|
|
* @property {boolean} isInitialized - Whether the first vault has been created. |
|
|
@ -139,13 +139,13 @@ setupMetamaskMeshMetrics() |
|
|
|
* @property {boolean} forgottenPassword - Returns true if the user has initiated the password recovery screen, is recovering from seed phrase. |
|
|
|
* @property {boolean} forgottenPassword - Returns true if the user has initiated the password recovery screen, is recovering from seed phrase. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* @typedef VersionedData |
|
|
|
* @typedef VersionedData |
|
|
|
* @property {MetaMaskState} data - The data emitted from MetaMask controller, or used to initialize it. |
|
|
|
* @property {MetaMaskState} data - The data emitted from MetaMask controller, or used to initialize it. |
|
|
|
* @property {Number} version - The latest migration version that has been run. |
|
|
|
* @property {Number} version - The latest migration version that has been run. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Initializes the MetaMask controller, and sets up all platform configuration. |
|
|
|
* Initializes the MetaMask controller, and sets up all platform configuration. |
|
|
|
* @returns {Promise} Setup complete. |
|
|
|
* @returns {Promise} Setup complete. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -160,7 +160,7 @@ async function initialize () { |
|
|
|
// State and Persistence
|
|
|
|
// State and Persistence
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Loads any stored data, prioritizing the latest storage strategy. |
|
|
|
* Loads any stored data, prioritizing the latest storage strategy. |
|
|
|
* Migrates that data schema in case it was last loaded on an older version. |
|
|
|
* Migrates that data schema in case it was last loaded on an older version. |
|
|
|
* @returns {Promise<MetaMaskState>} Last data emitted from previous instance of MetaMask. |
|
|
|
* @returns {Promise<MetaMaskState>} Last data emitted from previous instance of MetaMask. |
|
|
@ -227,7 +227,7 @@ async function loadStateFromPersistence () { |
|
|
|
return versionedData.data |
|
|
|
return versionedData.data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Initializes the MetaMask Controller with any initial state and default language. |
|
|
|
* Initializes the MetaMask Controller with any initial state and default language. |
|
|
|
* Configures platform-specific error reporting strategy. |
|
|
|
* Configures platform-specific error reporting strategy. |
|
|
|
* Streams emitted state updates to platform-specific storage strategy. |
|
|
|
* Streams emitted state updates to platform-specific storage strategy. |
|
|
@ -275,7 +275,7 @@ function setupController (initState, initLangCode) { |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Assigns the given state to the versioned object (with metadata), and returns that. |
|
|
|
* Assigns the given state to the versioned object (with metadata), and returns that. |
|
|
|
* @param {Object} state - The state object as emitted by the MetaMaskController. |
|
|
|
* @param {Object} state - The state object as emitted by the MetaMaskController. |
|
|
|
* @returns {VersionedData} The state object wrapped in an object that includes a metadata key. |
|
|
|
* @returns {VersionedData} The state object wrapped in an object that includes a metadata key. |
|
|
@ -316,14 +316,14 @@ function setupController (initState, initLangCode) { |
|
|
|
return popupIsOpen || Boolean(Object.keys(openMetamaskTabsIDs).length) || notificationIsOpen |
|
|
|
return popupIsOpen || Boolean(Object.keys(openMetamaskTabsIDs).length) || notificationIsOpen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* A runtime.Port object, as provided by the browser: |
|
|
|
* A runtime.Port object, as provided by the browser: |
|
|
|
* https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/Port
|
|
|
|
* @link https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/Port
|
|
|
|
* @typedef Port |
|
|
|
* @typedef Port |
|
|
|
* @type Object |
|
|
|
* @type Object |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Connects a Port to the MetaMask controller via a multiplexed duplex stream. |
|
|
|
* Connects a Port to the MetaMask controller via a multiplexed duplex stream. |
|
|
|
* This method identifies trusted (MetaMask) interfaces, and connects them differently from untrusted (web pages). |
|
|
|
* This method identifies trusted (MetaMask) interfaces, and connects them differently from untrusted (web pages). |
|
|
|
* @param {Port} remotePort - The port provided by a new context. |
|
|
|
* @param {Port} remotePort - The port provided by a new context. |
|
|
@ -381,7 +381,7 @@ function setupController (initState, initLangCode) { |
|
|
|
controller.messageManager.on('updateBadge', updateBadge) |
|
|
|
controller.messageManager.on('updateBadge', updateBadge) |
|
|
|
controller.personalMessageManager.on('updateBadge', updateBadge) |
|
|
|
controller.personalMessageManager.on('updateBadge', updateBadge) |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Updates the Web Extension's "badge" number, on the little fox in the toolbar. |
|
|
|
* Updates the Web Extension's "badge" number, on the little fox in the toolbar. |
|
|
|
* The number reflects the current number of pending transactions or message signatures needing user approval. |
|
|
|
* The number reflects the current number of pending transactions or message signatures needing user approval. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -406,7 +406,7 @@ function setupController (initState, initLangCode) { |
|
|
|
// Etc...
|
|
|
|
// Etc...
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
* Opens the browser popup for user confirmation |
|
|
|
* Opens the browser popup for user confirmation |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function triggerUi () { |
|
|
|
function triggerUi () { |
|
|
|