@metamask/preferences-controller
Advanced tools
Comparing version 4.4.3 to 5.0.0
@@ -9,2 +9,15 @@ # Changelog | ||
## [5.0.0] | ||
### Added | ||
- **BREAKING** Add required property `showIncomingTransactions` to `PreferencesState` ([#1659](https://github.com/MetaMask/core/pull/1659)) | ||
- Add types `EtherscanSupportedChains`, `EtherscanSupportedHexChainId` ([#1659](https://github.com/MetaMask/core/pull/1659)) | ||
- Add constant `ETHERSCAN_SUPPORTED_CHAIN_IDS` ([#1659](https://github.com/MetaMask/core/pull/1659)) | ||
- Add `setEnabledNetworkIncomingTransactions` method ([#1659](https://github.com/MetaMask/core/pull/1659)) | ||
- This can be used to set the `showIncomingTransactions` preference for the given chain ID. | ||
### Changed | ||
- Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) | ||
- This is not breaking because this controller still inherits from BaseController v1. | ||
- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) | ||
## [4.4.3] | ||
@@ -80,3 +93,4 @@ ### Changed | ||
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.3...HEAD | ||
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@5.0.0...HEAD | ||
[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.3...@metamask/preferences-controller@5.0.0 | ||
[4.4.3]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.2...@metamask/preferences-controller@4.4.3 | ||
@@ -83,0 +97,0 @@ [4.4.2]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.1...@metamask/preferences-controller@4.4.2 |
import type { BaseConfig, BaseState } from '@metamask/base-controller'; | ||
import { BaseController } from '@metamask/base-controller'; | ||
import { BaseControllerV1 } from '@metamask/base-controller'; | ||
import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants'; | ||
/** | ||
@@ -15,2 +16,4 @@ * ContactEntry representation. | ||
} | ||
export declare type EtherscanSupportedChains = keyof typeof ETHERSCAN_SUPPORTED_CHAIN_IDS; | ||
export declare type EtherscanSupportedHexChainId = (typeof ETHERSCAN_SUPPORTED_CHAIN_IDS)[EtherscanSupportedChains]; | ||
/** | ||
@@ -47,2 +50,5 @@ * @type PreferencesState | ||
isIpfsGatewayEnabled: boolean; | ||
showIncomingTransactions: { | ||
[chainId in EtherscanSupportedHexChainId]: boolean; | ||
}; | ||
} | ||
@@ -52,3 +58,3 @@ /** | ||
*/ | ||
export declare class PreferencesController extends BaseController<BaseConfig, PreferencesState> { | ||
export declare class PreferencesController extends BaseControllerV1<BaseConfig, PreferencesState> { | ||
/** | ||
@@ -167,4 +173,11 @@ * Name of this controller used during composition | ||
setIsIpfsGatewayEnabled(isIpfsGatewayEnabled: boolean): void; | ||
/** | ||
* A setter for the user allow to be fetched IPFS content | ||
* | ||
* @param chainId - On hexadecimal format to enable the incoming transaction network | ||
* @param isIncomingTransactionNetworkEnable - true to enable incoming transactions | ||
*/ | ||
setEnableNetworkIncomingTransactions(chainId: EtherscanSupportedHexChainId, isIncomingTransactionNetworkEnable: boolean): void; | ||
} | ||
export default PreferencesController; | ||
//# sourceMappingURL=PreferencesController.d.ts.map |
@@ -6,6 +6,7 @@ "use strict"; | ||
const controller_utils_1 = require("@metamask/controller-utils"); | ||
const constants_1 = require("./constants"); | ||
/** | ||
* Controller that stores shared settings and exposes convenience methods | ||
*/ | ||
class PreferencesController extends base_controller_1.BaseController { | ||
class PreferencesController extends base_controller_1.BaseControllerV1 { | ||
/** | ||
@@ -39,2 +40,23 @@ * Creates a PreferencesController instance. | ||
isIpfsGatewayEnabled: true, | ||
showIncomingTransactions: { | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true, | ||
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true, | ||
}, | ||
}; | ||
@@ -115,12 +137,10 @@ this.initialize(); | ||
const newlyLost = {}; | ||
for (const identity in identities) { | ||
if (!addresses.includes(identity)) { | ||
newlyLost[identity] = identities[identity]; | ||
delete identities[identity]; | ||
for (const [address, identity] of Object.entries(identities)) { | ||
if (!addresses.includes(address)) { | ||
newlyLost[address] = identity; | ||
delete identities[address]; | ||
} | ||
} | ||
if (Object.keys(newlyLost).length > 0) { | ||
for (const key in newlyLost) { | ||
lostIdentities[key] = newlyLost[key]; | ||
} | ||
for (const [address, identity] of Object.entries(newlyLost)) { | ||
lostIdentities[address] = identity; | ||
} | ||
@@ -250,2 +270,15 @@ this.update({ | ||
} | ||
/** | ||
* A setter for the user allow to be fetched IPFS content | ||
* | ||
* @param chainId - On hexadecimal format to enable the incoming transaction network | ||
* @param isIncomingTransactionNetworkEnable - true to enable incoming transactions | ||
*/ | ||
setEnableNetworkIncomingTransactions(chainId, isIncomingTransactionNetworkEnable) { | ||
if (Object.values(constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) { | ||
this.update({ | ||
showIncomingTransactions: Object.assign(Object.assign({}, this.state.showIncomingTransactions), { [chainId]: isIncomingTransactionNetworkEnable }), | ||
}); | ||
} | ||
} | ||
} | ||
@@ -252,0 +285,0 @@ exports.PreferencesController = PreferencesController; |
{ | ||
"name": "@metamask/preferences-controller", | ||
"version": "4.4.3", | ||
"version": "5.0.0", | ||
"description": "Manages user-configurable settings for MetaMask", | ||
@@ -27,12 +27,13 @@ "keywords": [ | ||
"publish:preview": "yarn npm publish --tag preview", | ||
"test": "jest", | ||
"test": "jest --reporters=jest-silent-reporter", | ||
"test:clean": "jest --clearCache", | ||
"test:verbose": "jest --verbose", | ||
"test:watch": "jest --watch" | ||
}, | ||
"dependencies": { | ||
"@metamask/base-controller": "^3.2.3", | ||
"@metamask/controller-utils": "^5.0.2" | ||
"@metamask/base-controller": "^4.0.0", | ||
"@metamask/controller-utils": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@metamask/auto-changelog": "^3.1.0", | ||
"@metamask/auto-changelog": "^3.4.3", | ||
"@types/jest": "^27.4.1", | ||
@@ -39,0 +40,0 @@ "deepmerge": "^4.2.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
52783
16
523
+ Added@metamask/base-controller@4.1.1(transitive)
+ Added@metamask/controller-utils@6.1.0(transitive)
+ Added@metamask/eth-query@4.0.0(transitive)
+ Added@metamask/ethjs-unit@0.2.1(transitive)
- Removed@metamask/base-controller@3.2.3(transitive)
- Removed@metamask/controller-utils@5.0.2(transitive)
- Removed@metamask/eth-query@3.0.1(transitive)
- Removedethjs-unit@0.1.6(transitive)