@metamask-previews/notification-services-controller 14.0.0-preview-bfc59609 → 14.0.0-preview-159e55f8
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 +17 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs +2 -115
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts +2 -14
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +2 -14
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +1 -114
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.cjs +7 -0
- package/dist/NotificationServicesController/ui/constants.cjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.cts +14 -8
- package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.d.mts +14 -8
- package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -1
- package/dist/NotificationServicesController/ui/constants.mjs +7 -0
- package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `BASE` chain to notification UI config in `ui/constants.ts` ([#6124](https://github.com/MetaMask/core/pull/6124))
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Update push notification utility `getChainSymbol` in `get-notification-message.ts` to use UI constants ([#6124](https://github.com/MetaMask/core/pull/6124))
|
|
17
|
+
|
|
18
|
+
### Removed
|
|
19
|
+
|
|
20
|
+
- **BREAKING:** Cleanup old config/constants ([#6124](https://github.com/MetaMask/core/pull/6124))
|
|
21
|
+
- Remove `NOTIFICATION_CHAINS` constant from `notification-schema.ts`
|
|
22
|
+
- Remove `CHAIN_SYMBOLS` constant from `notification-schema.ts`
|
|
23
|
+
- Remove `SUPPORTED_CHAINS` constant from `notification-schema.ts`
|
|
24
|
+
- Remove `Trigger` type from `notification-schema.ts`
|
|
25
|
+
- Remove `TRIGGERS` constant from `notification-schema.ts`
|
|
26
|
+
|
|
10
27
|
## [14.0.0]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NOTIFICATION_CHAINS_ID = exports.TRIGGER_TYPES_GROUPS = exports.TRIGGER_TYPES_WALLET_SET = exports.TRIGGER_TYPES = void 0;
|
|
4
4
|
var TRIGGER_TYPES;
|
|
5
5
|
(function (TRIGGER_TYPES) {
|
|
6
6
|
TRIGGER_TYPES["FEATURES_ANNOUNCEMENT"] = "features_announcement";
|
|
@@ -54,124 +54,11 @@ exports.NOTIFICATION_CHAINS_ID = {
|
|
|
54
54
|
ETHEREUM: '1',
|
|
55
55
|
OPTIMISM: '10',
|
|
56
56
|
BSC: '56',
|
|
57
|
+
BASE: '8453',
|
|
57
58
|
POLYGON: '137',
|
|
58
59
|
ARBITRUM: '42161',
|
|
59
60
|
AVALANCHE: '43114',
|
|
60
61
|
LINEA: '59144',
|
|
61
62
|
SEI: '1329',
|
|
62
63
|
};
|
|
63
|
-
exports.NOTIFICATION_CHAINS = exports.NOTIFICATION_CHAINS_ID;
|
|
64
|
-
exports.CHAIN_SYMBOLS = {
|
|
65
|
-
[exports.NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',
|
|
66
|
-
[exports.NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',
|
|
67
|
-
[exports.NOTIFICATION_CHAINS.BSC]: 'BNB',
|
|
68
|
-
[exports.NOTIFICATION_CHAINS.POLYGON]: 'POL',
|
|
69
|
-
[exports.NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',
|
|
70
|
-
[exports.NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',
|
|
71
|
-
[exports.NOTIFICATION_CHAINS.LINEA]: 'ETH',
|
|
72
|
-
};
|
|
73
|
-
exports.SUPPORTED_CHAINS = [
|
|
74
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
75
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
76
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
77
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
78
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
79
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
80
|
-
exports.NOTIFICATION_CHAINS.LINEA,
|
|
81
|
-
];
|
|
82
|
-
exports.TRIGGERS = {
|
|
83
|
-
[TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {
|
|
84
|
-
supported_chains: [
|
|
85
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
86
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
87
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
88
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
89
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
90
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
[TRIGGER_TYPES.ERC20_SENT]: {
|
|
94
|
-
supported_chains: [
|
|
95
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
96
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
97
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
98
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
99
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
100
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
101
|
-
exports.NOTIFICATION_CHAINS.LINEA,
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
[TRIGGER_TYPES.ERC20_RECEIVED]: {
|
|
105
|
-
supported_chains: [
|
|
106
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
107
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
108
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
109
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
110
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
111
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
112
|
-
exports.NOTIFICATION_CHAINS.LINEA,
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
[TRIGGER_TYPES.ERC721_SENT]: {
|
|
116
|
-
supported_chains: [
|
|
117
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
118
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
[TRIGGER_TYPES.ERC721_RECEIVED]: {
|
|
122
|
-
supported_chains: [
|
|
123
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
124
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
[TRIGGER_TYPES.ERC1155_SENT]: {
|
|
128
|
-
supported_chains: [
|
|
129
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
130
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
[TRIGGER_TYPES.ERC1155_RECEIVED]: {
|
|
134
|
-
supported_chains: [
|
|
135
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
136
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
[TRIGGER_TYPES.ETH_SENT]: {
|
|
140
|
-
supported_chains: [
|
|
141
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
142
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
143
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
144
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
145
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
146
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
147
|
-
exports.NOTIFICATION_CHAINS.LINEA,
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
[TRIGGER_TYPES.ETH_RECEIVED]: {
|
|
151
|
-
supported_chains: [
|
|
152
|
-
exports.NOTIFICATION_CHAINS.ETHEREUM,
|
|
153
|
-
exports.NOTIFICATION_CHAINS.OPTIMISM,
|
|
154
|
-
exports.NOTIFICATION_CHAINS.BSC,
|
|
155
|
-
exports.NOTIFICATION_CHAINS.POLYGON,
|
|
156
|
-
exports.NOTIFICATION_CHAINS.ARBITRUM,
|
|
157
|
-
exports.NOTIFICATION_CHAINS.AVALANCHE,
|
|
158
|
-
exports.NOTIFICATION_CHAINS.LINEA,
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
[TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {
|
|
162
|
-
supported_chains: [exports.NOTIFICATION_CHAINS.ETHEREUM],
|
|
163
|
-
},
|
|
164
|
-
[TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {
|
|
165
|
-
supported_chains: [exports.NOTIFICATION_CHAINS.ETHEREUM],
|
|
166
|
-
},
|
|
167
|
-
[TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {
|
|
168
|
-
supported_chains: [exports.NOTIFICATION_CHAINS.ETHEREUM],
|
|
169
|
-
},
|
|
170
|
-
[TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {
|
|
171
|
-
supported_chains: [exports.NOTIFICATION_CHAINS.ETHEREUM],
|
|
172
|
-
},
|
|
173
|
-
[TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {
|
|
174
|
-
supported_chains: [exports.NOTIFICATION_CHAINS.ETHEREUM],
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
64
|
//# sourceMappingURL=notification-schema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"notification-schema.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAwBX;AAxBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,gEAA+C,CAAA;IAC/C,kDAAiC,CAAA;IACjC,8DAA6C,CAAA;IAC7C,0EAAyD,CAAA;IACzD,sEAAqD,CAAA;IACrD,kEAAiD,CAAA;IACjD,8BAAa,CAAA;AACf,CAAC,EAxBW,aAAa,6BAAb,aAAa,QAwBxB;AAEY,QAAA,wBAAwB,GAAgB,IAAI,GAAG,CAAC;IAC3D,aAAa,CAAC,uBAAuB;IACrC,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,cAAc;IAC5B,aAAa,CAAC,QAAQ;IACtB,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,0BAA0B;IACxC,aAAa,CAAC,4BAA4B;IAC1C,aAAa,CAAC,oBAAoB;IAClC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,gCAAgC;IAC9C,aAAa,CAAC,WAAW;IACzB,aAAa,CAAC,eAAe;IAC7B,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,gBAAgB;CAC/B,CAA4E,CAAC;AAE9E,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,6CAAqB,CAAA;IACrB,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B;AAEY,QAAA,sBAAsB,GAAG;IACpC,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,MAAM;CACH,CAAC","sourcesContent":["export enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n AAVE_V3_HEALTH_FACTOR = 'aave_v3_health_factor',\n ENS_EXPIRATION = 'ens_expiration',\n LIDO_STAKING_REWARDS = 'lido_staking_rewards',\n ROCKETPOOL_STAKING_REWARDS = 'rocketpool_staking_rewards',\n NOTIONAL_LOAN_EXPIRATION = 'notional_loan_expiration',\n SPARK_FI_HEALTH_FACTOR = 'spark_fi_health_factor',\n SNAP = 'snap',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n BASE: '8453',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n SEI: '1329',\n} as const;\n\nexport type NOTIFICATION_CHAINS_IDS =\n (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Compute } from "../types/type-utils.cjs";
|
|
2
1
|
export declare enum TRIGGER_TYPES {
|
|
3
2
|
FEATURES_ANNOUNCEMENT = "features_announcement",
|
|
4
3
|
METAMASK_SWAP_COMPLETED = "metamask_swap_completed",
|
|
@@ -34,23 +33,12 @@ export declare const NOTIFICATION_CHAINS_ID: {
|
|
|
34
33
|
readonly ETHEREUM: "1";
|
|
35
34
|
readonly OPTIMISM: "10";
|
|
36
35
|
readonly BSC: "56";
|
|
36
|
+
readonly BASE: "8453";
|
|
37
37
|
readonly POLYGON: "137";
|
|
38
38
|
readonly ARBITRUM: "42161";
|
|
39
39
|
readonly AVALANCHE: "43114";
|
|
40
40
|
readonly LINEA: "59144";
|
|
41
41
|
readonly SEI: "1329";
|
|
42
42
|
};
|
|
43
|
-
type
|
|
44
|
-
[K in keyof TObj]: TObj[K] extends string ? string : TObj[K];
|
|
45
|
-
}>;
|
|
46
|
-
export declare const NOTIFICATION_CHAINS: ToPrimitiveKeys<typeof NOTIFICATION_CHAINS_ID>;
|
|
47
|
-
export declare const CHAIN_SYMBOLS: {
|
|
48
|
-
[x: string]: string;
|
|
49
|
-
};
|
|
50
|
-
export declare const SUPPORTED_CHAINS: string[];
|
|
51
|
-
export type Trigger = {
|
|
52
|
-
supported_chains: (typeof SUPPORTED_CHAINS)[number][];
|
|
53
|
-
};
|
|
54
|
-
export declare const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>>;
|
|
55
|
-
export {};
|
|
43
|
+
export type NOTIFICATION_CHAINS_IDS = (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];
|
|
56
44
|
//# sourceMappingURL=notification-schema.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"notification-schema.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B;IACvD,gCAAgC,qCAAqC;IACrE,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;IACjD,IAAI,SAAS;CACd;AAED,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAgB4B,CAAC;AAE9E,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;CAUzB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Compute } from "../types/type-utils.mjs";
|
|
2
1
|
export declare enum TRIGGER_TYPES {
|
|
3
2
|
FEATURES_ANNOUNCEMENT = "features_announcement",
|
|
4
3
|
METAMASK_SWAP_COMPLETED = "metamask_swap_completed",
|
|
@@ -34,23 +33,12 @@ export declare const NOTIFICATION_CHAINS_ID: {
|
|
|
34
33
|
readonly ETHEREUM: "1";
|
|
35
34
|
readonly OPTIMISM: "10";
|
|
36
35
|
readonly BSC: "56";
|
|
36
|
+
readonly BASE: "8453";
|
|
37
37
|
readonly POLYGON: "137";
|
|
38
38
|
readonly ARBITRUM: "42161";
|
|
39
39
|
readonly AVALANCHE: "43114";
|
|
40
40
|
readonly LINEA: "59144";
|
|
41
41
|
readonly SEI: "1329";
|
|
42
42
|
};
|
|
43
|
-
type
|
|
44
|
-
[K in keyof TObj]: TObj[K] extends string ? string : TObj[K];
|
|
45
|
-
}>;
|
|
46
|
-
export declare const NOTIFICATION_CHAINS: ToPrimitiveKeys<typeof NOTIFICATION_CHAINS_ID>;
|
|
47
|
-
export declare const CHAIN_SYMBOLS: {
|
|
48
|
-
[x: string]: string;
|
|
49
|
-
};
|
|
50
|
-
export declare const SUPPORTED_CHAINS: string[];
|
|
51
|
-
export type Trigger = {
|
|
52
|
-
supported_chains: (typeof SUPPORTED_CHAINS)[number][];
|
|
53
|
-
};
|
|
54
|
-
export declare const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>>;
|
|
55
|
-
export {};
|
|
43
|
+
export type NOTIFICATION_CHAINS_IDS = (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];
|
|
56
44
|
//# sourceMappingURL=notification-schema.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"notification-schema.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B;IACvD,gCAAgC,qCAAqC;IACrE,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;IACjD,IAAI,SAAS;CACd;AAED,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAgB4B,CAAC;AAE9E,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;CAUzB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -51,124 +51,11 @@ export const NOTIFICATION_CHAINS_ID = {
|
|
|
51
51
|
ETHEREUM: '1',
|
|
52
52
|
OPTIMISM: '10',
|
|
53
53
|
BSC: '56',
|
|
54
|
+
BASE: '8453',
|
|
54
55
|
POLYGON: '137',
|
|
55
56
|
ARBITRUM: '42161',
|
|
56
57
|
AVALANCHE: '43114',
|
|
57
58
|
LINEA: '59144',
|
|
58
59
|
SEI: '1329',
|
|
59
60
|
};
|
|
60
|
-
export const NOTIFICATION_CHAINS = NOTIFICATION_CHAINS_ID;
|
|
61
|
-
export const CHAIN_SYMBOLS = {
|
|
62
|
-
[NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',
|
|
63
|
-
[NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',
|
|
64
|
-
[NOTIFICATION_CHAINS.BSC]: 'BNB',
|
|
65
|
-
[NOTIFICATION_CHAINS.POLYGON]: 'POL',
|
|
66
|
-
[NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',
|
|
67
|
-
[NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',
|
|
68
|
-
[NOTIFICATION_CHAINS.LINEA]: 'ETH',
|
|
69
|
-
};
|
|
70
|
-
export const SUPPORTED_CHAINS = [
|
|
71
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
72
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
73
|
-
NOTIFICATION_CHAINS.BSC,
|
|
74
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
75
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
76
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
77
|
-
NOTIFICATION_CHAINS.LINEA,
|
|
78
|
-
];
|
|
79
|
-
export const TRIGGERS = {
|
|
80
|
-
[TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {
|
|
81
|
-
supported_chains: [
|
|
82
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
83
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
84
|
-
NOTIFICATION_CHAINS.BSC,
|
|
85
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
86
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
87
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
[TRIGGER_TYPES.ERC20_SENT]: {
|
|
91
|
-
supported_chains: [
|
|
92
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
93
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
94
|
-
NOTIFICATION_CHAINS.BSC,
|
|
95
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
96
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
97
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
98
|
-
NOTIFICATION_CHAINS.LINEA,
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
[TRIGGER_TYPES.ERC20_RECEIVED]: {
|
|
102
|
-
supported_chains: [
|
|
103
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
104
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
105
|
-
NOTIFICATION_CHAINS.BSC,
|
|
106
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
107
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
108
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
109
|
-
NOTIFICATION_CHAINS.LINEA,
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
[TRIGGER_TYPES.ERC721_SENT]: {
|
|
113
|
-
supported_chains: [
|
|
114
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
115
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
[TRIGGER_TYPES.ERC721_RECEIVED]: {
|
|
119
|
-
supported_chains: [
|
|
120
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
121
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
[TRIGGER_TYPES.ERC1155_SENT]: {
|
|
125
|
-
supported_chains: [
|
|
126
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
127
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
[TRIGGER_TYPES.ERC1155_RECEIVED]: {
|
|
131
|
-
supported_chains: [
|
|
132
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
133
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
[TRIGGER_TYPES.ETH_SENT]: {
|
|
137
|
-
supported_chains: [
|
|
138
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
139
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
140
|
-
NOTIFICATION_CHAINS.BSC,
|
|
141
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
142
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
143
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
144
|
-
NOTIFICATION_CHAINS.LINEA,
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
[TRIGGER_TYPES.ETH_RECEIVED]: {
|
|
148
|
-
supported_chains: [
|
|
149
|
-
NOTIFICATION_CHAINS.ETHEREUM,
|
|
150
|
-
NOTIFICATION_CHAINS.OPTIMISM,
|
|
151
|
-
NOTIFICATION_CHAINS.BSC,
|
|
152
|
-
NOTIFICATION_CHAINS.POLYGON,
|
|
153
|
-
NOTIFICATION_CHAINS.ARBITRUM,
|
|
154
|
-
NOTIFICATION_CHAINS.AVALANCHE,
|
|
155
|
-
NOTIFICATION_CHAINS.LINEA,
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
[TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {
|
|
159
|
-
supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],
|
|
160
|
-
},
|
|
161
|
-
[TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {
|
|
162
|
-
supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],
|
|
163
|
-
},
|
|
164
|
-
[TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {
|
|
165
|
-
supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],
|
|
166
|
-
},
|
|
167
|
-
[TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {
|
|
168
|
-
supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],
|
|
169
|
-
},
|
|
170
|
-
[TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {
|
|
171
|
-
supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
61
|
//# sourceMappingURL=notification-schema.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAwBX;AAxBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,gEAA+C,CAAA;IAC/C,kDAAiC,CAAA;IACjC,8DAA6C,CAAA;IAC7C,0EAAyD,CAAA;IACzD,sEAAqD,CAAA;IACrD,kEAAiD,CAAA;IACjD,8BAAa,CAAA;AACf,CAAC,EAxBW,aAAa,KAAb,aAAa,QAwBxB;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAgB,IAAI,GAAG,CAAC;IAC3D,aAAa,CAAC,uBAAuB;IACrC,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,cAAc;IAC5B,aAAa,CAAC,QAAQ;IACtB,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,0BAA0B;IACxC,aAAa,CAAC,4BAA4B;IAC1C,aAAa,CAAC,oBAAoB;IAClC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,gCAAgC;IAC9C,aAAa,CAAC,WAAW;IACzB,aAAa,CAAC,eAAe;IAC7B,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,gBAAgB;CAC/B,CAA4E,CAAC;AAE9E,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,6CAAqB,CAAA;IACrB,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,MAAM;CACH,CAAC","sourcesContent":["export enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n AAVE_V3_HEALTH_FACTOR = 'aave_v3_health_factor',\n ENS_EXPIRATION = 'ens_expiration',\n LIDO_STAKING_REWARDS = 'lido_staking_rewards',\n ROCKETPOOL_STAKING_REWARDS = 'rocketpool_staking_rewards',\n NOTIONAL_LOAN_EXPIRATION = 'notional_loan_expiration',\n SPARK_FI_HEALTH_FACTOR = 'spark_fi_health_factor',\n SNAP = 'snap',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n BASE: '8453',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n SEI: '1329',\n} as const;\n\nexport type NOTIFICATION_CHAINS_IDS =\n (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];\n"]}
|
|
@@ -7,6 +7,7 @@ exports.NOTIFICATION_NETWORK_CURRENCY_NAME = {
|
|
|
7
7
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',
|
|
8
8
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',
|
|
9
9
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.BSC]: 'Binance',
|
|
10
|
+
[notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: 'Base',
|
|
10
11
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',
|
|
11
12
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',
|
|
12
13
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',
|
|
@@ -17,6 +18,7 @@ exports.NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
|
|
|
17
18
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',
|
|
18
19
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',
|
|
19
20
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.BSC]: 'BNB',
|
|
21
|
+
[notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: 'ETH',
|
|
20
22
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',
|
|
21
23
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',
|
|
22
24
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',
|
|
@@ -38,6 +40,11 @@ exports.SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
|
|
|
38
40
|
url: 'https://bscscan.com',
|
|
39
41
|
name: 'BscScan',
|
|
40
42
|
},
|
|
43
|
+
// BASE
|
|
44
|
+
[notification_schema_1.NOTIFICATION_CHAINS_ID.BASE]: {
|
|
45
|
+
url: 'https://basescan.org',
|
|
46
|
+
name: 'BaseScan',
|
|
47
|
+
},
|
|
41
48
|
// POLYGON
|
|
42
49
|
[notification_schema_1.NOTIFICATION_CHAINS_ID.POLYGON]: {
|
|
43
50
|
url: 'https://polygonscan.com',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":";;;AAAA,8EAG0C;AAE7B,QAAA,kCAAkC,GAAG;IAChD,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7C,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7C,CAAC,4CAAsB,CAAC,SAAS,CAAC,EAAE,WAAW;IAC/C,CAAC,4CAAsB,CAAC,GAAG,CAAC,EAAE,SAAS;IACvC,CAAC,4CAAsB,CAAC,IAAI,CAAC,EAAE,MAAM;IACrC,CAAC,4CAAsB,CAAC,KAAK,CAAC,EAAE,OAAO;IACvC,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7C,CAAC,4CAAsB,CAAC,OAAO,CAAC,EAAE,SAAS;IAC3C,CAAC,4CAAsB,CAAC,GAAG,CAAC,EAAE,aAAa;CACM,CAAC;AAEvC,QAAA,oCAAoC,GAAG;IAClD,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,KAAK;IACxC,CAAC,4CAAsB,CAAC,QAAQ,CAAC,EAAE,KAAK;IACxC,CAAC,4CAAsB,CAAC,SAAS,CAAC,EAAE,MAAM;IAC1C,CAAC,4CAAsB,CAAC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AAC,4CAAsB,CAAC,GAAG,CAAC,EAAE;QAC5B,GAAG,EAAE,uBAAuB;QAC5B,IAAI,EAAE,UAAU;KACjB;CAC6D,CAAC;AAEjE,4EAA0E;AAAjE,6HAAA,sBAAsB,OAAA","sourcesContent":["import {\n NOTIFICATION_CHAINS_ID,\n type NOTIFICATION_CHAINS_IDS,\n} from '../constants/notification-schema';\n\nexport const NOTIFICATION_NETWORK_CURRENCY_NAME = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',\n [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',\n [NOTIFICATION_CHAINS_ID.BASE]: 'Base',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',\n [NOTIFICATION_CHAINS_ID.SEI]: 'Sei Network',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',\n [NOTIFICATION_CHAINS_ID.BASE]: 'ETH',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS_ID.SEI]: 'SEI',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport type BlockExplorerConfig = {\n url: string;\n name: string;\n};\n\nexport const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {\n // ETHEREUM\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: {\n url: 'https://etherscan.io',\n name: 'Etherscan',\n },\n // OPTIMISM\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: {\n url: 'https://optimistic.etherscan.io',\n name: 'Optimistic Etherscan',\n },\n // BSC\n [NOTIFICATION_CHAINS_ID.BSC]: {\n url: 'https://bscscan.com',\n name: 'BscScan',\n },\n // BASE\n [NOTIFICATION_CHAINS_ID.BASE]: {\n url: 'https://basescan.org',\n name: 'BaseScan',\n },\n // POLYGON\n [NOTIFICATION_CHAINS_ID.POLYGON]: {\n url: 'https://polygonscan.com',\n name: 'PolygonScan',\n },\n // ARBITRUM\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: {\n url: 'https://arbiscan.io',\n name: 'Arbiscan',\n },\n // AVALANCHE\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: {\n url: 'https://snowtrace.io',\n name: 'Snowtrace',\n },\n // LINEA\n [NOTIFICATION_CHAINS_ID.LINEA]: {\n url: 'https://lineascan.build',\n name: 'LineaScan',\n },\n [NOTIFICATION_CHAINS_ID.SEI]: {\n url: 'https://seitrace.com/',\n name: 'SeiTrace',\n },\n} satisfies Record<NOTIFICATION_CHAINS_IDS, BlockExplorerConfig>;\n\nexport { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n"]}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
export declare const NOTIFICATION_NETWORK_CURRENCY_NAME: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
1: string;
|
|
3
|
+
42161: string;
|
|
4
|
+
43114: string;
|
|
5
|
+
56: string;
|
|
6
|
+
8453: string;
|
|
7
|
+
59144: string;
|
|
8
|
+
10: string;
|
|
9
|
+
137: string;
|
|
10
|
+
1329: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const NOTIFICATION_NETWORK_CURRENCY_SYMBOL: {
|
|
12
13
|
1: string;
|
|
13
14
|
42161: string;
|
|
14
15
|
43114: string;
|
|
15
16
|
56: string;
|
|
17
|
+
8453: string;
|
|
16
18
|
59144: string;
|
|
17
19
|
10: string;
|
|
18
20
|
137: string;
|
|
@@ -35,6 +37,10 @@ export declare const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS: {
|
|
|
35
37
|
url: string;
|
|
36
38
|
name: string;
|
|
37
39
|
};
|
|
40
|
+
8453: {
|
|
41
|
+
url: string;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
38
44
|
137: {
|
|
39
45
|
url: string;
|
|
40
46
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC;;;;;;;;;;CAUI,CAAC;AAEpD,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUE,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ca,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,6CAAyC"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
export declare const NOTIFICATION_NETWORK_CURRENCY_NAME: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
1: string;
|
|
3
|
+
42161: string;
|
|
4
|
+
43114: string;
|
|
5
|
+
56: string;
|
|
6
|
+
8453: string;
|
|
7
|
+
59144: string;
|
|
8
|
+
10: string;
|
|
9
|
+
137: string;
|
|
10
|
+
1329: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const NOTIFICATION_NETWORK_CURRENCY_SYMBOL: {
|
|
12
13
|
1: string;
|
|
13
14
|
42161: string;
|
|
14
15
|
43114: string;
|
|
15
16
|
56: string;
|
|
17
|
+
8453: string;
|
|
16
18
|
59144: string;
|
|
17
19
|
10: string;
|
|
18
20
|
137: string;
|
|
@@ -35,6 +37,10 @@ export declare const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS: {
|
|
|
35
37
|
url: string;
|
|
36
38
|
name: string;
|
|
37
39
|
};
|
|
40
|
+
8453: {
|
|
41
|
+
url: string;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
38
44
|
137: {
|
|
39
45
|
url: string;
|
|
40
46
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kCAAkC;;;;;;;;;;CAUI,CAAC;AAEpD,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUE,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ca,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,6CAAyC"}
|
|
@@ -4,6 +4,7 @@ export const NOTIFICATION_NETWORK_CURRENCY_NAME = {
|
|
|
4
4
|
[NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',
|
|
5
5
|
[NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',
|
|
6
6
|
[NOTIFICATION_CHAINS_ID.BSC]: 'Binance',
|
|
7
|
+
[NOTIFICATION_CHAINS_ID.BASE]: 'Base',
|
|
7
8
|
[NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',
|
|
8
9
|
[NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',
|
|
9
10
|
[NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',
|
|
@@ -14,6 +15,7 @@ export const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
|
|
|
14
15
|
[NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',
|
|
15
16
|
[NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',
|
|
16
17
|
[NOTIFICATION_CHAINS_ID.BSC]: 'BNB',
|
|
18
|
+
[NOTIFICATION_CHAINS_ID.BASE]: 'ETH',
|
|
17
19
|
[NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',
|
|
18
20
|
[NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',
|
|
19
21
|
[NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',
|
|
@@ -35,6 +37,11 @@ export const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
|
|
|
35
37
|
url: 'https://bscscan.com',
|
|
36
38
|
name: 'BscScan',
|
|
37
39
|
},
|
|
40
|
+
// BASE
|
|
41
|
+
[NOTIFICATION_CHAINS_ID.BASE]: {
|
|
42
|
+
url: 'https://basescan.org',
|
|
43
|
+
name: 'BaseScan',
|
|
44
|
+
},
|
|
38
45
|
// POLYGON
|
|
39
46
|
[NOTIFICATION_CHAINS_ID.POLYGON]: {
|
|
40
47
|
url: 'https://polygonscan.com',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../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B,IAAI,EAAE,WAAW;KAClB;IACD,WAAW;IACX,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE;QACjC,GAAG,EAAE,iCAAiC;QACtC,IAAI,EAAE,sBAAsB;KAC7B;IACD,MAAM;IACN,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE;QAC5B,GAAG,EAAE,qBAAqB;QAC1B,IAAI,EAAE,SAAS;KAChB;IACD,OAAO;IACP,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE;QAC7B,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,UAAU;KACjB;IACD,UAAU;IACV,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE;QAChC,GAAG,EAAE,yBAAyB;QAC9B,IAAI,EAAE,aAAa;KACpB;IACD,WAAW;IACX,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE;QACjC,GAAG,EAAE,qBAAqB;QAC1B,IAAI,EAAE,UAAU;KACjB;IACD,YAAY;IACZ,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE;QAClC,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,WAAW;KAClB;IACD,QAAQ;IACR,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE;QAC9B,GAAG,EAAE,yBAAyB;QAC9B,IAAI,EAAE,WAAW;KAClB;IACD,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE;QAC5B,GAAG,EAAE,uBAAuB;QAC5B,IAAI,EAAE,UAAU;KACjB;CAC6D,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,6CAAyC","sourcesContent":["import {\n NOTIFICATION_CHAINS_ID,\n type NOTIFICATION_CHAINS_IDS,\n} from '../constants/notification-schema';\n\nexport const NOTIFICATION_NETWORK_CURRENCY_NAME = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',\n [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',\n [NOTIFICATION_CHAINS_ID.BASE]: 'Base',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',\n [NOTIFICATION_CHAINS_ID.SEI]: 'Sei Network',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',\n [NOTIFICATION_CHAINS_ID.BASE]: 'ETH',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS_ID.SEI]: 'SEI',\n} satisfies Record<NOTIFICATION_CHAINS_IDS, string>;\n\nexport type BlockExplorerConfig = {\n url: string;\n name: string;\n};\n\nexport const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {\n // ETHEREUM\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: {\n url: 'https://etherscan.io',\n name: 'Etherscan',\n },\n // OPTIMISM\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: {\n url: 'https://optimistic.etherscan.io',\n name: 'Optimistic Etherscan',\n },\n // BSC\n [NOTIFICATION_CHAINS_ID.BSC]: {\n url: 'https://bscscan.com',\n name: 'BscScan',\n },\n // BASE\n [NOTIFICATION_CHAINS_ID.BASE]: {\n url: 'https://basescan.org',\n name: 'BaseScan',\n },\n // POLYGON\n [NOTIFICATION_CHAINS_ID.POLYGON]: {\n url: 'https://polygonscan.com',\n name: 'PolygonScan',\n },\n // ARBITRUM\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: {\n url: 'https://arbiscan.io',\n name: 'Arbiscan',\n },\n // AVALANCHE\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: {\n url: 'https://snowtrace.io',\n name: 'Snowtrace',\n },\n // LINEA\n [NOTIFICATION_CHAINS_ID.LINEA]: {\n url: 'https://lineascan.build',\n name: 'LineaScan',\n },\n [NOTIFICATION_CHAINS_ID.SEI]: {\n url: 'https://seitrace.com/',\n name: 'SeiTrace',\n },\n} satisfies Record<NOTIFICATION_CHAINS_IDS, BlockExplorerConfig>;\n\nexport { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOnChainPushNotificationMessage = exports.createOnChainPushNotificationMessages = void 0;
|
|
4
4
|
const get_notification_data_1 = require("./get-notification-data.cjs");
|
|
5
|
-
const
|
|
5
|
+
const ui_1 = require("../../NotificationServicesController/ui/index.cjs");
|
|
6
6
|
/**
|
|
7
7
|
* On Chain Push Notification Messages.
|
|
8
8
|
* This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension
|
|
@@ -135,7 +135,7 @@ exports.createOnChainPushNotificationMessages = createOnChainPushNotificationMes
|
|
|
135
135
|
* @returns The symbol associated with the chain ID, or null if not found.
|
|
136
136
|
*/
|
|
137
137
|
function getChainSymbol(chainId) {
|
|
138
|
-
return
|
|
138
|
+
return (ui_1.NOTIFICATION_NETWORK_CURRENCY_SYMBOL[chainId.toString()] ?? null);
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Creates a push notification message based on the given on-chain raw notification.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAElE,mGAAiE;A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I,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AA7BD,oFA6BC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type { Types } from '../../NotificationServicesController';\nimport { Constants } from '../../NotificationServicesController';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return Constants.CHAIN_SYMBOLS[chainId] ?? null;\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAMlE,0EAA+F;AAkD/F;;;;;;GAMG;AACI,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,CAAC,GAAkB,CAAC,GAAG,IAAI,EAAE,EAAE;QACnC,MAAM,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;QAEjC,4CAA4C;QAC5C,8DAA8D;QAC9D,MAAM,EAAE,GAAQ,eAAe,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,CAAC,yCAAyC,CAAC;YACnD,kBAAkB,EAAE,CAAC,CACnB,sDAAsD,CACvD;YACD,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpB,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBACtC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBAC3C,MAAM,aAAa,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC;gBAC/C,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa,EAAE;oBAC7C,OAAO,IAAI,CAAC;iBACb;gBAED,MAAM,MAAM,GAAG,IAAA,iCAAS,EAAC,WAAW,EAAE,aAAa,EAAE;oBACnD,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAC;gBACH,OAAO,CAAC,CACN,+CAA+C,EAC/C,MAAM,EACN,MAAM,CACP,CAAC;YACJ,CAAC;SACF;QACD,QAAQ,EAAE;YACR,KAA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AC,kBAAkB;gBACtC,IAAI,CAAC;KACR;IAAC,MAAM;QACN,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,IAAI,IAAI,CAAC;KAC9D;IAED,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,EAAE;QACtC,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AA7BD,oFA6BC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Types } from "../../NotificationServicesController/index.cjs";
|
|
2
|
-
import { Constants } from "../../NotificationServicesController/index.cjs";
|
|
2
|
+
import type { Constants } from "../../NotificationServicesController/index.cjs";
|
|
3
3
|
export type TranslationKeys = {
|
|
4
4
|
pushPlatformNotificationsFundsSentTitle: () => string;
|
|
5
5
|
pushPlatformNotificationsFundsSentDescriptionDefault: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-notification-message.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get-notification-message.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MA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AAC,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,mBAAmB,CAClD,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAC1C;CACF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,oBAC/B,eAAe,KAC/B,uBAuKF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA0BhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Types } from "../../NotificationServicesController/index.mjs";
|
|
2
|
-
import { Constants } from "../../NotificationServicesController/index.mjs";
|
|
2
|
+
import type { Constants } from "../../NotificationServicesController/index.mjs";
|
|
3
3
|
export type TranslationKeys = {
|
|
4
4
|
pushPlatformNotificationsFundsSentTitle: () => string;
|
|
5
5
|
pushPlatformNotificationsFundsSentDescriptionDefault: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-notification-message.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get-notification-message.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1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S,CAAC,aAAa,CAAC,CAAC,EAAE,mBAAmB,CAClD,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAC1C;CACF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,oBAC/B,eAAe,KAC/B,uBAuKF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA0BhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAmount, formatAmount } from "./get-notification-data.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from "../../NotificationServicesController/ui/index.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* On Chain Push Notification Messages.
|
|
5
5
|
* This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension
|
|
@@ -131,7 +131,7 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
|
|
|
131
131
|
* @returns The symbol associated with the chain ID, or null if not found.
|
|
132
132
|
*/
|
|
133
133
|
function getChainSymbol(chainId) {
|
|
134
|
-
return
|
|
134
|
+
return (NOTIFICATION_NETWORK_CURRENCY_SYMBOL[chainId.toString()] ?? null);
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Creates a push notification message based on the given on-chain raw notification.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-notification-message.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,oCAAgC;AAElE,OAAO,EAAE,SAAS,EAAE,uDAA6C;AAkDjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,CAAC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AAkE,CACnE;YACD,kBAAkB,EAAE,CAAC,CACnB,wEAAwE,CACzE;SACF;QACD,yBAAyB,EAAE;YACzB,KAAK,EAAE,CAAC,CAAC,8DAA8D,CAAC;YACxE,kBAAkB,EAAE,CAAC,CACnB,oEAAoE,CACrE;SACF;QACD,yBAAyB,EAAE;YACzB,KAAK,EAAE,CAAC,CAAC,8DAA8D,CAAC;YACxE,kBAAkB,EAAE,CAAC,CACnB,oEAAoE,CACrE;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oCAAoC,CAClD,CAAsB,EACtB,YAA6B;IAE7B,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IACD,MAAM,mBAAmB,GACvB,qCAAqC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,GAAkB,IAAI,CAAC;IACtC,IAAI;QACF,WAAW;YACT,8DAA8D;YAC9D,mBAAmB,EAAE,cAAc,EAAE,CAAC,CAAQ,CAAC;gBAC/C,mBAAmB,CAAC,kBAAkB;gBACtC,IAAI,CAAC;KACR;IAAC,MAAM;QACN,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,IAAI,IAAI,CAAC;KAC9D;IAED,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,EAAE;QACtC,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type { Types } from '../../NotificationServicesController';\nimport { Constants } from '../../NotificationServicesController';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return Constants.CHAIN_SYMBOLS[chainId] ?? null;\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"get-notification-message.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,KAAK,IAAI,EAAE;QACtC,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
|
package/package.json
CHANGED