@avaprotocol/sdk-js 1.6.4 → 1.6.6
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 +16 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +502 -267
- package/dist/index.mjs +519 -280
- package/dist/models/node/factory.js +2 -2
- package/dist/models/node/interface.d.ts +8 -1
- package/dist/models/node/interface.d.ts.map +1 -1
- package/dist/models/node/interface.js +16 -2
- package/dist/models/trigger/interface.d.ts +1 -1
- package/dist/models/trigger/interface.d.ts.map +1 -1
- package/dist/models/trigger/reason.d.ts +1 -1
- package/dist/models/trigger/reason.d.ts.map +1 -1
- package/dist/models/trigger/reason.js +14 -14
- package/package.json +2 -2
|
@@ -31,8 +31,8 @@ class NodeFactory {
|
|
|
31
31
|
return new FilterNode(props);
|
|
32
32
|
case NodeType.Loop:
|
|
33
33
|
return new LoopNode(props);
|
|
34
|
-
case NodeType.
|
|
35
|
-
throw new Error("Cannot create node with
|
|
34
|
+
case NodeType.Unspecified:
|
|
35
|
+
throw new Error("Cannot create node with unspecified type");
|
|
36
36
|
default:
|
|
37
37
|
throw new Error(`Unsupported node type: ${props.type}`);
|
|
38
38
|
}
|
|
@@ -2,10 +2,17 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
|
2
2
|
import { NodeType } from "@avaprotocol/types";
|
|
3
3
|
export declare function covertNodeTypeToString(status: avs_pb.TaskNode.TaskTypeCase): NodeType;
|
|
4
4
|
export type NodeData = avs_pb.ETHTransferNode.AsObject | avs_pb.ContractWriteNode.AsObject | avs_pb.ContractReadNode.AsObject | avs_pb.GraphQLQueryNode.AsObject | avs_pb.RestAPINode.AsObject | avs_pb.BranchNode.AsObject | avs_pb.FilterNode.AsObject | avs_pb.LoopNode.AsObject | avs_pb.CustomCodeNode.AsObject;
|
|
5
|
-
export type NodeProps = Omit<avs_pb.TaskNode.AsObject, "ethTransfer" | "contractWrite" | "contractRead" | "graphqlDataQuery" | "restApi" | "branch" | "filter" | "loop" | "customCode"> & {
|
|
5
|
+
export type NodeProps = Omit<avs_pb.TaskNode.AsObject, "ethTransfer" | "contractWrite" | "contractRead" | "graphqlDataQuery" | "restApi" | "branch" | "filter" | "loop" | "customCode" | "type"> & {
|
|
6
6
|
type: NodeType;
|
|
7
7
|
data: NodeData;
|
|
8
8
|
};
|
|
9
|
+
export type ProtobufNodeProps = Omit<avs_pb.TaskNode.AsObject, "ethTransfer" | "contractWrite" | "contractRead" | "graphqlDataQuery" | "restApi" | "branch" | "filter" | "loop" | "customCode"> & {
|
|
10
|
+
data: NodeData;
|
|
11
|
+
};
|
|
12
|
+
export declare const ProtobufNodePropsUtils: {
|
|
13
|
+
getGoStringType: (props: ProtobufNodeProps) => string;
|
|
14
|
+
fromGoStringType: (goStringType: string, baseProps: Omit<ProtobufNodeProps, "type">) => ProtobufNodeProps;
|
|
15
|
+
};
|
|
9
16
|
declare class Node implements NodeProps {
|
|
10
17
|
id: string;
|
|
11
18
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/node/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/node/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAA0C,MAAM,oBAAoB,CAAC;AAItF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,GACnC,QAAQ,CAeV;AAED,MAAM,MAAM,QAAQ,GAChB,MAAM,CAAC,eAAe,CAAC,QAAQ,GAC/B,MAAM,CAAC,iBAAiB,CAAC,QAAQ,GACjC,MAAM,CAAC,gBAAg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-
import { NodeType } from "@avaprotocol/types";
|
|
2
|
+
import { NodeType, NodeTypeGoConverter } from "@avaprotocol/types";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
// Function to convert TaskStatus to string
|
|
5
5
|
export function covertNodeTypeToString(status) {
|
|
@@ -13,10 +13,24 @@ export function covertNodeTypeToString(status) {
|
|
|
13
13
|
[avs_pb.TaskNode.TaskTypeCase.FILTER]: NodeType.Filter,
|
|
14
14
|
[avs_pb.TaskNode.TaskTypeCase.LOOP]: NodeType.Loop,
|
|
15
15
|
[avs_pb.TaskNode.TaskTypeCase.CUSTOM_CODE]: NodeType.CustomCode,
|
|
16
|
-
[avs_pb.TaskNode.TaskTypeCase.TASK_TYPE_NOT_SET]: NodeType.
|
|
16
|
+
[avs_pb.TaskNode.TaskTypeCase.TASK_TYPE_NOT_SET]: NodeType.Unspecified,
|
|
17
17
|
};
|
|
18
18
|
return conversionMap[status];
|
|
19
19
|
}
|
|
20
|
+
// Utility functions to work with protobuf NodeProps
|
|
21
|
+
export const ProtobufNodePropsUtils = {
|
|
22
|
+
// Get the Go backend string representation of the node type
|
|
23
|
+
getGoStringType: (props) => {
|
|
24
|
+
return NodeTypeGoConverter.toGoString(props.type);
|
|
25
|
+
},
|
|
26
|
+
// Create ProtobufNodeProps from Go string type
|
|
27
|
+
fromGoStringType: (goStringType, baseProps) => {
|
|
28
|
+
return {
|
|
29
|
+
...baseProps,
|
|
30
|
+
type: NodeTypeGoConverter.fromGoString(goStringType)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
20
34
|
class Node {
|
|
21
35
|
constructor(props) {
|
|
22
36
|
this.id = props.id;
|
|
@@ -2,7 +2,7 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
|
2
2
|
import { TriggerType } from "@avaprotocol/types";
|
|
3
3
|
export type TriggerData = avs_pb.FixedTimeTrigger.AsObject | avs_pb.CronTrigger.AsObject | avs_pb.BlockTrigger.AsObject | avs_pb.EventTrigger.AsObject | Record<string, any> | null;
|
|
4
4
|
export type TriggerOutput = avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.BlockTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | null;
|
|
5
|
-
export type TriggerProps = Omit<avs_pb.TaskTrigger.AsObject, "manual" | "fixedTime" | "cron" | "block" | "event"> & {
|
|
5
|
+
export type TriggerProps = Omit<avs_pb.TaskTrigger.AsObject, "manual" | "fixedTime" | "cron" | "block" | "event" | "type"> & {
|
|
6
6
|
type: TriggerType;
|
|
7
7
|
data: TriggerData;
|
|
8
8
|
output?: TriggerOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,GACvC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,GAClC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,IAAI,CAAC;AAET,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,MAAM,CAAC,WAAW,CAAC,QAAQ,EAC3B,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,
|
|
1
|
+
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Ae,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reason.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/reason.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"reason.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/reason.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,WAAW,CAAC,WAAW,CAAA;CAAE,CAAC;AAoBtC,cAAM,aAAa;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEJ,KAAK,EAAE,kBAAkB;IAyBrC,MAAM,CAAC,YAAY,CACjB,IAAI,EAAE,MAAM,CAAC,aAAa,GAAG,SAAS,GACrC,aAAa,GAAG,SAAS;IAc5B,SAAS,IAAI,MAAM,CAAC,aAAa;CA8ClC;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,12 +3,12 @@ import { TriggerType } from "@avaprotocol/types";
|
|
|
3
3
|
// Convert the number values of gRPC TriggerType to string values of TriggerType
|
|
4
4
|
const convertTriggerType = (grpcType) => {
|
|
5
5
|
const conversionMap = {
|
|
6
|
-
[avs_pb.
|
|
7
|
-
[avs_pb.
|
|
8
|
-
[avs_pb.
|
|
9
|
-
[avs_pb.
|
|
10
|
-
[avs_pb.
|
|
11
|
-
[avs_pb.
|
|
6
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_FIXED_TIME]: TriggerType.FixedTime,
|
|
7
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_CRON]: TriggerType.Cron,
|
|
8
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_BLOCK]: TriggerType.Block,
|
|
9
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_EVENT]: TriggerType.Event,
|
|
10
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_MANUAL]: TriggerType.Manual,
|
|
11
|
+
[avs_pb.TriggerType.TRIGGER_TYPE_UNSPECIFIED]: TriggerType.Unspecified,
|
|
12
12
|
};
|
|
13
13
|
return conversionMap[grpcType];
|
|
14
14
|
};
|
|
@@ -30,7 +30,7 @@ class TriggerReason {
|
|
|
30
30
|
this.txHash = props.txHash;
|
|
31
31
|
break;
|
|
32
32
|
case TriggerType.Manual:
|
|
33
|
-
case TriggerType.
|
|
33
|
+
case TriggerType.Unspecified:
|
|
34
34
|
break;
|
|
35
35
|
default:
|
|
36
36
|
throw new Error("Unsupported trigger type");
|
|
@@ -52,25 +52,25 @@ class TriggerReason {
|
|
|
52
52
|
const request = new avs_pb.TriggerReason();
|
|
53
53
|
switch (this.type) {
|
|
54
54
|
case TriggerType.FixedTime:
|
|
55
|
-
request.setType(avs_pb.
|
|
55
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_FIXED_TIME);
|
|
56
56
|
if (this.epoch) {
|
|
57
57
|
request.setEpoch(this.epoch);
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
case TriggerType.Cron:
|
|
61
|
-
request.setType(avs_pb.
|
|
61
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_CRON);
|
|
62
62
|
if (this.epoch) {
|
|
63
63
|
request.setEpoch(this.epoch);
|
|
64
64
|
}
|
|
65
65
|
break;
|
|
66
66
|
case TriggerType.Block:
|
|
67
|
-
request.setType(avs_pb.
|
|
67
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_BLOCK);
|
|
68
68
|
if (this.blockNumber) {
|
|
69
69
|
request.setBlockNumber(this.blockNumber);
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
72
|
case TriggerType.Event:
|
|
73
|
-
request.setType(avs_pb.
|
|
73
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_EVENT);
|
|
74
74
|
if (this.blockNumber) {
|
|
75
75
|
request.setBlockNumber(this.blockNumber);
|
|
76
76
|
}
|
|
@@ -82,10 +82,10 @@ class TriggerReason {
|
|
|
82
82
|
}
|
|
83
83
|
break;
|
|
84
84
|
case TriggerType.Manual:
|
|
85
|
-
request.setType(avs_pb.
|
|
85
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_MANUAL);
|
|
86
86
|
break;
|
|
87
|
-
case TriggerType.
|
|
88
|
-
request.setType(avs_pb.
|
|
87
|
+
case TriggerType.Unspecified:
|
|
88
|
+
request.setType(avs_pb.TriggerType.TRIGGER_TYPE_UNSPECIFIED);
|
|
89
89
|
break;
|
|
90
90
|
default:
|
|
91
91
|
throw new Error("Unsupported trigger type");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf node_modules dist tsconfig.tsbuildinfo"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@avaprotocol/types": "1.0.
|
|
33
|
+
"@avaprotocol/types": "1.0.6",
|
|
34
34
|
"@grpc/grpc-js": "^1.11.3",
|
|
35
35
|
"@grpc/proto-loader": "^0.7.13",
|
|
36
36
|
"dotenv": "^16.4.5",
|