@metamask-previews/compliance-controller 1.0.2-preview-7bc465a23 → 2.0.0-preview-1d148d2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/ComplianceController-method-action-types.cjs.map +1 -1
  3. package/dist/ComplianceController-method-action-types.d.cts +8 -22
  4. package/dist/ComplianceController-method-action-types.d.cts.map +1 -1
  5. package/dist/ComplianceController-method-action-types.d.mts +8 -22
  6. package/dist/ComplianceController-method-action-types.d.mts.map +1 -1
  7. package/dist/ComplianceController-method-action-types.mjs.map +1 -1
  8. package/dist/ComplianceController.cjs +55 -112
  9. package/dist/ComplianceController.cjs.map +1 -1
  10. package/dist/ComplianceController.d.cts +16 -37
  11. package/dist/ComplianceController.d.cts.map +1 -1
  12. package/dist/ComplianceController.d.mts +16 -37
  13. package/dist/ComplianceController.d.mts.map +1 -1
  14. package/dist/ComplianceController.mjs +55 -112
  15. package/dist/ComplianceController.mjs.map +1 -1
  16. package/dist/ComplianceService-method-action-types.cjs.map +1 -1
  17. package/dist/ComplianceService-method-action-types.d.cts +1 -10
  18. package/dist/ComplianceService-method-action-types.d.cts.map +1 -1
  19. package/dist/ComplianceService-method-action-types.d.mts +1 -10
  20. package/dist/ComplianceService-method-action-types.d.mts.map +1 -1
  21. package/dist/ComplianceService-method-action-types.mjs.map +1 -1
  22. package/dist/ComplianceService.cjs +0 -29
  23. package/dist/ComplianceService.cjs.map +1 -1
  24. package/dist/ComplianceService.d.cts +0 -31
  25. package/dist/ComplianceService.d.cts.map +1 -1
  26. package/dist/ComplianceService.d.mts +0 -31
  27. package/dist/ComplianceService.d.mts.map +1 -1
  28. package/dist/ComplianceService.mjs +1 -30
  29. package/dist/ComplianceService.mjs.map +1 -1
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +3 -3
  32. package/dist/index.d.cts.map +1 -1
  33. package/dist/index.d.mts +3 -3
  34. package/dist/index.d.mts.map +1 -1
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/selectors.cjs +2 -9
  37. package/dist/selectors.cjs.map +1 -1
  38. package/dist/selectors.d.cts +1 -2
  39. package/dist/selectors.d.cts.map +1 -1
  40. package/dist/selectors.d.mts +1 -2
  41. package/dist/selectors.d.mts.map +1 -1
  42. package/dist/selectors.mjs +2 -9
  43. package/dist/selectors.mjs.map +1 -1
  44. package/dist/types.cjs.map +1 -1
  45. package/dist/types.d.cts +0 -25
  46. package/dist/types.d.cts.map +1 -1
  47. package/dist/types.d.mts +0 -25
  48. package/dist/types.d.mts.map +1 -1
  49. package/dist/types.mjs.map +1 -1
  50. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -7,9 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.0]
11
+
10
12
  ### Changed
11
13
 
14
+ - **BREAKING:** Remove proactive bulk-fetch pattern from `ComplianceController` and `ComplianceService` ([#8365](https://github.com/MetaMask/core/pull/8365))
15
+ - `ComplianceControllerState` no longer includes `blockedWallets` or `blockedWalletsLastFetched`. Consumers storing persisted state must drop these fields on migration.
16
+ - The `init()` and `updateBlockedWallets()` controller methods have been removed. Consumers should remove any calls to these methods.
17
+ - The `blockedWalletsRefreshInterval` constructor option has been removed.
18
+ - The `updateBlockedWallets()` service method and its `GET /v1/blocked-wallets` endpoint integration have been removed.
19
+ - `ComplianceControllerInitAction`, `ComplianceControllerUpdateBlockedWalletsAction`, and `ComplianceServiceUpdateBlockedWalletsAction` types have been removed from the public API.
20
+ - The `BlockedWalletsInfo` type has been removed from the public API.
21
+ - `checkWalletCompliance` and `checkWalletsCompliance` now fall back to the per-address `walletComplianceStatusMap` cache when the API is unavailable, re-throwing only if no cached result exists for a requested address.
22
+ - `selectIsWalletBlocked` now reads solely from `walletComplianceStatusMap` rather than also checking a cached full blocklist.
12
23
  - Bump `@metamask/controller-utils` from `^11.19.0` to `^11.20.0` ([#8344](https://github.com/MetaMask/core/pull/8344))
24
+ - Bump `@metamask/messenger` from `^1.0.0` to `^1.1.0` ([#8364](https://github.com/MetaMask/core/pull/8364))
13
25
 
14
26
  ## [1.0.2]
15
27
 
@@ -32,7 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
32
44
 
33
45
  - Bump `@metamask/controller-utils` from `^11.18.0` to `^11.19.0` ([#7995](https://github.com/MetaMask/core/pull/7995))
34
46
 
35
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.2...HEAD
47
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@2.0.0...HEAD
48
+ [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.2...@metamask/compliance-controller@2.0.0
36
49
  [1.0.2]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.1...@metamask/compliance-controller@1.0.2
37
50
  [1.0.1]: https://github.com/MetaMask/core/compare/@metamask/compliance-controller@1.0.0...@metamask/compliance-controller@1.0.1
38
51
  [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/compliance-controller@1.0.0
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController-method-action-types.cjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\nexport type ComplianceControllerInitAction = {\n type: `ComplianceController:init`;\n handler: ComplianceController['init'];\n};\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\nexport type ComplianceControllerUpdateBlockedWalletsAction = {\n type: `ComplianceController:updateBlockedWallets`;\n handler: ComplianceController['updateBlockedWallets'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerInitAction\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerUpdateBlockedWalletsAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
1
+ {"version":3,"file":"ComplianceController-method-action-types.cjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state. If the API call fails and a previously\n * cached result exists for the address, the cached result is returned as a\n * fallback. If no cached result exists, the error is re-thrown.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state. If the API call fails and every requested\n * address has a previously cached result, those cached results are returned\n * as a fallback. If any address lacks a cached result, the error is\n * re-thrown.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
@@ -3,18 +3,11 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  import type { ComplianceController } from "./ComplianceController.cjs";
6
- /**
7
- * Initializes the controller by fetching the blocked wallets list if it
8
- * is missing or stale. Call once after construction to ensure the blocklist
9
- * is ready for `selectIsWalletBlocked` lookups.
10
- */
11
- export type ComplianceControllerInitAction = {
12
- type: `ComplianceController:init`;
13
- handler: ComplianceController['init'];
14
- };
15
6
  /**
16
7
  * Checks compliance status for a single wallet address via the API and
17
- * persists the result to state.
8
+ * persists the result to state. If the API call fails and a previously
9
+ * cached result exists for the address, the cached result is returned as a
10
+ * fallback. If no cached result exists, the error is re-thrown.
18
11
  *
19
12
  * @param address - The wallet address to check.
20
13
  * @returns The compliance status of the wallet.
@@ -25,7 +18,10 @@ export type ComplianceControllerCheckWalletComplianceAction = {
25
18
  };
26
19
  /**
27
20
  * Checks compliance status for multiple wallet addresses via the API and
28
- * persists the results to state.
21
+ * persists the results to state. If the API call fails and every requested
22
+ * address has a previously cached result, those cached results are returned
23
+ * as a fallback. If any address lacks a cached result, the error is
24
+ * re-thrown.
29
25
  *
30
26
  * @param addresses - The wallet addresses to check.
31
27
  * @returns The compliance statuses of the wallets.
@@ -34,16 +30,6 @@ export type ComplianceControllerCheckWalletsComplianceAction = {
34
30
  type: `ComplianceController:checkWalletsCompliance`;
35
31
  handler: ComplianceController['checkWalletsCompliance'];
36
32
  };
37
- /**
38
- * Fetches the full list of blocked wallets from the API and persists the
39
- * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
40
- *
41
- * @returns The blocked wallets information.
42
- */
43
- export type ComplianceControllerUpdateBlockedWalletsAction = {
44
- type: `ComplianceController:updateBlockedWallets`;
45
- handler: ComplianceController['updateBlockedWallets'];
46
- };
47
33
  /**
48
34
  * Clears all compliance data from state.
49
35
  */
@@ -54,5 +40,5 @@ export type ComplianceControllerClearComplianceStateAction = {
54
40
  /**
55
41
  * Union of all ComplianceController action types.
56
42
  */
57
- export type ComplianceControllerMethodActions = ComplianceControllerInitAction | ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerUpdateBlockedWalletsAction | ComplianceControllerClearComplianceStateAction;
43
+ export type ComplianceControllerMethodActions = ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerClearComplianceStateAction;
58
44
  //# sourceMappingURL=ComplianceController-method-action-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController-method-action-types.d.cts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,8BAA8B,GAC9B,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,8CAA8C,CAAC"}
1
+ {"version":3,"file":"ComplianceController-method-action-types.d.cts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,CAAC"}
@@ -3,18 +3,11 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  import type { ComplianceController } from "./ComplianceController.mjs";
6
- /**
7
- * Initializes the controller by fetching the blocked wallets list if it
8
- * is missing or stale. Call once after construction to ensure the blocklist
9
- * is ready for `selectIsWalletBlocked` lookups.
10
- */
11
- export type ComplianceControllerInitAction = {
12
- type: `ComplianceController:init`;
13
- handler: ComplianceController['init'];
14
- };
15
6
  /**
16
7
  * Checks compliance status for a single wallet address via the API and
17
- * persists the result to state.
8
+ * persists the result to state. If the API call fails and a previously
9
+ * cached result exists for the address, the cached result is returned as a
10
+ * fallback. If no cached result exists, the error is re-thrown.
18
11
  *
19
12
  * @param address - The wallet address to check.
20
13
  * @returns The compliance status of the wallet.
@@ -25,7 +18,10 @@ export type ComplianceControllerCheckWalletComplianceAction = {
25
18
  };
26
19
  /**
27
20
  * Checks compliance status for multiple wallet addresses via the API and
28
- * persists the results to state.
21
+ * persists the results to state. If the API call fails and every requested
22
+ * address has a previously cached result, those cached results are returned
23
+ * as a fallback. If any address lacks a cached result, the error is
24
+ * re-thrown.
29
25
  *
30
26
  * @param addresses - The wallet addresses to check.
31
27
  * @returns The compliance statuses of the wallets.
@@ -34,16 +30,6 @@ export type ComplianceControllerCheckWalletsComplianceAction = {
34
30
  type: `ComplianceController:checkWalletsCompliance`;
35
31
  handler: ComplianceController['checkWalletsCompliance'];
36
32
  };
37
- /**
38
- * Fetches the full list of blocked wallets from the API and persists the
39
- * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
40
- *
41
- * @returns The blocked wallets information.
42
- */
43
- export type ComplianceControllerUpdateBlockedWalletsAction = {
44
- type: `ComplianceController:updateBlockedWallets`;
45
- handler: ComplianceController['updateBlockedWallets'];
46
- };
47
33
  /**
48
34
  * Clears all compliance data from state.
49
35
  */
@@ -54,5 +40,5 @@ export type ComplianceControllerClearComplianceStateAction = {
54
40
  /**
55
41
  * Union of all ComplianceController action types.
56
42
  */
57
- export type ComplianceControllerMethodActions = ComplianceControllerInitAction | ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerUpdateBlockedWalletsAction | ComplianceControllerClearComplianceStateAction;
43
+ export type ComplianceControllerMethodActions = ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerClearComplianceStateAction;
58
44
  //# sourceMappingURL=ComplianceController-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController-method-action-types.d.mts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,8BAA8B,GAC9B,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,GAC9C,8CAA8C,CAAC"}
1
+ {"version":3,"file":"ComplianceController-method-action-types.d.mts","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GACzC,+CAA+C,GAC/C,gDAAgD,GAChD,8CAA8C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController-method-action-types.mjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\nexport type ComplianceControllerInitAction = {\n type: `ComplianceController:init`;\n handler: ComplianceController['init'];\n};\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\nexport type ComplianceControllerUpdateBlockedWalletsAction = {\n type: `ComplianceController:updateBlockedWallets`;\n handler: ComplianceController['updateBlockedWallets'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerInitAction\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerUpdateBlockedWalletsAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
1
+ {"version":3,"file":"ComplianceController-method-action-types.mjs","sourceRoot":"","sources":["../src/ComplianceController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceController } from './ComplianceController';\n\n/**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state. If the API call fails and a previously\n * cached result exists for the address, the cached result is returned as a\n * fallback. If no cached result exists, the error is re-thrown.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceControllerCheckWalletComplianceAction = {\n type: `ComplianceController:checkWalletCompliance`;\n handler: ComplianceController['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state. If the API call fails and every requested\n * address has a previously cached result, those cached results are returned\n * as a fallback. If any address lacks a cached result, the error is\n * re-thrown.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceControllerCheckWalletsComplianceAction = {\n type: `ComplianceController:checkWalletsCompliance`;\n handler: ComplianceController['checkWalletsCompliance'];\n};\n\n/**\n * Clears all compliance data from state.\n */\nexport type ComplianceControllerClearComplianceStateAction = {\n type: `ComplianceController:clearComplianceState`;\n handler: ComplianceController['clearComplianceState'];\n};\n\n/**\n * Union of all ComplianceController action types.\n */\nexport type ComplianceControllerMethodActions =\n | ComplianceControllerCheckWalletComplianceAction\n | ComplianceControllerCheckWalletsComplianceAction\n | ComplianceControllerClearComplianceStateAction;\n"]}
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _ComplianceController_instances, _ComplianceController_blockedWalletsRefreshInterval, _ComplianceController_isBlockedWalletsStale;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.ComplianceController = exports.getDefaultComplianceControllerState = exports.controllerName = void 0;
16
4
  const base_controller_1 = require("@metamask/base-controller");
@@ -21,10 +9,6 @@ const base_controller_1 = require("@metamask/base-controller");
21
9
  * when composed with other controllers.
22
10
  */
23
11
  exports.controllerName = 'ComplianceController';
24
- /**
25
- * The default refresh interval for the blocked wallets list (1 hour).
26
- */
27
- const DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL = 60 * 60 * 1000;
28
12
  /**
29
13
  * The metadata for each property in {@link ComplianceControllerState}.
30
14
  */
@@ -35,18 +19,6 @@ const complianceControllerMetadata = {
35
19
  persist: true,
36
20
  usedInUi: true,
37
21
  },
38
- blockedWallets: {
39
- includeInDebugSnapshot: false,
40
- includeInStateLogs: false,
41
- persist: true,
42
- usedInUi: false,
43
- },
44
- blockedWalletsLastFetched: {
45
- includeInDebugSnapshot: false,
46
- includeInStateLogs: true,
47
- persist: true,
48
- usedInUi: false,
49
- },
50
22
  lastCheckedAt: {
51
23
  includeInDebugSnapshot: false,
52
24
  includeInStateLogs: true,
@@ -65,26 +37,22 @@ const complianceControllerMetadata = {
65
37
  function getDefaultComplianceControllerState() {
66
38
  return {
67
39
  walletComplianceStatusMap: {},
68
- blockedWallets: null,
69
- blockedWalletsLastFetched: 0,
70
40
  lastCheckedAt: null,
71
41
  };
72
42
  }
73
43
  exports.getDefaultComplianceControllerState = getDefaultComplianceControllerState;
74
44
  // === MESSENGER ===
75
45
  const MESSENGER_EXPOSED_METHODS = [
76
- 'init',
77
46
  'checkWalletCompliance',
78
47
  'checkWalletsCompliance',
79
- 'updateBlockedWallets',
80
48
  'clearComplianceState',
81
49
  ];
82
50
  // === CONTROLLER DEFINITION ===
83
51
  /**
84
52
  * `ComplianceController` manages OFAC compliance state for wallet addresses.
85
- * It proactively fetches and caches the blocked wallets list from the
86
- * Compliance API so that consumers can perform synchronous lookups via the
87
- * `selectIsWalletBlocked` selector without making API calls.
53
+ * It performs on-demand compliance checks via the API and caches results
54
+ * per address in state. Cached results serve as a fallback if the API is
55
+ * unavailable for a subsequent check on the same address.
88
56
  */
89
57
  class ComplianceController extends base_controller_1.BaseController {
90
58
  /**
@@ -94,11 +62,8 @@ class ComplianceController extends base_controller_1.BaseController {
94
62
  * @param args.messenger - The messenger suited for this controller.
95
63
  * @param args.state - The desired state with which to init this
96
64
  * controller. Missing properties will be filled in with defaults.
97
- * @param args.blockedWalletsRefreshInterval - The interval in milliseconds
98
- * after which the blocked wallets list is considered stale. Defaults to 1
99
- * hour.
100
65
  */
101
- constructor({ messenger, state, blockedWalletsRefreshInterval = DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL, }) {
66
+ constructor({ messenger, state, }) {
102
67
  super({
103
68
  messenger,
104
69
  metadata: complianceControllerMetadata,
@@ -108,91 +73,75 @@ class ComplianceController extends base_controller_1.BaseController {
108
73
  ...state,
109
74
  },
110
75
  });
111
- _ComplianceController_instances.add(this);
112
- /**
113
- * The interval (in milliseconds) after which the blocked wallets list
114
- * is considered stale.
115
- */
116
- _ComplianceController_blockedWalletsRefreshInterval.set(this, void 0);
117
- __classPrivateFieldSet(this, _ComplianceController_blockedWalletsRefreshInterval, blockedWalletsRefreshInterval, "f");
118
76
  this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
119
77
  }
120
- /**
121
- * Initializes the controller by fetching the blocked wallets list if it
122
- * is missing or stale. Call once after construction to ensure the blocklist
123
- * is ready for `selectIsWalletBlocked` lookups.
124
- */
125
- async init() {
126
- if (__classPrivateFieldGet(this, _ComplianceController_instances, "m", _ComplianceController_isBlockedWalletsStale).call(this)) {
127
- await this.updateBlockedWallets();
128
- }
129
- }
130
78
  /**
131
79
  * Checks compliance status for a single wallet address via the API and
132
- * persists the result to state.
80
+ * persists the result to state. If the API call fails and a previously
81
+ * cached result exists for the address, the cached result is returned as a
82
+ * fallback. If no cached result exists, the error is re-thrown.
133
83
  *
134
84
  * @param address - The wallet address to check.
135
85
  * @returns The compliance status of the wallet.
136
86
  */
137
87
  async checkWalletCompliance(address) {
138
- const result = await this.messenger.call('ComplianceService:checkWalletCompliance', address);
139
- const now = new Date().toISOString();
140
- const status = {
141
- address: result.address,
142
- blocked: result.blocked,
143
- checkedAt: now,
144
- };
145
- this.update((draftState) => {
146
- draftState.walletComplianceStatusMap[address] = status;
147
- draftState.lastCheckedAt = now;
148
- });
149
- return status;
88
+ try {
89
+ const result = await this.messenger.call('ComplianceService:checkWalletCompliance', address);
90
+ const now = new Date().toISOString();
91
+ const status = {
92
+ address: result.address,
93
+ blocked: result.blocked,
94
+ checkedAt: now,
95
+ };
96
+ this.update((draftState) => {
97
+ draftState.walletComplianceStatusMap[address] = status;
98
+ draftState.lastCheckedAt = now;
99
+ });
100
+ return status;
101
+ }
102
+ catch (error) {
103
+ const cached = this.state.walletComplianceStatusMap[address];
104
+ if (cached) {
105
+ return cached;
106
+ }
107
+ throw error;
108
+ }
150
109
  }
151
110
  /**
152
111
  * Checks compliance status for multiple wallet addresses via the API and
153
- * persists the results to state.
112
+ * persists the results to state. If the API call fails and every requested
113
+ * address has a previously cached result, those cached results are returned
114
+ * as a fallback. If any address lacks a cached result, the error is
115
+ * re-thrown.
154
116
  *
155
117
  * @param addresses - The wallet addresses to check.
156
118
  * @returns The compliance statuses of the wallets.
157
119
  */
158
120
  async checkWalletsCompliance(addresses) {
159
- const results = await this.messenger.call('ComplianceService:checkWalletsCompliance', addresses);
160
- const now = new Date().toISOString();
161
- const statuses = results.map((result) => ({
162
- address: result.address,
163
- blocked: result.blocked,
164
- checkedAt: now,
165
- }));
166
- this.update((draftState) => {
167
- for (let idx = 0; idx < statuses.length; idx++) {
168
- const callerAddress = addresses[idx];
169
- draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];
121
+ try {
122
+ const results = await this.messenger.call('ComplianceService:checkWalletsCompliance', addresses);
123
+ const now = new Date().toISOString();
124
+ const statuses = results.map((result) => ({
125
+ address: result.address,
126
+ blocked: result.blocked,
127
+ checkedAt: now,
128
+ }));
129
+ this.update((draftState) => {
130
+ for (let idx = 0; idx < statuses.length; idx++) {
131
+ const callerAddress = addresses[idx];
132
+ draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];
133
+ }
134
+ draftState.lastCheckedAt = now;
135
+ });
136
+ return statuses;
137
+ }
138
+ catch (error) {
139
+ const cachedStatuses = addresses.map((address) => this.state.walletComplianceStatusMap[address]);
140
+ if (cachedStatuses.every(Boolean)) {
141
+ return cachedStatuses;
170
142
  }
171
- draftState.lastCheckedAt = now;
172
- });
173
- return statuses;
174
- }
175
- /**
176
- * Fetches the full list of blocked wallets from the API and persists the
177
- * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
178
- *
179
- * @returns The blocked wallets information.
180
- */
181
- async updateBlockedWallets() {
182
- const result = await this.messenger.call('ComplianceService:updateBlockedWallets');
183
- const now = new Date().toISOString();
184
- const blockedWallets = {
185
- addresses: result.addresses,
186
- sources: result.sources,
187
- lastUpdated: result.lastUpdated,
188
- fetchedAt: now,
189
- };
190
- this.update((draftState) => {
191
- draftState.blockedWallets = blockedWallets;
192
- draftState.blockedWalletsLastFetched = Date.now();
193
- draftState.lastCheckedAt = now;
194
- });
195
- return blockedWallets;
143
+ throw error;
144
+ }
196
145
  }
197
146
  /**
198
147
  * Clears all compliance data from state.
@@ -200,15 +149,9 @@ class ComplianceController extends base_controller_1.BaseController {
200
149
  clearComplianceState() {
201
150
  this.update((draftState) => {
202
151
  draftState.walletComplianceStatusMap = {};
203
- draftState.blockedWallets = null;
204
- draftState.blockedWalletsLastFetched = 0;
205
152
  draftState.lastCheckedAt = null;
206
153
  });
207
154
  }
208
155
  }
209
156
  exports.ComplianceController = ComplianceController;
210
- _ComplianceController_blockedWalletsRefreshInterval = new WeakMap(), _ComplianceController_instances = new WeakSet(), _ComplianceController_isBlockedWalletsStale = function _ComplianceController_isBlockedWalletsStale() {
211
- return (Date.now() - this.state.blockedWalletsLastFetched >=
212
- __classPrivateFieldGet(this, _ComplianceController_blockedWalletsRefreshInterval, "f"));
213
- };
214
157
  //# sourceMappingURL=ComplianceController.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController.cjs","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA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Ac,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,yBAAyB,GAAG,EAAE,CAAC;YAC1C,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC;YACjC,UAAU,CAAC,yBAAyB,GAAG,CAAC,CAAC;YACzC,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CAeF;AAhLD,oDAgLC;;IALG,OAAO,CACL,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB;QACjD,uBAAA,IAAI,2DAA+B,CACpC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { ComplianceControllerMethodActions } from './ComplianceController-method-action-types';\nimport type { ComplianceServiceMethodActions } from './ComplianceService-method-action-types';\nimport type { BlockedWalletsInfo, WalletComplianceStatus } from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ComplianceController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ComplianceController';\n\n/**\n * The default refresh interval for the blocked wallets list (1 hour).\n */\nconst DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL = 60 * 60 * 1000;\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link ComplianceController}.\n */\nexport type ComplianceControllerState = {\n /**\n * A map of wallet addresses to their on-demand compliance check results.\n */\n walletComplianceStatusMap: Record<string, WalletComplianceStatus>;\n\n /**\n * Information about all blocked wallets, or `null` if not yet fetched.\n */\n blockedWallets: BlockedWalletsInfo | null;\n\n /**\n * Timestamp (in milliseconds) of the last blocked wallets fetch, or 0 if\n * never fetched.\n */\n blockedWalletsLastFetched: number;\n\n /**\n * The date/time (in ISO-8601 format) when the last compliance check was\n * performed, or `null` if no checks have been performed yet.\n */\n lastCheckedAt: string | null;\n};\n\n/**\n * The metadata for each property in {@link ComplianceControllerState}.\n */\nconst complianceControllerMetadata = {\n walletComplianceStatusMap: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: true,\n },\n blockedWallets: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: false,\n },\n blockedWalletsLastFetched: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: false,\n },\n lastCheckedAt: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<ComplianceControllerState>;\n\n/**\n * Constructs the default {@link ComplianceController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link ComplianceController} state.\n */\nexport function getDefaultComplianceControllerState(): ComplianceControllerState {\n return {\n walletComplianceStatusMap: {},\n blockedWallets: null,\n blockedWalletsLastFetched: 0,\n lastCheckedAt: null,\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'init',\n 'checkWalletCompliance',\n 'checkWalletsCompliance',\n 'updateBlockedWallets',\n 'clearComplianceState',\n] as const;\n\n/**\n * Retrieves the state of the {@link ComplianceController}.\n */\nexport type ComplianceControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Actions that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerActions =\n | ComplianceControllerGetStateAction\n | ComplianceControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ComplianceController} calls.\n */\ntype AllowedActions = ComplianceServiceMethodActions;\n\n/**\n * Published when the state of {@link ComplianceController} changes.\n */\nexport type ComplianceControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Events that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerEvents = ComplianceControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ComplianceController} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ComplianceController}.\n */\nexport type ComplianceControllerMessenger = Messenger<\n typeof controllerName,\n ComplianceControllerActions | AllowedActions,\n ComplianceControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `ComplianceController` manages OFAC compliance state for wallet addresses.\n * It proactively fetches and caches the blocked wallets list from the\n * Compliance API so that consumers can perform synchronous lookups via the\n * `selectIsWalletBlocked` selector without making API calls.\n */\nexport class ComplianceController extends BaseController<\n typeof controllerName,\n ComplianceControllerState,\n ComplianceControllerMessenger\n> {\n /**\n * The interval (in milliseconds) after which the blocked wallets list\n * is considered stale.\n */\n readonly #blockedWalletsRefreshInterval: number;\n\n /**\n * Constructs a new {@link ComplianceController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to init this\n * controller. Missing properties will be filled in with defaults.\n * @param args.blockedWalletsRefreshInterval - The interval in milliseconds\n * after which the blocked wallets list is considered stale. Defaults to 1\n * hour.\n */\n constructor({\n messenger,\n state,\n blockedWalletsRefreshInterval = DEFAULT_BLOCKED_WALLETS_REFRESH_INTERVAL,\n }: {\n messenger: ComplianceControllerMessenger;\n state?: Partial<ComplianceControllerState>;\n blockedWalletsRefreshInterval?: number;\n }) {\n super({\n messenger,\n metadata: complianceControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultComplianceControllerState(),\n ...state,\n },\n });\n\n this.#blockedWalletsRefreshInterval = blockedWalletsRefreshInterval;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the controller by fetching the blocked wallets list if it\n * is missing or stale. Call once after construction to ensure the blocklist\n * is ready for `selectIsWalletBlocked` lookups.\n */\n async init(): Promise<void> {\n if (this.#isBlockedWalletsStale()) {\n await this.updateBlockedWallets();\n }\n }\n\n /**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\n async checkWalletCompliance(\n address: string,\n ): Promise<WalletComplianceStatus> {\n const result = await this.messenger.call(\n 'ComplianceService:checkWalletCompliance',\n address,\n );\n\n const now = new Date().toISOString();\n const status: WalletComplianceStatus = {\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n };\n\n this.update((draftState) => {\n draftState.walletComplianceStatusMap[address] = status;\n draftState.lastCheckedAt = now;\n });\n\n return status;\n }\n\n /**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\n async checkWalletsCompliance(\n addresses: string[],\n ): Promise<WalletComplianceStatus[]> {\n const results = await this.messenger.call(\n 'ComplianceService:checkWalletsCompliance',\n addresses,\n );\n\n const now = new Date().toISOString();\n const statuses: WalletComplianceStatus[] = results.map((result) => ({\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n }));\n\n this.update((draftState) => {\n for (let idx = 0; idx < statuses.length; idx++) {\n const callerAddress = addresses[idx];\n draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];\n }\n draftState.lastCheckedAt = now;\n });\n\n return statuses;\n }\n\n /**\n * Fetches the full list of blocked wallets from the API and persists the\n * data to state. This also updates the `blockedWalletsLastFetched` timestamp.\n *\n * @returns The blocked wallets information.\n */\n async updateBlockedWallets(): Promise<BlockedWalletsInfo> {\n const result = await this.messenger.call(\n 'ComplianceService:updateBlockedWallets',\n );\n\n const now = new Date().toISOString();\n const blockedWallets: BlockedWalletsInfo = {\n addresses: result.addresses,\n sources: result.sources,\n lastUpdated: result.lastUpdated,\n fetchedAt: now,\n };\n\n this.update((draftState) => {\n draftState.blockedWallets = blockedWallets;\n draftState.blockedWalletsLastFetched = Date.now();\n draftState.lastCheckedAt = now;\n });\n\n return blockedWallets;\n }\n\n /**\n * Clears all compliance data from state.\n */\n clearComplianceState(): void {\n this.update((draftState) => {\n draftState.walletComplianceStatusMap = {};\n draftState.blockedWallets = null;\n draftState.blockedWalletsLastFetched = 0;\n draftState.lastCheckedAt = null;\n });\n }\n\n /**\n * Determines whether the blocked wallets list is stale and needs to be\n * refreshed.\n *\n * @returns `true` if the list has never been fetched or the refresh\n * interval has elapsed.\n */\n #isBlockedWalletsStale(): boolean {\n return (\n Date.now() - this.state.blockedWalletsLastFetched >=\n this.#blockedWalletsRefreshInterval\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ComplianceController.cjs","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAU3D,kBAAkB;AAElB;;;;GAIG;AACU,QAAA,cAAc,GAAG,sBAAsB,CAAC;AAqBrD;;GAEG;AACH,MAAM,4BAA4B,GAAG;IACnC,yBAAyB,EAAE;QACzB,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;IACD,aAAa,EAAE;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;CACiD,CAAC;AAErD;;;;;;;GAOG;AACH,SAAgB,mCAAmC;IACjD,OAAO;QACL,yBAAyB,EAAE,EAAE;QAC7B,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC;AALD,kFAKC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;CACd,CAAC;AAoDX,gCAAgC;AAEhC;;;;;GAKG;AACH,MAAa,oBAAqB,SAAQ,gCAIzC;IACC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KA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ACF;AAnID,oDAmIC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { ComplianceControllerMethodActions } from './ComplianceController-method-action-types';\nimport type {\n ComplianceServiceCheckWalletComplianceAction,\n ComplianceServiceCheckWalletsComplianceAction,\n} from './ComplianceService-method-action-types';\nimport type { WalletComplianceStatus } from './types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ComplianceController}, used to namespace the\n * controller's actions and events and to namespace the controller's state data\n * when composed with other controllers.\n */\nexport const controllerName = 'ComplianceController';\n\n// === STATE ===\n\n/**\n * Describes the shape of the state object for {@link ComplianceController}.\n */\nexport type ComplianceControllerState = {\n /**\n * A map of wallet addresses to their compliance check results, used as a\n * fallback cache when the API is unavailable.\n */\n walletComplianceStatusMap: Record<string, WalletComplianceStatus>;\n\n /**\n * The date/time (in ISO-8601 format) when the last compliance check was\n * performed, or `null` if no checks have been performed yet.\n */\n lastCheckedAt: string | null;\n};\n\n/**\n * The metadata for each property in {@link ComplianceControllerState}.\n */\nconst complianceControllerMetadata = {\n walletComplianceStatusMap: {\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n persist: true,\n usedInUi: true,\n },\n lastCheckedAt: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: true,\n usedInUi: false,\n },\n} satisfies StateMetadata<ComplianceControllerState>;\n\n/**\n * Constructs the default {@link ComplianceController} state. This allows\n * consumers to provide a partial state object when initializing the controller\n * and also helps in constructing complete state objects for this controller in\n * tests.\n *\n * @returns The default {@link ComplianceController} state.\n */\nexport function getDefaultComplianceControllerState(): ComplianceControllerState {\n return {\n walletComplianceStatusMap: {},\n lastCheckedAt: null,\n };\n}\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'checkWalletCompliance',\n 'checkWalletsCompliance',\n 'clearComplianceState',\n] as const;\n\n/**\n * Retrieves the state of the {@link ComplianceController}.\n */\nexport type ComplianceControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Actions that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerActions =\n | ComplianceControllerGetStateAction\n | ComplianceControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ComplianceController} calls.\n */\ntype AllowedActions =\n | ComplianceServiceCheckWalletComplianceAction\n | ComplianceServiceCheckWalletsComplianceAction;\n\n/**\n * Published when the state of {@link ComplianceController} changes.\n */\nexport type ComplianceControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n ComplianceControllerState\n>;\n\n/**\n * Events that {@link ComplianceController} exposes to other consumers.\n */\nexport type ComplianceControllerEvents = ComplianceControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ComplianceController} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ComplianceController}.\n */\nexport type ComplianceControllerMessenger = Messenger<\n typeof controllerName,\n ComplianceControllerActions | AllowedActions,\n ComplianceControllerEvents | AllowedEvents\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * `ComplianceController` manages OFAC compliance state for wallet addresses.\n * It performs on-demand compliance checks via the API and caches results\n * per address in state. Cached results serve as a fallback if the API is\n * unavailable for a subsequent check on the same address.\n */\nexport class ComplianceController extends BaseController<\n typeof controllerName,\n ComplianceControllerState,\n ComplianceControllerMessenger\n> {\n /**\n * Constructs a new {@link ComplianceController}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this controller.\n * @param args.state - The desired state with which to init this\n * controller. Missing properties will be filled in with defaults.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: ComplianceControllerMessenger;\n state?: Partial<ComplianceControllerState>;\n }) {\n super({\n messenger,\n metadata: complianceControllerMetadata,\n name: controllerName,\n state: {\n ...getDefaultComplianceControllerState(),\n ...state,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Checks compliance status for a single wallet address via the API and\n * persists the result to state. If the API call fails and a previously\n * cached result exists for the address, the cached result is returned as a\n * fallback. If no cached result exists, the error is re-thrown.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\n async checkWalletCompliance(\n address: string,\n ): Promise<WalletComplianceStatus> {\n try {\n const result = await this.messenger.call(\n 'ComplianceService:checkWalletCompliance',\n address,\n );\n\n const now = new Date().toISOString();\n const status: WalletComplianceStatus = {\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n };\n\n this.update((draftState) => {\n draftState.walletComplianceStatusMap[address] = status;\n draftState.lastCheckedAt = now;\n });\n\n return status;\n } catch (error) {\n const cached = this.state.walletComplianceStatusMap[address];\n if (cached) {\n return cached;\n }\n throw error;\n }\n }\n\n /**\n * Checks compliance status for multiple wallet addresses via the API and\n * persists the results to state. If the API call fails and every requested\n * address has a previously cached result, those cached results are returned\n * as a fallback. If any address lacks a cached result, the error is\n * re-thrown.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\n async checkWalletsCompliance(\n addresses: string[],\n ): Promise<WalletComplianceStatus[]> {\n try {\n const results = await this.messenger.call(\n 'ComplianceService:checkWalletsCompliance',\n addresses,\n );\n\n const now = new Date().toISOString();\n const statuses: WalletComplianceStatus[] = results.map((result) => ({\n address: result.address,\n blocked: result.blocked,\n checkedAt: now,\n }));\n\n this.update((draftState) => {\n for (let idx = 0; idx < statuses.length; idx++) {\n const callerAddress = addresses[idx];\n draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];\n }\n draftState.lastCheckedAt = now;\n });\n\n return statuses;\n } catch (error) {\n const cachedStatuses = addresses.map(\n (address) => this.state.walletComplianceStatusMap[address],\n );\n if (cachedStatuses.every(Boolean)) {\n return cachedStatuses;\n }\n throw error;\n }\n }\n\n /**\n * Clears all compliance data from state.\n */\n clearComplianceState(): void {\n this.update((draftState) => {\n draftState.walletComplianceStatusMap = {};\n draftState.lastCheckedAt = null;\n });\n }\n}\n"]}
@@ -2,8 +2,8 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
2
2
  import { BaseController } from "@metamask/base-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
4
  import type { ComplianceControllerMethodActions } from "./ComplianceController-method-action-types.cjs";
5
- import type { ComplianceServiceMethodActions } from "./ComplianceService-method-action-types.cjs";
6
- import type { BlockedWalletsInfo, WalletComplianceStatus } from "./types.cjs";
5
+ import type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction } from "./ComplianceService-method-action-types.cjs";
6
+ import type { WalletComplianceStatus } from "./types.cjs";
7
7
  /**
8
8
  * The name of the {@link ComplianceController}, used to namespace the
9
9
  * controller's actions and events and to namespace the controller's state data
@@ -15,18 +15,10 @@ export declare const controllerName = "ComplianceController";
15
15
  */
16
16
  export type ComplianceControllerState = {
17
17
  /**
18
- * A map of wallet addresses to their on-demand compliance check results.
18
+ * A map of wallet addresses to their compliance check results, used as a
19
+ * fallback cache when the API is unavailable.
19
20
  */
20
21
  walletComplianceStatusMap: Record<string, WalletComplianceStatus>;
21
- /**
22
- * Information about all blocked wallets, or `null` if not yet fetched.
23
- */
24
- blockedWallets: BlockedWalletsInfo | null;
25
- /**
26
- * Timestamp (in milliseconds) of the last blocked wallets fetch, or 0 if
27
- * never fetched.
28
- */
29
- blockedWalletsLastFetched: number;
30
22
  /**
31
23
  * The date/time (in ISO-8601 format) when the last compliance check was
32
24
  * performed, or `null` if no checks have been performed yet.
@@ -53,7 +45,7 @@ export type ComplianceControllerActions = ComplianceControllerGetStateAction | C
53
45
  /**
54
46
  * Actions from other messengers that {@link ComplianceController} calls.
55
47
  */
56
- type AllowedActions = ComplianceServiceMethodActions;
48
+ type AllowedActions = ComplianceServiceCheckWalletComplianceAction | ComplianceServiceCheckWalletsComplianceAction;
57
49
  /**
58
50
  * Published when the state of {@link ComplianceController} changes.
59
51
  */
@@ -73,12 +65,11 @@ type AllowedEvents = never;
73
65
  export type ComplianceControllerMessenger = Messenger<typeof controllerName, ComplianceControllerActions | AllowedActions, ComplianceControllerEvents | AllowedEvents>;
74
66
  /**
75
67
  * `ComplianceController` manages OFAC compliance state for wallet addresses.
76
- * It proactively fetches and caches the blocked wallets list from the
77
- * Compliance API so that consumers can perform synchronous lookups via the
78
- * `selectIsWalletBlocked` selector without making API calls.
68
+ * It performs on-demand compliance checks via the API and caches results
69
+ * per address in state. Cached results serve as a fallback if the API is
70
+ * unavailable for a subsequent check on the same address.
79
71
  */
80
72
  export declare class ComplianceController extends BaseController<typeof controllerName, ComplianceControllerState, ComplianceControllerMessenger> {
81
- #private;
82
73
  /**
83
74
  * Constructs a new {@link ComplianceController}.
84
75
  *
@@ -86,24 +77,16 @@ export declare class ComplianceController extends BaseController<typeof controll
86
77
  * @param args.messenger - The messenger suited for this controller.
87
78
  * @param args.state - The desired state with which to init this
88
79
  * controller. Missing properties will be filled in with defaults.
89
- * @param args.blockedWalletsRefreshInterval - The interval in milliseconds
90
- * after which the blocked wallets list is considered stale. Defaults to 1
91
- * hour.
92
80
  */
93
- constructor({ messenger, state, blockedWalletsRefreshInterval, }: {
81
+ constructor({ messenger, state, }: {
94
82
  messenger: ComplianceControllerMessenger;
95
83
  state?: Partial<ComplianceControllerState>;
96
- blockedWalletsRefreshInterval?: number;
97
84
  });
98
- /**
99
- * Initializes the controller by fetching the blocked wallets list if it
100
- * is missing or stale. Call once after construction to ensure the blocklist
101
- * is ready for `selectIsWalletBlocked` lookups.
102
- */
103
- init(): Promise<void>;
104
85
  /**
105
86
  * Checks compliance status for a single wallet address via the API and
106
- * persists the result to state.
87
+ * persists the result to state. If the API call fails and a previously
88
+ * cached result exists for the address, the cached result is returned as a
89
+ * fallback. If no cached result exists, the error is re-thrown.
107
90
  *
108
91
  * @param address - The wallet address to check.
109
92
  * @returns The compliance status of the wallet.
@@ -111,19 +94,15 @@ export declare class ComplianceController extends BaseController<typeof controll
111
94
  checkWalletCompliance(address: string): Promise<WalletComplianceStatus>;
112
95
  /**
113
96
  * Checks compliance status for multiple wallet addresses via the API and
114
- * persists the results to state.
97
+ * persists the results to state. If the API call fails and every requested
98
+ * address has a previously cached result, those cached results are returned
99
+ * as a fallback. If any address lacks a cached result, the error is
100
+ * re-thrown.
115
101
  *
116
102
  * @param addresses - The wallet addresses to check.
117
103
  * @returns The compliance statuses of the wallets.
118
104
  */
119
105
  checkWalletsCompliance(addresses: string[]): Promise<WalletComplianceStatus[]>;
120
- /**
121
- * Fetches the full list of blocked wallets from the API and persists the
122
- * data to state. This also updates the `blockedWalletsLastFetched` timestamp.
123
- *
124
- * @returns The blocked wallets information.
125
- */
126
- updateBlockedWallets(): Promise<BlockedWalletsInfo>;
127
106
  /**
128
107
  * Clears all compliance data from state.
129
108
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ComplianceController.d.cts","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EAAE,iCAAiC,EAAE,uDAAmD;AACpG,OAAO,KAAK,EAAE,8BAA8B,EAAE,oDAAgD;AAC9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,oBAAgB;AAI1E;;;;GAIG;AACH,eAAO,MAAM,cAAc,yBAAyB,CAAC;AASrD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAElE;;OAEG;IACH,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE1C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAElC;;;OAGG;IACH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