-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
310 lines (276 loc) · 8.63 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
import { JsonFragment } from 'ethers';
import { Network, SupportedNetwork } from '@openzeppelin/defender-sdk-base-client';
import { Contract } from '@openzeppelin/defender-sdk-proposal-client/lib/models/contract';
import {
RelayerGetResponse,
RelayerApiKey,
PrivateTransactionMode,
} from '@openzeppelin/defender-sdk-relay-client/lib/models';
import { RelayerGroupResponse, RelayerGroupRelayer } from '@openzeppelin/defender-sdk-relay-group-client/lib/models';
import { DefenderApiResponseError } from '@openzeppelin/defender-sdk-base-client/lib/api/api-error';
import {
SaveNotificationRequest,
NotificationSummary,
DatadogConfig,
SlackConfig,
TelegramBotConfig,
EmailConfig,
DiscordConfig,
NotificationType,
} from '@openzeppelin/defender-sdk-monitor-client/lib/models/notification';
import { CreateMonitorResponse, BlockWatcher } from '@openzeppelin/defender-sdk-monitor-client';
import { TenantNetworkResponse } from '@openzeppelin/defender-sdk-network-client';
import {
CreateBlockMonitorResponse,
CreateFortaMonitorResponse,
ExternalCreateBlockMonitorRequest,
ExternalCreateFortaMonitorRequest,
NotificationReference,
MonitorRiskCategory,
} from '@openzeppelin/defender-sdk-monitor-client/lib/models/monitor';
import {
Action,
SecretsMap,
ScheduleTrigger,
WebhookTrigger,
SentinelTrigger,
MonitorFilterTrigger,
} from '@openzeppelin/defender-sdk-action-client/lib/models/action';
import { BlockExplorerApiKeyResponse } from '@openzeppelin/defender-sdk-deploy-client';
import { OpsgenieConfig } from '@openzeppelin/defender-sdk-monitor-client/lib/models/opsgenie';
import { PagerDutyConfig } from '@openzeppelin/defender-sdk-monitor-client/lib/models/pager-duty';
export type DefenderAPIError = DefenderApiResponseError;
export type DefenderRelayerApiKey = RelayerApiKey;
export type DefenderSecretsMap = SecretsMap;
export type DefenderContract = Contract;
export type DefenderRelayer = RelayerGetResponse;
export type DefenderRelayerGroup = RelayerGroupResponse;
export type DefenderRelayerGroupRelayer = RelayerGroupRelayer;
export type DefenderAction = Action;
export type DefenderBlockWatcher = BlockWatcher;
export type DefenderNotification = NotificationSummary;
export type DefenderNotificationReference = NotificationReference;
export type DefenderMonitor = CreateMonitorResponse;
export type DefenderBlockMonitorResponse = CreateBlockMonitorResponse;
export type DefenderFortaMonitorResponse = CreateFortaMonitorResponse;
export type DefenderBlockMonitor = ExternalCreateBlockMonitorRequest;
export type DefenderFortaMonitor = ExternalCreateFortaMonitorRequest;
export type DefenderSlackConfig = SlackConfig;
export type DefenderDatadogConfig = DatadogConfig;
export type DefenderDiscordConfig = DiscordConfig;
export type DefenderTelegramConfig = TelegramBotConfig;
export type DefenderEmailConfig = EmailConfig;
export type DefenderNetwork = Network;
export type DefenderBlockExplorerApiKey = BlockExplorerApiKeyResponse;
export type DefenderWebhookTrigger = WebhookTrigger;
export type DefenderScheduleTrigger = ScheduleTrigger;
export type DefenderMonitorTrigger = SentinelTrigger;
export type DefenderMonitorFilterTrigger = MonitorFilterTrigger;
export type DefenderMonitorRiskCategory = MonitorRiskCategory;
export type DefenderTenantNetwork = TenantNetworkResponse;
// Generated Interfaces from Schemas
import * as SchemaDefender from '../types/types/defender.schema';
import * as SchemaResources from '../types/types/resources.schema';
import * as SchemaProvider from '../types/types/provider.schema';
export type Resources = SchemaResources.Resources;
export type Provider = SchemaProvider.Provider;
export type Defender = SchemaDefender.Defender;
export interface IDefenderServerless {
provider: { name: 'defender' } & Provider;
defender: Defender;
resources: Resources;
}
export type ResourceType =
| 'Monitors'
| 'Relayers'
| 'Relayer Groups'
| 'Notifications'
| 'Actions'
| 'Contracts'
| 'Secrets'
| 'Block Explorer Api Keys'
| 'Forked Networks'
| 'Private Networks';
export type YPolicy = {
'gas-price-cap'?: number;
'whitelist-receivers'?: string[];
'eip1559-pricing'?: boolean;
'private-transactions'?: boolean | PrivateTransactionMode;
};
export type YRelayer = {
'name': string;
'network': Network;
'min-balance': number;
'policy'?: YPolicy;
'api-keys': any[];
'address-from-relayer'?: YRelayer;
};
export type YRelayerGroupRelayer = {
'relayer-id': string;
'address': string;
'key-id'?: string;
'balance'?: string;
};
export type YRelayerGroup = {
'name': string;
'network': Network;
'min-balance': number;
'policies'?: YPolicy;
'api-keys': any[];
'relayers': number;
'user-weight-caps': {
[user: string]: number;
};
'notification-channels': {
'events': ('pending' | 'sent' | 'submitted' | 'inmempool' | 'mined' | 'confirmed' | 'failed' | 'expired')[];
'notification-ids': (YNotification | string)[];
};
};
export type YAction = {
name: string;
path: string;
relayer?: YRelayer;
trigger: {
type: 'schedule' | 'webhook' | 'sentinel' | 'monitor-filter';
frequency?: number;
cron?: string;
};
paused: boolean;
};
export type YSlackConfig = {
url: string;
};
export type YTelegramConfig = {
'bot-token': string;
'chat-id': string;
};
export type YDiscordConfig = {
url: string;
};
export type YEmailConfig = {
emails: string[];
};
export type YDatadogConfig = {
'api-key': string;
'metric-prefix': string;
};
export type YWebhookConfig = {
url: string;
secret?: string;
};
export type YOpsgenieConfig = OpsgenieConfig;
export type YPagerdutyConfig = PagerDutyConfig;
export type YNotificationSeverityLevel = 'LOW' | 'MEDIUM' | 'HIGH';
export type YNotification = SaveNotificationRequest & {
type: NotificationType;
name: string;
paused: boolean;
config:
| YSlackConfig
| YTelegramConfig
| YDatadogConfig
| YDiscordConfig
| YEmailConfig
| YOpsgenieConfig
| YPagerdutyConfig;
};
export type YBlockMonitor = {
'name': string;
'type': 'BLOCK';
'network': Network;
'addresses': string[];
'abi'?: string | string[] | JsonFragment[];
'alert-threshold'?: { 'amount': number; 'window-seconds': number };
'paused'?: boolean;
'action-condition'?: YAction;
'action-trigger'?: YAction;
'confirm-level'?: number | 'safe' | 'finalized';
'notify-config': {
'timeout'?: number;
'message'?: string;
'message-subject'?: string;
'channels': YNotification[];
'severity-level': YNotificationSeverityLevel;
};
'conditions'?: {
event: { signature: string; expression?: string }[];
function: { signature: string; expression?: string }[];
transaction?: string;
};
'risk-category': DefenderMonitorRiskCategory;
};
export type YFortaMonitor = {
'name': string;
'type': 'FORTA';
'network'?: Network;
'addresses'?: string[];
'abi'?: string | string[] | JsonFragment[];
'alert-threshold'?: { 'amount': number; 'window-seconds': number };
'paused'?: boolean;
'action-condition'?: YAction;
'action-trigger'?: YAction;
'notify-config': {
'timeout'?: number;
'message'?: string;
'message-subject'?: string;
'channels': YNotification[];
'severity-level': YNotificationSeverityLevel;
};
'conditions'?: {
'min-scanner-count': number;
'severity'?: 0 | 1 | 2 | 3 | 4 | 5;
'alert-ids'?: string[];
};
'forta-node-id'?: string;
'agent-ids'?: string[];
'forta-last-processed-time'?: string;
'risk-category': DefenderMonitorRiskCategory;
};
export type YMonitor = YBlockMonitor | YFortaMonitor;
export type YContract = {
'name': string;
'address': string;
'network': Network;
'abi'?: string | string[] | JsonFragment[];
'nat-spec'?: string;
};
export type YSecret = {
[k: string]: string;
};
export type YForkedNetwork = {
'name': string;
'supported-network': SupportedNetwork;
'rpc-url': string;
'api-key': string;
'block-explorer-url': string;
};
export type TeamKey = {
apiKey: string;
apiSecret: string;
};
export type DeployResponse = {
name: string;
id: string;
success: boolean;
notice?: string;
error?: string;
[k: string]: any;
};
export type DeployOutput<T> = { removed: T[]; created: T[]; updated: T[] };
export type ListDefenderResources = {
monitors: DefenderMonitor[];
actions: DefenderAction[];
notifications: DefenderNotification[];
contracts: DefenderContract[];
relayerApiKeys: DefenderRelayerApiKey[];
relayerGroupApiKeys: DefenderRelayerApiKey[];
secrets: string[];
blockExplorerApiKeys: DefenderBlockExplorerApiKey[];
forkedNetworks: DefenderTenantNetwork[];
privateNetworks: DefenderTenantNetwork[];
};
export type YBlockExplorerApiKey = {
'key': string;
'key-hash'?: string;
'network': Network;
};