@avaprotocol/sdk-js 2.3.9-dev.1 → 2.3.9

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @avaprotocol/sdk-js
2
2
 
3
+ ## 2.3.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 42b23c8: Fixed contract read Step Output;added data validity check to block and cron
8
+
3
9
  ## 2.3.8
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -17723,7 +17723,42 @@ var Step = class _Step {
17723
17723
  nodeOutputMessage = step.getFilter();
17724
17724
  return nodeOutputMessage && nodeOutputMessage.hasData() ? nodeOutputMessage.getData() : void 0;
17725
17725
  case avs_pb20.Execution.Step.OutputDataCase.LOOP:
17726
- return step.getLoop()?.getData();
17726
+ const loopOutput = step.getLoop();
17727
+ if (!loopOutput) return void 0;
17728
+ const loopData = loopOutput.getData();
17729
+ if (!loopData) return void 0;
17730
+ try {
17731
+ const parsedData = JSON.parse(loopData);
17732
+ if (Array.isArray(parsedData)) {
17733
+ return parsedData.map((item, index) => {
17734
+ if (!item || typeof item !== "object") {
17735
+ return item;
17736
+ }
17737
+ if (item.statusCode !== void 0 && (item.body !== void 0 || item.headers !== void 0)) {
17738
+ return item;
17739
+ }
17740
+ if (item.result !== void 0 || item.output !== void 0 || item.error !== void 0) {
17741
+ return item;
17742
+ }
17743
+ if (item.transactionHash !== void 0) {
17744
+ return { transactionHash: item.transactionHash };
17745
+ }
17746
+ if (item.methodName !== void 0 && item.data !== void 0) {
17747
+ return item;
17748
+ }
17749
+ if (item.data !== void 0 && typeof item.data === "object") {
17750
+ return item;
17751
+ }
17752
+ return item;
17753
+ });
17754
+ }
17755
+ if (parsedData && typeof parsedData === "object") {
17756
+ return parsedData;
17757
+ }
17758
+ return { data: parsedData };
17759
+ } catch (e) {
17760
+ return { data: loopData };
17761
+ }
17727
17762
  default:
17728
17763
  console.warn(
17729
17764
  `Unhandled output data type in Step.getOutput: ${outputDataType}`
package/dist/index.mjs CHANGED
@@ -17706,7 +17706,42 @@ var Step = class _Step {
17706
17706
  nodeOutputMessage = step.getFilter();
17707
17707
  return nodeOutputMessage && nodeOutputMessage.hasData() ? nodeOutputMessage.getData() : void 0;
17708
17708
  case avs_pb20.Execution.Step.OutputDataCase.LOOP:
17709
- return step.getLoop()?.getData();
17709
+ const loopOutput = step.getLoop();
17710
+ if (!loopOutput) return void 0;
17711
+ const loopData = loopOutput.getData();
17712
+ if (!loopData) return void 0;
17713
+ try {
17714
+ const parsedData = JSON.parse(loopData);
17715
+ if (Array.isArray(parsedData)) {
17716
+ return parsedData.map((item, index) => {
17717
+ if (!item || typeof item !== "object") {
17718
+ return item;
17719
+ }
17720
+ if (item.statusCode !== void 0 && (item.body !== void 0 || item.headers !== void 0)) {
17721
+ return item;
17722
+ }
17723
+ if (item.result !== void 0 || item.output !== void 0 || item.error !== void 0) {
17724
+ return item;
17725
+ }
17726
+ if (item.transactionHash !== void 0) {
17727
+ return { transactionHash: item.transactionHash };
17728
+ }
17729
+ if (item.methodName !== void 0 && item.data !== void 0) {
17730
+ return item;
17731
+ }
17732
+ if (item.data !== void 0 && typeof item.data === "object") {
17733
+ return item;
17734
+ }
17735
+ return item;
17736
+ });
17737
+ }
17738
+ if (parsedData && typeof parsedData === "object") {
17739
+ return parsedData;
17740
+ }
17741
+ return { data: parsedData };
17742
+ } catch (e) {
17743
+ return { data: loopData };
17744
+ }
17710
17745
  default:
17711
17746
  console.warn(
17712
17747
  `Unhandled output data type in Step.getOutput: ${outputDataType}`
@@ -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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,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
@@ -202,7 +202,60 @@ class Step {
202
202
  ? nodeOutputMessage.getData()
203
203
  : undefined;
204
204
  case avs_pb.Execution.Step.OutputDataCase.LOOP:
205
- return step.getLoop()?.getData();
205
+ const loopOutput = step.getLoop();
206
+ if (!loopOutput)
207
+ return undefined;
208
+ const loopData = loopOutput.getData();
209
+ if (!loopData)
210
+ return undefined;
211
+ // Loop nodes return an array of results from child node executions
212
+ // The backend should serialize this as JSON, but may have issues
213
+ // Try to parse as JSON first (expected format for array of child results)
214
+ try {
215
+ const parsedData = JSON.parse(loopData);
216
+ // If it's an array, process each item with appropriate child node conversion
217
+ if (Array.isArray(parsedData)) {
218
+ return parsedData.map((item, index) => {
219
+ if (!item || typeof item !== 'object') {
220
+ return item; // Primitive values, return as-is
221
+ }
222
+ // Apply child node-specific conversions based on detected structure
223
+ // REST API child output (has statusCode, body, headers)
224
+ if (item.statusCode !== undefined && (item.body !== undefined || item.headers !== undefined)) {
225
+ return item; // Already in raw format
226
+ }
227
+ // Custom Code child output (arbitrary object structure)
228
+ if (item.result !== undefined || item.output !== undefined || item.error !== undefined) {
229
+ return item; // Already processed by convertProtobufValueToJs in backend
230
+ }
231
+ // ETH Transfer child output (has transactionHash)
232
+ if (item.transactionHash !== undefined) {
233
+ return { transactionHash: item.transactionHash };
234
+ }
235
+ // Contract Read child output (has methodName and data)
236
+ if (item.methodName !== undefined && item.data !== undefined) {
237
+ return item; // Already in structured format
238
+ }
239
+ // GraphQL child output (has data field)
240
+ if (item.data !== undefined && typeof item.data === 'object') {
241
+ return item; // Already processed
242
+ }
243
+ // Generic object - return as-is (might be custom structure)
244
+ return item;
245
+ });
246
+ }
247
+ // Single object result (not an array)
248
+ if (parsedData && typeof parsedData === 'object') {
249
+ return parsedData;
250
+ }
251
+ // Parsed successfully but primitive value
252
+ return { data: parsedData };
253
+ }
254
+ catch (e) {
255
+ // Not JSON or parsing failed - could be a simple string result
256
+ // This might happen if backend has serialization issues
257
+ return { data: loopData };
258
+ }
206
259
  default:
207
260
  console.warn(`Unhandled output data type in Step.getOutput: ${outputDataType}`);
208
261
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.3.9-dev.1",
3
+ "version": "2.3.9",
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",