@avaprotocol/sdk-js 2.6.1 → 2.6.3
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.js +322 -214
- package/dist/index.mjs +322 -214
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +22 -26
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +46 -9
- package/dist/models/node/filter.d.ts +1 -1
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +5 -14
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +28 -19
- package/dist/models/trigger/event.d.ts.map +1 -1
- package/dist/models/trigger/event.js +17 -5
- package/package.json +2 -2
- 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/index.d.ts +0 -351
- package/dist/models/edge.d.ts +0 -12
- package/dist/models/execution.d.ts +0 -20
- package/dist/models/node/branch.d.ts +0 -11
- package/dist/models/node/contractRead.d.ts +0 -26
- package/dist/models/node/contractWrite.d.ts +0 -26
- package/dist/models/node/customCode.d.ts +0 -20
- package/dist/models/node/ethTransfer.d.ts +0 -20
- package/dist/models/node/factory.d.ts +0 -23
- package/dist/models/node/graphqlQuery.d.ts +0 -21
- package/dist/models/node/interface.d.ts +0 -20
- package/dist/models/node/loop.d.ts +0 -15
- package/dist/models/node/restApi.d.ts +0 -22
- package/dist/models/secret.d.ts +0 -16
- package/dist/models/step.d.ts +0 -27
- package/dist/models/trigger/block.d.ts +0 -22
- package/dist/models/trigger/cron.d.ts +0 -23
- package/dist/models/trigger/event.d.ts +0 -22
- package/dist/models/trigger/factory.d.ts +0 -27
- package/dist/models/trigger/fixedTime.d.ts +0 -23
- package/dist/models/trigger/interface.d.ts +0 -19
- package/dist/models/trigger/manual.d.ts +0 -16
- package/dist/models/workflow.d.ts +0 -47
- package/dist/utils.d.ts +0 -72
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAO5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAAC,gBAAgB;IAuCpF,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IA6B3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO,GAAG,IAAI;CAUhF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
3
4
|
import { NodeType, } from "@avaprotocol/types";
|
|
4
5
|
import { convertProtobufValueToJs, } from "../../utils";
|
|
5
6
|
// Required props for constructor: id, name, type and data
|
|
@@ -16,12 +17,21 @@ class ContractReadNode extends Node {
|
|
|
16
17
|
const node = new avs_pb.ContractReadNode();
|
|
17
18
|
const config = new avs_pb.ContractReadNode.Config();
|
|
18
19
|
config.setContractAddress(configData.contractAddress);
|
|
19
|
-
|
|
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);
|
|
20
27
|
// Handle method calls array
|
|
21
28
|
const methodCalls = configData.methodCalls || [];
|
|
22
29
|
methodCalls.forEach((methodCall) => {
|
|
23
30
|
const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
|
|
24
|
-
|
|
31
|
+
// Set callData only if provided (now optional)
|
|
32
|
+
if (methodCall.callData) {
|
|
33
|
+
methodCallMsg.setCallData(methodCall.callData);
|
|
34
|
+
}
|
|
25
35
|
if (methodCall.methodName) {
|
|
26
36
|
methodCallMsg.setMethodName(methodCall.methodName);
|
|
27
37
|
}
|
|
@@ -39,11 +49,13 @@ class ContractReadNode extends Node {
|
|
|
39
49
|
static fromResponse(raw) {
|
|
40
50
|
// Convert the raw object to ContractReadNodeProps, which should keep name and id
|
|
41
51
|
const obj = raw.toObject();
|
|
42
|
-
const
|
|
52
|
+
const contractReadNode = raw.getContractRead();
|
|
53
|
+
const config = contractReadNode.getConfig();
|
|
54
|
+
const protobufData = config.toObject();
|
|
43
55
|
// Convert protobuf data to our custom interface
|
|
44
56
|
const data = {
|
|
45
57
|
contractAddress: protobufData.contractAddress,
|
|
46
|
-
contractAbi:
|
|
58
|
+
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
47
59
|
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
48
60
|
callData: call.callData,
|
|
49
61
|
methodName: call.methodName,
|
|
@@ -67,28 +79,12 @@ class ContractReadNode extends Node {
|
|
|
67
79
|
}
|
|
68
80
|
static fromOutputData(outputData) {
|
|
69
81
|
const contractReadOutput = outputData.getContractRead();
|
|
70
|
-
if (contractReadOutput
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// The data should now be directly an array of results
|
|
77
|
-
if (Array.isArray(jsData)) {
|
|
78
|
-
return jsData.map((result) => ({
|
|
79
|
-
methodName: result.methodName,
|
|
80
|
-
success: result.success,
|
|
81
|
-
error: result.error || "",
|
|
82
|
-
data: result.data || {},
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Fallback for old format or unexpected structure
|
|
87
|
-
return jsData;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
82
|
+
if (!contractReadOutput)
|
|
83
|
+
return null;
|
|
84
|
+
// Get the clean data from the data field (now a single flattened object)
|
|
85
|
+
const dataValue = contractReadOutput.getData();
|
|
86
|
+
const cleanData = dataValue ? convertProtobufValueToJs(dataValue) : {};
|
|
87
|
+
return cleanData;
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
export default ContractReadNode;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAuCtF,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB;IA8B5D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO,EAAE,GAAG,IAAI;CAqClF;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
3
4
|
import { NodeType, } from "@avaprotocol/types";
|
|
4
5
|
import { convertProtobufValueToJs } from "../../utils";
|
|
5
6
|
// Required props for constructor: id, name, type and data: { config: { contractAddress, callData, contractAbi, methodCallsList? } }
|
|
@@ -16,19 +17,29 @@ class ContractWriteNode extends Node {
|
|
|
16
17
|
const node = new avs_pb.ContractWriteNode();
|
|
17
18
|
const config = new avs_pb.ContractWriteNode.Config();
|
|
18
19
|
config.setContractAddress(configData.contractAddress);
|
|
19
|
-
|
|
20
|
-
|
|
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);
|
|
21
28
|
// Handle method calls array
|
|
22
29
|
const methodCalls = configData.methodCalls || [];
|
|
23
30
|
methodCalls.forEach((methodCall) => {
|
|
24
31
|
const methodCallMsg = new avs_pb.ContractWriteNode.MethodCall();
|
|
25
|
-
|
|
32
|
+
// Set callData only if provided (now optional)
|
|
33
|
+
if (methodCall.callData) {
|
|
34
|
+
methodCallMsg.setCallData(methodCall.callData);
|
|
35
|
+
}
|
|
26
36
|
if (methodCall.methodName) {
|
|
27
37
|
methodCallMsg.setMethodName(methodCall.methodName);
|
|
28
38
|
}
|
|
29
39
|
if (methodCall.methodParams) {
|
|
30
40
|
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
31
41
|
}
|
|
42
|
+
// Note: applyToFields is not supported for ContractWrite nodes
|
|
32
43
|
config.addMethodCalls(methodCallMsg);
|
|
33
44
|
});
|
|
34
45
|
node.setConfig(config);
|
|
@@ -37,16 +48,19 @@ class ContractWriteNode extends Node {
|
|
|
37
48
|
static fromResponse(raw) {
|
|
38
49
|
// Convert the raw object to ContractWriteNodeProps, which should keep name and id
|
|
39
50
|
const obj = raw.toObject();
|
|
40
|
-
const
|
|
51
|
+
const contractWriteNode = raw.getContractWrite();
|
|
52
|
+
const config = contractWriteNode.getConfig();
|
|
53
|
+
const protobufData = config.toObject();
|
|
41
54
|
// Convert protobuf data to our custom interface
|
|
42
55
|
const data = {
|
|
43
56
|
contractAddress: protobufData.contractAddress,
|
|
44
|
-
|
|
45
|
-
contractAbi: protobufData.contractAbi,
|
|
57
|
+
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
46
58
|
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
47
|
-
callData: call.callData,
|
|
48
59
|
methodName: call.methodName,
|
|
49
60
|
methodParams: call.methodParamsList || [],
|
|
61
|
+
// Note: applyToFields is not supported for ContractWrite nodes in protobuf
|
|
62
|
+
// callData is optional, only include if present
|
|
63
|
+
...(call.callData && { callData: call.callData }),
|
|
50
64
|
})) || [],
|
|
51
65
|
};
|
|
52
66
|
return new ContractWriteNode({
|
|
@@ -73,8 +87,31 @@ class ContractWriteNode extends Node {
|
|
|
73
87
|
return null;
|
|
74
88
|
// Convert protobuf Value to JavaScript object
|
|
75
89
|
const jsData = convertProtobufValueToJs(data);
|
|
76
|
-
//
|
|
77
|
-
|
|
90
|
+
// Format response for consistency with ContractRead
|
|
91
|
+
if (Array.isArray(jsData)) {
|
|
92
|
+
return jsData.map((result) => {
|
|
93
|
+
// ContractWrite already uses the consistent format with method_abi and value
|
|
94
|
+
const methodName = result.method_name || result.methodName;
|
|
95
|
+
return {
|
|
96
|
+
methodName: methodName,
|
|
97
|
+
methodABI: result.method_abi || null,
|
|
98
|
+
success: result.success,
|
|
99
|
+
error: result.error || "",
|
|
100
|
+
value: result.value,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Single result - wrap in array for consistency
|
|
106
|
+
const methodName = jsData.method_name || jsData.methodName;
|
|
107
|
+
return [{
|
|
108
|
+
methodName: methodName,
|
|
109
|
+
methodABI: jsData.method_abi || null,
|
|
110
|
+
success: jsData.success,
|
|
111
|
+
error: jsData.error || "",
|
|
112
|
+
value: jsData.value,
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
78
115
|
}
|
|
79
116
|
}
|
|
80
117
|
export default ContractWriteNode;
|
|
@@ -5,7 +5,7 @@ declare class FilterNode extends Node {
|
|
|
5
5
|
constructor(props: FilterNodeProps);
|
|
6
6
|
static fromResponse(raw: avs_pb.TaskNode): FilterNode;
|
|
7
7
|
toRequest(): avs_pb.TaskNode;
|
|
8
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp):
|
|
8
|
+
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown[];
|
|
9
9
|
}
|
|
10
10
|
export default FilterNode;
|
|
11
11
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;AAM5B,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;IAiB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,
|
|
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;AAM5B,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;IAiB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO,EAAE;CAoC3E;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -36,18 +36,13 @@ class FilterNode extends Node {
|
|
|
36
36
|
if (!anyData) {
|
|
37
37
|
throw new Error("FilterNode output data.getData() is missing");
|
|
38
38
|
}
|
|
39
|
-
// The data is now directly a Value
|
|
39
|
+
// The data is now directly a Value containing the filtered array
|
|
40
40
|
const result = anyData.toJavaScript();
|
|
41
|
-
//
|
|
42
|
-
if (result
|
|
43
|
-
|
|
44
|
-
!Array.isArray(result) &&
|
|
45
|
-
result.data &&
|
|
46
|
-
result.data.data &&
|
|
47
|
-
Array.isArray(result.data.data)) {
|
|
48
|
-
return result.data.data;
|
|
41
|
+
// If result is already an array, return it directly (this should be the normal case now)
|
|
42
|
+
if (Array.isArray(result)) {
|
|
43
|
+
return result;
|
|
49
44
|
}
|
|
50
|
-
//
|
|
45
|
+
// Fallback: if result is an object with data field
|
|
51
46
|
if (result &&
|
|
52
47
|
typeof result === "object" &&
|
|
53
48
|
!Array.isArray(result) &&
|
|
@@ -55,10 +50,6 @@ class FilterNode extends Node {
|
|
|
55
50
|
Array.isArray(result.data)) {
|
|
56
51
|
return result.data;
|
|
57
52
|
}
|
|
58
|
-
// If result is already an array, return it directly
|
|
59
|
-
if (Array.isArray(result)) {
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
53
|
throw new Error("FilterNode output data does not contain expected data structure");
|
|
63
54
|
}
|
|
64
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/models/node/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAO/B,OAAO,EAGL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAG5B,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IA8BnD,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAsBxC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAe3C,OAAO,CAAC,0BAA0B;IA4BlC,SAAS,IAAI,MAAM,CAAC,QAAQ;IA8B5B,OAAO,CAAC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/models/node/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAO/B,OAAO,EAGL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAG5B,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IA8BnD,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAsBxC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAe3C,OAAO,CAAC,0BAA0B;IA4BlC,SAAS,IAAI,MAAM,CAAC,QAAQ;IA8B5B,OAAO,CAAC,mBAAmB;IA+G3B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO;CAwCzE;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/models/node/loop.js
CHANGED
|
@@ -7,6 +7,7 @@ import GraphQLQueryNode from "./graphqlQuery";
|
|
|
7
7
|
import ContractReadNode from "./contractRead";
|
|
8
8
|
import ContractWriteNode from "./contractWrite";
|
|
9
9
|
import { NodeType, ExecutionMode, } from "@avaprotocol/types";
|
|
10
|
+
import { convertProtobufValueToJs } from "../../utils";
|
|
10
11
|
class LoopNode extends Node {
|
|
11
12
|
constructor(props) {
|
|
12
13
|
super({ ...props, type: NodeType.Loop, data: props.data });
|
|
@@ -48,7 +49,7 @@ class LoopNode extends Node {
|
|
|
48
49
|
// Iterate over the mapping to find the matching runner type
|
|
49
50
|
for (const [type, key] of Object.entries(runnerMapping)) {
|
|
50
51
|
if (loopNodeData[key]) {
|
|
51
|
-
return { type,
|
|
52
|
+
return { type, config: loopNodeData[key] };
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
return null;
|
|
@@ -135,9 +136,12 @@ class LoopNode extends Node {
|
|
|
135
136
|
const writeConfig = config;
|
|
136
137
|
const contractWrite = ContractWriteNode.createProtobufNode({
|
|
137
138
|
contractAddress: writeConfig.contractAddress,
|
|
138
|
-
callData: writeConfig.callData,
|
|
139
139
|
contractAbi: writeConfig.contractAbi,
|
|
140
|
-
methodCalls: writeConfig.
|
|
140
|
+
methodCalls: writeConfig.methodCalls?.map((call) => ({
|
|
141
|
+
methodName: call.methodName || "",
|
|
142
|
+
methodParams: call.methodParams || [],
|
|
143
|
+
...(call.callData && { callData: call.callData }),
|
|
144
|
+
})) || [],
|
|
141
145
|
});
|
|
142
146
|
loopNode.setContractWrite(contractWrite);
|
|
143
147
|
break;
|
|
@@ -147,7 +151,12 @@ class LoopNode extends Node {
|
|
|
147
151
|
const contractRead = ContractReadNode.createProtobufNode({
|
|
148
152
|
contractAddress: readConfig.contractAddress,
|
|
149
153
|
contractAbi: readConfig.contractAbi,
|
|
150
|
-
methodCalls: readConfig.
|
|
154
|
+
methodCalls: readConfig.methodCalls?.map((call) => ({
|
|
155
|
+
methodName: call.methodName || "",
|
|
156
|
+
methodParams: call.methodParams || [],
|
|
157
|
+
...(call.callData && { callData: call.callData }),
|
|
158
|
+
...(call.applyToFields && { applyToFields: call.applyToFields }),
|
|
159
|
+
})) || [],
|
|
151
160
|
});
|
|
152
161
|
loopNode.setContractRead(contractRead);
|
|
153
162
|
break;
|
|
@@ -185,19 +194,6 @@ class LoopNode extends Node {
|
|
|
185
194
|
}
|
|
186
195
|
}
|
|
187
196
|
static fromOutputData(outputData) {
|
|
188
|
-
// For immediate execution, data comes as CustomCode format
|
|
189
|
-
const customCodeOutput = outputData.getCustomCode();
|
|
190
|
-
if (customCodeOutput) {
|
|
191
|
-
const result = customCodeOutput.toObject();
|
|
192
|
-
// Handle nested data structure
|
|
193
|
-
if (result &&
|
|
194
|
-
typeof result === "object" &&
|
|
195
|
-
Object.keys(result).length === 1 &&
|
|
196
|
-
"data" in result) {
|
|
197
|
-
return result.data;
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
197
|
// For workflow execution, data comes as Loop format with new protobuf Value
|
|
202
198
|
const loopOutput = outputData.getLoop();
|
|
203
199
|
if (loopOutput) {
|
|
@@ -205,8 +201,8 @@ class LoopNode extends Node {
|
|
|
205
201
|
const dataValue = loopOutput.getData();
|
|
206
202
|
if (dataValue) {
|
|
207
203
|
try {
|
|
208
|
-
//
|
|
209
|
-
return dataValue
|
|
204
|
+
// Use the standard protobuf conversion utility
|
|
205
|
+
return convertProtobufValueToJs(dataValue);
|
|
210
206
|
}
|
|
211
207
|
catch (error) {
|
|
212
208
|
console.warn("Failed to convert loop data from protobuf Value:", error);
|
|
@@ -214,6 +210,19 @@ class LoopNode extends Node {
|
|
|
214
210
|
}
|
|
215
211
|
}
|
|
216
212
|
}
|
|
213
|
+
// Fallback: For immediate execution, data might come as CustomCode format
|
|
214
|
+
const customCodeOutput = outputData.getCustomCode();
|
|
215
|
+
if (customCodeOutput) {
|
|
216
|
+
const result = customCodeOutput.toObject();
|
|
217
|
+
// Handle nested data structure
|
|
218
|
+
if (result &&
|
|
219
|
+
typeof result === "object" &&
|
|
220
|
+
Object.keys(result).length === 1 &&
|
|
221
|
+
"data" in result) {
|
|
222
|
+
return result.data;
|
|
223
|
+
}
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
217
226
|
return null;
|
|
218
227
|
}
|
|
219
228
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAIlB,MAAM,oBAAoB,CAAC;AAkD5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IA6G/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAwF1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CA0B9D;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
2
3
|
import Trigger from "./interface";
|
|
3
4
|
import { TriggerType, } from "@avaprotocol/types";
|
|
4
5
|
import { convertProtobufValueToJs, } from "../../utils";
|
|
@@ -85,9 +86,19 @@ class EventTrigger extends Trigger {
|
|
|
85
86
|
if (queryData.maxEventsPerBlock !== undefined) {
|
|
86
87
|
query.setMaxEventsPerBlock(queryData.maxEventsPerBlock);
|
|
87
88
|
}
|
|
88
|
-
// Set contractAbi if provided
|
|
89
|
+
// Set contractAbi if provided - must be an array like ContractRead
|
|
89
90
|
if (queryData.contractAbi) {
|
|
90
|
-
|
|
91
|
+
// Strictly require array format (no string support)
|
|
92
|
+
if (!Array.isArray(queryData.contractAbi)) {
|
|
93
|
+
throw new Error('contractAbi must be an array of ABI elements');
|
|
94
|
+
}
|
|
95
|
+
// Convert array to protobuf Value list
|
|
96
|
+
const abiValueList = queryData.contractAbi.map(item => {
|
|
97
|
+
const value = new google_protobuf_struct_pb.Value();
|
|
98
|
+
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
99
|
+
return value;
|
|
100
|
+
});
|
|
101
|
+
query.setContractAbiList(abiValueList);
|
|
91
102
|
}
|
|
92
103
|
// Set conditions if provided
|
|
93
104
|
if (queryData.conditions && queryData.conditions.length > 0) {
|
|
@@ -135,6 +146,7 @@ class EventTrigger extends Trigger {
|
|
|
135
146
|
const queryData = {
|
|
136
147
|
addresses: [],
|
|
137
148
|
topics: [],
|
|
149
|
+
contractAbi: [], // Add the required contractAbi field
|
|
138
150
|
};
|
|
139
151
|
// Extract addresses
|
|
140
152
|
if (query.getAddressesList && query.getAddressesList().length > 0) {
|
|
@@ -155,9 +167,9 @@ class EventTrigger extends Trigger {
|
|
|
155
167
|
queryData.maxEventsPerBlock = maxEvents;
|
|
156
168
|
}
|
|
157
169
|
// Extract contractAbi
|
|
158
|
-
const contractAbi = query.
|
|
159
|
-
if (contractAbi) {
|
|
160
|
-
queryData.contractAbi = contractAbi;
|
|
170
|
+
const contractAbi = query.getContractAbiList();
|
|
171
|
+
if (contractAbi && contractAbi.length > 0) {
|
|
172
|
+
queryData.contractAbi = contractAbi.map(value => convertProtobufValueToJs(value));
|
|
161
173
|
}
|
|
162
174
|
// Extract conditions
|
|
163
175
|
const conditions = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepare": "node ../../scripts/prepare-package.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@avaprotocol/types": "^2.4.
|
|
34
|
+
"@avaprotocol/types": "^2.4.3",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|
package/dist/auth.d.ts
DELETED
package/dist/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,IAAI,EAAE,WAAW,IAAI,KAAG,MAUxG,CAAA"}
|
package/dist/auth.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const getKeyRequestMessage = (chainId, address, issuedAt, expiredAt) => {
|
|
2
|
-
return `Please sign the below text for ownership verification.
|
|
3
|
-
|
|
4
|
-
URI: https://app.avaprotocol.org
|
|
5
|
-
Chain ID: ${chainId}
|
|
6
|
-
Version: 1
|
|
7
|
-
Issued At: ${issuedAt.toISOString()}
|
|
8
|
-
Expire At: ${expiredAt.toISOString()}
|
|
9
|
-
Wallet: ${address}`;
|
|
10
|
-
};
|
package/dist/config.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Environment } from "@avaprotocol/types";
|
|
2
|
-
export declare const DEFAULT_JWT_EXPIRATION: number;
|
|
3
|
-
interface Config {
|
|
4
|
-
AVS_RPC_URL: string;
|
|
5
|
-
}
|
|
6
|
-
declare const configs: Record<Environment, Config>;
|
|
7
|
-
export declare function getRpcEndpoint(env: Environment): string;
|
|
8
|
-
export { configs };
|
|
9
|
-
//# sourceMappingURL=config.d.ts.map
|