denotify-client 1.1.16 → 1.1.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,28 @@
2
2
 
3
3
  import * as yup from 'yup';
4
4
 
5
+ export type DiscordEmbedOptions = {
6
+ type?: string;
7
+ title?: string;
8
+ color?: number;
9
+ thumbnail?: {
10
+ url?: string;
11
+ height?: number;
12
+ width?: number;
13
+ };
14
+ image?: {
15
+ url?: string;
16
+ height?: number;
17
+ width?: number;
18
+ };
19
+ url?: string;
20
+ };
5
21
  export type DiscordWebhook = {
6
22
  url: string;
7
23
  username?: string;
8
24
  avatar_url?: string;
9
25
  message: string;
26
+ embed?: DiscordEmbedOptions;
10
27
  };
11
28
  export type NotifyDiscordWebhookRawId = "notify_discord_webhook";
12
29
  export type NotifyDiscordWebhookRawResponse = {
@@ -16,11 +33,36 @@ export type NotifyDiscordWebhookRawResponse = {
16
33
  username: string;
17
34
  avatar_url: string;
18
35
  message: string;
36
+ embed?: DiscordEmbedOptions;
37
+ };
38
+ export type Email = {
39
+ email: string;
40
+ subject?: string;
41
+ html: string;
42
+ };
43
+ export type NotifyEmailRawId = "notify_telegram";
44
+ export type NotifyEmailRawResponse = {
45
+ id: number;
46
+ created_at: string;
47
+ email: string;
48
+ subject: string | null;
49
+ html: string;
19
50
  };
20
- export type NotificationTypeId = "Discord";
21
- export type NotificationConfig = DiscordWebhook;
22
- export type NotifyRawId = NotifyDiscordWebhookRawId;
23
- export type NotifyRawResponse = NotifyDiscordWebhookRawResponse;
51
+ export type Telegram = {
52
+ clientId: number;
53
+ content: string;
54
+ };
55
+ export type NotifyTelegramRawId = "notify_telegram";
56
+ export type NotifyTelegramRawResponse = {
57
+ id: number;
58
+ created_at: string;
59
+ clientId: number;
60
+ content: string;
61
+ };
62
+ export type NotificationTypeId = "Discord" | "Telegram" | "Email";
63
+ export type NotificationConfig = DiscordWebhook | Telegram | Email;
64
+ export type NotifyRawId = NotifyDiscordWebhookRawId | NotifyTelegramRawId | NotifyEmailRawId;
65
+ export type NotifyRawResponse = NotifyDiscordWebhookRawResponse | NotifyTelegramRawResponse | NotifyEmailRawResponse;
24
66
  export type NotificationRawResponse = {
25
67
  notify_type: NotifyRawId;
26
68
  notify: NotifyRawResponse;
@@ -107,7 +149,7 @@ export declare class FunctionBuilder {
107
149
  private constructor();
108
150
  static create(api?: DeNotifyClient): FunctionBuilder;
109
151
  getAbiHash(abi: any): Promise<string>;
110
- addFunction<T = any>(address: string, func: string, args: T[], abi: any): Promise<this>;
152
+ addFunction<T = any>(address: string, func: string, args: T[], abi: any, abiHash?: string): Promise<this>;
111
153
  get(): FunctionCallerConfig;
112
154
  static schema(): yup.ArraySchema<{
113
155
  function: string;
@@ -126,8 +168,8 @@ export type FilterCondition = {
126
168
  logic?: Logic;
127
169
  key: string;
128
170
  type: FilterDataTypes;
129
- operation: FilterOpertationType;
130
- constant: string | number;
171
+ operation: FilterOpertationType | string;
172
+ constant: string | number | any;
131
173
  };
132
174
  export type ConditionGroup = {
133
175
  logic: Logic;
@@ -143,14 +185,14 @@ export declare class FilterBuilder {
143
185
  addCondition(logic: Logic, key: string, type: FilterDataTypes, operation: FilterOpertationType, constant: string | number): FilterBuilder;
144
186
  finalise(): ConditionGroup[];
145
187
  static schema(): yup.ArraySchema<{
146
- conditions?: {
147
- constant?: {} | undefined;
148
- operation?: string | undefined;
188
+ logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
189
+ conditions: {
149
190
  type: NonNullable<"String" | "Address" | "Number" | undefined>;
150
191
  key: string;
192
+ constant: {};
151
193
  logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
152
- }[] | undefined;
153
- logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
194
+ operation: string;
195
+ }[];
154
196
  }[] | undefined, yup.AnyObject, "", "">;
155
197
  }
156
198
  export type TimeBase = "blocks" | "time";
@@ -199,12 +241,49 @@ export type HandlerFunctionCallV2RawResponse = {
199
241
  abi: string[];
200
242
  version: number;
201
243
  };
244
+ export type OnchainEventV2 = {
245
+ addresses: string[];
246
+ abiHash: string;
247
+ event: string;
248
+ debounceCount?: number;
249
+ functions?: FunctionCallerConfig;
250
+ triggerOn?: "always" | "filter";
251
+ latch?: boolean;
252
+ filterVersion?: string;
253
+ filter?: FilterConfig;
254
+ };
255
+ export type HandlerOnchainEventV2RawConfig = {
256
+ addresses: string[];
257
+ abiHash: string;
258
+ event: string;
259
+ debounceCount?: number;
260
+ functions: FunctionCallerConfig | null;
261
+ triggerOn: "always" | "filter";
262
+ latch: boolean;
263
+ filterVersion: string | null;
264
+ filter: FilterConfig | null;
265
+ };
266
+ export type HandlerOnchainEventV2Update = Partial<HandlerOnchainEventV2RawConfig>;
267
+ export type HandlerOnchainEventV2RawResponse = {
268
+ id: number;
269
+ created_at: string;
270
+ nBlocks: number;
271
+ address: string;
272
+ fixedArgs: string[];
273
+ responseArgIndex: number;
274
+ responseArgDecimals: number;
275
+ function: string;
276
+ condition: Condition;
277
+ constant: number;
278
+ abi: string[];
279
+ version: number;
280
+ };
202
281
  export type Network = "ethereum" | "avalanche" | "bsc" | "polygon" | "fantom" | "optimism" | "arbitrum" | "canto";
203
- export type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1;
204
- export type TriggerTypeId = "PollFunctionV2" | "OnchainEventV1" | "PollFunctionV1";
205
- export type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate;
206
- export type TriggerTypeRawId = "handler_function_call" | "handler_onchain_event" | "handler_function_call_v2";
207
- export type HandlerRawResponse = HandlerFunctionCallV2RawResponse | HandlerFunctionCallRawResponse | HandlerOnchainEventRawResponse;
282
+ export type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1 | OnchainEventV2;
283
+ export type TriggerTypeId = "PollFunctionV2" | "OnchainEventV1" | "PollFunctionV1" | "OnchainEventV2";
284
+ export type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate | HandlerOnchainEventV2Update;
285
+ export type TriggerTypeRawId = "handler_function_call" | "handler_onchain_event" | "handler_function_call_v2" | "handler_onchain_event_v2";
286
+ export type HandlerRawResponse = HandlerFunctionCallV2RawResponse | HandlerFunctionCallRawResponse | HandlerOnchainEventRawResponse | HandlerOnchainEventV2RawResponse;
208
287
  export type TriggerRawResponse = {
209
288
  id: number;
210
289
  type: TriggerTypeRawId;
@@ -273,10 +352,11 @@ export declare class DeNotifyClient {
273
352
  deleteAlert(id: number): Promise<any>;
274
353
  private request;
275
354
  getAbi(network: string, address: string): Promise<{
276
- abi: any[];
355
+ abi: unknown[];
277
356
  proxy?: string;
357
+ hash: string;
278
358
  }>;
279
- getAbiHash(abi: any): Promise<any>;
359
+ getAbiHash(abi: unknown): Promise<any>;
280
360
  setAlertName(_triggerId: number, _name: string): Promise<void>;
281
361
  enableAlert(_triggerId: number): Promise<void>;
282
362
  disableAlert(_triggerId: number): Promise<void>;
@@ -300,55 +380,8 @@ export declare class AlertBuilder {
300
380
  * @param options Desired trigger configuration
301
381
  * @returns self for piping
302
382
  */
303
- withTrigger<TTriggerTypeId extends TriggerTypeId>(id: TTriggerTypeId, options: TTriggerTypeId extends "PollFunctionV2" ? PollFunctionV2 : TTriggerTypeId extends "OnchainEventV1" ? OnchainEventV1 : TTriggerTypeId extends "PollFunctionV1" ? PollFunctionV1 : never): AlertBuilder;
304
- withNotification<TNotificationTypeId extends NotificationTypeId>(id: TNotificationTypeId, options: TNotificationTypeId extends "Discord" ? DiscordWebhook : never): AlertBuilder;
305
- validate(): Promise<{
306
- username?: string | undefined;
307
- avatar_url?: string | undefined;
308
- message: string;
309
- url: string;
310
- } | {
311
- condition?: string | undefined;
312
- nBlocks?: number | undefined;
313
- constant?: number | undefined;
314
- responseArgIndex?: number | undefined;
315
- responseArgDecimals?: number | undefined;
316
- address: string;
317
- abi: any[];
318
- } | {
319
- condition?: string | undefined;
320
- constant?: number | undefined;
321
- paramsIndex?: number | undefined;
322
- paramsDecimals?: number | undefined;
323
- address: string;
324
- event: string;
325
- abi: any[];
326
- } | {
327
- filter?: {
328
- conditions?: {
329
- constant?: {} | undefined;
330
- operation?: string | undefined;
331
- type: NonNullable<"String" | "Address" | "Number" | undefined>;
332
- key: string;
333
- logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
334
- }[] | undefined;
335
- logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
336
- }[] | undefined;
337
- nBlocks?: number | undefined;
338
- timePeriod?: string | undefined;
339
- debounceCount?: number | undefined;
340
- functions?: {
341
- function: string;
342
- address: string;
343
- bytecode: string;
344
- abiHash: string;
345
- }[] | undefined;
346
- filterVersion?: string | undefined;
347
- startTime: number;
348
- latch: boolean;
349
- timeBase: NonNullable<"time" | "blocks" | undefined>;
350
- triggerOn: "filter" | "always";
351
- }>;
383
+ withTrigger<TTriggerTypeId extends TriggerTypeId>(id: TTriggerTypeId, options: TTriggerTypeId extends "PollFunctionV2" ? PollFunctionV2 : TTriggerTypeId extends "OnchainEventV2" ? OnchainEventV2 : TTriggerTypeId extends "PollFunctionV1" ? PollFunctionV1 : TTriggerTypeId extends "OnchainEventV1" ? OnchainEventV1 : never): AlertBuilder;
384
+ withNotification<TNotificationTypeId extends NotificationTypeId>(id: TNotificationTypeId, options: TNotificationTypeId extends "Discord" ? DiscordWebhook : TNotificationTypeId extends "Telegram" ? Telegram : TNotificationTypeId extends "Email" ? Email : never): AlertBuilder;
352
385
  config(): Promise<AlertConfig>;
353
386
  }
354
387