@metamask-previews/compliance-controller 2.1.0-preview-3866c0ff1 → 2.1.0-preview-e3275932a
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.
- package/CHANGELOG.md +0 -1
- package/dist/ComplianceController-method-action-types.cjs +7 -0
- package/dist/ComplianceController-method-action-types.cjs.map +1 -0
- package/dist/{ComplianceController-method-action-types.d.ts → ComplianceController-method-action-types.d.cts} +2 -2
- package/dist/ComplianceController-method-action-types.d.cts.map +1 -0
- package/dist/ComplianceController-method-action-types.d.mts +44 -0
- package/dist/ComplianceController-method-action-types.d.mts.map +1 -0
- package/dist/{ComplianceController-method-action-types.js → ComplianceController-method-action-types.mjs} +1 -1
- package/dist/ComplianceController-method-action-types.mjs.map +1 -0
- package/dist/ComplianceController.cjs +158 -0
- package/dist/ComplianceController.cjs.map +1 -0
- package/dist/{ComplianceController.d.ts → ComplianceController.d.cts} +7 -7
- package/dist/ComplianceController.d.cts.map +1 -0
- package/dist/ComplianceController.d.mts +112 -0
- package/dist/ComplianceController.d.mts.map +1 -0
- package/dist/{ComplianceController.js → ComplianceController.mjs} +3 -3
- package/dist/ComplianceController.mjs.map +1 -0
- package/dist/ComplianceService-method-action-types.cjs +7 -0
- package/dist/ComplianceService-method-action-types.cjs.map +1 -0
- package/dist/{ComplianceService-method-action-types.d.ts → ComplianceService-method-action-types.d.cts} +2 -2
- package/dist/ComplianceService-method-action-types.d.cts.map +1 -0
- package/dist/ComplianceService-method-action-types.d.mts +30 -0
- package/dist/ComplianceService-method-action-types.d.mts.map +1 -0
- package/dist/{ComplianceService-method-action-types.js → ComplianceService-method-action-types.mjs} +1 -1
- package/dist/ComplianceService-method-action-types.mjs.map +1 -0
- package/dist/ComplianceService.cjs +239 -0
- package/dist/ComplianceService.cjs.map +1 -0
- package/dist/{ComplianceService.d.ts → ComplianceService.d.cts} +6 -6
- package/dist/ComplianceService.d.cts.map +1 -0
- package/dist/ComplianceService.d.mts +184 -0
- package/dist/ComplianceService.d.mts.map +1 -0
- package/dist/{ComplianceService.js → ComplianceService.mjs} +48 -39
- package/dist/ComplianceService.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/{index.js.map → index.cjs.map} +1 -1
- package/dist/{index.d.ts → index.d.cts} +9 -9
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/selectors.cjs +27 -0
- package/dist/selectors.cjs.map +1 -0
- package/dist/{selectors.d.ts → selectors.d.cts} +4 -4
- package/dist/selectors.d.cts.map +1 -0
- package/dist/selectors.d.mts +20 -0
- package/dist/selectors.d.mts.map +1 -0
- package/dist/{selectors.js → selectors.mjs} +3 -3
- package/dist/selectors.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +1 -1
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +18 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.cjs +15 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/{utils.d.ts → utils.d.cts} +2 -2
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +3 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/{utils.js → utils.mjs} +2 -2
- package/dist/utils.mjs.map +1 -0
- package/package.json +16 -12
- package/dist/ComplianceController-method-action-types.d.ts.map +0 -1
- package/dist/ComplianceController-method-action-types.js.map +0 -1
- package/dist/ComplianceController.d.ts.map +0 -1
- package/dist/ComplianceController.js.map +0 -1
- package/dist/ComplianceService-method-action-types.d.ts.map +0 -1
- package/dist/ComplianceService-method-action-types.js.map +0 -1
- package/dist/ComplianceService.d.ts.map +0 -1
- package/dist/ComplianceService.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/selectors.d.ts.map +0 -1
- package/dist/selectors.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
-
- **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
|
|
13
12
|
- Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
|
|
14
13
|
- Bump `@metamask/controller-utils` from `^12.1.0` to `^12.3.0` ([#9058](https://github.com/MetaMask/core/pull/9058), [#9083](https://github.com/MetaMask/core/pull/9083), [#9218](https://github.com/MetaMask/core/pull/9218))
|
|
15
14
|
- Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392))
|
|
@@ -0,0 +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.js';\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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file is auto generated.
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
|
-
import type { ComplianceController } from
|
|
5
|
+
import type { ComplianceController } from "./ComplianceController.cjs";
|
|
6
6
|
/**
|
|
7
7
|
* Checks compliance status for a single wallet address via the API and
|
|
8
8
|
* persists the result to state. If the API call fails and a previously
|
|
@@ -41,4 +41,4 @@ export type ComplianceControllerClearComplianceStateAction = {
|
|
|
41
41
|
* Union of all ComplianceController action types.
|
|
42
42
|
*/
|
|
43
43
|
export type ComplianceControllerMethodActions = ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerClearComplianceStateAction;
|
|
44
|
-
//# sourceMappingURL=ComplianceController-method-action-types.d.
|
|
44
|
+
//# sourceMappingURL=ComplianceController-method-action-types.d.cts.map
|
|
@@ -0,0 +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,mCAAkC;AAEtE;;;;;;;;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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { ComplianceController } from "./ComplianceController.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Checks compliance status for a single wallet address via the API and
|
|
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.
|
|
11
|
+
*
|
|
12
|
+
* @param address - The wallet address to check.
|
|
13
|
+
* @returns The compliance status of the wallet.
|
|
14
|
+
*/
|
|
15
|
+
export type ComplianceControllerCheckWalletComplianceAction = {
|
|
16
|
+
type: `ComplianceController:checkWalletCompliance`;
|
|
17
|
+
handler: ComplianceController['checkWalletCompliance'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Checks compliance status for multiple wallet addresses via the API and
|
|
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.
|
|
25
|
+
*
|
|
26
|
+
* @param addresses - The wallet addresses to check.
|
|
27
|
+
* @returns The compliance statuses of the wallets.
|
|
28
|
+
*/
|
|
29
|
+
export type ComplianceControllerCheckWalletsComplianceAction = {
|
|
30
|
+
type: `ComplianceController:checkWalletsCompliance`;
|
|
31
|
+
handler: ComplianceController['checkWalletsCompliance'];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Clears all compliance data from state.
|
|
35
|
+
*/
|
|
36
|
+
export type ComplianceControllerClearComplianceStateAction = {
|
|
37
|
+
type: `ComplianceController:clearComplianceState`;
|
|
38
|
+
handler: ComplianceController['clearComplianceState'];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Union of all ComplianceController action types.
|
|
42
|
+
*/
|
|
43
|
+
export type ComplianceControllerMethodActions = ComplianceControllerCheckWalletComplianceAction | ComplianceControllerCheckWalletsComplianceAction | ComplianceControllerClearComplianceStateAction;
|
|
44
|
+
//# sourceMappingURL=ComplianceController-method-action-types.d.mts.map
|
|
@@ -0,0 +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,mCAAkC;AAEtE;;;;;;;;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"}
|
|
@@ -0,0 +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.js';\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"]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComplianceController = exports.getDefaultComplianceControllerState = exports.controllerName = void 0;
|
|
4
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
5
|
+
const utils_js_1 = require("./utils.cjs");
|
|
6
|
+
// === GENERAL ===
|
|
7
|
+
/**
|
|
8
|
+
* The name of the {@link ComplianceController}, used to namespace the
|
|
9
|
+
* controller's actions and events and to namespace the controller's state data
|
|
10
|
+
* when composed with other controllers.
|
|
11
|
+
*/
|
|
12
|
+
exports.controllerName = 'ComplianceController';
|
|
13
|
+
/**
|
|
14
|
+
* The metadata for each property in {@link ComplianceControllerState}.
|
|
15
|
+
*/
|
|
16
|
+
const complianceControllerMetadata = {
|
|
17
|
+
walletComplianceStatusMap: {
|
|
18
|
+
includeInDebugSnapshot: false,
|
|
19
|
+
includeInStateLogs: false,
|
|
20
|
+
persist: true,
|
|
21
|
+
usedInUi: true,
|
|
22
|
+
},
|
|
23
|
+
lastCheckedAt: {
|
|
24
|
+
includeInDebugSnapshot: false,
|
|
25
|
+
includeInStateLogs: true,
|
|
26
|
+
persist: true,
|
|
27
|
+
usedInUi: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Constructs the default {@link ComplianceController} state. This allows
|
|
32
|
+
* consumers to provide a partial state object when initializing the controller
|
|
33
|
+
* and also helps in constructing complete state objects for this controller in
|
|
34
|
+
* tests.
|
|
35
|
+
*
|
|
36
|
+
* @returns The default {@link ComplianceController} state.
|
|
37
|
+
*/
|
|
38
|
+
function getDefaultComplianceControllerState() {
|
|
39
|
+
return {
|
|
40
|
+
walletComplianceStatusMap: {},
|
|
41
|
+
lastCheckedAt: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.getDefaultComplianceControllerState = getDefaultComplianceControllerState;
|
|
45
|
+
// === MESSENGER ===
|
|
46
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
47
|
+
'checkWalletCompliance',
|
|
48
|
+
'checkWalletsCompliance',
|
|
49
|
+
'clearComplianceState',
|
|
50
|
+
];
|
|
51
|
+
// === CONTROLLER DEFINITION ===
|
|
52
|
+
/**
|
|
53
|
+
* `ComplianceController` manages OFAC compliance state for wallet addresses.
|
|
54
|
+
* It performs on-demand compliance checks via the API and caches results
|
|
55
|
+
* per address in state. Cached results serve as a fallback if the API is
|
|
56
|
+
* unavailable for a subsequent check on the same address.
|
|
57
|
+
*/
|
|
58
|
+
class ComplianceController extends base_controller_1.BaseController {
|
|
59
|
+
/**
|
|
60
|
+
* Constructs a new {@link ComplianceController}.
|
|
61
|
+
*
|
|
62
|
+
* @param args - The constructor arguments.
|
|
63
|
+
* @param args.messenger - The messenger suited for this controller.
|
|
64
|
+
* @param args.state - The desired state with which to init this
|
|
65
|
+
* controller. Missing properties will be filled in with defaults.
|
|
66
|
+
*/
|
|
67
|
+
constructor({ messenger, state, }) {
|
|
68
|
+
super({
|
|
69
|
+
messenger,
|
|
70
|
+
metadata: complianceControllerMetadata,
|
|
71
|
+
name: exports.controllerName,
|
|
72
|
+
state: {
|
|
73
|
+
...getDefaultComplianceControllerState(),
|
|
74
|
+
...state,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks compliance status for a single wallet address via the API and
|
|
81
|
+
* persists the result to state. If the API call fails and a previously
|
|
82
|
+
* cached result exists for the address, the cached result is returned as a
|
|
83
|
+
* fallback. If no cached result exists, the error is re-thrown.
|
|
84
|
+
*
|
|
85
|
+
* @param address - The wallet address to check.
|
|
86
|
+
* @returns The compliance status of the wallet.
|
|
87
|
+
*/
|
|
88
|
+
async checkWalletCompliance(address) {
|
|
89
|
+
try {
|
|
90
|
+
const result = await this.messenger.call('ComplianceService:checkWalletCompliance', address);
|
|
91
|
+
const now = new Date().toISOString();
|
|
92
|
+
const status = {
|
|
93
|
+
address: result.address,
|
|
94
|
+
blocked: result.blocked,
|
|
95
|
+
checkedAt: now,
|
|
96
|
+
};
|
|
97
|
+
this.update((draftState) => {
|
|
98
|
+
draftState.walletComplianceStatusMap[address] = status;
|
|
99
|
+
draftState.lastCheckedAt = now;
|
|
100
|
+
});
|
|
101
|
+
return status;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const cached = (0, utils_js_1.getWalletComplianceStatus)(this.state.walletComplianceStatusMap, address);
|
|
105
|
+
if (cached) {
|
|
106
|
+
return cached;
|
|
107
|
+
}
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Checks compliance status for multiple wallet addresses via the API and
|
|
113
|
+
* persists the results to state. If the API call fails and every requested
|
|
114
|
+
* address has a previously cached result, those cached results are returned
|
|
115
|
+
* as a fallback. If any address lacks a cached result, the error is
|
|
116
|
+
* re-thrown.
|
|
117
|
+
*
|
|
118
|
+
* @param addresses - The wallet addresses to check.
|
|
119
|
+
* @returns The compliance statuses of the wallets.
|
|
120
|
+
*/
|
|
121
|
+
async checkWalletsCompliance(addresses) {
|
|
122
|
+
try {
|
|
123
|
+
const results = await this.messenger.call('ComplianceService:checkWalletsCompliance', addresses);
|
|
124
|
+
const now = new Date().toISOString();
|
|
125
|
+
const statuses = results.map((result) => ({
|
|
126
|
+
address: result.address,
|
|
127
|
+
blocked: result.blocked,
|
|
128
|
+
checkedAt: now,
|
|
129
|
+
}));
|
|
130
|
+
this.update((draftState) => {
|
|
131
|
+
for (let idx = 0; idx < statuses.length; idx++) {
|
|
132
|
+
const callerAddress = addresses[idx];
|
|
133
|
+
draftState.walletComplianceStatusMap[callerAddress] = statuses[idx];
|
|
134
|
+
}
|
|
135
|
+
draftState.lastCheckedAt = now;
|
|
136
|
+
});
|
|
137
|
+
return statuses;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const cachedStatuses = addresses.map((address) => (0, utils_js_1.getWalletComplianceStatus)(this.state.walletComplianceStatusMap, address));
|
|
141
|
+
if (cachedStatuses.every((status) => Boolean(status))) {
|
|
142
|
+
return cachedStatuses;
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Clears all compliance data from state.
|
|
149
|
+
*/
|
|
150
|
+
clearComplianceState() {
|
|
151
|
+
this.update((draftState) => {
|
|
152
|
+
draftState.walletComplianceStatusMap = {};
|
|
153
|
+
draftState.lastCheckedAt = null;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.ComplianceController = ComplianceController;
|
|
158
|
+
//# sourceMappingURL=ComplianceController.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceController.cjs","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAS3D,0CAAuD;AAEvD,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,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,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IAAI,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7ID,oDA6IC","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.js';\nimport type {\n ComplianceServiceCheckWalletComplianceAction,\n ComplianceServiceCheckWalletsComplianceAction,\n} from './ComplianceService-method-action-types.js';\nimport type { WalletComplianceStatus } from './types.js';\nimport { getWalletComplianceStatus } from './utils.js';\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 = getWalletComplianceStatus(\n this.state.walletComplianceStatusMap,\n address,\n );\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((address) =>\n getWalletComplianceStatus(\n this.state.walletComplianceStatusMap,\n address,\n ),\n );\n if (\n cachedStatuses.every((status): status is WalletComplianceStatus =>\n Boolean(status),\n )\n ) {\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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent } from
|
|
2
|
-
import { BaseController } from
|
|
3
|
-
import type { Messenger } from
|
|
4
|
-
import type { ComplianceControllerMethodActions } from
|
|
5
|
-
import type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction } from
|
|
6
|
-
import type { WalletComplianceStatus } from
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { Messenger } from "@metamask/messenger";
|
|
4
|
+
import type { ComplianceControllerMethodActions } from "./ComplianceController-method-action-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
|
|
@@ -109,4 +109,4 @@ export declare class ComplianceController extends BaseController<typeof controll
|
|
|
109
109
|
clearComplianceState(): void;
|
|
110
110
|
}
|
|
111
111
|
export {};
|
|
112
|
-
//# sourceMappingURL=ComplianceController.d.
|
|
112
|
+
//# sourceMappingURL=ComplianceController.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceController.d.cts","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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CACtD,OAAO,cAAc,EACrB,yBAAyB,EACzB,6BAA6B,CAC9B;IACC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,6BAA6B,CAAC;QACzC,KAAK,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAiBD;;;;;;;;OAQG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,sBAAsB,CAAC;IAgClC;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAyCpC;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAM7B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { Messenger } from "@metamask/messenger";
|
|
4
|
+
import type { ComplianceControllerMethodActions } from "./ComplianceController-method-action-types.mjs";
|
|
5
|
+
import type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction } from "./ComplianceService-method-action-types.mjs";
|
|
6
|
+
import type { WalletComplianceStatus } from "./types.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* The name of the {@link ComplianceController}, used to namespace the
|
|
9
|
+
* controller's actions and events and to namespace the controller's state data
|
|
10
|
+
* when composed with other controllers.
|
|
11
|
+
*/
|
|
12
|
+
export declare const controllerName = "ComplianceController";
|
|
13
|
+
/**
|
|
14
|
+
* Describes the shape of the state object for {@link ComplianceController}.
|
|
15
|
+
*/
|
|
16
|
+
export type ComplianceControllerState = {
|
|
17
|
+
/**
|
|
18
|
+
* A map of wallet addresses to their compliance check results, used as a
|
|
19
|
+
* fallback cache when the API is unavailable.
|
|
20
|
+
*/
|
|
21
|
+
walletComplianceStatusMap: Record<string, WalletComplianceStatus>;
|
|
22
|
+
/**
|
|
23
|
+
* The date/time (in ISO-8601 format) when the last compliance check was
|
|
24
|
+
* performed, or `null` if no checks have been performed yet.
|
|
25
|
+
*/
|
|
26
|
+
lastCheckedAt: string | null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Constructs the default {@link ComplianceController} state. This allows
|
|
30
|
+
* consumers to provide a partial state object when initializing the controller
|
|
31
|
+
* and also helps in constructing complete state objects for this controller in
|
|
32
|
+
* tests.
|
|
33
|
+
*
|
|
34
|
+
* @returns The default {@link ComplianceController} state.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDefaultComplianceControllerState(): ComplianceControllerState;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the state of the {@link ComplianceController}.
|
|
39
|
+
*/
|
|
40
|
+
export type ComplianceControllerGetStateAction = ControllerGetStateAction<typeof controllerName, ComplianceControllerState>;
|
|
41
|
+
/**
|
|
42
|
+
* Actions that {@link ComplianceController} exposes to other consumers.
|
|
43
|
+
*/
|
|
44
|
+
export type ComplianceControllerActions = ComplianceControllerGetStateAction | ComplianceControllerMethodActions;
|
|
45
|
+
/**
|
|
46
|
+
* Actions from other messengers that {@link ComplianceController} calls.
|
|
47
|
+
*/
|
|
48
|
+
type AllowedActions = ComplianceServiceCheckWalletComplianceAction | ComplianceServiceCheckWalletsComplianceAction;
|
|
49
|
+
/**
|
|
50
|
+
* Published when the state of {@link ComplianceController} changes.
|
|
51
|
+
*/
|
|
52
|
+
export type ComplianceControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, ComplianceControllerState>;
|
|
53
|
+
/**
|
|
54
|
+
* Events that {@link ComplianceController} exposes to other consumers.
|
|
55
|
+
*/
|
|
56
|
+
export type ComplianceControllerEvents = ComplianceControllerStateChangeEvent;
|
|
57
|
+
/**
|
|
58
|
+
* Events from other messengers that {@link ComplianceController} subscribes to.
|
|
59
|
+
*/
|
|
60
|
+
type AllowedEvents = never;
|
|
61
|
+
/**
|
|
62
|
+
* The messenger restricted to actions and events accessed by
|
|
63
|
+
* {@link ComplianceController}.
|
|
64
|
+
*/
|
|
65
|
+
export type ComplianceControllerMessenger = Messenger<typeof controllerName, ComplianceControllerActions | AllowedActions, ComplianceControllerEvents | AllowedEvents>;
|
|
66
|
+
/**
|
|
67
|
+
* `ComplianceController` manages OFAC compliance state for wallet addresses.
|
|
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.
|
|
71
|
+
*/
|
|
72
|
+
export declare class ComplianceController extends BaseController<typeof controllerName, ComplianceControllerState, ComplianceControllerMessenger> {
|
|
73
|
+
/**
|
|
74
|
+
* Constructs a new {@link ComplianceController}.
|
|
75
|
+
*
|
|
76
|
+
* @param args - The constructor arguments.
|
|
77
|
+
* @param args.messenger - The messenger suited for this controller.
|
|
78
|
+
* @param args.state - The desired state with which to init this
|
|
79
|
+
* controller. Missing properties will be filled in with defaults.
|
|
80
|
+
*/
|
|
81
|
+
constructor({ messenger, state, }: {
|
|
82
|
+
messenger: ComplianceControllerMessenger;
|
|
83
|
+
state?: Partial<ComplianceControllerState>;
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Checks compliance status for a single wallet address via the API and
|
|
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.
|
|
90
|
+
*
|
|
91
|
+
* @param address - The wallet address to check.
|
|
92
|
+
* @returns The compliance status of the wallet.
|
|
93
|
+
*/
|
|
94
|
+
checkWalletCompliance(address: string): Promise<WalletComplianceStatus>;
|
|
95
|
+
/**
|
|
96
|
+
* Checks compliance status for multiple wallet addresses via the API and
|
|
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.
|
|
101
|
+
*
|
|
102
|
+
* @param addresses - The wallet addresses to check.
|
|
103
|
+
* @returns The compliance statuses of the wallets.
|
|
104
|
+
*/
|
|
105
|
+
checkWalletsCompliance(addresses: string[]): Promise<WalletComplianceStatus[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Clears all compliance data from state.
|
|
108
|
+
*/
|
|
109
|
+
clearComplianceState(): void;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=ComplianceController.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceController.d.mts","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,uDAAsD;AACvG,OAAO,KAAK,EACV,4CAA4C,EAC5C,6CAA6C,EAC9C,oDAAmD;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAmB;AAKzD;;;;GAIG;AACH,eAAO,MAAM,cAAc,yBAAyB,CAAC;AAIrD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAElE;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAoBF;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,IAAI,yBAAyB,CAK/E;AAUD;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,wBAAwB,CACvE,OAAO,cAAc,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,kCAAkC,GAClC,iCAAiC,CAAC;AAEtC;;GAEG;AACH,KAAK,cAAc,GACf,4CAA4C,GAC5C,6CAA6C,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,0BAA0B,CAC3E,OAAO,cAAc,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AAE9E;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,CACnD,OAAO,cAAc,EACrB,2BAA2B,GAAG,cAAc,EAC5C,0BAA0B,GAAG,aAAa,CAC3C,CAAC;AAIF;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,cAAc,CACtD,OAAO,cAAc,EACrB,yBAAyB,EACzB,6BAA6B,CAC9B;IACC;;;;;;;OAOG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,6BAA6B,CAAC;QACzC,KAAK,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAiBD;;;;;;;;OAQG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,sBAAsB,CAAC;IAgClC;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAyCpC;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAM7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseController } from
|
|
2
|
-
import { getWalletComplianceStatus } from
|
|
1
|
+
import { BaseController } from "@metamask/base-controller";
|
|
2
|
+
import { getWalletComplianceStatus } from "./utils.mjs";
|
|
3
3
|
// === GENERAL ===
|
|
4
4
|
/**
|
|
5
5
|
* The name of the {@link ComplianceController}, used to namespace the
|
|
@@ -150,4 +150,4 @@ export class ComplianceController extends BaseController {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
//# sourceMappingURL=ComplianceController.
|
|
153
|
+
//# sourceMappingURL=ComplianceController.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceController.mjs","sourceRoot":"","sources":["../src/ComplianceController.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAS3D,OAAO,EAAE,yBAAyB,EAAE,oBAAmB;AAEvD,kBAAkB;AAElB;;;;GAIG;AACH,MAAM,CAAC,MAAM,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,MAAM,UAAU,mCAAmC;IACjD,OAAO;QACL,yBAAyB,EAAE,EAAE;QAC7B,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC;AAED,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;CACd,CAAC;AAoDX,gCAAgC;AAEhC;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAIzC;IACC;;;;;;;OAOG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ,EAAE,4BAA4B;YACtC,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE;gBACL,GAAG,mCAAmC,EAAE;gBACxC,GAAG,KAAK;aACT;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,4BAA4B,CACzC,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;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SAAS,EAAE,GAAG;aACf,CAAC,CAAC,CAAC;YAEJ,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;gBACzB,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;oBAC/C,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;oBACrC,UAAU,CAAC,yBAAyB,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACtE,CAAC;gBACD,UAAU,CAAC,aAAa,GAAG,GAAG,CAAC;YACjC,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAC/C,yBAAyB,CACvB,IAAI,CAAC,KAAK,CAAC,yBAAyB,EACpC,OAAO,CACR,CACF,CAAC;YACF,IACE,cAAc,CAAC,KAAK,CAAC,CAAC,MAAM,EAAoC,EAAE,CAChE,OAAO,CAAC,MAAM,CAAC,CAChB,EACD,CAAC;gBACD,OAAO,cAAc,CAAC;YACxB,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,UAAU,CAAC,yBAAyB,GAAG,EAAE,CAAC;YAC1C,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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.js';\nimport type {\n ComplianceServiceCheckWalletComplianceAction,\n ComplianceServiceCheckWalletsComplianceAction,\n} from './ComplianceService-method-action-types.js';\nimport type { WalletComplianceStatus } from './types.js';\nimport { getWalletComplianceStatus } from './utils.js';\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 = getWalletComplianceStatus(\n this.state.walletComplianceStatusMap,\n address,\n );\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((address) =>\n getWalletComplianceStatus(\n this.state.walletComplianceStatusMap,\n address,\n ),\n );\n if (\n cachedStatuses.every((status): status is WalletComplianceStatus =>\n Boolean(status),\n )\n ) {\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceService-method-action-types.cjs","sourceRoot":"","sources":["../src/ComplianceService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceService } from './ComplianceService.js';\n\n/**\n * Checks compliance status for a single wallet address.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceServiceCheckWalletComplianceAction = {\n type: `ComplianceService:checkWalletCompliance`;\n handler: ComplianceService['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses in a single request.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceServiceCheckWalletsComplianceAction = {\n type: `ComplianceService:checkWalletsCompliance`;\n handler: ComplianceService['checkWalletsCompliance'];\n};\n\n/**\n * Union of all ComplianceService action types.\n */\nexport type ComplianceServiceMethodActions =\n | ComplianceServiceCheckWalletComplianceAction\n | ComplianceServiceCheckWalletsComplianceAction;\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file is auto generated.
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
|
-
import type { ComplianceService } from
|
|
5
|
+
import type { ComplianceService } from "./ComplianceService.cjs";
|
|
6
6
|
/**
|
|
7
7
|
* Checks compliance status for a single wallet address.
|
|
8
8
|
*
|
|
@@ -27,4 +27,4 @@ export type ComplianceServiceCheckWalletsComplianceAction = {
|
|
|
27
27
|
* Union of all ComplianceService action types.
|
|
28
28
|
*/
|
|
29
29
|
export type ComplianceServiceMethodActions = ComplianceServiceCheckWalletComplianceAction | ComplianceServiceCheckWalletsComplianceAction;
|
|
30
|
-
//# sourceMappingURL=ComplianceService-method-action-types.d.
|
|
30
|
+
//# sourceMappingURL=ComplianceService-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceService-method-action-types.d.cts","sourceRoot":"","sources":["../src/ComplianceService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gCAA+B;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;CACtD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,4CAA4C,GAC5C,6CAA6C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { ComplianceService } from "./ComplianceService.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Checks compliance status for a single wallet address.
|
|
8
|
+
*
|
|
9
|
+
* @param address - The wallet address to check.
|
|
10
|
+
* @returns The compliance status of the wallet.
|
|
11
|
+
*/
|
|
12
|
+
export type ComplianceServiceCheckWalletComplianceAction = {
|
|
13
|
+
type: `ComplianceService:checkWalletCompliance`;
|
|
14
|
+
handler: ComplianceService['checkWalletCompliance'];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Checks compliance status for multiple wallet addresses in a single request.
|
|
18
|
+
*
|
|
19
|
+
* @param addresses - The wallet addresses to check.
|
|
20
|
+
* @returns The compliance statuses of the wallets.
|
|
21
|
+
*/
|
|
22
|
+
export type ComplianceServiceCheckWalletsComplianceAction = {
|
|
23
|
+
type: `ComplianceService:checkWalletsCompliance`;
|
|
24
|
+
handler: ComplianceService['checkWalletsCompliance'];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Union of all ComplianceService action types.
|
|
28
|
+
*/
|
|
29
|
+
export type ComplianceServiceMethodActions = ComplianceServiceCheckWalletComplianceAction | ComplianceServiceCheckWalletsComplianceAction;
|
|
30
|
+
//# sourceMappingURL=ComplianceService-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceService-method-action-types.d.mts","sourceRoot":"","sources":["../src/ComplianceService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gCAA+B;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;CACtD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,4CAA4C,GAC5C,6CAA6C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplianceService-method-action-types.mjs","sourceRoot":"","sources":["../src/ComplianceService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ComplianceService } from './ComplianceService.js';\n\n/**\n * Checks compliance status for a single wallet address.\n *\n * @param address - The wallet address to check.\n * @returns The compliance status of the wallet.\n */\nexport type ComplianceServiceCheckWalletComplianceAction = {\n type: `ComplianceService:checkWalletCompliance`;\n handler: ComplianceService['checkWalletCompliance'];\n};\n\n/**\n * Checks compliance status for multiple wallet addresses in a single request.\n *\n * @param addresses - The wallet addresses to check.\n * @returns The compliance statuses of the wallets.\n */\nexport type ComplianceServiceCheckWalletsComplianceAction = {\n type: `ComplianceService:checkWalletsCompliance`;\n handler: ComplianceService['checkWalletsCompliance'];\n};\n\n/**\n * Union of all ComplianceService action types.\n */\nexport type ComplianceServiceMethodActions =\n | ComplianceServiceCheckWalletComplianceAction\n | ComplianceServiceCheckWalletsComplianceAction;\n"]}
|