@metamask-previews/compliance-controller 1.0.2-preview-08282b0e4 → 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.
- package/CHANGELOG.md +13 -1
- package/dist/ComplianceController-method-action-types.cjs.map +1 -1
- package/dist/ComplianceController-method-action-types.d.cts +8 -22
- package/dist/ComplianceController-method-action-types.d.cts.map +1 -1
- package/dist/ComplianceController-method-action-types.d.mts +8 -22
- package/dist/ComplianceController-method-action-types.d.mts.map +1 -1
- package/dist/ComplianceController-method-action-types.mjs.map +1 -1
- package/dist/ComplianceController.cjs +55 -112
- package/dist/ComplianceController.cjs.map +1 -1
- package/dist/ComplianceController.d.cts +16 -37
- package/dist/ComplianceController.d.cts.map +1 -1
- package/dist/ComplianceController.d.mts +16 -37
- package/dist/ComplianceController.d.mts.map +1 -1
- package/dist/ComplianceController.mjs +55 -112
- package/dist/ComplianceController.mjs.map +1 -1
- package/dist/ComplianceService-method-action-types.cjs.map +1 -1
- package/dist/ComplianceService-method-action-types.d.cts +1 -10
- package/dist/ComplianceService-method-action-types.d.cts.map +1 -1
- package/dist/ComplianceService-method-action-types.d.mts +1 -10
- package/dist/ComplianceService-method-action-types.d.mts.map +1 -1
- package/dist/ComplianceService-method-action-types.mjs.map +1 -1
- package/dist/ComplianceService.cjs +0 -29
- package/dist/ComplianceService.cjs.map +1 -1
- package/dist/ComplianceService.d.cts +0 -31
- package/dist/ComplianceService.d.cts.map +1 -1
- package/dist/ComplianceService.d.mts +0 -31
- package/dist/ComplianceService.d.mts.map +1 -1
- package/dist/ComplianceService.mjs +1 -30
- package/dist/ComplianceService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +2 -9
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +1 -2
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +1 -2
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +2 -9
- package/dist/selectors.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +0 -25
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +0 -25
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -62,31 +62,6 @@ declare const BatchWalletCheckResponseItemStruct: import("@metamask/superstruct"
|
|
|
62
62
|
* The validated shape of a single item in a batch compliance check response.
|
|
63
63
|
*/
|
|
64
64
|
type BatchWalletCheckResponseItem = Infer<typeof BatchWalletCheckResponseItemStruct>;
|
|
65
|
-
/**
|
|
66
|
-
* Schema for the response from `GET /v1/blocked-wallets`.
|
|
67
|
-
*/
|
|
68
|
-
declare const BlockedWalletsResponseStruct: import("@metamask/superstruct").Struct<{
|
|
69
|
-
addresses: string[];
|
|
70
|
-
sources: {
|
|
71
|
-
ofac: number;
|
|
72
|
-
remote: number;
|
|
73
|
-
};
|
|
74
|
-
lastUpdated: string;
|
|
75
|
-
}, {
|
|
76
|
-
addresses: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
|
|
77
|
-
sources: import("@metamask/superstruct").Struct<{
|
|
78
|
-
ofac: number;
|
|
79
|
-
remote: number;
|
|
80
|
-
}, {
|
|
81
|
-
ofac: import("@metamask/superstruct").Struct<number, null>;
|
|
82
|
-
remote: import("@metamask/superstruct").Struct<number, null>;
|
|
83
|
-
}>;
|
|
84
|
-
lastUpdated: import("@metamask/superstruct").Struct<string, null>;
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* The validated shape of the blocked wallets response.
|
|
88
|
-
*/
|
|
89
|
-
type BlockedWalletsResponse = Infer<typeof BlockedWalletsResponseStruct>;
|
|
90
65
|
/**
|
|
91
66
|
* `ComplianceService` communicates with the Compliance API to check whether
|
|
92
67
|
* wallet addresses are sanctioned under OFAC regulations.
|
|
@@ -193,12 +168,6 @@ export declare class ComplianceService {
|
|
|
193
168
|
* @returns The compliance statuses of the wallets.
|
|
194
169
|
*/
|
|
195
170
|
checkWalletsCompliance(addresses: string[]): Promise<BatchWalletCheckResponseItem[]>;
|
|
196
|
-
/**
|
|
197
|
-
* Fetches the full list of blocked wallets and source metadata.
|
|
198
|
-
*
|
|
199
|
-
* @returns The blocked wallets data.
|
|
200
|
-
*/
|
|
201
|
-
updateBlockedWallets(): Promise<BlockedWalletsResponse>;
|
|
202
171
|
}
|
|
203
172
|
export {};
|
|
204
173
|
//# sourceMappingURL=ComplianceService.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplianceService.d.cts","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAE7C,OAAO,KAAK,EAAE,8BAA8B,EAAE,oDAAgD;AAI9F;;;GAGG;AACH,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,YAAY,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ComplianceService.d.cts","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAE7C,OAAO,KAAK,EAAE,8BAA8B,EAA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AAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW;IAIvE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW;IAIvE;;;;;;;OAOG;IACH,UAAU,CACR,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACnD,WAAW;IAId;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwB1E;;;;;OAKG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,4BAA4B,EAAE,CAAC;CAwB3C"}
|
|
@@ -62,31 +62,6 @@ declare const BatchWalletCheckResponseItemStruct: import("@metamask/superstruct"
|
|
|
62
62
|
* The validated shape of a single item in a batch compliance check response.
|
|
63
63
|
*/
|
|
64
64
|
type BatchWalletCheckResponseItem = Infer<typeof BatchWalletCheckResponseItemStruct>;
|
|
65
|
-
/**
|
|
66
|
-
* Schema for the response from `GET /v1/blocked-wallets`.
|
|
67
|
-
*/
|
|
68
|
-
declare const BlockedWalletsResponseStruct: import("@metamask/superstruct").Struct<{
|
|
69
|
-
addresses: string[];
|
|
70
|
-
sources: {
|
|
71
|
-
ofac: number;
|
|
72
|
-
remote: number;
|
|
73
|
-
};
|
|
74
|
-
lastUpdated: string;
|
|
75
|
-
}, {
|
|
76
|
-
addresses: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
|
|
77
|
-
sources: import("@metamask/superstruct").Struct<{
|
|
78
|
-
ofac: number;
|
|
79
|
-
remote: number;
|
|
80
|
-
}, {
|
|
81
|
-
ofac: import("@metamask/superstruct").Struct<number, null>;
|
|
82
|
-
remote: import("@metamask/superstruct").Struct<number, null>;
|
|
83
|
-
}>;
|
|
84
|
-
lastUpdated: import("@metamask/superstruct").Struct<string, null>;
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* The validated shape of the blocked wallets response.
|
|
88
|
-
*/
|
|
89
|
-
type BlockedWalletsResponse = Infer<typeof BlockedWalletsResponseStruct>;
|
|
90
65
|
/**
|
|
91
66
|
* `ComplianceService` communicates with the Compliance API to check whether
|
|
92
67
|
* wallet addresses are sanctioned under OFAC regulations.
|
|
@@ -193,12 +168,6 @@ export declare class ComplianceService {
|
|
|
193
168
|
* @returns The compliance statuses of the wallets.
|
|
194
169
|
*/
|
|
195
170
|
checkWalletsCompliance(addresses: string[]): Promise<BatchWalletCheckResponseItem[]>;
|
|
196
|
-
/**
|
|
197
|
-
* Fetches the full list of blocked wallets and source metadata.
|
|
198
|
-
*
|
|
199
|
-
* @returns The blocked wallets data.
|
|
200
|
-
*/
|
|
201
|
-
updateBlockedWallets(): Promise<BlockedWalletsResponse>;
|
|
202
171
|
}
|
|
203
172
|
export {};
|
|
204
173
|
//# sourceMappingURL=ComplianceService.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplianceService.d.mts","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACd,mCAAmC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAE7C,OAAO,KAAK,EAAE,8BAA8B,EAAE,oDAAgD;AAI9F;;;GAGG;AACH,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,YAAY,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ComplianceService.d.mts","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EAC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,EAAE,OAAO,KAAK,CAAC;QACpB,GAAG,EAAE,4BAA4B,CAAC;QAClC,aAAa,CAAC,EAAE,0BAA0B,CAAC;KAC5C;IAaD;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW;IAIvE;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW;IAIvE;;;;;;;OAOG;IACH,UAAU,CACR,QAAQ,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACnD,WAAW;IAId;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwB1E;;;;;OAKG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,4BAA4B,EAAE,CAAC;CAwB3C"}
|
|
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _a, _ComplianceService_messenger, _ComplianceService_fetch, _ComplianceService_complianceApiUrl, _ComplianceService_policy;
|
|
13
13
|
import { createServicePolicy, HttpError } from "@metamask/controller-utils";
|
|
14
|
-
import { array, boolean,
|
|
14
|
+
import { array, boolean, object, string } from "@metamask/superstruct";
|
|
15
15
|
// === GENERAL ===
|
|
16
16
|
/**
|
|
17
17
|
* The name of the {@link ComplianceService}, used to namespace the service's
|
|
@@ -26,7 +26,6 @@ const COMPLIANCE_API_URLS = {
|
|
|
26
26
|
const MESSENGER_EXPOSED_METHODS = [
|
|
27
27
|
'checkWalletCompliance',
|
|
28
28
|
'checkWalletsCompliance',
|
|
29
|
-
'updateBlockedWallets',
|
|
30
29
|
];
|
|
31
30
|
// === API RESPONSE SCHEMAS ===
|
|
32
31
|
/**
|
|
@@ -41,17 +40,6 @@ const WalletCheckResponseStruct = object({
|
|
|
41
40
|
* Reuses the same shape as a single wallet check.
|
|
42
41
|
*/
|
|
43
42
|
const BatchWalletCheckResponseItemStruct = WalletCheckResponseStruct;
|
|
44
|
-
/**
|
|
45
|
-
* Schema for the response from `GET /v1/blocked-wallets`.
|
|
46
|
-
*/
|
|
47
|
-
const BlockedWalletsResponseStruct = object({
|
|
48
|
-
addresses: array(string()),
|
|
49
|
-
sources: object({
|
|
50
|
-
ofac: number(),
|
|
51
|
-
remote: number(),
|
|
52
|
-
}),
|
|
53
|
-
lastUpdated: string(),
|
|
54
|
-
});
|
|
55
43
|
// === SERVICE DEFINITION ===
|
|
56
44
|
/**
|
|
57
45
|
* `ComplianceService` communicates with the Compliance API to check whether
|
|
@@ -206,23 +194,6 @@ export class ComplianceService {
|
|
|
206
194
|
const jsonResponse = await response.json();
|
|
207
195
|
return validateResponse(jsonResponse, array(BatchWalletCheckResponseItemStruct), 'compliance batch check API');
|
|
208
196
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Fetches the full list of blocked wallets and source metadata.
|
|
211
|
-
*
|
|
212
|
-
* @returns The blocked wallets data.
|
|
213
|
-
*/
|
|
214
|
-
async updateBlockedWallets() {
|
|
215
|
-
const response = await __classPrivateFieldGet(this, _ComplianceService_policy, "f").execute(async () => {
|
|
216
|
-
const url = new URL('/v1/blocked-wallets', __classPrivateFieldGet(this, _ComplianceService_complianceApiUrl, "f"));
|
|
217
|
-
const localResponse = await __classPrivateFieldGet(this, _ComplianceService_fetch, "f").call(this, url);
|
|
218
|
-
if (!localResponse.ok) {
|
|
219
|
-
throw new HttpError(localResponse.status, `Fetching '${url.toString()}' failed with status '${localResponse.status}'`);
|
|
220
|
-
}
|
|
221
|
-
return localResponse;
|
|
222
|
-
});
|
|
223
|
-
const jsonResponse = await response.json();
|
|
224
|
-
return validateResponse(jsonResponse, BlockedWalletsResponseStruct, 'compliance blocked wallets API');
|
|
225
|
-
}
|
|
226
197
|
}
|
|
227
198
|
_a = ComplianceService, _ComplianceService_messenger = new WeakMap(), _ComplianceService_fetch = new WeakMap(), _ComplianceService_complianceApiUrl = new WeakMap(), _ComplianceService_policy = new WeakMap();
|
|
228
199
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplianceService.mjs","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAG5E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAK/E,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAO/C,MAAM,mBAAmB,GAAiD;IACxE,UAAU,EAAE,uCAAuC;IACnD,WAAW,EAAE,2CAA2C;CACzD,CAAC;AAEF,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;CACd,CAAC;AAgCX,+BAA+B;AAE/B;;GAEG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE;IACjB,OAAO,EAAE,OAAO,EAAE;CACnB,CAAC,CAAC;AAOH;;;GAGG;AACH,MAAM,kCAAkC,GAAG,yBAAyB,CAAC;AASrE;;GAEG;AACH,MAAM,4BAA4B,GAAG,MAAM,CAAC;IAC1C,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,EAAE;QACd,MAAM,EAAE,MAAM,EAAE;KACjB,CAAC;IACF,WAAW,EAAE,MAAM,EAAE;CACtB,CAAC,CAAC;AAOH,6BAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,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AC,IAAI,EAAE,CAAC;QAEpD,OAAO,gBAAgB,CACrB,YAAY,EACZ,KAAK,CAAC,kCAAkC,CAAC,EACzC,4BAA4B,CAC7B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,oBAAoB;QACxB,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,iCAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;YACrD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,qBAAqB,EAAE,uBAAA,IAAI,2CAAkB,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,MAAM,uBAAA,IAAI,gCAAO,MAAX,IAAI,EAAQ,GAAG,CAAC,CAAC;YAC7C,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;gBACtB,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,MAAM,EACpB,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,aAAa,CAAC,MAAM,GAAG,CAC5E,CAAC;YACJ,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,MAAM,YAAY,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEpD,OAAO,gBAAgB,CACrB,YAAY,EACZ,4BAA4B,EAC5B,gCAAgC,CACjC,CAAC;IACJ,CAAC;CACF;;AAED;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CACvB,IAAa,EACb,MAAqD,EACrD,OAAe;IAEf,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, boolean, number, object, string } from '@metamask/superstruct';\nimport type { IDisposable } from 'cockatiel';\n\nimport type { ComplianceServiceMethodActions } from './ComplianceService-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ComplianceService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'ComplianceService';\n\n/**\n * The supported environments for the Compliance API.\n */\nexport type ComplianceServiceEnvironment = 'production' | 'development';\n\nconst COMPLIANCE_API_URLS: Record<ComplianceServiceEnvironment, string> = {\n production: 'https://compliance.api.cx.metamask.io',\n development: 'https://compliance.dev-api.cx.metamask.io',\n};\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'checkWalletCompliance',\n 'checkWalletsCompliance',\n 'updateBlockedWallets',\n] as const;\n\n/**\n * Actions that {@link ComplianceService} exposes to other consumers.\n */\nexport type ComplianceServiceActions = ComplianceServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link ComplianceService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link ComplianceService} exposes to other consumers.\n */\nexport type ComplianceServiceEvents = never;\n\n/**\n * Events from other messengers that {@link ComplianceService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ComplianceService}.\n */\nexport type ComplianceServiceMessenger = Messenger<\n typeof serviceName,\n ComplianceServiceActions | AllowedActions,\n ComplianceServiceEvents | AllowedEvents\n>;\n\n// === API RESPONSE SCHEMAS ===\n\n/**\n * Schema for the response from `GET /v1/wallet/:address`.\n */\nconst WalletCheckResponseStruct = object({\n address: string(),\n blocked: boolean(),\n});\n\n/**\n * The validated shape of a single wallet compliance check response.\n */\ntype WalletCheckResponse = Infer<typeof WalletCheckResponseStruct>;\n\n/**\n * Schema for each item in the response from `POST /v1/wallet/batch`.\n * Reuses the same shape as a single wallet check.\n */\nconst BatchWalletCheckResponseItemStruct = WalletCheckResponseStruct;\n\n/**\n * The validated shape of a single item in a batch compliance check response.\n */\ntype BatchWalletCheckResponseItem = Infer<\n typeof BatchWalletCheckResponseItemStruct\n>;\n\n/**\n * Schema for the response from `GET /v1/blocked-wallets`.\n */\nconst BlockedWalletsResponseStruct = object({\n addresses: array(string()),\n sources: object({\n ofac: number(),\n remote: number(),\n }),\n lastUpdated: string(),\n});\n\n/**\n * The validated shape of the blocked wallets response.\n */\ntype BlockedWalletsResponse = Infer<typeof BlockedWalletsResponseStruct>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * `ComplianceService` communicates with the Compliance API to check whether\n * wallet addresses are sanctioned under OFAC regulations.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * } from '@metamask/compliance-controller';\n * import { ComplianceService } from '@metamask/compliance-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * >({ namespace: 'Root' });\n * const serviceMessenger = new Messenger<\n * 'ComplianceService',\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'ComplianceService',\n * parent: rootMessenger,\n * });\n * new ComplianceService({\n * messenger: serviceMessenger,\n * fetch,\n * env: 'production',\n * });\n *\n * // Check a single wallet\n * const result = await rootMessenger.call(\n * 'ComplianceService:checkWalletCompliance',\n * '0x1234...',\n * );\n * // => { address: '0x1234...', blocked: false }\n * ```\n */\nexport class ComplianceService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof ComplianceService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof ComplianceService>[0]['fetch'];\n\n /**\n * The resolved base URL for the Compliance API.\n */\n readonly #complianceApiUrl: string;\n\n /**\n * The policy that wraps each request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new ComplianceService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * @param args.env - The environment to use for the Compliance API. Determines\n * the base URL.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n fetch: fetchFunction,\n env,\n policyOptions = {},\n }: {\n messenger: ComplianceServiceMessenger;\n fetch: typeof fetch;\n env: ComplianceServiceEnvironment;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#complianceApiUrl = COMPLIANCE_API_URLS[env];\n this.#policy = createServicePolicy(policyOptions);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onRetry(listener: Parameters<ServicePolicy['onRetry']>[0]): IDisposable {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onBreak(listener: Parameters<ServicePolicy['onBreak']>[0]): IDisposable {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called when the service is degraded due\n * to slow responses or repeated failures.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): IDisposable {\n return this.#policy.onDegraded(listener);\n }\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 */\n async checkWalletCompliance(address: string): Promise<WalletCheckResponse> {\n const response = await this.#policy.execute(async () => {\n const url = new URL(\n `/v1/wallet/${encodeURIComponent(address)}`,\n this.#complianceApiUrl,\n );\n const localResponse = await this.#fetch(url);\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n const jsonResponse: unknown = await response.json();\n\n return validateResponse(\n jsonResponse,\n WalletCheckResponseStruct,\n 'compliance wallet check API',\n );\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 */\n async checkWalletsCompliance(\n addresses: string[],\n ): Promise<BatchWalletCheckResponseItem[]> {\n const response = await this.#policy.execute(async () => {\n const url = new URL('/v1/wallet/batch', this.#complianceApiUrl);\n const localResponse = await this.#fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(addresses),\n });\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n const jsonResponse: unknown = await response.json();\n\n return validateResponse(\n jsonResponse,\n array(BatchWalletCheckResponseItemStruct),\n 'compliance batch check API',\n );\n }\n\n /**\n * Fetches the full list of blocked wallets and source metadata.\n *\n * @returns The blocked wallets data.\n */\n async updateBlockedWallets(): Promise<BlockedWalletsResponse> {\n const response = await this.#policy.execute(async () => {\n const url = new URL('/v1/blocked-wallets', this.#complianceApiUrl);\n const localResponse = await this.#fetch(url);\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n const jsonResponse: unknown = await response.json();\n\n return validateResponse(\n jsonResponse,\n BlockedWalletsResponseStruct,\n 'compliance blocked wallets API',\n );\n }\n}\n\n/**\n * Validates an API response against a superstruct schema.\n *\n * @param data - The raw response data to validate.\n * @param struct - The superstruct schema to validate against.\n * @param struct.is - The type guard function from the schema.\n * @param apiName - A human-readable name for the API, used in error messages.\n * @returns The validated data.\n * @throws If the data does not match the schema.\n */\nfunction validateResponse<Response>(\n data: unknown,\n struct: { is: (value: unknown) => value is Response },\n apiName: string,\n): Response {\n if (struct.is(data)) {\n return data;\n }\n throw new Error(`Malformed response received from ${apiName}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ComplianceService.mjs","sourceRoot":"","sources":["../src/ComplianceService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,mCAAmC;AAG5E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAKvE,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAO/C,MAAM,mBAAmB,GAAiD;IACxE,UAAU,EAAE,uCAAuC;IACnD,WAAW,EAAE,2CAA2C;CACzD,CAAC;AAEF,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,uBAAuB;IACvB,wBAAwB;CAChB,CAAC;AAgCX,+BAA+B;AAE/B;;GAEG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE;IACjB,OAAO,EAAE,OAAO,EAAE;CACnB,CAAC,CAAC;AAOH;;;GAGG;AACH,MAAM,kCAAkC,GAAG,yBAAyB,CAAC;AASrE,6BAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,iBAAiB;IA8B5B;;;;;;;;;;OAUG;IACH,YAAY,EACV,SAAS,EACT,KAAK,EAAE,aAAa,EACpB,GAAG,EACH,aAAa,GAAG,EAAE,GAMnB;QA7CD;;WAEG;QACM,+CAES;QAElB;;WAEG;QACM,2CAAoE;QAE7E;;WAEG;QACM,sDAA0B;QAEnC;;;;WAIG;QACM,4CAAuB;QAwB9B,IAAI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,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport { createServicePolicy, HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, boolean, object, string } from '@metamask/superstruct';\nimport type { IDisposable } from 'cockatiel';\n\nimport type { ComplianceServiceMethodActions } from './ComplianceService-method-action-types';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ComplianceService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'ComplianceService';\n\n/**\n * The supported environments for the Compliance API.\n */\nexport type ComplianceServiceEnvironment = 'production' | 'development';\n\nconst COMPLIANCE_API_URLS: Record<ComplianceServiceEnvironment, string> = {\n production: 'https://compliance.api.cx.metamask.io',\n development: 'https://compliance.dev-api.cx.metamask.io',\n};\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'checkWalletCompliance',\n 'checkWalletsCompliance',\n] as const;\n\n/**\n * Actions that {@link ComplianceService} exposes to other consumers.\n */\nexport type ComplianceServiceActions = ComplianceServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link ComplianceService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link ComplianceService} exposes to other consumers.\n */\nexport type ComplianceServiceEvents = never;\n\n/**\n * Events from other messengers that {@link ComplianceService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ComplianceService}.\n */\nexport type ComplianceServiceMessenger = Messenger<\n typeof serviceName,\n ComplianceServiceActions | AllowedActions,\n ComplianceServiceEvents | AllowedEvents\n>;\n\n// === API RESPONSE SCHEMAS ===\n\n/**\n * Schema for the response from `GET /v1/wallet/:address`.\n */\nconst WalletCheckResponseStruct = object({\n address: string(),\n blocked: boolean(),\n});\n\n/**\n * The validated shape of a single wallet compliance check response.\n */\ntype WalletCheckResponse = Infer<typeof WalletCheckResponseStruct>;\n\n/**\n * Schema for each item in the response from `POST /v1/wallet/batch`.\n * Reuses the same shape as a single wallet check.\n */\nconst BatchWalletCheckResponseItemStruct = WalletCheckResponseStruct;\n\n/**\n * The validated shape of a single item in a batch compliance check response.\n */\ntype BatchWalletCheckResponseItem = Infer<\n typeof BatchWalletCheckResponseItemStruct\n>;\n\n// === SERVICE DEFINITION ===\n\n/**\n * `ComplianceService` communicates with the Compliance API to check whether\n * wallet addresses are sanctioned under OFAC regulations.\n *\n * @example\n *\n * ``` ts\n * import { Messenger } from '@metamask/messenger';\n * import type {\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * } from '@metamask/compliance-controller';\n * import { ComplianceService } from '@metamask/compliance-controller';\n *\n * const rootMessenger = new Messenger<\n * 'Root',\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * >({ namespace: 'Root' });\n * const serviceMessenger = new Messenger<\n * 'ComplianceService',\n * ComplianceServiceActions,\n * ComplianceServiceEvents,\n * typeof rootMessenger,\n * >({\n * namespace: 'ComplianceService',\n * parent: rootMessenger,\n * });\n * new ComplianceService({\n * messenger: serviceMessenger,\n * fetch,\n * env: 'production',\n * });\n *\n * // Check a single wallet\n * const result = await rootMessenger.call(\n * 'ComplianceService:checkWalletCompliance',\n * '0x1234...',\n * );\n * // => { address: '0x1234...', blocked: false }\n * ```\n */\nexport class ComplianceService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n /**\n * The messenger suited for this service.\n */\n readonly #messenger: ConstructorParameters<\n typeof ComplianceService\n >[0]['messenger'];\n\n /**\n * A function that can be used to make an HTTP request.\n */\n readonly #fetch: ConstructorParameters<typeof ComplianceService>[0]['fetch'];\n\n /**\n * The resolved base URL for the Compliance API.\n */\n readonly #complianceApiUrl: string;\n\n /**\n * The policy that wraps each request.\n *\n * @see {@link createServicePolicy}\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new ComplianceService object.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * @param args.env - The environment to use for the Compliance API. Determines\n * the base URL.\n * @param args.policyOptions - Options to pass to `createServicePolicy`, which\n * is used to wrap each request. See {@link CreateServicePolicyOptions}.\n */\n constructor({\n messenger,\n fetch: fetchFunction,\n env,\n policyOptions = {},\n }: {\n messenger: ComplianceServiceMessenger;\n fetch: typeof fetch;\n env: ComplianceServiceEnvironment;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n this.name = serviceName;\n this.#messenger = messenger;\n this.#fetch = fetchFunction;\n this.#complianceApiUrl = COMPLIANCE_API_URLS[env];\n this.#policy = createServicePolicy(policyOptions);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Registers a handler that will be called after a request returns a non-500\n * response, causing a retry.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onRetry(listener: Parameters<ServicePolicy['onRetry']>[0]): IDisposable {\n return this.#policy.onRetry(listener);\n }\n\n /**\n * Registers a handler that will be called after a set number of retry rounds\n * prove that requests to the API endpoint consistently return a 5xx response.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onBreak(listener: Parameters<ServicePolicy['onBreak']>[0]): IDisposable {\n return this.#policy.onBreak(listener);\n }\n\n /**\n * Registers a handler that will be called when the service is degraded due\n * to slow responses or repeated failures.\n *\n * @param listener - The handler to be called.\n * @returns An object that can be used to unregister the handler.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: Parameters<ServicePolicy['onDegraded']>[0],\n ): IDisposable {\n return this.#policy.onDegraded(listener);\n }\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 */\n async checkWalletCompliance(address: string): Promise<WalletCheckResponse> {\n const response = await this.#policy.execute(async () => {\n const url = new URL(\n `/v1/wallet/${encodeURIComponent(address)}`,\n this.#complianceApiUrl,\n );\n const localResponse = await this.#fetch(url);\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n const jsonResponse: unknown = await response.json();\n\n return validateResponse(\n jsonResponse,\n WalletCheckResponseStruct,\n 'compliance wallet check API',\n );\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 */\n async checkWalletsCompliance(\n addresses: string[],\n ): Promise<BatchWalletCheckResponseItem[]> {\n const response = await this.#policy.execute(async () => {\n const url = new URL('/v1/wallet/batch', this.#complianceApiUrl);\n const localResponse = await this.#fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(addresses),\n });\n if (!localResponse.ok) {\n throw new HttpError(\n localResponse.status,\n `Fetching '${url.toString()}' failed with status '${localResponse.status}'`,\n );\n }\n return localResponse;\n });\n const jsonResponse: unknown = await response.json();\n\n return validateResponse(\n jsonResponse,\n array(BatchWalletCheckResponseItemStruct),\n 'compliance batch check API',\n );\n }\n}\n\n/**\n * Validates an API response against a superstruct schema.\n *\n * @param data - The raw response data to validate.\n * @param struct - The superstruct schema to validate against.\n * @param struct.is - The type guard function from the schema.\n * @param apiName - A human-readable name for the API, used in error messages.\n * @returns The validated data.\n * @throws If the data does not match the schema.\n */\nfunction validateResponse<Response>(\n data: unknown,\n struct: { is: (value: unknown) => value is Response },\n apiName: string,\n): Response {\n if (struct.is(data)) {\n return data;\n }\n throw new Error(`Malformed response received from ${apiName}`);\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAUA,6DAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAc1B,mEAGgC;AAF9B,4HAAA,oBAAoB,OAAA;AACpB,2IAAA,mCAAmC,OAAA;AAErC,6CAAoD;AAA3C,kHAAA,qBAAqB,OAAA","sourcesContent":["export type {\n ComplianceServiceActions,\n ComplianceServiceEnvironment,\n ComplianceServiceEvents,\n ComplianceServiceMessenger,\n} from './ComplianceService';\nexport type {\n ComplianceServiceCheckWalletComplianceAction,\n ComplianceServiceCheckWalletsComplianceAction,\n} from './ComplianceService-method-action-types';\nexport { ComplianceService } from './ComplianceService';\nexport type {\n ComplianceControllerActions,\n ComplianceControllerEvents,\n ComplianceControllerGetStateAction,\n ComplianceControllerMessenger,\n ComplianceControllerState,\n ComplianceControllerStateChangeEvent,\n} from './ComplianceController';\nexport type {\n ComplianceControllerCheckWalletComplianceAction,\n ComplianceControllerCheckWalletsComplianceAction,\n ComplianceControllerClearComplianceStateAction,\n} from './ComplianceController-method-action-types';\nexport {\n ComplianceController,\n getDefaultComplianceControllerState,\n} from './ComplianceController';\nexport { selectIsWalletBlocked } from './selectors';\nexport type { WalletComplianceStatus } from './types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type { ComplianceServiceActions, ComplianceServiceEnvironment, ComplianceServiceEvents, ComplianceServiceMessenger, } from "./ComplianceService.cjs";
|
|
2
|
-
export type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction,
|
|
2
|
+
export type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction, } from "./ComplianceService-method-action-types.cjs";
|
|
3
3
|
export { ComplianceService } from "./ComplianceService.cjs";
|
|
4
4
|
export type { ComplianceControllerActions, ComplianceControllerEvents, ComplianceControllerGetStateAction, ComplianceControllerMessenger, ComplianceControllerState, ComplianceControllerStateChangeEvent, } from "./ComplianceController.cjs";
|
|
5
|
-
export type { ComplianceControllerCheckWalletComplianceAction, ComplianceControllerCheckWalletsComplianceAction, ComplianceControllerClearComplianceStateAction,
|
|
5
|
+
export type { ComplianceControllerCheckWalletComplianceAction, ComplianceControllerCheckWalletsComplianceAction, ComplianceControllerClearComplianceStateAction, } from "./ComplianceController-method-action-types.cjs";
|
|
6
6
|
export { ComplianceController, getDefaultComplianceControllerState, } from "./ComplianceController.cjs";
|
|
7
7
|
export { selectIsWalletBlocked } from "./selectors.cjs";
|
|
8
|
-
export type { WalletComplianceStatus
|
|
8
|
+
export type { WalletComplianceStatus } from "./types.cjs";
|
|
9
9
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,gCAA4B;AAC7B,YAAY,EACV,4CAA4C,EAC5C,6CAA6C,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,gCAA4B;AAC7B,YAAY,EACV,4CAA4C,EAC5C,6CAA6C,GAC9C,oDAAgD;AACjD,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AACxD,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,6BAA6B,EAC7B,yBAAyB,EACzB,oCAAoC,GACrC,mCAA+B;AAChC,YAAY,EACV,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,GAC/C,uDAAmD;AACpD,OAAO,EACL,oBAAoB,EACpB,mCAAmC,GACpC,mCAA+B;AAChC,OAAO,EAAE,qBAAqB,EAAE,wBAAoB;AACpD,YAAY,EAAE,sBAAsB,EAAE,oBAAgB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type { ComplianceServiceActions, ComplianceServiceEnvironment, ComplianceServiceEvents, ComplianceServiceMessenger, } from "./ComplianceService.mjs";
|
|
2
|
-
export type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction,
|
|
2
|
+
export type { ComplianceServiceCheckWalletComplianceAction, ComplianceServiceCheckWalletsComplianceAction, } from "./ComplianceService-method-action-types.mjs";
|
|
3
3
|
export { ComplianceService } from "./ComplianceService.mjs";
|
|
4
4
|
export type { ComplianceControllerActions, ComplianceControllerEvents, ComplianceControllerGetStateAction, ComplianceControllerMessenger, ComplianceControllerState, ComplianceControllerStateChangeEvent, } from "./ComplianceController.mjs";
|
|
5
|
-
export type { ComplianceControllerCheckWalletComplianceAction, ComplianceControllerCheckWalletsComplianceAction, ComplianceControllerClearComplianceStateAction,
|
|
5
|
+
export type { ComplianceControllerCheckWalletComplianceAction, ComplianceControllerCheckWalletsComplianceAction, ComplianceControllerClearComplianceStateAction, } from "./ComplianceController-method-action-types.mjs";
|
|
6
6
|
export { ComplianceController, getDefaultComplianceControllerState, } from "./ComplianceController.mjs";
|
|
7
7
|
export { selectIsWalletBlocked } from "./selectors.mjs";
|
|
8
|
-
export type { WalletComplianceStatus
|
|
8
|
+
export type { WalletComplianceStatus } from "./types.mjs";
|
|
9
9
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,gCAA4B;AAC7B,YAAY,EACV,4CAA4C,EAC5C,6CAA6C,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC3B,gCAA4B;AAC7B,YAAY,EACV,4CAA4C,EAC5C,6CAA6C,GAC9C,oDAAgD;AACjD,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AACxD,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,6BAA6B,EAC7B,yBAAyB,EACzB,oCAAoC,GACrC,mCAA+B;AAChC,YAAY,EACV,+CAA+C,EAC/C,gDAAgD,EAChD,8CAA8C,GAC/C,uDAAmD;AACpD,OAAO,EACL,oBAAoB,EACpB,mCAAmC,GACpC,mCAA+B;AAChC,OAAO,EAAE,qBAAqB,EAAE,wBAAoB;AACpD,YAAY,EAAE,sBAAsB,EAAE,oBAAgB"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AAcxD,OAAO,EACL,oBAAoB,EACpB,mCAAmC,EACpC,mCAA+B;AAChC,OAAO,EAAE,qBAAqB,EAAE,wBAAoB","sourcesContent":["export type {\n ComplianceServiceActions,\n ComplianceServiceEnvironment,\n ComplianceServiceEvents,\n ComplianceServiceMessenger,\n} from './ComplianceService';\nexport type {\n ComplianceServiceCheckWalletComplianceAction,\n ComplianceServiceCheckWalletsComplianceAction,\n} from './ComplianceService-method-action-types';\nexport { ComplianceService } from './ComplianceService';\nexport type {\n ComplianceControllerActions,\n ComplianceControllerEvents,\n ComplianceControllerGetStateAction,\n ComplianceControllerMessenger,\n ComplianceControllerState,\n ComplianceControllerStateChangeEvent,\n} from './ComplianceController';\nexport type {\n ComplianceControllerCheckWalletComplianceAction,\n ComplianceControllerCheckWalletsComplianceAction,\n ComplianceControllerClearComplianceStateAction,\n} from './ComplianceController-method-action-types';\nexport {\n ComplianceController,\n getDefaultComplianceControllerState,\n} from './ComplianceController';\nexport { selectIsWalletBlocked } from './selectors';\nexport type { WalletComplianceStatus } from './types';\n"]}
|
package/dist/selectors.cjs
CHANGED
|
@@ -2,22 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectIsWalletBlocked = void 0;
|
|
4
4
|
const reselect_1 = require("reselect");
|
|
5
|
-
const selectBlockedWallets = (state) => state.blockedWallets;
|
|
6
5
|
const selectWalletComplianceStatusMap = (state) => state.walletComplianceStatusMap;
|
|
7
6
|
/**
|
|
8
7
|
* Creates a selector that returns whether a wallet address is blocked, based
|
|
9
|
-
* on the
|
|
10
|
-
* first, then falls back to the per-address compliance status map.
|
|
8
|
+
* on the per-address compliance status cache.
|
|
11
9
|
*
|
|
12
10
|
* @param address - The wallet address to check.
|
|
13
11
|
* @returns A selector that takes `ComplianceControllerState` and returns
|
|
14
12
|
* `true` if the wallet is blocked, `false` otherwise.
|
|
15
13
|
*/
|
|
16
|
-
const selectIsWalletBlocked = (address) => (0, reselect_1.createSelector)([
|
|
17
|
-
if (blockedWallets?.addresses.includes(address)) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return statusMap[address]?.blocked ?? false;
|
|
21
|
-
});
|
|
14
|
+
const selectIsWalletBlocked = (address) => (0, reselect_1.createSelector)([selectWalletComplianceStatusMap], (statusMap) => statusMap[address]?.blocked ?? false);
|
|
22
15
|
exports.selectIsWalletBlocked = selectIsWalletBlocked;
|
|
23
16
|
//# sourceMappingURL=selectors.cjs.map
|
package/dist/selectors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAI1C,MAAM
|
|
1
|
+
{"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAI1C,MAAM,+BAA+B,GAAG,CACtC,KAAgC,EACwB,EAAE,CAC1D,KAAK,CAAC,yBAAyB,CAAC;AAElC;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CACnC,OAAe,EACkC,EAAE,CACnD,IAAA,yBAAc,EACZ,CAAC,+BAA+B,CAAC,EACjC,CAAC,SAAS,EAAW,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,IAAI,KAAK,CAC7D,CAAC;AANS,QAAA,qBAAqB,yBAM9B","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { ComplianceControllerState } from './ComplianceController';\n\nconst selectWalletComplianceStatusMap = (\n state: ComplianceControllerState,\n): ComplianceControllerState['walletComplianceStatusMap'] =>\n state.walletComplianceStatusMap;\n\n/**\n * Creates a selector that returns whether a wallet address is blocked, based\n * on the per-address compliance status cache.\n *\n * @param address - The wallet address to check.\n * @returns A selector that takes `ComplianceControllerState` and returns\n * `true` if the wallet is blocked, `false` otherwise.\n */\nexport const selectIsWalletBlocked = (\n address: string,\n): ((state: ComplianceControllerState) => boolean) =>\n createSelector(\n [selectWalletComplianceStatusMap],\n (statusMap): boolean => statusMap[address]?.blocked ?? false,\n );\n"]}
|
package/dist/selectors.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ComplianceControllerState } from "./ComplianceController.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a selector that returns whether a wallet address is blocked, based
|
|
4
|
-
* on the
|
|
5
|
-
* first, then falls back to the per-address compliance status map.
|
|
4
|
+
* on the per-address compliance status cache.
|
|
6
5
|
*
|
|
7
6
|
* @param address - The wallet address to check.
|
|
8
7
|
* @returns A selector that takes `ComplianceControllerState` and returns
|
package/dist/selectors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mCAA+B;
|
|
1
|
+
{"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mCAA+B;AAOxE;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YACvB,MAAM,aACL,yBAAyB,KAAK,OAIvC,CAAC"}
|
package/dist/selectors.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ComplianceControllerState } from "./ComplianceController.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a selector that returns whether a wallet address is blocked, based
|
|
4
|
-
* on the
|
|
5
|
-
* first, then falls back to the per-address compliance status map.
|
|
4
|
+
* on the per-address compliance status cache.
|
|
6
5
|
*
|
|
7
6
|
* @param address - The wallet address to check.
|
|
8
7
|
* @returns A selector that takes `ComplianceControllerState` and returns
|
package/dist/selectors.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mCAA+B;
|
|
1
|
+
{"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,mCAA+B;AAOxE;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YACvB,MAAM,aACL,yBAAyB,KAAK,OAIvC,CAAC"}
|
package/dist/selectors.mjs
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { createSelector } from "reselect";
|
|
2
|
-
const selectBlockedWallets = (state) => state.blockedWallets;
|
|
3
2
|
const selectWalletComplianceStatusMap = (state) => state.walletComplianceStatusMap;
|
|
4
3
|
/**
|
|
5
4
|
* Creates a selector that returns whether a wallet address is blocked, based
|
|
6
|
-
* on the
|
|
7
|
-
* first, then falls back to the per-address compliance status map.
|
|
5
|
+
* on the per-address compliance status cache.
|
|
8
6
|
*
|
|
9
7
|
* @param address - The wallet address to check.
|
|
10
8
|
* @returns A selector that takes `ComplianceControllerState` and returns
|
|
11
9
|
* `true` if the wallet is blocked, `false` otherwise.
|
|
12
10
|
*/
|
|
13
|
-
export const selectIsWalletBlocked = (address) => createSelector([
|
|
14
|
-
if (blockedWallets?.addresses.includes(address)) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return statusMap[address]?.blocked ?? false;
|
|
18
|
-
});
|
|
11
|
+
export const selectIsWalletBlocked = (address) => createSelector([selectWalletComplianceStatusMap], (statusMap) => statusMap[address]?.blocked ?? false);
|
|
19
12
|
//# sourceMappingURL=selectors.mjs.map
|
package/dist/selectors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB;AAI1C,MAAM
|
|
1
|
+
{"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB;AAI1C,MAAM,+BAA+B,GAAG,CACtC,KAAgC,EACwB,EAAE,CAC1D,KAAK,CAAC,yBAAyB,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAe,EACkC,EAAE,CACnD,cAAc,CACZ,CAAC,+BAA+B,CAAC,EACjC,CAAC,SAAS,EAAW,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,IAAI,KAAK,CAC7D,CAAC","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { ComplianceControllerState } from './ComplianceController';\n\nconst selectWalletComplianceStatusMap = (\n state: ComplianceControllerState,\n): ComplianceControllerState['walletComplianceStatusMap'] =>\n state.walletComplianceStatusMap;\n\n/**\n * Creates a selector that returns whether a wallet address is blocked, based\n * on the per-address compliance status cache.\n *\n * @param address - The wallet address to check.\n * @returns A selector that takes `ComplianceControllerState` and returns\n * `true` if the wallet is blocked, `false` otherwise.\n */\nexport const selectIsWalletBlocked = (\n address: string,\n): ((state: ComplianceControllerState) => boolean) =>\n createSelector(\n [selectWalletComplianceStatusMap],\n (statusMap): boolean => statusMap[address]?.blocked ?? false,\n );\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The result of checking a single wallet address for compliance.\n */\nexport type WalletComplianceStatus = {\n /**\n * The wallet address that was checked.\n */\n address: string;\n\n /**\n * Whether the wallet address is blocked.\n */\n blocked: boolean;\n\n /**\n * The date/time (in ISO-8601 format) when this check was performed.\n */\n checkedAt: string;\n};\n
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The result of checking a single wallet address for compliance.\n */\nexport type WalletComplianceStatus = {\n /**\n * The wallet address that was checked.\n */\n address: string;\n\n /**\n * Whether the wallet address is blocked.\n */\n blocked: boolean;\n\n /**\n * The date/time (in ISO-8601 format) when this check was performed.\n */\n checkedAt: string;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -15,29 +15,4 @@ export type WalletComplianceStatus = {
|
|
|
15
15
|
*/
|
|
16
16
|
checkedAt: string;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* Information about the full set of blocked wallets returned by the API.
|
|
20
|
-
*/
|
|
21
|
-
export type BlockedWalletsInfo = {
|
|
22
|
-
/**
|
|
23
|
-
* The list of all blocked wallet addresses.
|
|
24
|
-
*/
|
|
25
|
-
addresses: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The number of blocked addresses from each source.
|
|
28
|
-
*/
|
|
29
|
-
sources: {
|
|
30
|
-
ofac: number;
|
|
31
|
-
remote: number;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* The date/time (in ISO-8601 format) when the blocklist was last updated
|
|
35
|
-
* on the server.
|
|
36
|
-
*/
|
|
37
|
-
lastUpdated: string;
|
|
38
|
-
/**
|
|
39
|
-
* The date/time (in ISO-8601 format) when this data was fetched.
|
|
40
|
-
*/
|
|
41
|
-
fetchedAt: string;
|
|
42
|
-
};
|
|
43
18
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -15,29 +15,4 @@ export type WalletComplianceStatus = {
|
|
|
15
15
|
*/
|
|
16
16
|
checkedAt: string;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* Information about the full set of blocked wallets returned by the API.
|
|
20
|
-
*/
|
|
21
|
-
export type BlockedWalletsInfo = {
|
|
22
|
-
/**
|
|
23
|
-
* The list of all blocked wallet addresses.
|
|
24
|
-
*/
|
|
25
|
-
addresses: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The number of blocked addresses from each source.
|
|
28
|
-
*/
|
|
29
|
-
sources: {
|
|
30
|
-
ofac: number;
|
|
31
|
-
remote: number;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* The date/time (in ISO-8601 format) when the blocklist was last updated
|
|
35
|
-
* on the server.
|
|
36
|
-
*/
|
|
37
|
-
lastUpdated: string;
|
|
38
|
-
/**
|
|
39
|
-
* The date/time (in ISO-8601 format) when this data was fetched.
|
|
40
|
-
*/
|
|
41
|
-
fetchedAt: string;
|
|
42
|
-
};
|
|
43
18
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The result of checking a single wallet address for compliance.\n */\nexport type WalletComplianceStatus = {\n /**\n * The wallet address that was checked.\n */\n address: string;\n\n /**\n * Whether the wallet address is blocked.\n */\n blocked: boolean;\n\n /**\n * The date/time (in ISO-8601 format) when this check was performed.\n */\n checkedAt: string;\n};\n
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The result of checking a single wallet address for compliance.\n */\nexport type WalletComplianceStatus = {\n /**\n * The wallet address that was checked.\n */\n address: string;\n\n /**\n * Whether the wallet address is blocked.\n */\n blocked: boolean;\n\n /**\n * The date/time (in ISO-8601 format) when this check was performed.\n */\n checkedAt: string;\n};\n"]}
|