@avaprotocol/sdk-js 2.1.0 → 2.2.0

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 +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,EAAkC,qBAAqB,EAAa,MAAM,oBAAoB,CAAC;AAMtG,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAU3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAoB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAUrE;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;AAChD,OAAO,EAAkC,qBAAqB,EAAa,MAAM,oBAAoB,CAAC;AAMtG,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAU3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IA8B5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAmBrE;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import Node from "./interface";
2
2
  import * as avs_pb from "@/grpc_codegen/avs_pb";
3
3
  import { NodeType } from "@avaprotocol/types";
4
- import { convertProtobufValueToJs } from "../../utils";
5
4
  // Required props for constructor: id, name, type and data
6
5
  class ContractReadNode extends Node {
7
6
  constructor(props) {
@@ -23,18 +22,36 @@ class ContractReadNode extends Node {
23
22
  const nodeData = new avs_pb.ContractReadNode();
24
23
  const config = new avs_pb.ContractReadNode.Config();
25
24
  config.setContractAddress(this.data.contractAddress);
26
- config.setCallData(this.data.callData);
27
25
  config.setContractAbi(this.data.contractAbi);
26
+ // Handle method calls array - use camelCase property name from protobuf AsObject
27
+ const methodCalls = this.data.methodCallsList || [];
28
+ methodCalls.forEach((methodCall) => {
29
+ const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
30
+ methodCallMsg.setCallData(methodCall.callData);
31
+ if (methodCall.methodName) {
32
+ methodCallMsg.setMethodName(methodCall.methodName);
33
+ }
34
+ config.addMethodCalls(methodCallMsg);
35
+ });
28
36
  nodeData.setConfig(config);
29
37
  request.setContractRead(nodeData);
30
38
  return request;
31
39
  }
32
40
  static fromOutputData(outputData) {
33
41
  const contractReadOutput = outputData.getContractRead();
34
- if (contractReadOutput && contractReadOutput.getDataList()) {
35
- const dataList = contractReadOutput.getDataList();
42
+ if (contractReadOutput && contractReadOutput.getResultsList()) {
43
+ const resultsList = contractReadOutput.getResultsList();
36
44
  return {
37
- dataList: dataList.map((value) => convertProtobufValueToJs(value))
45
+ results: resultsList.map((result) => ({
46
+ methodName: result.getMethodName(),
47
+ success: result.getSuccess(),
48
+ error: result.getError(),
49
+ data: result.getDataList().map((field) => ({
50
+ name: field.getName(),
51
+ type: field.getType(),
52
+ value: field.getValue()
53
+ }))
54
+ }))
38
55
  };
39
56
  }
40
57
  return null;
@@ -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;AAC/B,OAAO,EAA0B,aAAa,EAAa,MAAM,oBAAoB,CAAC;AAKtF,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IA+BnD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAkG5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAIrE;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;AAC/B,OAAO,EAA0B,aAAa,EAAa,MAAM,oBAAoB,CAAC;AAKtF,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IA+BnD,SAAS,IAAI,MAAM,CAAC,QAAQ;IA6G5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAIrE;AAED,eAAe,QAAQ,CAAC"}
@@ -71,8 +71,17 @@ class LoopNode extends Node {
71
71
  if (data.contractRead.config) {
72
72
  const config = new avs_pb.ContractReadNode.Config();
73
73
  config.setContractAddress(data.contractRead.config.contractAddress);
74
- config.setCallData(data.contractRead.config.callData);
75
74
  config.setContractAbi(data.contractRead.config.contractAbi);
75
+ // Handle method calls array
76
+ const methodCalls = data.contractRead.config.methodCallsList || [];
77
+ methodCalls.forEach((methodCall) => {
78
+ const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
79
+ methodCallMsg.setCallData(methodCall.callData);
80
+ if (methodCall.methodName) {
81
+ methodCallMsg.setMethodName(methodCall.methodName);
82
+ }
83
+ config.addMethodCalls(methodCallMsg);
84
+ });
76
85
  contractRead.setConfig(config);
77
86
  }
78
87
  loopNode.setContractRead(contractRead);
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAa5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAenB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IA8F9D,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAa5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAenB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IA0H9D,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
@@ -89,11 +89,40 @@ class Step {
89
89
  case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
90
90
  nodeOutputMessage = step.getContractRead();
91
91
  if (nodeOutputMessage) {
92
- return nodeOutputMessage
93
- .getDataList()
94
- .map((val) => convertProtobufValueToJs(val));
92
+ const results = nodeOutputMessage.getResultsList();
93
+ if (results && results.length > 0) {
94
+ // If single result, return it directly for backward compatibility
95
+ if (results.length === 1) {
96
+ const result = results[0];
97
+ const structuredData = {};
98
+ result.getDataList().forEach((field) => {
99
+ structuredData[field.getName()] = field.getValue();
100
+ });
101
+ return {
102
+ methodName: result.getMethodName(),
103
+ success: result.getSuccess(),
104
+ error: result.getError(),
105
+ data: structuredData,
106
+ };
107
+ }
108
+ else {
109
+ // Multiple results - return as array
110
+ return results.map((result) => {
111
+ const structuredData = {};
112
+ result.getDataList().forEach((field) => {
113
+ structuredData[field.getName()] = field.getValue();
114
+ });
115
+ return {
116
+ methodName: result.getMethodName(),
117
+ success: result.getSuccess(),
118
+ error: result.getError(),
119
+ data: structuredData,
120
+ };
121
+ });
122
+ }
123
+ }
95
124
  }
96
- return [];
125
+ return undefined;
97
126
  case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
98
127
  return step.getContractWrite()?.toObject();
99
128
  case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
@@ -19,7 +19,7 @@ import { TriggerType } from "@avaprotocol/types";
19
19
  // }
20
20
  // ]
21
21
  // ```
22
- // Required props for constructor: id, name, type and data: { expression, matcherList }
22
+ // Required props for constructor: id, name, type and data: { queriesList }
23
23
  // EventTrigger now uses queries-based filtering instead of expression/matcher
24
24
  // Each query represents an independent filter that creates its own subscription
25
25
  // For FROM-OR-TO scenarios, provide two queries: one for FROM, one for TO.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "clean": "rm -rf node_modules dist tsconfig.tsbuildinfo"
31
31
  },
32
32
  "dependencies": {
33
- "@avaprotocol/types": "2.0.2",
33
+ "@avaprotocol/types": "workspace:*",
34
34
  "@grpc/grpc-js": "^1.11.3",
35
35
  "@grpc/proto-loader": "^0.7.13",
36
36
  "dotenv": "^16.4.5",