mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
d359429f04
* Stop GasFeeController polling when pop closes * Stop estimate gas polling on window unload * lint + comments * Improve client closed logic * lint * Add back _beforeUnload on unmount in gas-modal-page-container * Add full check and call onClientClosed method for notifcation environment * Add gas pollingToken tracking to appStateController and use to disconnect polling for each environment type * remove unused method * move controller manipulation logic from background.js to metamask-controller, disaggregate methods * add beforeunload handling to reset gas polling tokens from root of send page * cleanup, lint and address feedback * clear appState gasPollingTokens when all instances of all env types are closed, fix pollingTokenType arg from onEnvironmentTypeClosed call in metamask-controller * mock new methods to fix tests * final bit of cleanup + comments Co-authored-by: Dan Miller <danjm.com@gmail.com>
39 lines
1.6 KiB
JavaScript
39 lines
1.6 KiB
JavaScript
/**
|
|
* A string representing the type of environment the application is currently running in
|
|
* popup - When the user click's the icon in their browser's extension bar; the default view
|
|
* notification - When the extension opens due to interaction with a Web3 enabled website
|
|
* fullscreen - When the user clicks 'expand view' to open the extension in a new tab
|
|
* background - The background process that powers the extension
|
|
* @typedef {'popup' | 'notification' | 'fullscreen' | 'background'} EnvironmentType
|
|
*/
|
|
export const ENVIRONMENT_TYPE_POPUP = 'popup';
|
|
export const ENVIRONMENT_TYPE_NOTIFICATION = 'notification';
|
|
export const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen';
|
|
export const ENVIRONMENT_TYPE_BACKGROUND = 'background';
|
|
|
|
export const PLATFORM_BRAVE = 'Brave';
|
|
export const PLATFORM_CHROME = 'Chrome';
|
|
export const PLATFORM_EDGE = 'Edge';
|
|
export const PLATFORM_FIREFOX = 'Firefox';
|
|
export const PLATFORM_OPERA = 'Opera';
|
|
|
|
export const MESSAGE_TYPE = {
|
|
ETH_DECRYPT: 'eth_decrypt',
|
|
ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey',
|
|
ETH_SIGN: 'eth_sign',
|
|
ETH_SIGN_TYPED_DATA: 'eth_signTypedData',
|
|
GET_PROVIDER_STATE: 'metamask_getProviderState',
|
|
LOG_WEB3_SHIM_USAGE: 'metamask_logWeb3ShimUsage',
|
|
PERSONAL_SIGN: 'personal_sign',
|
|
WATCH_ASSET: 'wallet_watchAsset',
|
|
WATCH_ASSET_LEGACY: 'metamask_watchAsset',
|
|
ADD_ETHEREUM_CHAIN: 'wallet_addEthereumChain',
|
|
SWITCH_ETHEREUM_CHAIN: 'wallet_switchEthereumChain',
|
|
};
|
|
|
|
export const POLLING_TOKEN_ENVIRONMENT_TYPES = {
|
|
[ENVIRONMENT_TYPE_POPUP]: 'popupGasPollTokens',
|
|
[ENVIRONMENT_TYPE_NOTIFICATION]: 'notificationGasPollTokens',
|
|
[ENVIRONMENT_TYPE_FULLSCREEN]: 'fullScreenGasPollTokens',
|
|
};
|