@avaprotocol/sdk-js 2.6.1 → 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.
@@ -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,19 +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
- methodParams?: string[];
19
- }>;
20
- }): avs_pb.ContractReadNode;
11
+ static createProtobufNode(configData: ContractReadNodeData): avs_pb.ContractReadNode;
21
12
  static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
22
13
  toRequest(): avs_pb.TaskNode;
23
- static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
14
+ static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown | null;
24
15
  }
25
16
  export default ContractReadNode;
26
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;AAChD,OAAO,EAGL,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AAS5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;YACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;SACzB,CAAC,CAAC;KACJ,GAAG,MAAM,CAAC,gBAAgB;IA4B3B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAyB3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAyBrE;AAED,eAAe,gBAAgB,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
- config.setContractAbi(configData.contractAbi);
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
- methodCallMsg.setCallData(methodCall.callData);
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 protobufData = raw.getContractRead().getConfig().toObject();
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: protobufData.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 && contractReadOutput.getData()) {
71
- // The new structure uses getData() which returns a protobuf Value
72
- const data = contractReadOutput.getData();
73
- if (data) {
74
- // Convert protobuf Value to JavaScript object
75
- const jsData = convertProtobufValueToJs(data);
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,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,16 +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
- methodParams?: string[];
19
- }>;
20
- }): avs_pb.ContractWriteNode;
11
+ static createProtobufNode(configData: ContractWriteNodeData): avs_pb.ContractWriteNode;
21
12
  static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
22
13
  toRequest(): avs_pb.TaskNode;
23
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;AAChD,OAAO,EAGL,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,iBAAkB,SAAQ,IAAI;gBACtB,KAAK,EAAE,sBAAsB;IAIzC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;SACzB,CAAC,CAAC;KACJ,GAAG,MAAM,CAAC,iBAAiB;IA0B5B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB;IAyB5D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO,EAAE,GAAG,IAAI;CAclF;AAED,eAAe,iBAAiB,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
- config.setCallData(configData.callData);
20
- config.setContractAbi(configData.contractAbi);
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
- methodCallMsg.setCallData(methodCall.callData);
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 protobufData = raw.getContractWrite().getConfig().toObject();
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
- callData: protobufData.callData,
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
- // Return the array directly, matching ContractRead format
77
- return Array.isArray(jsData) ? jsData : [jsData];
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;
@@ -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;IA4F3B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO;CAqCzE;AAED,eAAe,QAAQ,CAAC"}
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"}
@@ -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, data: loopNodeData[key] };
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.methodCallsList || [],
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.methodCallsList || [],
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
- // Convert protobuf Value to JavaScript
209
- return dataValue.toJavaScript();
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;AAChD,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;IAkG/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAqF1D;;;;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
+ {"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
- query.setContractAbi(queryData.contractAbi);
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.getContractAbi();
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.1",
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.1",
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",