@avaprotocol/sdk-js 2.6.0 → 2.6.2
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.map +1 -1
- package/dist/index.js +549 -1281
- package/dist/index.mjs +549 -1281
- package/dist/models/node/contractRead.d.ts +3 -11
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +26 -26
- package/dist/models/node/contractWrite.d.ts +2 -10
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +50 -9
- 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 +12 -4
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractReadNodeProps } from "@avaprotocol/types";
|
|
3
|
+
import { ContractReadNodeData, ContractReadNodeProps } from "@avaprotocol/types";
|
|
4
4
|
declare class ContractReadNode extends Node {
|
|
5
5
|
constructor(props: ContractReadNodeProps);
|
|
6
6
|
/**
|
|
@@ -8,18 +8,10 @@ declare class ContractReadNode extends Node {
|
|
|
8
8
|
* @param configData - The configuration data for the contract read node
|
|
9
9
|
* @returns Configured avs_pb.ContractReadNode
|
|
10
10
|
*/
|
|
11
|
-
static createProtobufNode(configData:
|
|
12
|
-
contractAddress: string;
|
|
13
|
-
contractAbi: string;
|
|
14
|
-
methodCalls?: Array<{
|
|
15
|
-
callData: string;
|
|
16
|
-
methodName?: string;
|
|
17
|
-
applyToFields?: string[];
|
|
18
|
-
}>;
|
|
19
|
-
}): avs_pb.ContractReadNode;
|
|
11
|
+
static createProtobufNode(configData: ContractReadNodeData): avs_pb.ContractReadNode;
|
|
20
12
|
static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
|
|
21
13
|
toRequest(): avs_pb.TaskNode;
|
|
22
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp):
|
|
14
|
+
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown | null;
|
|
23
15
|
}
|
|
24
16
|
export default ContractReadNode;
|
|
25
17
|
//# sourceMappingURL=contractRead.d.ts.map
|
|
@@ -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,18 +17,30 @@ 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
|
}
|
|
28
38
|
if (methodCall.applyToFields) {
|
|
29
39
|
methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
|
|
30
40
|
}
|
|
41
|
+
if (methodCall.methodParams) {
|
|
42
|
+
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
43
|
+
}
|
|
31
44
|
config.addMethodCalls(methodCallMsg);
|
|
32
45
|
});
|
|
33
46
|
node.setConfig(config);
|
|
@@ -36,15 +49,18 @@ class ContractReadNode extends Node {
|
|
|
36
49
|
static fromResponse(raw) {
|
|
37
50
|
// Convert the raw object to ContractReadNodeProps, which should keep name and id
|
|
38
51
|
const obj = raw.toObject();
|
|
39
|
-
const
|
|
52
|
+
const contractReadNode = raw.getContractRead();
|
|
53
|
+
const config = contractReadNode.getConfig();
|
|
54
|
+
const protobufData = config.toObject();
|
|
40
55
|
// Convert protobuf data to our custom interface
|
|
41
56
|
const data = {
|
|
42
57
|
contractAddress: protobufData.contractAddress,
|
|
43
|
-
contractAbi:
|
|
58
|
+
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
44
59
|
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
45
60
|
callData: call.callData,
|
|
46
61
|
methodName: call.methodName,
|
|
47
62
|
applyToFields: call.applyToFieldsList || [],
|
|
63
|
+
methodParams: call.methodParamsList || [],
|
|
48
64
|
})) || [],
|
|
49
65
|
};
|
|
50
66
|
return new ContractReadNode({
|
|
@@ -63,28 +79,12 @@ class ContractReadNode extends Node {
|
|
|
63
79
|
}
|
|
64
80
|
static fromOutputData(outputData) {
|
|
65
81
|
const contractReadOutput = outputData.getContractRead();
|
|
66
|
-
if (contractReadOutput
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// The data should now be directly an array of results
|
|
73
|
-
if (Array.isArray(jsData)) {
|
|
74
|
-
return jsData.map((result) => ({
|
|
75
|
-
methodName: result.methodName,
|
|
76
|
-
success: result.success,
|
|
77
|
-
error: result.error || "",
|
|
78
|
-
data: result.data || {},
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// Fallback for old format or unexpected structure
|
|
83
|
-
return jsData;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
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;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export default ContractReadNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractWriteNodeProps } from "@avaprotocol/types";
|
|
3
|
+
import { ContractWriteNodeData, ContractWriteNodeProps } from "@avaprotocol/types";
|
|
4
4
|
declare class ContractWriteNode extends Node {
|
|
5
5
|
constructor(props: ContractWriteNodeProps);
|
|
6
6
|
/**
|
|
@@ -8,15 +8,7 @@ declare class ContractWriteNode extends Node {
|
|
|
8
8
|
* @param configData - The configuration data for the contract write node
|
|
9
9
|
* @returns Configured avs_pb.ContractWriteNode
|
|
10
10
|
*/
|
|
11
|
-
static createProtobufNode(configData:
|
|
12
|
-
contractAddress: string;
|
|
13
|
-
callData: string;
|
|
14
|
-
contractAbi: string;
|
|
15
|
-
methodCalls?: Array<{
|
|
16
|
-
callData: string;
|
|
17
|
-
methodName?: string;
|
|
18
|
-
}>;
|
|
19
|
-
}): avs_pb.ContractWriteNode;
|
|
11
|
+
static createProtobufNode(configData: ContractWriteNodeData): avs_pb.ContractWriteNode;
|
|
20
12
|
static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
|
|
21
13
|
toRequest(): avs_pb.TaskNode;
|
|
22
14
|
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown[] | null;
|
|
@@ -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,16 +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
|
}
|
|
39
|
+
if (methodCall.methodParams) {
|
|
40
|
+
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
41
|
+
}
|
|
42
|
+
// Note: applyToFields is not supported for ContractWrite nodes
|
|
29
43
|
config.addMethodCalls(methodCallMsg);
|
|
30
44
|
});
|
|
31
45
|
node.setConfig(config);
|
|
@@ -34,15 +48,19 @@ class ContractWriteNode extends Node {
|
|
|
34
48
|
static fromResponse(raw) {
|
|
35
49
|
// Convert the raw object to ContractWriteNodeProps, which should keep name and id
|
|
36
50
|
const obj = raw.toObject();
|
|
37
|
-
const
|
|
51
|
+
const contractWriteNode = raw.getContractWrite();
|
|
52
|
+
const config = contractWriteNode.getConfig();
|
|
53
|
+
const protobufData = config.toObject();
|
|
38
54
|
// Convert protobuf data to our custom interface
|
|
39
55
|
const data = {
|
|
40
56
|
contractAddress: protobufData.contractAddress,
|
|
41
|
-
|
|
42
|
-
contractAbi: protobufData.contractAbi,
|
|
57
|
+
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
43
58
|
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
44
|
-
callData: call.callData,
|
|
45
59
|
methodName: call.methodName,
|
|
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 }),
|
|
46
64
|
})) || [],
|
|
47
65
|
};
|
|
48
66
|
return new ContractWriteNode({
|
|
@@ -69,8 +87,31 @@ class ContractWriteNode extends Node {
|
|
|
69
87
|
return null;
|
|
70
88
|
// Convert protobuf Value to JavaScript object
|
|
71
89
|
const jsData = convertProtobufValueToJs(data);
|
|
72
|
-
//
|
|
73
|
-
|
|
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
|
+
}
|
|
74
115
|
}
|
|
75
116
|
}
|
|
76
117
|
export default ContractWriteNode;
|
|
@@ -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;IAwG/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";
|
|
@@ -87,7 +88,13 @@ class EventTrigger extends Trigger {
|
|
|
87
88
|
}
|
|
88
89
|
// Set contractAbi if provided
|
|
89
90
|
if (queryData.contractAbi) {
|
|
90
|
-
|
|
91
|
+
// Convert array to protobuf Value list
|
|
92
|
+
const abiValueList = queryData.contractAbi.map(item => {
|
|
93
|
+
const value = new google_protobuf_struct_pb.Value();
|
|
94
|
+
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
95
|
+
return value;
|
|
96
|
+
});
|
|
97
|
+
query.setContractAbiList(abiValueList);
|
|
91
98
|
}
|
|
92
99
|
// Set conditions if provided
|
|
93
100
|
if (queryData.conditions && queryData.conditions.length > 0) {
|
|
@@ -135,6 +142,7 @@ class EventTrigger extends Trigger {
|
|
|
135
142
|
const queryData = {
|
|
136
143
|
addresses: [],
|
|
137
144
|
topics: [],
|
|
145
|
+
contractAbi: [], // Add the required contractAbi field
|
|
138
146
|
};
|
|
139
147
|
// Extract addresses
|
|
140
148
|
if (query.getAddressesList && query.getAddressesList().length > 0) {
|
|
@@ -155,9 +163,9 @@ class EventTrigger extends Trigger {
|
|
|
155
163
|
queryData.maxEventsPerBlock = maxEvents;
|
|
156
164
|
}
|
|
157
165
|
// Extract contractAbi
|
|
158
|
-
const contractAbi = query.
|
|
159
|
-
if (contractAbi) {
|
|
160
|
-
queryData.contractAbi = contractAbi;
|
|
166
|
+
const contractAbi = query.getContractAbiList();
|
|
167
|
+
if (contractAbi && contractAbi.length > 0) {
|
|
168
|
+
queryData.contractAbi = contractAbi.map(value => convertProtobufValueToJs(value));
|
|
161
169
|
}
|
|
162
170
|
// Extract conditions
|
|
163
171
|
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.2",
|
|
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.2",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|