denotify-client 1.1.4 → 1.1.5
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/dist/alertbuilder.js +24 -1
- package/dist/examples/balance-monitor.js +47 -0
- package/dist/functionbuilder.js +9 -0
- package/dist/index.js +303 -164
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +284 -164
- package/dist/notifications/notify_discord_webhook.js +11 -0
- package/dist/triggers/handler_function_call.js +14 -0
- package/dist/triggers/handler_function_call_v2.js +29 -0
- package/dist/triggers/handler_onchain_event.js +16 -0
- package/dist/triggers/trigger.js +1 -1
- package/dist/util/filter.js +29 -0
- package/package.json +6 -4
- package/types/alertbuilder.d.ts +57 -3
- package/types/examples/aave-healthcheck.d.ts +1 -1
- package/types/examples/balance-monitor.d.ts +1 -0
- package/types/functionbuilder.d.ts +7 -0
- package/types/notifications/notify_discord_webhook.d.ts +6 -0
- package/types/triggers/handler_function_call.d.ts +9 -0
- package/types/triggers/handler_function_call_v2.d.ts +26 -0
- package/types/triggers/handler_onchain_event.d.ts +11 -1
- package/types/triggers/trigger.d.ts +1 -1
- package/types/util/filter.d.ts +11 -0
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "1.1.
|
2
|
+
"version": "1.1.5",
|
3
3
|
"name": "denotify-client",
|
4
4
|
"umd:name": "denotify-client",
|
5
5
|
"repository": "robo-labs/denotify-client",
|
@@ -52,14 +52,16 @@
|
|
52
52
|
"rollup-plugin-terser": "7.0.2",
|
53
53
|
"rollup-plugin-typescript2": "0.27.1",
|
54
54
|
"tsm": "2.2.1",
|
55
|
-
"
|
56
|
-
"
|
55
|
+
"typescript": "^4.9.5",
|
56
|
+
"uvu": "0.5.3"
|
57
57
|
},
|
58
58
|
"dependencies": {
|
59
59
|
"@supabase/supabase-js": "^2.10.0",
|
60
60
|
"@types/axios": "^0.14.0",
|
61
61
|
"axois": "^0.0.1-security",
|
62
62
|
"ethers": "^6.0.8",
|
63
|
-
"
|
63
|
+
"ts-node": "^10.9.1",
|
64
|
+
"typescript": "^4.9.5",
|
65
|
+
"yup": "^1.0.2"
|
64
66
|
}
|
65
67
|
}
|
package/types/alertbuilder.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { NotificationConfig, NotificationTypeId } from "./notifications/notification.js";
|
2
|
-
import { Network,
|
2
|
+
import { Network, TriggerTypeId } from "./triggers/trigger.js";
|
3
3
|
import { AlertConfig } from "./types/types.js";
|
4
4
|
export declare class AlertBuilder {
|
5
5
|
private name;
|
@@ -11,7 +11,61 @@ export declare class AlertBuilder {
|
|
11
11
|
private constructor();
|
12
12
|
static create(name: string): AlertBuilder;
|
13
13
|
onNetwork(network: Network): AlertBuilder;
|
14
|
-
|
14
|
+
/**
|
15
|
+
* Call withTrigger with one of the TriggerConfig types:
|
16
|
+
* PollFunctionV2 | PollFunctionV1 | OnchainEventV1
|
17
|
+
* @param id Simple ID
|
18
|
+
* @param options Desired trigger configuration
|
19
|
+
* @returns self for piping
|
20
|
+
*/
|
21
|
+
withTrigger<T>(id: TriggerTypeId, options: T): AlertBuilder;
|
15
22
|
withNotification<T = NotificationConfig>(id: NotificationTypeId, options: T): AlertBuilder;
|
16
|
-
|
23
|
+
validate(): Promise<{
|
24
|
+
condition?: string | undefined;
|
25
|
+
constant?: number | undefined;
|
26
|
+
paramsIndex?: number | undefined;
|
27
|
+
paramsDecimals?: number | undefined;
|
28
|
+
address: string;
|
29
|
+
event: string;
|
30
|
+
abi: any[];
|
31
|
+
} | {
|
32
|
+
condition?: string | undefined;
|
33
|
+
constant?: number | undefined;
|
34
|
+
nBlocks?: number | undefined;
|
35
|
+
responseArgIndex?: number | undefined;
|
36
|
+
responseArgDecimals?: number | undefined;
|
37
|
+
address: string;
|
38
|
+
abi: any[];
|
39
|
+
} | {
|
40
|
+
nBlocks?: number | undefined;
|
41
|
+
timePeriod?: string | undefined;
|
42
|
+
debounceCount?: number | undefined;
|
43
|
+
functions?: {
|
44
|
+
function: string;
|
45
|
+
address: string;
|
46
|
+
bytecode: string;
|
47
|
+
abiHash: string;
|
48
|
+
}[] | undefined;
|
49
|
+
filter?: {
|
50
|
+
conditions?: {
|
51
|
+
constant?: {} | undefined;
|
52
|
+
operation?: string | undefined;
|
53
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
54
|
+
key: string;
|
55
|
+
type: NonNullable<"String" | "Address" | "Number" | undefined>;
|
56
|
+
}[] | undefined;
|
57
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
58
|
+
}[] | undefined;
|
59
|
+
filterVersion?: string | undefined;
|
60
|
+
timeBase: NonNullable<"blocks" | "time" | undefined>;
|
61
|
+
startTime: number;
|
62
|
+
triggerOn: "always" | "filter";
|
63
|
+
latch: boolean;
|
64
|
+
} | {
|
65
|
+
username?: string | undefined;
|
66
|
+
avatar_url?: string | undefined;
|
67
|
+
message: string;
|
68
|
+
url: string;
|
69
|
+
} | undefined>;
|
70
|
+
config(): Promise<AlertConfig>;
|
17
71
|
}
|
@@ -1 +1 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { DeNotifyClient } from "./denotifyclient.js";
|
2
|
+
import * as yup from 'yup';
|
2
3
|
export type FunctionCallerConfig = {
|
3
4
|
address: string;
|
4
5
|
bytecode: string;
|
@@ -13,4 +14,10 @@ export declare class FunctionBuilder {
|
|
13
14
|
getAbiHash(abi: any): Promise<string>;
|
14
15
|
addFunction<T = any>(address: string, func: string, args: T[], abi: any): Promise<this>;
|
15
16
|
get(): FunctionCallerConfig;
|
17
|
+
static schema(): yup.ArraySchema<{
|
18
|
+
function: string;
|
19
|
+
address: string;
|
20
|
+
bytecode: string;
|
21
|
+
abiHash: string;
|
22
|
+
}[] | undefined, yup.AnyObject, "", "">;
|
16
23
|
}
|
@@ -29,4 +29,10 @@ export type NotifyDiscordWebhookRawUpdate = {
|
|
29
29
|
};
|
30
30
|
export declare class NotifyDiscordWebhook {
|
31
31
|
static SimpleToRaw(config: DiscordWebhook): NotificationRawConfig;
|
32
|
+
static validateCreate(options: any): Promise<{
|
33
|
+
username?: string | undefined;
|
34
|
+
avatar_url?: string | undefined;
|
35
|
+
message: string;
|
36
|
+
url: string;
|
37
|
+
}>;
|
32
38
|
}
|
@@ -50,4 +50,13 @@ export type HandlerFunctionCallRawUpdate = {
|
|
50
50
|
};
|
51
51
|
export declare class HandlerFunctionCall {
|
52
52
|
static SimpleToRaw(name: string, network: Network, config: PollFunctionV1): TriggerRawConfig;
|
53
|
+
static validateCreate(options: any): Promise<{
|
54
|
+
condition?: string | undefined;
|
55
|
+
nBlocks?: number | undefined;
|
56
|
+
constant?: number | undefined;
|
57
|
+
responseArgIndex?: number | undefined;
|
58
|
+
responseArgDecimals?: number | undefined;
|
59
|
+
address: string;
|
60
|
+
abi: any[];
|
61
|
+
}>;
|
53
62
|
}
|
@@ -61,5 +61,31 @@ export type HandlerFunctionCallV2RawUpdate = {
|
|
61
61
|
};
|
62
62
|
export declare class HandlerFunctionCallV2 {
|
63
63
|
static SimpleToRaw(name: string, network: Network, config: PollFunctionV2): TriggerRawConfig;
|
64
|
+
static validateCreate(options: any): Promise<{
|
65
|
+
filter?: {
|
66
|
+
conditions?: {
|
67
|
+
operation?: string | undefined;
|
68
|
+
constant?: {} | undefined;
|
69
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
70
|
+
key: string;
|
71
|
+
type: NonNullable<"String" | "Address" | "Number" | undefined>;
|
72
|
+
}[] | undefined;
|
73
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
74
|
+
}[] | undefined;
|
75
|
+
nBlocks?: number | undefined;
|
76
|
+
timePeriod?: string | undefined;
|
77
|
+
debounceCount?: number | undefined;
|
78
|
+
functions?: {
|
79
|
+
function: string;
|
80
|
+
address: string;
|
81
|
+
bytecode: string;
|
82
|
+
abiHash: string;
|
83
|
+
}[] | undefined;
|
84
|
+
filterVersion?: string | undefined;
|
85
|
+
latch: boolean;
|
86
|
+
timeBase: NonNullable<"blocks" | "time" | undefined>;
|
87
|
+
startTime: number;
|
88
|
+
triggerOn: "always" | "filter";
|
89
|
+
}>;
|
64
90
|
}
|
65
91
|
export {};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Condition } from "../util/filter.js";
|
2
1
|
import { Network, TriggerRawConfig } from "./trigger.js";
|
2
|
+
import { Condition } from "../types/types.js";
|
3
3
|
export type OnchainEventV1 = {
|
4
4
|
address: string;
|
5
5
|
event: string;
|
@@ -40,4 +40,14 @@ export type HandlerOnchainEventRawUpdate = {
|
|
40
40
|
};
|
41
41
|
export declare class HandlerOnchainEvent {
|
42
42
|
static SimpleToRaw(name: string, network: Network, config: OnchainEventV1): TriggerRawConfig;
|
43
|
+
static validateCreate(options: any): Promise<{
|
44
|
+
condition?: string | undefined;
|
45
|
+
constant?: number | undefined;
|
46
|
+
paramsIndex?: number | undefined;
|
47
|
+
paramsDecimals?: number | undefined;
|
48
|
+
event: string;
|
49
|
+
address: string;
|
50
|
+
abi: any[];
|
51
|
+
}>;
|
52
|
+
static validateUpdate(options: any): void;
|
43
53
|
}
|
@@ -3,7 +3,7 @@ import { HandlerOnchainEventRawConfig, HandlerOnchainEventUpdate, OnchainEventV1
|
|
3
3
|
import { HandlerFunctionCallV2RawConfig, HandlerFunctionCallV2Update, PollFunctionV2 } from "./handler_function_call_v2.js";
|
4
4
|
export type Network = 'avalanche' | 'ethereum';
|
5
5
|
export type TriggerConfig = PollFunctionV2 | PollFunctionV1 | OnchainEventV1;
|
6
|
-
export type TriggerTypeId = 'PollFunctionV2' | '
|
6
|
+
export type TriggerTypeId = 'PollFunctionV2' | 'OnchainEventV1' | 'PollFunctionV1';
|
7
7
|
export type TriggerUpdate = HandlerFunctionCallV2Update | HandlerFunctionCallUpdate | HandlerOnchainEventUpdate;
|
8
8
|
export type TriggerTypeRawId = 'handler_function_call' | 'handler_onchain_event' | 'handler_function_call_v2';
|
9
9
|
export type TriggerOn = 'event' | 'latch';
|
package/types/util/filter.d.ts
CHANGED
@@ -4,6 +4,7 @@ type StringOperation = 'contains' | '!contains' | 'is' | '!is' | 'isEmpty' | '!i
|
|
4
4
|
type AddressOperation = 'is' | '!is' | 'isEmpty' | '!isEmpty';
|
5
5
|
type FilterDataTypes = 'String' | 'Address' | 'Number';
|
6
6
|
type FilterOpertationType = NumericOperation | StringOperation | AddressOperation;
|
7
|
+
import * as yup from 'yup';
|
7
8
|
export type Condition = {
|
8
9
|
logic?: Logic;
|
9
10
|
key: string;
|
@@ -31,5 +32,15 @@ export declare class FilterBuilder {
|
|
31
32
|
newGroup(logic: Logic): FilterBuilder;
|
32
33
|
addCondition(logic: Logic, key: string, type: FilterDataTypes, operation: FilterOpertationType, constant: string | number): FilterBuilder;
|
33
34
|
finalise(): ConditionGroup[];
|
35
|
+
static schema(): yup.ArraySchema<{
|
36
|
+
conditions?: {
|
37
|
+
operation?: string | undefined;
|
38
|
+
constant?: {} | undefined;
|
39
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
40
|
+
key: string;
|
41
|
+
type: NonNullable<"String" | "Address" | "Number" | undefined>;
|
42
|
+
}[] | undefined;
|
43
|
+
logic: NonNullable<"AND" | "OR" | "XOR" | "NAND" | "NOR" | "WHERE" | undefined>;
|
44
|
+
}[] | undefined, yup.AnyObject, "", "">;
|
34
45
|
}
|
35
46
|
export {};
|