@metamask-previews/notification-services-controller 10.0.0-preview-5ff65365 → 10.0.0-preview-d327019
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 -18
- package/dist/NotificationServicesController/NotificationServicesController.cjs +188 -78
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +16 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +16 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +189 -79
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/constants.cjs +7 -0
- package/dist/NotificationServicesController/constants/constants.cjs.map +1 -0
- package/dist/NotificationServicesController/constants/constants.d.cts +3 -0
- package/dist/NotificationServicesController/constants/constants.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.d.mts +3 -0
- package/dist/NotificationServicesController/constants/constants.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.mjs +4 -0
- package/dist/NotificationServicesController/constants/constants.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.cjs +1 -0
- package/dist/NotificationServicesController/constants/index.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.cts +1 -0
- package/dist/NotificationServicesController/constants/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.mts +1 -0
- package/dist/NotificationServicesController/constants/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/index.mjs +1 -0
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.cjs +2 -0
- package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.cts +2 -0
- package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.mts +2 -0
- package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.mjs +2 -0
- package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +22 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +9 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +9 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +18 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +82 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +35 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +35 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +76 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts +4 -7
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts +4 -7
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +1 -4
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +0 -623
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +0 -623
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +0 -2
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.cjs +140 -67
- package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts +31 -25
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts +31 -25
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +137 -65
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesController/types/index.d.cts +1 -0
- package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/index.d.mts +1 -0
- package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/user-storage/index.cjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +26 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +26 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +2 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/ui/constants.cjs +0 -6
- package/dist/NotificationServicesController/ui/constants.cjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.cts +0 -6
- package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.mts +0 -6
- package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.mjs +0 -6
- package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.cjs +350 -1
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.cts +141 -0
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.mts +141 -0
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.mjs +337 -0
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +15 -22
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +5 -6
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +5 -6
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +16 -23
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +16 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +7 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +7 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +14 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +41 -18
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +33 -19
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +33 -19
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +39 -17
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +0 -61
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts +0 -15
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts +0 -15
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.mjs +0 -57
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./mock-feature-announcements.cjs";
|
|
2
|
+
export * from "./mock-notification-trigger.cjs";
|
|
3
|
+
export * from "./mock-notification-user-storage.cjs";
|
|
2
4
|
export * from "./mock-raw-notifications.cjs";
|
|
3
5
|
export * from "./mockResponses.cjs";
|
|
4
6
|
export * from "./mock-snap-notification.cjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./mock-feature-announcements.mjs";
|
|
2
|
+
export * from "./mock-notification-trigger.mjs";
|
|
3
|
+
export * from "./mock-notification-user-storage.mjs";
|
|
2
4
|
export * from "./mock-raw-notifications.mjs";
|
|
3
5
|
export * from "./mockResponses.mjs";
|
|
4
6
|
export * from "./mock-snap-notification.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./mock-feature-announcements.mjs";
|
|
2
|
+
export * from "./mock-notification-trigger.mjs";
|
|
3
|
+
export * from "./mock-notification-user-storage.mjs";
|
|
2
4
|
export * from "./mock-raw-notifications.mjs";
|
|
3
5
|
export * from "./mockResponses.mjs";
|
|
4
6
|
export * from "./mock-snap-notification.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC","sourcesContent":["export * from './mock-feature-announcements';\nexport * from './mock-raw-notifications';\nexport * from './mockResponses';\nexport * from './mock-snap-notification';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC;AAChC,6CAAyC","sourcesContent":["export * from './mock-feature-announcements';\nexport * from './mock-notification-trigger';\nexport * from './mock-notification-user-storage';\nexport * from './mock-raw-notifications';\nexport * from './mockResponses';\nexport * from './mock-snap-notification';\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMockNotificationTrigger = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
/**
|
|
6
|
+
* Mocking Utility - create a mock Notification Trigger
|
|
7
|
+
*
|
|
8
|
+
* @param override - provide any override configuration for the mock
|
|
9
|
+
* @returns a mock Notification Trigger
|
|
10
|
+
*/
|
|
11
|
+
function createMockNotificationTrigger(override) {
|
|
12
|
+
return {
|
|
13
|
+
id: (0, uuid_1.v4)(),
|
|
14
|
+
address: '0xFAKE_ADDRESS',
|
|
15
|
+
chainId: '1',
|
|
16
|
+
kind: 'eth_sent',
|
|
17
|
+
enabled: true,
|
|
18
|
+
...override,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.createMockNotificationTrigger = createMockNotificationTrigger;
|
|
22
|
+
//# sourceMappingURL=mock-notification-trigger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-trigger.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAIpC;;;;;GAKG;AACH,SAAgB,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,IAAA,SAAM,GAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAXD,sEAWC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NotificationTrigger } from "../utils/utils.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Mocking Utility - create a mock Notification Trigger
|
|
4
|
+
*
|
|
5
|
+
* @param override - provide any override configuration for the mock
|
|
6
|
+
* @returns a mock Notification Trigger
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMockNotificationTrigger(override?: Partial<NotificationTrigger>): NotificationTrigger;
|
|
9
|
+
//# sourceMappingURL=mock-notification-trigger.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-trigger.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NotificationTrigger } from "../utils/utils.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Mocking Utility - create a mock Notification Trigger
|
|
4
|
+
*
|
|
5
|
+
* @param override - provide any override configuration for the mock
|
|
6
|
+
* @returns a mock Notification Trigger
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMockNotificationTrigger(override?: Partial<NotificationTrigger>): NotificationTrigger;
|
|
9
|
+
//# sourceMappingURL=mock-notification-trigger.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-trigger.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
/**
|
|
3
|
+
* Mocking Utility - create a mock Notification Trigger
|
|
4
|
+
*
|
|
5
|
+
* @param override - provide any override configuration for the mock
|
|
6
|
+
* @returns a mock Notification Trigger
|
|
7
|
+
*/
|
|
8
|
+
export function createMockNotificationTrigger(override) {
|
|
9
|
+
return {
|
|
10
|
+
id: uuidv4(),
|
|
11
|
+
address: '0xFAKE_ADDRESS',
|
|
12
|
+
chainId: '1',
|
|
13
|
+
kind: 'eth_sent',
|
|
14
|
+
enabled: true,
|
|
15
|
+
...override,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=mock-notification-trigger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-trigger.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AAIpC;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMockFullUserStorage = exports.createMockUserStorageWithTriggers = exports.createMockUserStorage = exports.MOCK_USER_STORAGE_CHAIN = exports.MOCK_USER_STORAGE_ACCOUNT = void 0;
|
|
4
|
+
const constants_1 = require("../constants/constants.cjs");
|
|
5
|
+
const notification_schema_1 = require("../constants/notification-schema.cjs");
|
|
6
|
+
const utils_1 = require("../utils/utils.cjs");
|
|
7
|
+
exports.MOCK_USER_STORAGE_ACCOUNT = '0x0000000000000000000000000000000000000000';
|
|
8
|
+
exports.MOCK_USER_STORAGE_CHAIN = '1';
|
|
9
|
+
/**
|
|
10
|
+
* Mocking Utility - create a mock notification user storage object
|
|
11
|
+
*
|
|
12
|
+
* @param override - provide any override configuration for the mock
|
|
13
|
+
* @returns a mock notification user storage object
|
|
14
|
+
*/
|
|
15
|
+
function createMockUserStorage(override) {
|
|
16
|
+
return {
|
|
17
|
+
[constants_1.USER_STORAGE_VERSION_KEY]: '1',
|
|
18
|
+
[exports.MOCK_USER_STORAGE_ACCOUNT]: {
|
|
19
|
+
[exports.MOCK_USER_STORAGE_CHAIN]: {
|
|
20
|
+
'111-111-111-111': {
|
|
21
|
+
k: notification_schema_1.TRIGGER_TYPES.ERC20_RECEIVED,
|
|
22
|
+
e: true,
|
|
23
|
+
},
|
|
24
|
+
'222-222-222-222': {
|
|
25
|
+
k: notification_schema_1.TRIGGER_TYPES.ERC20_SENT,
|
|
26
|
+
e: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
...override,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.createMockUserStorage = createMockUserStorage;
|
|
34
|
+
/**
|
|
35
|
+
* Mocking Utility - create a mock notification user storage object with triggers
|
|
36
|
+
*
|
|
37
|
+
* @param triggers - provide any override configuration for the mock
|
|
38
|
+
* @returns a mock notification user storage object with triggers
|
|
39
|
+
*/
|
|
40
|
+
function createMockUserStorageWithTriggers(triggers) {
|
|
41
|
+
const userStorage = {
|
|
42
|
+
[constants_1.USER_STORAGE_VERSION_KEY]: '1',
|
|
43
|
+
[exports.MOCK_USER_STORAGE_ACCOUNT]: {
|
|
44
|
+
[exports.MOCK_USER_STORAGE_CHAIN]: {},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
// insert triggerIds
|
|
48
|
+
triggers.forEach((t) => {
|
|
49
|
+
let tId;
|
|
50
|
+
let e;
|
|
51
|
+
let k;
|
|
52
|
+
if (typeof t === 'string') {
|
|
53
|
+
tId = t;
|
|
54
|
+
e = true;
|
|
55
|
+
k = notification_schema_1.TRIGGER_TYPES.ERC20_RECEIVED;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
tId = t.id;
|
|
59
|
+
e = t.e;
|
|
60
|
+
k = t.k ?? notification_schema_1.TRIGGER_TYPES.ERC20_RECEIVED;
|
|
61
|
+
}
|
|
62
|
+
userStorage[exports.MOCK_USER_STORAGE_ACCOUNT][exports.MOCK_USER_STORAGE_CHAIN][tId] = {
|
|
63
|
+
k,
|
|
64
|
+
e,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return userStorage;
|
|
68
|
+
}
|
|
69
|
+
exports.createMockUserStorageWithTriggers = createMockUserStorageWithTriggers;
|
|
70
|
+
/**
|
|
71
|
+
* Mocking Utility - create a mock notification user storage object (full/realistic object)
|
|
72
|
+
*
|
|
73
|
+
* @param props - provide any override configuration for the mock
|
|
74
|
+
* @param props.triggersEnabled - choose if all triggers created are enabled/disabled
|
|
75
|
+
* @param props.address - choose a specific address for triggers to be assigned to
|
|
76
|
+
* @returns a mock full notification user storage object
|
|
77
|
+
*/
|
|
78
|
+
function createMockFullUserStorage(props = {}) {
|
|
79
|
+
return (0, utils_1.initializeUserStorage)([{ address: props.address ?? exports.MOCK_USER_STORAGE_ACCOUNT }], props.triggersEnabled ?? true, false);
|
|
80
|
+
}
|
|
81
|
+
exports.createMockFullUserStorage = createMockFullUserStorage;
|
|
82
|
+
//# sourceMappingURL=mock-notification-user-storage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-user-storage.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-user-storage.ts"],"names":[],"mappings":";;;AAAA,0DAAkE;AAClE,8EAAiE;AAEjE,8CAAuD;AAE1C,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,QAA+B;IAE/B,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,iCAAyB,CAAC,EAAE;YAC3B,CAAC,+BAAuB,CAAC,EAAE;gBACzB,iBAAiB,EAAE;oBACjB,CAAC,EAAE,mCAAa,CAAC,cAAc;oBAC/B,CAAC,EAAE,IAAI;iBACR;gBACD,iBAAiB,EAAE;oBACjB,CAAC,EAAE,mCAAa,CAAC,UAAU;oBAC3B,CAAC,EAAE,IAAI;iBACR;aACF;SACF;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAnBD,sDAmBC;AAED;;;;;GAKG;AACH,SAAgB,iCAAiC,CAC/C,QAAoE;IAEpE,MAAM,WAAW,GAAgB;QAC/B,CAAC,oCAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,iCAAyB,CAAC,EAAE;YAC3B,CAAC,+BAAuB,CAAC,EAAE,EAAE;SAC9B;KACF,CAAC;IAEF,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,IAAI,GAAW,CAAC;QAChB,IAAI,CAAU,CAAC;QACf,IAAI,CAAgB,CAAC;QACrB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YACzB,GAAG,GAAG,CAAC,CAAC;YACR,CAAC,GAAG,IAAI,CAAC;YACT,CAAC,GAAG,mCAAa,CAAC,cAAc,CAAC;SAClC;aAAM;YACL,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;YACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACR,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,mCAAa,CAAC,cAAc,CAAC;SACzC;QAED,WAAW,CAAC,iCAAyB,CAAC,CAAC,+BAAuB,CAAC,CAAC,GAAG,CAAC,GAAG;YACrE,CAAC;YACD,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAhCD,8EAgCC;AAED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,QAAyD,EAAE;IAE3D,OAAO,IAAA,6BAAqB,EAC1B,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,iCAAyB,EAAE,CAAC,EACzD,KAAK,CAAC,eAAe,IAAI,IAAI,EAC7B,KAAK,CACN,CAAC;AACJ,CAAC;AARD,8DAQC","sourcesContent":["import { USER_STORAGE_VERSION_KEY } from '../constants/constants';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\nimport { initializeUserStorage } from '../utils/utils';\n\nexport const MOCK_USER_STORAGE_ACCOUNT =\n '0x0000000000000000000000000000000000000000';\nexport const MOCK_USER_STORAGE_CHAIN = '1';\n\n/**\n * Mocking Utility - create a mock notification user storage object\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock notification user storage object\n */\nexport function createMockUserStorage(\n override?: Partial<UserStorage>,\n): UserStorage {\n return {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {\n '111-111-111-111': {\n k: TRIGGER_TYPES.ERC20_RECEIVED,\n e: true,\n },\n '222-222-222-222': {\n k: TRIGGER_TYPES.ERC20_SENT,\n e: true,\n },\n },\n },\n ...override,\n };\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object with triggers\n *\n * @param triggers - provide any override configuration for the mock\n * @returns a mock notification user storage object with triggers\n */\nexport function createMockUserStorageWithTriggers(\n triggers: string[] | { id: string; e: boolean; k?: TRIGGER_TYPES }[],\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {},\n },\n };\n\n // insert triggerIds\n triggers.forEach((t) => {\n let tId: string;\n let e: boolean;\n let k: TRIGGER_TYPES;\n if (typeof t === 'string') {\n tId = t;\n e = true;\n k = TRIGGER_TYPES.ERC20_RECEIVED;\n } else {\n tId = t.id;\n e = t.e;\n k = t.k ?? TRIGGER_TYPES.ERC20_RECEIVED;\n }\n\n userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {\n k,\n e,\n };\n });\n\n return userStorage;\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object (full/realistic object)\n *\n * @param props - provide any override configuration for the mock\n * @param props.triggersEnabled - choose if all triggers created are enabled/disabled\n * @param props.address - choose a specific address for triggers to be assigned to\n * @returns a mock full notification user storage object\n */\nexport function createMockFullUserStorage(\n props: { triggersEnabled?: boolean; address?: string } = {},\n): UserStorage {\n return initializeUserStorage(\n [{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }],\n props.triggersEnabled ?? true,\n false,\n );\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TRIGGER_TYPES } from "../constants/notification-schema.cjs";
|
|
2
|
+
import type { UserStorage } from "../types/user-storage/user-storage.cjs";
|
|
3
|
+
export declare const MOCK_USER_STORAGE_ACCOUNT = "0x0000000000000000000000000000000000000000";
|
|
4
|
+
export declare const MOCK_USER_STORAGE_CHAIN = "1";
|
|
5
|
+
/**
|
|
6
|
+
* Mocking Utility - create a mock notification user storage object
|
|
7
|
+
*
|
|
8
|
+
* @param override - provide any override configuration for the mock
|
|
9
|
+
* @returns a mock notification user storage object
|
|
10
|
+
*/
|
|
11
|
+
export declare function createMockUserStorage(override?: Partial<UserStorage>): UserStorage;
|
|
12
|
+
/**
|
|
13
|
+
* Mocking Utility - create a mock notification user storage object with triggers
|
|
14
|
+
*
|
|
15
|
+
* @param triggers - provide any override configuration for the mock
|
|
16
|
+
* @returns a mock notification user storage object with triggers
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMockUserStorageWithTriggers(triggers: string[] | {
|
|
19
|
+
id: string;
|
|
20
|
+
e: boolean;
|
|
21
|
+
k?: TRIGGER_TYPES;
|
|
22
|
+
}[]): UserStorage;
|
|
23
|
+
/**
|
|
24
|
+
* Mocking Utility - create a mock notification user storage object (full/realistic object)
|
|
25
|
+
*
|
|
26
|
+
* @param props - provide any override configuration for the mock
|
|
27
|
+
* @param props.triggersEnabled - choose if all triggers created are enabled/disabled
|
|
28
|
+
* @param props.address - choose a specific address for triggers to be assigned to
|
|
29
|
+
* @returns a mock full notification user storage object
|
|
30
|
+
*/
|
|
31
|
+
export declare function createMockFullUserStorage(props?: {
|
|
32
|
+
triggersEnabled?: boolean;
|
|
33
|
+
address?: string;
|
|
34
|
+
}): UserStorage;
|
|
35
|
+
//# sourceMappingURL=mock-notification-user-storage.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-user-storage.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-user-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,+CAA2C;AAGtE,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC9B,WAAW,CAiBb;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,EAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,aAAa,CAAA;CAAE,EAAE,GACnE,WAAW,CA8Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1D,WAAW,CAMb"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
|
|
2
|
+
import type { UserStorage } from "../types/user-storage/user-storage.mjs";
|
|
3
|
+
export declare const MOCK_USER_STORAGE_ACCOUNT = "0x0000000000000000000000000000000000000000";
|
|
4
|
+
export declare const MOCK_USER_STORAGE_CHAIN = "1";
|
|
5
|
+
/**
|
|
6
|
+
* Mocking Utility - create a mock notification user storage object
|
|
7
|
+
*
|
|
8
|
+
* @param override - provide any override configuration for the mock
|
|
9
|
+
* @returns a mock notification user storage object
|
|
10
|
+
*/
|
|
11
|
+
export declare function createMockUserStorage(override?: Partial<UserStorage>): UserStorage;
|
|
12
|
+
/**
|
|
13
|
+
* Mocking Utility - create a mock notification user storage object with triggers
|
|
14
|
+
*
|
|
15
|
+
* @param triggers - provide any override configuration for the mock
|
|
16
|
+
* @returns a mock notification user storage object with triggers
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMockUserStorageWithTriggers(triggers: string[] | {
|
|
19
|
+
id: string;
|
|
20
|
+
e: boolean;
|
|
21
|
+
k?: TRIGGER_TYPES;
|
|
22
|
+
}[]): UserStorage;
|
|
23
|
+
/**
|
|
24
|
+
* Mocking Utility - create a mock notification user storage object (full/realistic object)
|
|
25
|
+
*
|
|
26
|
+
* @param props - provide any override configuration for the mock
|
|
27
|
+
* @param props.triggersEnabled - choose if all triggers created are enabled/disabled
|
|
28
|
+
* @param props.address - choose a specific address for triggers to be assigned to
|
|
29
|
+
* @returns a mock full notification user storage object
|
|
30
|
+
*/
|
|
31
|
+
export declare function createMockFullUserStorage(props?: {
|
|
32
|
+
triggersEnabled?: boolean;
|
|
33
|
+
address?: string;
|
|
34
|
+
}): UserStorage;
|
|
35
|
+
//# sourceMappingURL=mock-notification-user-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-user-storage.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-user-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,+CAA2C;AAGtE,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAC9B,WAAW,CAiBb;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,EAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,aAAa,CAAA;CAAE,EAAE,GACnE,WAAW,CA8Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1D,WAAW,CAMb"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { USER_STORAGE_VERSION_KEY } from "../constants/constants.mjs";
|
|
2
|
+
import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
|
|
3
|
+
import { initializeUserStorage } from "../utils/utils.mjs";
|
|
4
|
+
export const MOCK_USER_STORAGE_ACCOUNT = '0x0000000000000000000000000000000000000000';
|
|
5
|
+
export const MOCK_USER_STORAGE_CHAIN = '1';
|
|
6
|
+
/**
|
|
7
|
+
* Mocking Utility - create a mock notification user storage object
|
|
8
|
+
*
|
|
9
|
+
* @param override - provide any override configuration for the mock
|
|
10
|
+
* @returns a mock notification user storage object
|
|
11
|
+
*/
|
|
12
|
+
export function createMockUserStorage(override) {
|
|
13
|
+
return {
|
|
14
|
+
[USER_STORAGE_VERSION_KEY]: '1',
|
|
15
|
+
[MOCK_USER_STORAGE_ACCOUNT]: {
|
|
16
|
+
[MOCK_USER_STORAGE_CHAIN]: {
|
|
17
|
+
'111-111-111-111': {
|
|
18
|
+
k: TRIGGER_TYPES.ERC20_RECEIVED,
|
|
19
|
+
e: true,
|
|
20
|
+
},
|
|
21
|
+
'222-222-222-222': {
|
|
22
|
+
k: TRIGGER_TYPES.ERC20_SENT,
|
|
23
|
+
e: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
...override,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Mocking Utility - create a mock notification user storage object with triggers
|
|
32
|
+
*
|
|
33
|
+
* @param triggers - provide any override configuration for the mock
|
|
34
|
+
* @returns a mock notification user storage object with triggers
|
|
35
|
+
*/
|
|
36
|
+
export function createMockUserStorageWithTriggers(triggers) {
|
|
37
|
+
const userStorage = {
|
|
38
|
+
[USER_STORAGE_VERSION_KEY]: '1',
|
|
39
|
+
[MOCK_USER_STORAGE_ACCOUNT]: {
|
|
40
|
+
[MOCK_USER_STORAGE_CHAIN]: {},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
// insert triggerIds
|
|
44
|
+
triggers.forEach((t) => {
|
|
45
|
+
let tId;
|
|
46
|
+
let e;
|
|
47
|
+
let k;
|
|
48
|
+
if (typeof t === 'string') {
|
|
49
|
+
tId = t;
|
|
50
|
+
e = true;
|
|
51
|
+
k = TRIGGER_TYPES.ERC20_RECEIVED;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
tId = t.id;
|
|
55
|
+
e = t.e;
|
|
56
|
+
k = t.k ?? TRIGGER_TYPES.ERC20_RECEIVED;
|
|
57
|
+
}
|
|
58
|
+
userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {
|
|
59
|
+
k,
|
|
60
|
+
e,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return userStorage;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Mocking Utility - create a mock notification user storage object (full/realistic object)
|
|
67
|
+
*
|
|
68
|
+
* @param props - provide any override configuration for the mock
|
|
69
|
+
* @param props.triggersEnabled - choose if all triggers created are enabled/disabled
|
|
70
|
+
* @param props.address - choose a specific address for triggers to be assigned to
|
|
71
|
+
* @returns a mock full notification user storage object
|
|
72
|
+
*/
|
|
73
|
+
export function createMockFullUserStorage(props = {}) {
|
|
74
|
+
return initializeUserStorage([{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }], props.triggersEnabled ?? true, false);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=mock-notification-user-storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-notification-user-storage.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-user-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,mCAA+B;AAClE,OAAO,EAAE,aAAa,EAAE,6CAAyC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,2BAAuB;AAEvD,MAAM,CAAC,MAAM,yBAAyB,GACpC,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA+B;IAE/B,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,yBAAyB,CAAC,EAAE;YAC3B,CAAC,uBAAuB,CAAC,EAAE;gBACzB,iBAAiB,EAAE;oBACjB,CAAC,EAAE,aAAa,CAAC,cAAc;oBAC/B,CAAC,EAAE,IAAI;iBACR;gBACD,iBAAiB,EAAE;oBACjB,CAAC,EAAE,aAAa,CAAC,UAAU;oBAC3B,CAAC,EAAE,IAAI;iBACR;aACF;SACF;QACD,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAAoE;IAEpE,MAAM,WAAW,GAAgB;QAC/B,CAAC,wBAAwB,CAAC,EAAE,GAAG;QAC/B,CAAC,yBAAyB,CAAC,EAAE;YAC3B,CAAC,uBAAuB,CAAC,EAAE,EAAE;SAC9B;KACF,CAAC;IAEF,oBAAoB;IACpB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACrB,IAAI,GAAW,CAAC;QAChB,IAAI,CAAU,CAAC;QACf,IAAI,CAAgB,CAAC;QACrB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;YACzB,GAAG,GAAG,CAAC,CAAC;YACR,CAAC,GAAG,IAAI,CAAC;YACT,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC;SAClC;aAAM;YACL,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;YACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACR,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC;SACzC;QAED,WAAW,CAAC,yBAAyB,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,GAAG;YACrE,CAAC;YACD,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAyD,EAAE;IAE3D,OAAO,qBAAqB,CAC1B,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,yBAAyB,EAAE,CAAC,EACzD,KAAK,CAAC,eAAe,IAAI,IAAI,EAC7B,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { USER_STORAGE_VERSION_KEY } from '../constants/constants';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\nimport { initializeUserStorage } from '../utils/utils';\n\nexport const MOCK_USER_STORAGE_ACCOUNT =\n '0x0000000000000000000000000000000000000000';\nexport const MOCK_USER_STORAGE_CHAIN = '1';\n\n/**\n * Mocking Utility - create a mock notification user storage object\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock notification user storage object\n */\nexport function createMockUserStorage(\n override?: Partial<UserStorage>,\n): UserStorage {\n return {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {\n '111-111-111-111': {\n k: TRIGGER_TYPES.ERC20_RECEIVED,\n e: true,\n },\n '222-222-222-222': {\n k: TRIGGER_TYPES.ERC20_SENT,\n e: true,\n },\n },\n },\n ...override,\n };\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object with triggers\n *\n * @param triggers - provide any override configuration for the mock\n * @returns a mock notification user storage object with triggers\n */\nexport function createMockUserStorageWithTriggers(\n triggers: string[] | { id: string; e: boolean; k?: TRIGGER_TYPES }[],\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: '1',\n [MOCK_USER_STORAGE_ACCOUNT]: {\n [MOCK_USER_STORAGE_CHAIN]: {},\n },\n };\n\n // insert triggerIds\n triggers.forEach((t) => {\n let tId: string;\n let e: boolean;\n let k: TRIGGER_TYPES;\n if (typeof t === 'string') {\n tId = t;\n e = true;\n k = TRIGGER_TYPES.ERC20_RECEIVED;\n } else {\n tId = t.id;\n e = t.e;\n k = t.k ?? TRIGGER_TYPES.ERC20_RECEIVED;\n }\n\n userStorage[MOCK_USER_STORAGE_ACCOUNT][MOCK_USER_STORAGE_CHAIN][tId] = {\n k,\n e,\n };\n });\n\n return userStorage;\n}\n\n/**\n * Mocking Utility - create a mock notification user storage object (full/realistic object)\n *\n * @param props - provide any override configuration for the mock\n * @param props.triggersEnabled - choose if all triggers created are enabled/disabled\n * @param props.address - choose a specific address for triggers to be assigned to\n * @returns a mock full notification user storage object\n */\nexport function createMockFullUserStorage(\n props: { triggersEnabled?: boolean; address?: string } = {},\n): UserStorage {\n return initializeUserStorage(\n [{ address: props.address ?? MOCK_USER_STORAGE_ACCOUNT }],\n props.triggersEnabled ?? true,\n false,\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMockMarkNotificationsAsReadResponse = exports.getMockListNotificationsResponse = exports.MOCK_RAW_ON_CHAIN_NOTIFICATIONS = exports.
|
|
3
|
+
exports.getMockMarkNotificationsAsReadResponse = exports.getMockListNotificationsResponse = exports.MOCK_RAW_ON_CHAIN_NOTIFICATIONS = exports.getMockBatchDeleteTriggersResponse = exports.getMockBatchCreateTriggersResponse = exports.getMockFeatureAnnouncementResponse = exports.CONTENTFUL_RESPONSE = void 0;
|
|
4
4
|
const mock_feature_announcements_1 = require("./mock-feature-announcements.cjs");
|
|
5
5
|
const mock_raw_notifications_1 = require("./mock-raw-notifications.cjs");
|
|
6
6
|
const feature_announcements_1 = require("../services/feature-announcements.cjs");
|
|
@@ -14,22 +14,22 @@ const getMockFeatureAnnouncementResponse = () => {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
exports.getMockFeatureAnnouncementResponse = getMockFeatureAnnouncementResponse;
|
|
17
|
-
const
|
|
17
|
+
const getMockBatchCreateTriggersResponse = () => {
|
|
18
18
|
return {
|
|
19
|
-
url: onchain_notifications_1.
|
|
19
|
+
url: onchain_notifications_1.TRIGGER_API_BATCH_ENDPOINT,
|
|
20
20
|
requestMethod: 'POST',
|
|
21
21
|
response: null,
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
exports.
|
|
25
|
-
const
|
|
24
|
+
exports.getMockBatchCreateTriggersResponse = getMockBatchCreateTriggersResponse;
|
|
25
|
+
const getMockBatchDeleteTriggersResponse = () => {
|
|
26
26
|
return {
|
|
27
|
-
url: onchain_notifications_1.
|
|
28
|
-
requestMethod: '
|
|
29
|
-
response:
|
|
27
|
+
url: onchain_notifications_1.TRIGGER_API_BATCH_ENDPOINT,
|
|
28
|
+
requestMethod: 'DELETE',
|
|
29
|
+
response: null,
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
exports.
|
|
32
|
+
exports.getMockBatchDeleteTriggersResponse = getMockBatchDeleteTriggersResponse;
|
|
33
33
|
exports.MOCK_RAW_ON_CHAIN_NOTIFICATIONS = (0, mock_raw_notifications_1.createMockRawOnChainNotifications)();
|
|
34
34
|
const getMockListNotificationsResponse = () => {
|
|
35
35
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,yEAA6E;AAC7E,iFAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,yEAA6E;AAC7E,iFAA6E;AAC7E,iFAI2C;AAQ9B,QAAA,mBAAmB,GAAG,IAAA,mEAAsC,GAAE,CAAC;AAErE,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,gDAAwB;QAC7B,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,kCAAkC,sCAM7C;AAEK,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,kDAA0B;QAC/B,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,kCAAkC,sCAM7C;AAEK,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,kDAA0B;QAC/B,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,kCAAkC,sCAM7C;AAEW,QAAA,+BAA+B,GAC1C,IAAA,0DAAiC,GAAE,CAAC;AAE/B,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO;QACL,GAAG,EAAE,sDAA8B;QACnC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,uCAA+B;KACnB,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,gCAAgC,oCAM3C;AAEK,MAAM,sCAAsC,GAAG,GAAG,EAAE;IACzD,OAAO;QACL,GAAG,EAAE,kEAA0C;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,sCAAsC,0CAMjD","sourcesContent":["import { createMockFeatureAnnouncementAPIResult } from './mock-feature-announcements';\nimport { createMockRawOnChainNotifications } from './mock-raw-notifications';\nimport { FEATURE_ANNOUNCEMENT_API } from '../services/feature-announcements';\nimport {\n NOTIFICATION_API_LIST_ENDPOINT,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n TRIGGER_API_BATCH_ENDPOINT,\n} from '../services/onchain-notifications';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();\n\nexport const getMockFeatureAnnouncementResponse = () => {\n return {\n url: FEATURE_ANNOUNCEMENT_API,\n requestMethod: 'GET',\n response: CONTENTFUL_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockBatchCreateTriggersResponse = () => {\n return {\n url: TRIGGER_API_BATCH_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockBatchDeleteTriggersResponse = () => {\n return {\n url: TRIGGER_API_BATCH_ENDPOINT,\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const MOCK_RAW_ON_CHAIN_NOTIFICATIONS =\n createMockRawOnChainNotifications();\n\nexport const getMockListNotificationsResponse = () => {\n return {\n url: NOTIFICATION_API_LIST_ENDPOINT,\n requestMethod: 'POST',\n response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS,\n } satisfies MockResponse;\n};\n\nexport const getMockMarkNotificationsAsReadResponse = () => {\n return {\n url: NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -4,18 +4,15 @@ export declare const getMockFeatureAnnouncementResponse: () => {
|
|
|
4
4
|
requestMethod: "GET";
|
|
5
5
|
response: import("../services/feature-announcements.cjs").ContentfulResult;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const getMockBatchCreateTriggersResponse: () => {
|
|
8
8
|
url: string;
|
|
9
9
|
requestMethod: "POST";
|
|
10
10
|
response: null;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const getMockBatchDeleteTriggersResponse: () => {
|
|
13
13
|
url: string;
|
|
14
|
-
requestMethod: "
|
|
15
|
-
response:
|
|
16
|
-
address: string;
|
|
17
|
-
enabled: boolean;
|
|
18
|
-
}[];
|
|
14
|
+
requestMethod: "DELETE";
|
|
15
|
+
response: null;
|
|
19
16
|
};
|
|
20
17
|
export declare const MOCK_RAW_ON_CHAIN_NOTIFICATIONS: import("../index.cjs").OnChainRawNotification[];
|
|
21
18
|
export declare const getMockListNotificationsResponse: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;AAE5E,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,+BAA+B,uCACP,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;CAM5C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;CAMlD,CAAC"}
|
|
@@ -4,18 +4,15 @@ export declare const getMockFeatureAnnouncementResponse: () => {
|
|
|
4
4
|
requestMethod: "GET";
|
|
5
5
|
response: import("../services/feature-announcements.mjs").ContentfulResult;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const getMockBatchCreateTriggersResponse: () => {
|
|
8
8
|
url: string;
|
|
9
9
|
requestMethod: "POST";
|
|
10
10
|
response: null;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const getMockBatchDeleteTriggersResponse: () => {
|
|
13
13
|
url: string;
|
|
14
|
-
requestMethod: "
|
|
15
|
-
response:
|
|
16
|
-
address: string;
|
|
17
|
-
enabled: boolean;
|
|
18
|
-
}[];
|
|
14
|
+
requestMethod: "DELETE";
|
|
15
|
+
response: null;
|
|
19
16
|
};
|
|
20
17
|
export declare const MOCK_RAW_ON_CHAIN_NOTIFICATIONS: import("../index.mjs").OnChainRawNotification[];
|
|
21
18
|
export declare const getMockListNotificationsResponse: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;AAE5E,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,+BAA+B,uCACP,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;CAM5C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;CAMlD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createMockFeatureAnnouncementAPIResult } from "./mock-feature-announcements.mjs";
|
|
2
2
|
import { createMockRawOnChainNotifications } from "./mock-raw-notifications.mjs";
|
|
3
3
|
import { FEATURE_ANNOUNCEMENT_API } from "../services/feature-announcements.mjs";
|
|
4
|
-
import { NOTIFICATION_API_LIST_ENDPOINT, NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
|
|
4
|
+
import { NOTIFICATION_API_LIST_ENDPOINT, NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT, TRIGGER_API_BATCH_ENDPOINT } from "../services/onchain-notifications.mjs";
|
|
5
5
|
export const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();
|
|
6
6
|
export const getMockFeatureAnnouncementResponse = () => {
|
|
7
7
|
return {
|
|
@@ -10,18 +10,18 @@ export const getMockFeatureAnnouncementResponse = () => {
|
|
|
10
10
|
response: CONTENTFUL_RESPONSE,
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export const
|
|
13
|
+
export const getMockBatchCreateTriggersResponse = () => {
|
|
14
14
|
return {
|
|
15
|
-
url:
|
|
15
|
+
url: TRIGGER_API_BATCH_ENDPOINT,
|
|
16
16
|
requestMethod: 'POST',
|
|
17
17
|
response: null,
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export const
|
|
20
|
+
export const getMockBatchDeleteTriggersResponse = () => {
|
|
21
21
|
return {
|
|
22
|
-
url:
|
|
23
|
-
requestMethod: '
|
|
24
|
-
response:
|
|
22
|
+
url: TRIGGER_API_BATCH_ENDPOINT,
|
|
23
|
+
requestMethod: 'DELETE',
|
|
24
|
+
response: null,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
export const MOCK_RAW_ON_CHAIN_NOTIFICATIONS = createMockRawOnChainNotifications();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,yCAAqC;AACtF,OAAO,EAAE,iCAAiC,EAAE,qCAAiC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,8CAA0C;AAC7E,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,
|
|
1
|
+
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,yCAAqC;AACtF,OAAO,EAAE,iCAAiC,EAAE,qCAAiC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,8CAA0C;AAC7E,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,0BAA0B,EAC3B,8CAA0C;AAQ3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,EAAE,CAAC;AAE5E,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,wBAAwB;QAC7B,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,0BAA0B;QAC/B,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,0BAA0B;QAC/B,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAC1C,iCAAiC,EAAE,CAAC;AAEtC,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO;QACL,GAAG,EAAE,8BAA8B;QACnC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,+BAA+B;KACnB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,EAAE;IACzD,OAAO;QACL,GAAG,EAAE,0CAA0C;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { createMockFeatureAnnouncementAPIResult } from './mock-feature-announcements';\nimport { createMockRawOnChainNotifications } from './mock-raw-notifications';\nimport { FEATURE_ANNOUNCEMENT_API } from '../services/feature-announcements';\nimport {\n NOTIFICATION_API_LIST_ENDPOINT,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n TRIGGER_API_BATCH_ENDPOINT,\n} from '../services/onchain-notifications';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();\n\nexport const getMockFeatureAnnouncementResponse = () => {\n return {\n url: FEATURE_ANNOUNCEMENT_API,\n requestMethod: 'GET',\n response: CONTENTFUL_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockBatchCreateTriggersResponse = () => {\n return {\n url: TRIGGER_API_BATCH_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockBatchDeleteTriggersResponse = () => {\n return {\n url: TRIGGER_API_BATCH_ENDPOINT,\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const MOCK_RAW_ON_CHAIN_NOTIFICATIONS =\n createMockRawOnChainNotifications();\n\nexport const getMockListNotificationsResponse = () => {\n return {\n url: NOTIFICATION_API_LIST_ENDPOINT,\n requestMethod: 'POST',\n response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS,\n } satisfies MockResponse;\n};\n\nexport const getMockMarkNotificationsAsReadResponse = () => {\n return {\n url: NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.safeProcessNotification = exports.processNotification = void 0;
|
|
4
4
|
const process_feature_announcement_1 = require("./process-feature-announcement.cjs");
|
|
5
5
|
const process_onchain_notifications_1 = require("./process-onchain-notifications.cjs");
|
|
6
6
|
const process_snap_notifications_1 = require("./process-snap-notifications.cjs");
|
|
@@ -52,7 +52,4 @@ function safeProcessNotification(notification, readNotifications = []) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.safeProcessNotification = safeProcessNotification;
|
|
55
|
-
const isNotUndefined = (t) => Boolean(t);
|
|
56
|
-
const processAndFilterNotifications = (ns, readIds) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);
|
|
57
|
-
exports.processAndFilterNotifications = processAndFilterNotifications;
|
|
58
55
|
//# sourceMappingURL=process-notifications.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,qFAGwC;AACxC,uFAA6E;AAC7E,iFAAuE;AACvE,8EAAiE;AASjE,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACkB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,qBAAqB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,CACzB,CAAuB,EACG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,IAAI,CAAC;AAE7D;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,MAAM,CAAC,GAAG,IAAA,yDAA0B,EAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,IAAA,wDAAyB,EAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE;QACpC,OAAO,IAAA,oDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,IAAA,0DAA0B,EAAC,YAAY,CAAC,CAAC;KACjD;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AA1BD,kDA0BC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAbD,0DAaC
|
|
1
|
+
{"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,qFAGwC;AACxC,uFAA6E;AAC7E,iFAAuE;AACvE,8EAAiE;AASjE,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACkB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,qBAAqB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,CACzB,CAAuB,EACG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,IAAI,CAAC;AAE7D;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,MAAM,CAAC,GAAG,IAAA,yDAA0B,EAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,IAAA,wDAAyB,EAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE;QACpC,OAAO,IAAA,oDAAuB,EAAC,YAAY,CAAC,CAAC;KAC9C;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,IAAA,0DAA0B,EAAC,YAAY,CAAC,CAAC;KACjD;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AA1BD,kDA0BC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAbD,0DAaC","sourcesContent":["import {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\nimport { processSnapNotification } from './process-snap-notifications';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n RawNotificationUnion,\n} from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(n.type);\n\nconst isFeatureAnnouncement = (\n n: RawNotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n n: RawNotificationUnion,\n): n is RawSnapNotification => n.type === TRIGGER_TYPES.SNAP;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isSnapNotification(notification)) {\n return processSnapNotification(notification);\n }\n\n if (isOnChainNotification(notification)) {\n return processOnChainNotification(notification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n"]}
|