@avaprotocol/sdk-js 2.17.0 → 4.0.0-dev.1
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/index.d.ts +1 -370
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +842 -22377
- package/dist/index.mjs +806 -22409
- package/dist/v4/auth.d.ts +54 -0
- package/dist/v4/auth.d.ts.map +1 -0
- package/dist/v4/auth.js +70 -0
- package/dist/v4/builders/nodes.d.ts +106 -0
- package/dist/v4/builders/nodes.d.ts.map +1 -0
- package/dist/v4/builders/nodes.js +133 -0
- package/dist/v4/builders/triggers.d.ts +66 -0
- package/dist/v4/builders/triggers.d.ts.map +1 -0
- package/dist/v4/builders/triggers.js +74 -0
- package/dist/v4/chains.d.ts +16 -0
- package/dist/v4/chains.d.ts.map +1 -0
- package/dist/v4/chains.js +23 -0
- package/dist/v4/client.d.ts +60 -0
- package/dist/v4/client.d.ts.map +1 -0
- package/dist/v4/client.js +53 -0
- package/dist/v4/index.d.ts +18 -0
- package/dist/v4/index.d.ts.map +1 -0
- package/dist/v4/index.js +23 -0
- package/dist/v4/internal/errors.d.ts +36 -0
- package/dist/v4/internal/errors.d.ts.map +1 -0
- package/dist/v4/internal/errors.js +32 -0
- package/dist/v4/internal/transport.d.ts +64 -0
- package/dist/v4/internal/transport.d.ts.map +1 -0
- package/dist/v4/internal/transport.js +133 -0
- package/dist/v4/resources/auth.d.ts +39 -0
- package/dist/v4/resources/auth.d.ts.map +1 -0
- package/dist/v4/resources/auth.js +53 -0
- package/dist/v4/resources/executions.d.ts +74 -0
- package/dist/v4/resources/executions.d.ts.map +1 -0
- package/dist/v4/resources/executions.js +132 -0
- package/dist/v4/resources/health.d.ts +19 -0
- package/dist/v4/resources/health.d.ts.map +1 -0
- package/dist/v4/resources/health.js +19 -0
- package/dist/v4/resources/nodes.d.ts +29 -0
- package/dist/v4/resources/nodes.d.ts.map +1 -0
- package/dist/v4/resources/nodes.js +33 -0
- package/dist/v4/resources/operators.d.ts +23 -0
- package/dist/v4/resources/operators.d.ts.map +1 -0
- package/dist/v4/resources/operators.js +23 -0
- package/dist/v4/resources/secrets.d.ts +34 -0
- package/dist/v4/resources/secrets.d.ts.map +1 -0
- package/dist/v4/resources/secrets.js +38 -0
- package/dist/v4/resources/tokens.d.ts +28 -0
- package/dist/v4/resources/tokens.d.ts.map +1 -0
- package/dist/v4/resources/tokens.js +29 -0
- package/dist/v4/resources/triggers.d.ts +29 -0
- package/dist/v4/resources/triggers.d.ts.map +1 -0
- package/dist/v4/resources/triggers.js +33 -0
- package/dist/v4/resources/wallets.d.ts +72 -0
- package/dist/v4/resources/wallets.d.ts.map +1 -0
- package/dist/v4/resources/wallets.js +92 -0
- package/dist/v4/resources/workflows.d.ts +64 -0
- package/dist/v4/resources/workflows.d.ts.map +1 -0
- package/dist/v4/resources/workflows.js +91 -0
- package/package.json +8 -11
- package/dist/auth.d.ts +0 -2
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -10
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -19
- package/dist/models/edge.d.ts +0 -12
- package/dist/models/edge.d.ts.map +0 -1
- package/dist/models/edge.js +0 -19
- package/dist/models/execution.d.ts +0 -30
- package/dist/models/execution.d.ts.map +0 -1
- package/dist/models/execution.js +0 -100
- package/dist/models/node/balance.d.ts +0 -17
- package/dist/models/node/balance.d.ts.map +0 -1
- package/dist/models/node/balance.js +0 -78
- package/dist/models/node/branch.d.ts +0 -11
- package/dist/models/node/branch.d.ts.map +0 -1
- package/dist/models/node/branch.js +0 -63
- package/dist/models/node/contractRead.d.ts +0 -17
- package/dist/models/node/contractRead.d.ts.map +0 -1
- package/dist/models/node/contractRead.js +0 -91
- package/dist/models/node/contractWrite.d.ts +0 -17
- package/dist/models/node/contractWrite.d.ts.map +0 -1
- package/dist/models/node/contractWrite.js +0 -102
- package/dist/models/node/customCode.d.ts +0 -20
- package/dist/models/node/customCode.d.ts.map +0 -1
- package/dist/models/node/customCode.js +0 -74
- package/dist/models/node/ethTransfer.d.ts +0 -20
- package/dist/models/node/ethTransfer.d.ts.map +0 -1
- package/dist/models/node/ethTransfer.js +0 -58
- package/dist/models/node/factory.d.ts +0 -24
- package/dist/models/node/factory.d.ts.map +0 -1
- package/dist/models/node/factory.js +0 -108
- package/dist/models/node/filter.d.ts +0 -11
- package/dist/models/node/filter.d.ts.map +0 -1
- package/dist/models/node/filter.js +0 -57
- package/dist/models/node/graphqlQuery.d.ts +0 -21
- package/dist/models/node/graphqlQuery.d.ts.map +0 -1
- package/dist/models/node/graphqlQuery.js +0 -74
- package/dist/models/node/interface.d.ts +0 -20
- package/dist/models/node/interface.d.ts.map +0 -1
- package/dist/models/node/interface.js +0 -58
- package/dist/models/node/loop.d.ts +0 -15
- package/dist/models/node/loop.d.ts.map +0 -1
- package/dist/models/node/loop.js +0 -235
- package/dist/models/node/restApi.d.ts +0 -23
- package/dist/models/node/restApi.d.ts.map +0 -1
- package/dist/models/node/restApi.js +0 -84
- package/dist/models/secret.d.ts +0 -16
- package/dist/models/secret.d.ts.map +0 -1
- package/dist/models/secret.js +0 -28
- package/dist/models/step.d.ts +0 -33
- package/dist/models/step.d.ts.map +0 -1
- package/dist/models/step.js +0 -287
- package/dist/models/trigger/block.d.ts +0 -21
- package/dist/models/trigger/block.d.ts.map +0 -1
- package/dist/models/trigger/block.js +0 -81
- package/dist/models/trigger/cron.d.ts +0 -23
- package/dist/models/trigger/cron.d.ts.map +0 -1
- package/dist/models/trigger/cron.js +0 -77
- package/dist/models/trigger/event.d.ts +0 -22
- package/dist/models/trigger/event.d.ts.map +0 -1
- package/dist/models/trigger/event.js +0 -244
- package/dist/models/trigger/factory.d.ts +0 -27
- package/dist/models/trigger/factory.d.ts.map +0 -1
- package/dist/models/trigger/factory.js +0 -73
- package/dist/models/trigger/fixedTime.d.ts +0 -23
- package/dist/models/trigger/fixedTime.d.ts.map +0 -1
- package/dist/models/trigger/fixedTime.js +0 -69
- package/dist/models/trigger/interface.d.ts +0 -19
- package/dist/models/trigger/interface.d.ts.map +0 -1
- package/dist/models/trigger/interface.js +0 -35
- package/dist/models/trigger/manual.d.ts +0 -16
- package/dist/models/trigger/manual.d.ts.map +0 -1
- package/dist/models/trigger/manual.js +0 -117
- package/dist/models/workflow.d.ts +0 -53
- package/dist/models/workflow.d.ts.map +0 -1
- package/dist/models/workflow.js +0 -219
- package/dist/utils.d.ts +0 -82
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -286
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
2
|
-
import Node from "./interface";
|
|
3
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { conditions }
|
|
6
|
-
class BranchNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.Branch, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
static fromResponse(raw) {
|
|
11
|
-
// Convert the raw object to BranchNodeProps, which should keep name and id
|
|
12
|
-
const obj = raw.toObject();
|
|
13
|
-
const protobufData = raw.getBranch().toObject().config;
|
|
14
|
-
// Convert protobuf data to our custom interface
|
|
15
|
-
const data = {
|
|
16
|
-
conditions: protobufData?.conditionsList?.map((condition) => ({
|
|
17
|
-
id: condition.id,
|
|
18
|
-
type: condition.type,
|
|
19
|
-
expression: condition.expression,
|
|
20
|
-
})) || [],
|
|
21
|
-
};
|
|
22
|
-
return new BranchNode({
|
|
23
|
-
...obj,
|
|
24
|
-
type: NodeType.Branch,
|
|
25
|
-
data: data,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
toRequest() {
|
|
29
|
-
const request = new avs_pb.TaskNode();
|
|
30
|
-
request.setId(this.id);
|
|
31
|
-
request.setName(this.name);
|
|
32
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_BRANCH);
|
|
33
|
-
const node = new avs_pb.BranchNode();
|
|
34
|
-
const config = new avs_pb.BranchNode.Config();
|
|
35
|
-
if (this.data.conditions &&
|
|
36
|
-
this.data.conditions.length > 0) {
|
|
37
|
-
const conditionsList = this.data.conditions.map((condition) => {
|
|
38
|
-
const conditionObj = new avs_pb.BranchNode.Condition();
|
|
39
|
-
conditionObj.setId(condition.id);
|
|
40
|
-
conditionObj.setType(condition.type);
|
|
41
|
-
conditionObj.setExpression(condition.expression);
|
|
42
|
-
return conditionObj;
|
|
43
|
-
});
|
|
44
|
-
config.setConditionsList(conditionsList);
|
|
45
|
-
}
|
|
46
|
-
node.setConfig(config);
|
|
47
|
-
request.setBranch(node);
|
|
48
|
-
return request;
|
|
49
|
-
}
|
|
50
|
-
static fromOutputData(outputData) {
|
|
51
|
-
const branchOutput = outputData.getBranch();
|
|
52
|
-
if (!branchOutput) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
// Use convertProtobufValueToJs to get clean JavaScript objects
|
|
56
|
-
const rawData = branchOutput.getData();
|
|
57
|
-
if (rawData) {
|
|
58
|
-
return convertProtobufValueToJs(rawData);
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export default BranchNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractReadNodeData, ContractReadNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class ContractReadNode extends Node {
|
|
5
|
-
constructor(props: ContractReadNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf ContractReadNode from config data
|
|
8
|
-
* @param configData - The configuration data for the contract read node
|
|
9
|
-
* @returns Configured avs_pb.ContractReadNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: ContractReadNodeData): avs_pb.ContractReadNode;
|
|
12
|
-
static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
|
|
13
|
-
toRequest(): avs_pb.TaskNode;
|
|
14
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown | null;
|
|
15
|
-
}
|
|
16
|
-
export default ContractReadNode;
|
|
17
|
-
//# sourceMappingURL=contractRead.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contractRead.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractRead.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAAC,gBAAgB;IAuC1B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IA8B3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,OAAO,GAAG,IAAI;CAUlB;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
4
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
5
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
6
|
-
// Required props for constructor: id, name, type and data
|
|
7
|
-
class ContractReadNode extends Node {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super({ ...props, type: NodeType.ContractRead, data: props.data });
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create a protobuf ContractReadNode from config data
|
|
13
|
-
* @param configData - The configuration data for the contract read node
|
|
14
|
-
* @returns Configured avs_pb.ContractReadNode
|
|
15
|
-
*/
|
|
16
|
-
static createProtobufNode(configData) {
|
|
17
|
-
const node = new avs_pb.ContractReadNode();
|
|
18
|
-
const config = new avs_pb.ContractReadNode.Config();
|
|
19
|
-
config.setContractAddress(configData.contractAddress);
|
|
20
|
-
// Convert array to protobuf Value list
|
|
21
|
-
const abiValueList = configData.contractAbi.map((item) => {
|
|
22
|
-
const value = new google_protobuf_struct_pb.Value();
|
|
23
|
-
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
24
|
-
return value;
|
|
25
|
-
});
|
|
26
|
-
config.setContractAbiList(abiValueList);
|
|
27
|
-
// Handle method calls array (now required)
|
|
28
|
-
const methodCalls = configData.methodCalls;
|
|
29
|
-
methodCalls.forEach((methodCall) => {
|
|
30
|
-
const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
|
|
31
|
-
methodCallMsg.setMethodName(methodCall.methodName);
|
|
32
|
-
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
33
|
-
// Optional: Set callData if provided
|
|
34
|
-
if (methodCall.callData) {
|
|
35
|
-
methodCallMsg.setCallData(methodCall.callData);
|
|
36
|
-
}
|
|
37
|
-
// Optional: Set applyToFields if provided
|
|
38
|
-
if (methodCall.applyToFields) {
|
|
39
|
-
methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
|
|
40
|
-
}
|
|
41
|
-
config.addMethodCalls(methodCallMsg);
|
|
42
|
-
});
|
|
43
|
-
node.setConfig(config);
|
|
44
|
-
return node;
|
|
45
|
-
}
|
|
46
|
-
static fromResponse(raw) {
|
|
47
|
-
// Convert the raw object to ContractReadNodeProps, which should keep name and id
|
|
48
|
-
const obj = raw.toObject();
|
|
49
|
-
const contractReadNode = raw.getContractRead();
|
|
50
|
-
const config = contractReadNode.getConfig();
|
|
51
|
-
const protobufData = config.toObject();
|
|
52
|
-
// Convert protobuf data to our custom interface
|
|
53
|
-
const data = {
|
|
54
|
-
contractAddress: protobufData.contractAddress,
|
|
55
|
-
contractAbi: config
|
|
56
|
-
.getContractAbiList()
|
|
57
|
-
.map((value) => convertProtobufValueToJs(value)),
|
|
58
|
-
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
59
|
-
methodName: call.methodName,
|
|
60
|
-
applyToFields: call.applyToFieldsList || [],
|
|
61
|
-
methodParams: call.methodParamsList || [],
|
|
62
|
-
// Only include callData if present
|
|
63
|
-
...(call.callData && { callData: call.callData }),
|
|
64
|
-
})) || [],
|
|
65
|
-
};
|
|
66
|
-
return new ContractReadNode({
|
|
67
|
-
...obj,
|
|
68
|
-
type: NodeType.ContractRead,
|
|
69
|
-
data: data,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
toRequest() {
|
|
73
|
-
const request = new avs_pb.TaskNode();
|
|
74
|
-
request.setId(this.id);
|
|
75
|
-
request.setName(this.name);
|
|
76
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CONTRACT_READ);
|
|
77
|
-
const node = ContractReadNode.createProtobufNode(this.data);
|
|
78
|
-
request.setContractRead(node);
|
|
79
|
-
return request;
|
|
80
|
-
}
|
|
81
|
-
static fromOutputData(outputData) {
|
|
82
|
-
const contractReadOutput = outputData.getContractRead();
|
|
83
|
-
if (!contractReadOutput)
|
|
84
|
-
return null;
|
|
85
|
-
// Get the clean data from the data field (now a single flattened object)
|
|
86
|
-
const dataValue = contractReadOutput.getData();
|
|
87
|
-
const cleanData = dataValue ? convertProtobufValueToJs(dataValue) : {};
|
|
88
|
-
return cleanData;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export default ContractReadNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractWriteNodeData, ContractWriteNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class ContractWriteNode extends Node {
|
|
5
|
-
constructor(props: ContractWriteNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf ContractWriteNode from config data
|
|
8
|
-
* @param configData - The configuration data for the contract write node
|
|
9
|
-
* @returns Configured avs_pb.ContractWriteNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: ContractWriteNodeData): avs_pb.ContractWriteNode;
|
|
12
|
-
static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
|
|
13
|
-
toRequest(): avs_pb.TaskNode;
|
|
14
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
15
|
-
}
|
|
16
|
-
export default ContractWriteNode;
|
|
17
|
-
//# sourceMappingURL=contractWrite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contractWrite.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractWrite.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAEL,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,iBAAkB,SAAQ,IAAI;gBACtB,KAAK,EAAE,sBAAsB;IAIzC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAAC,iBAAiB;IA6CtF,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB;IAmC5D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAYrE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
4
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
5
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
6
|
-
// Required props for constructor: id, name, type and data: { config: { contractAddress, callData, contractAbi, methodCallsList? } }
|
|
7
|
-
class ContractWriteNode extends Node {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super({ ...props, type: NodeType.ContractWrite, data: props.data });
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create a protobuf ContractWriteNode from config data
|
|
13
|
-
* @param configData - The configuration data for the contract write node
|
|
14
|
-
* @returns Configured avs_pb.ContractWriteNode
|
|
15
|
-
*/
|
|
16
|
-
static createProtobufNode(configData) {
|
|
17
|
-
const node = new avs_pb.ContractWriteNode();
|
|
18
|
-
const config = new avs_pb.ContractWriteNode.Config();
|
|
19
|
-
config.setContractAddress(configData.contractAddress);
|
|
20
|
-
// Remove the top-level callData since it's no longer part of ContractWriteNodeData
|
|
21
|
-
// Convert array to protobuf Value list
|
|
22
|
-
const abiValueList = configData.contractAbi.map(item => {
|
|
23
|
-
const value = new google_protobuf_struct_pb.Value();
|
|
24
|
-
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
25
|
-
return value;
|
|
26
|
-
});
|
|
27
|
-
config.setContractAbiList(abiValueList);
|
|
28
|
-
// Handle method calls array (now required)
|
|
29
|
-
const methodCalls = configData.methodCalls;
|
|
30
|
-
methodCalls.forEach((methodCall) => {
|
|
31
|
-
const methodCallMsg = new avs_pb.ContractWriteNode.MethodCall();
|
|
32
|
-
// Set callData only if provided (now optional)
|
|
33
|
-
if (methodCall.callData) {
|
|
34
|
-
methodCallMsg.setCallData(methodCall.callData);
|
|
35
|
-
}
|
|
36
|
-
if (methodCall.methodName) {
|
|
37
|
-
methodCallMsg.setMethodName(methodCall.methodName);
|
|
38
|
-
}
|
|
39
|
-
if (methodCall.methodParams) {
|
|
40
|
-
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
41
|
-
}
|
|
42
|
-
// Note: applyToFields is not supported for ContractWrite nodes
|
|
43
|
-
config.addMethodCalls(methodCallMsg);
|
|
44
|
-
});
|
|
45
|
-
// Set isSimulated only if explicitly provided (optional field in protobuf)
|
|
46
|
-
// When unset, the backend defaults to true (simulation mode)
|
|
47
|
-
if (configData.isSimulated !== undefined) {
|
|
48
|
-
config.setIsSimulated(configData.isSimulated);
|
|
49
|
-
}
|
|
50
|
-
node.setConfig(config);
|
|
51
|
-
return node;
|
|
52
|
-
}
|
|
53
|
-
static fromResponse(raw) {
|
|
54
|
-
// Convert the raw object to ContractWriteNodeProps, which should keep name and id
|
|
55
|
-
const obj = raw.toObject();
|
|
56
|
-
const contractWriteNode = raw.getContractWrite();
|
|
57
|
-
const config = contractWriteNode.getConfig();
|
|
58
|
-
const protobufData = config.toObject();
|
|
59
|
-
// Convert protobuf data to our custom interface
|
|
60
|
-
const data = {
|
|
61
|
-
contractAddress: protobufData.contractAddress,
|
|
62
|
-
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
63
|
-
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
64
|
-
methodName: call.methodName,
|
|
65
|
-
methodParams: call.methodParamsList || [],
|
|
66
|
-
// Note: applyToFields is not supported for ContractWrite nodes in protobuf
|
|
67
|
-
// callData is optional, only include if present
|
|
68
|
-
...(call.callData && { callData: call.callData }),
|
|
69
|
-
})) || [],
|
|
70
|
-
};
|
|
71
|
-
// Include isSimulated if present in protobuf
|
|
72
|
-
if (protobufData.isSimulated !== undefined) {
|
|
73
|
-
data.isSimulated = protobufData.isSimulated;
|
|
74
|
-
}
|
|
75
|
-
return new ContractWriteNode({
|
|
76
|
-
...obj,
|
|
77
|
-
type: NodeType.ContractWrite,
|
|
78
|
-
data: data,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
toRequest() {
|
|
82
|
-
const request = new avs_pb.TaskNode();
|
|
83
|
-
request.setId(this.id);
|
|
84
|
-
request.setName(this.name);
|
|
85
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CONTRACT_WRITE);
|
|
86
|
-
const node = ContractWriteNode.createProtobufNode(this.data);
|
|
87
|
-
request.setContractWrite(node);
|
|
88
|
-
return request;
|
|
89
|
-
}
|
|
90
|
-
static fromOutputData(outputData) {
|
|
91
|
-
const contractWriteOutput = outputData.getContractWrite();
|
|
92
|
-
if (!contractWriteOutput)
|
|
93
|
-
return null;
|
|
94
|
-
// ContractWrite decoded events are stored in data field (flattened object format)
|
|
95
|
-
// This contains parsed receipt logs/events, similar to ContractRead format
|
|
96
|
-
const dataValue = contractWriteOutput.getData();
|
|
97
|
-
// Convert protobuf Value to JavaScript object (decoded events object)
|
|
98
|
-
// Return empty object if no events were decoded from transaction receipts
|
|
99
|
-
return dataValue ? convertProtobufValueToJs(dataValue) : {};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export default ContractWriteNode;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { CustomCodeNodeProps, Lang } from "@avaprotocol/types";
|
|
4
|
-
declare class CustomCodeNode extends Node {
|
|
5
|
-
constructor(props: CustomCodeNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf CustomCodeNode from config data
|
|
8
|
-
* @param configData - The configuration data for the custom code node
|
|
9
|
-
* @returns Configured avs_pb.CustomCodeNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: {
|
|
12
|
-
lang: Lang;
|
|
13
|
-
source: string;
|
|
14
|
-
}): avs_pb.CustomCodeNode;
|
|
15
|
-
static fromResponse(raw: avs_pb.TaskNode): CustomCodeNode;
|
|
16
|
-
toRequest(): avs_pb.TaskNode;
|
|
17
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
18
|
-
}
|
|
19
|
-
export default CustomCodeNode;
|
|
20
|
-
//# sourceMappingURL=customCode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customCode.d.ts","sourceRoot":"","sources":["../../../src/models/node/customCode.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,mBAAmB,EAEnB,IAAI,EAEL,MAAM,oBAAoB,CAAC;AAK5B,cAAM,cAAe,SAAQ,IAAI;gBACnB,KAAK,EAAE,mBAAmB;IAItC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,IAAI,EAAE,IAAI,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,MAAM,CAAC,cAAc;IAazB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,cAAc;IA2BzD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAqBrE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { NodeType, LangConverter, } from "@avaprotocol/types";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { lang: number, source: string }
|
|
6
|
-
class CustomCodeNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.CustomCode, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Create a protobuf CustomCodeNode from config data
|
|
12
|
-
* @param configData - The configuration data for the custom code node
|
|
13
|
-
* @returns Configured avs_pb.CustomCodeNode
|
|
14
|
-
*/
|
|
15
|
-
static createProtobufNode(configData) {
|
|
16
|
-
const node = new avs_pb.CustomCodeNode();
|
|
17
|
-
const config = new avs_pb.CustomCodeNode.Config();
|
|
18
|
-
// Convert lang to protobuf enum using centralized converter
|
|
19
|
-
const langValue = LangConverter.toProtobuf(configData.lang);
|
|
20
|
-
config.setLang(langValue);
|
|
21
|
-
config.setSource(configData.source);
|
|
22
|
-
node.setConfig(config);
|
|
23
|
-
return node;
|
|
24
|
-
}
|
|
25
|
-
static fromResponse(raw) {
|
|
26
|
-
// Convert the raw object to CustomCodeNodeProps, which should keep name and id
|
|
27
|
-
const obj = raw.toObject();
|
|
28
|
-
// Get the raw protobuf config
|
|
29
|
-
const customCodeNode = raw.getCustomCode();
|
|
30
|
-
if (!customCodeNode) {
|
|
31
|
-
throw new Error("CustomCode node data is missing");
|
|
32
|
-
}
|
|
33
|
-
const config = customCodeNode.getConfig();
|
|
34
|
-
if (!config) {
|
|
35
|
-
throw new Error("CustomCode config is missing");
|
|
36
|
-
}
|
|
37
|
-
const convertedConfig = {
|
|
38
|
-
lang: LangConverter.fromProtobuf(config.getLang()),
|
|
39
|
-
source: config.getSource(),
|
|
40
|
-
};
|
|
41
|
-
return new CustomCodeNode({
|
|
42
|
-
...obj,
|
|
43
|
-
type: NodeType.CustomCode,
|
|
44
|
-
data: convertedConfig,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
toRequest() {
|
|
48
|
-
const request = new avs_pb.TaskNode();
|
|
49
|
-
request.setId(this.id);
|
|
50
|
-
request.setName(this.name);
|
|
51
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CUSTOM_CODE);
|
|
52
|
-
const node = CustomCodeNode.createProtobufNode(this.data);
|
|
53
|
-
request.setCustomCode(node);
|
|
54
|
-
return request;
|
|
55
|
-
}
|
|
56
|
-
static fromOutputData(outputData) {
|
|
57
|
-
const customCodeOutput = outputData.getCustomCode();
|
|
58
|
-
if (customCodeOutput?.getData()) {
|
|
59
|
-
// Use the modern protobuf conversion function
|
|
60
|
-
const result = convertProtobufValueToJs(customCodeOutput.getData());
|
|
61
|
-
// SPECIAL FIX: Check if the result is incorrectly wrapped with a single "data" property
|
|
62
|
-
// This handles the case where primitive values get wrapped as {"data": value}
|
|
63
|
-
if (result &&
|
|
64
|
-
typeof result === "object" &&
|
|
65
|
-
Object.keys(result).length === 1 &&
|
|
66
|
-
"data" in result) {
|
|
67
|
-
return result.data;
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export default CustomCodeNode;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ETHTransferNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class ETHTransferNode extends Node {
|
|
5
|
-
constructor(props: ETHTransferNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf ETHTransferNode from config data
|
|
8
|
-
* @param configData - The configuration data for the ETH transfer node
|
|
9
|
-
* @returns Configured avs_pb.ETHTransferNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: {
|
|
12
|
-
destination: string;
|
|
13
|
-
amount: string;
|
|
14
|
-
}): avs_pb.ETHTransferNode;
|
|
15
|
-
static fromResponse(raw: avs_pb.TaskNode): ETHTransferNode;
|
|
16
|
-
toRequest(): avs_pb.TaskNode;
|
|
17
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
18
|
-
}
|
|
19
|
-
export default ETHTransferNode;
|
|
20
|
-
//# sourceMappingURL=ethTransfer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ethTransfer.d.ts","sourceRoot":"","sources":["../../../src/models/node/ethTransfer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,eAAgB,SAAQ,IAAI;gBACpB,KAAK,EAAE,oBAAoB;IAIvC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,MAAM,CAAC,eAAe;IAW1B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,eAAe;IAgB1D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAcrE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { destination, amount }
|
|
6
|
-
class ETHTransferNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.ETHTransfer, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Create a protobuf ETHTransferNode from config data
|
|
12
|
-
* @param configData - The configuration data for the ETH transfer node
|
|
13
|
-
* @returns Configured avs_pb.ETHTransferNode
|
|
14
|
-
*/
|
|
15
|
-
static createProtobufNode(configData) {
|
|
16
|
-
const node = new avs_pb.ETHTransferNode();
|
|
17
|
-
const config = new avs_pb.ETHTransferNode.Config();
|
|
18
|
-
config.setDestination(configData.destination);
|
|
19
|
-
config.setAmount(configData.amount);
|
|
20
|
-
node.setConfig(config);
|
|
21
|
-
return node;
|
|
22
|
-
}
|
|
23
|
-
static fromResponse(raw) {
|
|
24
|
-
// Convert the raw object to ETHTransferNodeProps, which should keep name and id
|
|
25
|
-
const obj = raw.toObject();
|
|
26
|
-
const data = raw
|
|
27
|
-
.getEthTransfer()
|
|
28
|
-
.getConfig()
|
|
29
|
-
.toObject();
|
|
30
|
-
return new ETHTransferNode({
|
|
31
|
-
...obj,
|
|
32
|
-
type: NodeType.ETHTransfer,
|
|
33
|
-
data: data,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
toRequest() {
|
|
37
|
-
const request = new avs_pb.TaskNode();
|
|
38
|
-
request.setId(this.id);
|
|
39
|
-
request.setName(this.name);
|
|
40
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_ETH_TRANSFER);
|
|
41
|
-
const node = ETHTransferNode.createProtobufNode(this.data);
|
|
42
|
-
request.setEthTransfer(node);
|
|
43
|
-
return request;
|
|
44
|
-
}
|
|
45
|
-
static fromOutputData(outputData) {
|
|
46
|
-
const ethTransferOutput = outputData.getEthTransfer();
|
|
47
|
-
if (!ethTransferOutput) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
// Use convertProtobufValueToJs to get clean JavaScript objects
|
|
51
|
-
const rawData = ethTransferOutput.getData();
|
|
52
|
-
if (rawData) {
|
|
53
|
-
return convertProtobufValueToJs(rawData);
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export default ETHTransferNode;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import ContractWriteNode from "./contractWrite";
|
|
3
|
-
import CustomCodeNode from "./customCode";
|
|
4
|
-
import GraphQLQueryNode from "./graphqlQuery";
|
|
5
|
-
import Node from "./interface";
|
|
6
|
-
import RestAPINode from "./restApi";
|
|
7
|
-
import ContractReadNode from "./contractRead";
|
|
8
|
-
import ETHTransferNode from "./ethTransfer";
|
|
9
|
-
import BranchNode from "./branch";
|
|
10
|
-
import FilterNode from "./filter";
|
|
11
|
-
import LoopNode from "./loop";
|
|
12
|
-
import BalanceNode from "./balance";
|
|
13
|
-
import { ContractWriteNodeData, ContractReadNodeData, BranchNodeData, ETHTransferNodeData, GraphQLQueryNodeData, RestAPINodeData, CustomCodeNodeData, FilterNodeData, LoopNodeData, BalanceNodeData, NodeProps, ContractWriteNodeProps, ContractReadNodeProps, BranchNodeProps, ETHTransferNodeProps, GraphQLQueryNodeProps, RestAPINodeProps, CustomCodeNodeProps, FilterNodeProps, LoopNodeProps, BalanceNodeProps } from "@avaprotocol/types";
|
|
14
|
-
declare class NodeFactory {
|
|
15
|
-
static create(props: NodeProps): Node;
|
|
16
|
-
static createNodes(props: NodeProps[]): Node[];
|
|
17
|
-
static fromResponse(raw: avs_pb.TaskNode): Node;
|
|
18
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
19
|
-
}
|
|
20
|
-
export default NodeFactory;
|
|
21
|
-
export { Node, ContractWriteNode, ContractReadNode, BranchNode, ETHTransferNode, GraphQLQueryNode, RestAPINode, CustomCodeNode, FilterNode, LoopNode, BalanceNode, };
|
|
22
|
-
export type { ContractWriteNodeData, ContractReadNodeData, BranchNodeData, ETHTransferNodeData, GraphQLQueryNodeData, RestAPINodeData, CustomCodeNodeData, FilterNodeData, LoopNodeData, BalanceNodeData, };
|
|
23
|
-
export type { NodeProps, ContractWriteNodeProps, ContractReadNodeProps, BranchNodeProps, ETHTransferNodeProps, GraphQLQueryNodeProps, RestAPINodeProps, CustomCodeNodeProps, FilterNodeProps, LoopNodeProps, BalanceNodeProps, };
|
|
24
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/models/node/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,iBAAiB,MAAM,iBAAiB,CAAC;AAChD,OAAO,cAAc,MAAM,cAAc,CAAC;AAC1C,OAAO,gBAAgB,MAAM,gBAAgB,CAAC;AAC9C,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,gBAAgB,MAAM,gBAAgB,CAAC;AAC9C,OAAO,eAAe,MAAM,eAAe,CAAC;AAC5C,OAAO,UAAU,MAAM,UAAU,CAAC;AAClC,OAAO,UAAU,MAAM,UAAU,CAAC;AAClC,OAAO,QAAQ,MAAM,QAAQ,CAAC;AAC9B,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,EAEL,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,WAAW;IACf,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IA6BrC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE;IAI9C,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,IAAI;IA2B/C,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAiCrE;AAED,eAAe,WAAW,CAAC;AAG3B,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,UAAU,EACV,QAAQ,EACR,WAAW,GACZ,CAAC;AAGF,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,CAAC;AAGF,YAAY,EACV,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,gBAAgB,GACjB,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import _ from "lodash";
|
|
3
|
-
import ContractWriteNode from "./contractWrite";
|
|
4
|
-
import CustomCodeNode from "./customCode";
|
|
5
|
-
import GraphQLQueryNode from "./graphqlQuery";
|
|
6
|
-
import Node from "./interface";
|
|
7
|
-
import RestAPINode from "./restApi";
|
|
8
|
-
import ContractReadNode from "./contractRead";
|
|
9
|
-
import ETHTransferNode from "./ethTransfer";
|
|
10
|
-
import BranchNode from "./branch";
|
|
11
|
-
import FilterNode from "./filter";
|
|
12
|
-
import LoopNode from "./loop";
|
|
13
|
-
import BalanceNode from "./balance";
|
|
14
|
-
import { NodeType } from "@avaprotocol/types";
|
|
15
|
-
class NodeFactory {
|
|
16
|
-
static create(props) {
|
|
17
|
-
switch (props.type) {
|
|
18
|
-
case NodeType.ContractWrite:
|
|
19
|
-
return new ContractWriteNode(props);
|
|
20
|
-
case NodeType.RestAPI:
|
|
21
|
-
return new RestAPINode(props);
|
|
22
|
-
case NodeType.CustomCode:
|
|
23
|
-
return new CustomCodeNode(props);
|
|
24
|
-
case NodeType.ContractRead:
|
|
25
|
-
return new ContractReadNode(props);
|
|
26
|
-
case NodeType.ETHTransfer:
|
|
27
|
-
return new ETHTransferNode(props);
|
|
28
|
-
case NodeType.GraphQLQuery:
|
|
29
|
-
return new GraphQLQueryNode(props);
|
|
30
|
-
case NodeType.Branch:
|
|
31
|
-
return new BranchNode(props);
|
|
32
|
-
case NodeType.Filter:
|
|
33
|
-
return new FilterNode(props);
|
|
34
|
-
case NodeType.Loop:
|
|
35
|
-
return new LoopNode(props);
|
|
36
|
-
case NodeType.Balance:
|
|
37
|
-
return new BalanceNode(props);
|
|
38
|
-
case NodeType.Unspecified:
|
|
39
|
-
throw new Error("Cannot create node with unspecified type");
|
|
40
|
-
default:
|
|
41
|
-
throw new Error(`Unsupported node type: ${props.type}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
static createNodes(props) {
|
|
45
|
-
return _.map(props, (node) => this.create(node));
|
|
46
|
-
}
|
|
47
|
-
static fromResponse(raw) {
|
|
48
|
-
switch (true) {
|
|
49
|
-
case !!raw.getEthTransfer():
|
|
50
|
-
return ETHTransferNode.fromResponse(raw);
|
|
51
|
-
case !!raw.getContractRead():
|
|
52
|
-
return ContractReadNode.fromResponse(raw);
|
|
53
|
-
case !!raw.getContractWrite():
|
|
54
|
-
return ContractWriteNode.fromResponse(raw);
|
|
55
|
-
case !!raw.getGraphqlQuery():
|
|
56
|
-
return GraphQLQueryNode.fromResponse(raw);
|
|
57
|
-
case !!raw.getRestApi():
|
|
58
|
-
return RestAPINode.fromResponse(raw);
|
|
59
|
-
case !!raw.getCustomCode():
|
|
60
|
-
return CustomCodeNode.fromResponse(raw);
|
|
61
|
-
case !!raw.getBranch():
|
|
62
|
-
return BranchNode.fromResponse(raw);
|
|
63
|
-
case !!raw.getFilter():
|
|
64
|
-
return FilterNode.fromResponse(raw);
|
|
65
|
-
case !!raw.getLoop():
|
|
66
|
-
return LoopNode.fromResponse(raw);
|
|
67
|
-
case !!raw.getBalance():
|
|
68
|
-
return BalanceNode.fromResponse(raw);
|
|
69
|
-
default:
|
|
70
|
-
throw new Error(`Unsupported node type: ${raw.getName()}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
static fromOutputData(outputData) {
|
|
74
|
-
// Delegate to the specific node type's fromOutputData method
|
|
75
|
-
// This is the correct approach, similar to how TriggerFactory.fromOutputData works
|
|
76
|
-
switch (outputData.getOutputDataCase()) {
|
|
77
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.REST_API:
|
|
78
|
-
return RestAPINode.fromOutputData(outputData);
|
|
79
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.CUSTOM_CODE:
|
|
80
|
-
return CustomCodeNode.fromOutputData(outputData);
|
|
81
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.CONTRACT_READ:
|
|
82
|
-
return ContractReadNode.fromOutputData(outputData);
|
|
83
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.CONTRACT_WRITE:
|
|
84
|
-
return ContractWriteNode.fromOutputData(outputData);
|
|
85
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.ETH_TRANSFER:
|
|
86
|
-
return ETHTransferNode.fromOutputData(outputData);
|
|
87
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.GRAPHQL:
|
|
88
|
-
return GraphQLQueryNode.fromOutputData(outputData);
|
|
89
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.BRANCH:
|
|
90
|
-
return BranchNode.fromOutputData(outputData);
|
|
91
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.FILTER:
|
|
92
|
-
return FilterNode.fromOutputData(outputData);
|
|
93
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.LOOP:
|
|
94
|
-
return LoopNode.fromOutputData(outputData);
|
|
95
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.BALANCE:
|
|
96
|
-
return BalanceNode.fromOutputData(outputData);
|
|
97
|
-
case avs_pb.RunNodeWithInputsResp.OutputDataCase.OUTPUT_DATA_NOT_SET:
|
|
98
|
-
// Some node types may not return output data (e.g., FilterNode with no matches)
|
|
99
|
-
// Return null to indicate no output data
|
|
100
|
-
return null;
|
|
101
|
-
default:
|
|
102
|
-
throw new Error(`Unsupported output data case: ${outputData.getOutputDataCase()}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
export default NodeFactory;
|
|
107
|
-
// Node object definitions
|
|
108
|
-
export { Node, ContractWriteNode, ContractReadNode, BranchNode, ETHTransferNode, GraphQLQueryNode, RestAPINode, CustomCodeNode, FilterNode, LoopNode, BalanceNode, };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { FilterNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class FilterNode extends Node {
|
|
5
|
-
constructor(props: FilterNodeProps);
|
|
6
|
-
static fromResponse(raw: avs_pb.TaskNode): FilterNode;
|
|
7
|
-
toRequest(): avs_pb.TaskNode;
|
|
8
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown[];
|
|
9
|
-
}
|
|
10
|
-
export default FilterNode;
|
|
11
|
-
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/models/node/filter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAI5B,cAAM,UAAW,SAAQ,IAAI;gBACf,KAAK,EAAE,eAAe;IAIlC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,UAAU;IAWrD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAkB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO,EAAE;CAoC3E;AAED,eAAe,UAAU,CAAC"}
|