@avaprotocol/sdk-js 2.6.10 → 2.6.12

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,19 @@
1
1
  # @avaprotocol/sdk-js
2
2
 
3
+ ## 2.6.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 56d89ae: Updated ContractWrite protobuf conversion
8
+ - Updated dependencies [56d89ae]
9
+ - @avaprotocol/types@2.4.10
10
+
11
+ ## 2.6.11
12
+
13
+ ### Patch Changes
14
+
15
+ - 9261ba8: Update response of ContractWriteNode to fix metadata
16
+
3
17
  ## 2.6.10
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -3723,7 +3723,8 @@ var require_avs_pb = __commonJS({
3723
3723
  };
3724
3724
  proto.aggregator.ContractWriteNode.Output.toObject = function(includeInstance, msg) {
3725
3725
  var f, obj = {
3726
- data: (f = msg.getData()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f)
3726
+ data: (f = msg.getData()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f),
3727
+ metadata: (f = msg.getMetadata()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f)
3727
3728
  };
3728
3729
  if (includeInstance) {
3729
3730
  obj.$jspbMessageInstance = msg;
@@ -3748,6 +3749,11 @@ var require_avs_pb = __commonJS({
3748
3749
  reader.readMessage(value, google_protobuf_struct_pb5.Value.deserializeBinaryFromReader);
3749
3750
  msg.setData(value);
3750
3751
  break;
3752
+ case 2:
3753
+ var value = new google_protobuf_struct_pb5.Value();
3754
+ reader.readMessage(value, google_protobuf_struct_pb5.Value.deserializeBinaryFromReader);
3755
+ msg.setMetadata(value);
3756
+ break;
3751
3757
  default:
3752
3758
  reader.skipField();
3753
3759
  break;
@@ -3770,6 +3776,14 @@ var require_avs_pb = __commonJS({
3770
3776
  google_protobuf_struct_pb5.Value.serializeBinaryToWriter
3771
3777
  );
3772
3778
  }
3779
+ f = message.getMetadata();
3780
+ if (f != null) {
3781
+ writer.writeMessage(
3782
+ 2,
3783
+ f,
3784
+ google_protobuf_struct_pb5.Value.serializeBinaryToWriter
3785
+ );
3786
+ }
3773
3787
  };
3774
3788
  proto.aggregator.ContractWriteNode.Output.prototype.getData = function() {
3775
3789
  return (
@@ -3786,6 +3800,21 @@ var require_avs_pb = __commonJS({
3786
3800
  proto.aggregator.ContractWriteNode.Output.prototype.hasData = function() {
3787
3801
  return jspb.Message.getField(this, 1) != null;
3788
3802
  };
3803
+ proto.aggregator.ContractWriteNode.Output.prototype.getMetadata = function() {
3804
+ return (
3805
+ /** @type{?proto.google.protobuf.Value} */
3806
+ jspb.Message.getWrapperField(this, google_protobuf_struct_pb5.Value, 2)
3807
+ );
3808
+ };
3809
+ proto.aggregator.ContractWriteNode.Output.prototype.setMetadata = function(value) {
3810
+ return jspb.Message.setWrapperField(this, 2, value);
3811
+ };
3812
+ proto.aggregator.ContractWriteNode.Output.prototype.clearMetadata = function() {
3813
+ return this.setMetadata(void 0);
3814
+ };
3815
+ proto.aggregator.ContractWriteNode.Output.prototype.hasMetadata = function() {
3816
+ return jspb.Message.getField(this, 2) != null;
3817
+ };
3789
3818
  if (jspb.Message.GENERATE_TO_OBJECT) {
3790
3819
  proto.aggregator.ContractWriteNode.MethodResult.prototype.toObject = function(opt_includeInstance) {
3791
3820
  return proto.aggregator.ContractWriteNode.MethodResult.toObject(opt_includeInstance, this);
@@ -16458,7 +16487,7 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
16458
16487
  return value;
16459
16488
  });
16460
16489
  config.setContractAbiList(abiValueList);
16461
- const methodCalls = configData.methodCalls || [];
16490
+ const methodCalls = configData.methodCalls;
16462
16491
  methodCalls.forEach((methodCall) => {
16463
16492
  const methodCallMsg = new avs_pb9.ContractWriteNode.MethodCall();
16464
16493
  if (methodCall.callData) {
@@ -16512,34 +16541,8 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
16512
16541
  static fromOutputData(outputData) {
16513
16542
  const contractWriteOutput = outputData.getContractWrite();
16514
16543
  if (!contractWriteOutput) return null;
16515
- const data = contractWriteOutput.getData();
16516
- if (!data) return null;
16517
- const jsData = convertProtobufValueToJs(data);
16518
- if (Array.isArray(jsData)) {
16519
- return jsData.map((result) => {
16520
- const methodName = result.method_name || result.methodName;
16521
- return {
16522
- methodName,
16523
- methodABI: result.method_abi || null,
16524
- success: result.success,
16525
- error: result.error || "",
16526
- value: result.value,
16527
- receipt: result.receipt || null
16528
- // Add receipt field
16529
- };
16530
- });
16531
- } else {
16532
- const methodName = jsData.method_name || jsData.methodName;
16533
- return [{
16534
- methodName,
16535
- methodABI: jsData.method_abi || null,
16536
- success: jsData.success,
16537
- error: jsData.error || "",
16538
- value: jsData.value,
16539
- receipt: jsData.receipt || null
16540
- // Add receipt field
16541
- }];
16542
- }
16544
+ const dataValue = contractWriteOutput.getData();
16545
+ return dataValue ? convertProtobufValueToJs(dataValue) : {};
16543
16546
  }
16544
16547
  };
16545
16548
  var contractWrite_default = ContractWriteNode2;
@@ -16622,9 +16625,9 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
16622
16625
  const config = new avs_pb11.GraphQLQueryNode.Config();
16623
16626
  config.setUrl(configData.url);
16624
16627
  config.setQuery(configData.query);
16625
- if (configData.variablesMap && configData.variablesMap.length > 0) {
16628
+ if (configData.variables && Object.keys(configData.variables).length > 0) {
16626
16629
  const variablesMap = config.getVariablesMap();
16627
- configData.variablesMap.forEach(([key, value]) => {
16630
+ Object.entries(configData.variables).forEach(([key, value]) => {
16628
16631
  variablesMap.set(key, value);
16629
16632
  });
16630
16633
  }
@@ -16633,10 +16636,20 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
16633
16636
  }
16634
16637
  static fromResponse(raw) {
16635
16638
  const obj = raw.toObject();
16639
+ const config = raw.getGraphqlQuery().getConfig();
16640
+ const variablesMap = config.getVariablesMap();
16641
+ const variables = {};
16642
+ variablesMap.forEach((value, key) => {
16643
+ variables[key] = value;
16644
+ });
16636
16645
  return new _GraphQLQueryNode({
16637
16646
  ...obj,
16638
16647
  type: import_types11.NodeType.GraphQLQuery,
16639
- data: raw.getGraphqlQuery().getConfig().toObject()
16648
+ data: {
16649
+ url: config.getUrl(),
16650
+ query: config.getQuery(),
16651
+ variables
16652
+ }
16640
16653
  });
16641
16654
  }
16642
16655
  toRequest() {
@@ -16723,7 +16736,6 @@ var RestAPINode2 = class _RestAPINode extends Node {
16723
16736
  static fromOutputData(outputData) {
16724
16737
  const restApiOutput = outputData.getRestApi();
16725
16738
  if (!restApiOutput) {
16726
- console.log("Debug RestAPI: No restApiOutput found");
16727
16739
  return null;
16728
16740
  }
16729
16741
  const rawData = restApiOutput.getData();
@@ -16760,7 +16772,7 @@ var ContractReadNode2 = class _ContractReadNode extends Node {
16760
16772
  return value;
16761
16773
  });
16762
16774
  config.setContractAbiList(abiValueList);
16763
- const methodCalls = configData.methodCalls || [];
16775
+ const methodCalls = configData.methodCalls;
16764
16776
  methodCalls.forEach((methodCall) => {
16765
16777
  const methodCallMsg = new avs_pb13.ContractReadNode.MethodCall();
16766
16778
  methodCallMsg.setMethodName(methodCall.methodName);
@@ -17130,7 +17142,7 @@ var LoopNode2 = class _LoopNode extends Node {
17130
17142
  const graphqlQuery = graphqlQuery_default.createProtobufNode({
17131
17143
  url: gqlConfig.url,
17132
17144
  query: gqlConfig.query,
17133
- variablesMap: gqlConfig.variablesMap
17145
+ variables: gqlConfig.variables
17134
17146
  });
17135
17147
  loopNode.setGraphqlDataQuery(graphqlQuery);
17136
17148
  break;
@@ -17470,6 +17482,22 @@ var Step = class _Step {
17470
17482
  static getOutput(step) {
17471
17483
  const outputData = this.extractOutputData(step);
17472
17484
  if (!outputData) return null;
17485
+ const outputCase = this.getOutputDataCase(step);
17486
+ if (outputCase === avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE || outputCase === avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ) {
17487
+ try {
17488
+ const result = {};
17489
+ if (typeof outputData.getData === "function") {
17490
+ result.data = convertProtobufValueToJs(outputData.getData());
17491
+ }
17492
+ if (typeof outputData.getMetadata === "function") {
17493
+ result.metadata = convertProtobufValueToJs(outputData.getMetadata());
17494
+ }
17495
+ return result;
17496
+ } catch (error) {
17497
+ console.warn("Failed to convert ContractWrite/ContractRead protobuf to JavaScript:", error);
17498
+ return outputData.getData ? outputData.getData() : null;
17499
+ }
17500
+ }
17473
17501
  if (typeof outputData.hasData === "function" && outputData.hasData()) {
17474
17502
  try {
17475
17503
  return convertProtobufValueToJs(outputData.getData());
@@ -17477,6 +17505,13 @@ var Step = class _Step {
17477
17505
  console.warn("Failed to convert protobuf Value to JavaScript:", error);
17478
17506
  return outputData.getData();
17479
17507
  }
17508
+ } else if (typeof outputData.getData === "function") {
17509
+ try {
17510
+ return convertProtobufValueToJs(outputData.getData());
17511
+ } catch (error) {
17512
+ console.warn("Failed to convert protobuf Value to JavaScript:", error);
17513
+ return outputData.getData();
17514
+ }
17480
17515
  } else if (outputData.data) {
17481
17516
  return typeof outputData.data.getKindCase === "function" ? convertProtobufValueToJs(outputData.data) : outputData.data;
17482
17517
  }
package/dist/index.mjs CHANGED
@@ -3723,7 +3723,8 @@ var require_avs_pb = __commonJS({
3723
3723
  };
3724
3724
  proto.aggregator.ContractWriteNode.Output.toObject = function(includeInstance, msg) {
3725
3725
  var f, obj = {
3726
- data: (f = msg.getData()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f)
3726
+ data: (f = msg.getData()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f),
3727
+ metadata: (f = msg.getMetadata()) && google_protobuf_struct_pb5.Value.toObject(includeInstance, f)
3727
3728
  };
3728
3729
  if (includeInstance) {
3729
3730
  obj.$jspbMessageInstance = msg;
@@ -3748,6 +3749,11 @@ var require_avs_pb = __commonJS({
3748
3749
  reader.readMessage(value, google_protobuf_struct_pb5.Value.deserializeBinaryFromReader);
3749
3750
  msg.setData(value);
3750
3751
  break;
3752
+ case 2:
3753
+ var value = new google_protobuf_struct_pb5.Value();
3754
+ reader.readMessage(value, google_protobuf_struct_pb5.Value.deserializeBinaryFromReader);
3755
+ msg.setMetadata(value);
3756
+ break;
3751
3757
  default:
3752
3758
  reader.skipField();
3753
3759
  break;
@@ -3770,6 +3776,14 @@ var require_avs_pb = __commonJS({
3770
3776
  google_protobuf_struct_pb5.Value.serializeBinaryToWriter
3771
3777
  );
3772
3778
  }
3779
+ f = message.getMetadata();
3780
+ if (f != null) {
3781
+ writer.writeMessage(
3782
+ 2,
3783
+ f,
3784
+ google_protobuf_struct_pb5.Value.serializeBinaryToWriter
3785
+ );
3786
+ }
3773
3787
  };
3774
3788
  proto.aggregator.ContractWriteNode.Output.prototype.getData = function() {
3775
3789
  return (
@@ -3786,6 +3800,21 @@ var require_avs_pb = __commonJS({
3786
3800
  proto.aggregator.ContractWriteNode.Output.prototype.hasData = function() {
3787
3801
  return jspb.Message.getField(this, 1) != null;
3788
3802
  };
3803
+ proto.aggregator.ContractWriteNode.Output.prototype.getMetadata = function() {
3804
+ return (
3805
+ /** @type{?proto.google.protobuf.Value} */
3806
+ jspb.Message.getWrapperField(this, google_protobuf_struct_pb5.Value, 2)
3807
+ );
3808
+ };
3809
+ proto.aggregator.ContractWriteNode.Output.prototype.setMetadata = function(value) {
3810
+ return jspb.Message.setWrapperField(this, 2, value);
3811
+ };
3812
+ proto.aggregator.ContractWriteNode.Output.prototype.clearMetadata = function() {
3813
+ return this.setMetadata(void 0);
3814
+ };
3815
+ proto.aggregator.ContractWriteNode.Output.prototype.hasMetadata = function() {
3816
+ return jspb.Message.getField(this, 2) != null;
3817
+ };
3789
3818
  if (jspb.Message.GENERATE_TO_OBJECT) {
3790
3819
  proto.aggregator.ContractWriteNode.MethodResult.prototype.toObject = function(opt_includeInstance) {
3791
3820
  return proto.aggregator.ContractWriteNode.MethodResult.toObject(opt_includeInstance, this);
@@ -16446,7 +16475,7 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
16446
16475
  return value;
16447
16476
  });
16448
16477
  config.setContractAbiList(abiValueList);
16449
- const methodCalls = configData.methodCalls || [];
16478
+ const methodCalls = configData.methodCalls;
16450
16479
  methodCalls.forEach((methodCall) => {
16451
16480
  const methodCallMsg = new avs_pb9.ContractWriteNode.MethodCall();
16452
16481
  if (methodCall.callData) {
@@ -16500,34 +16529,8 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
16500
16529
  static fromOutputData(outputData) {
16501
16530
  const contractWriteOutput = outputData.getContractWrite();
16502
16531
  if (!contractWriteOutput) return null;
16503
- const data = contractWriteOutput.getData();
16504
- if (!data) return null;
16505
- const jsData = convertProtobufValueToJs(data);
16506
- if (Array.isArray(jsData)) {
16507
- return jsData.map((result) => {
16508
- const methodName = result.method_name || result.methodName;
16509
- return {
16510
- methodName,
16511
- methodABI: result.method_abi || null,
16512
- success: result.success,
16513
- error: result.error || "",
16514
- value: result.value,
16515
- receipt: result.receipt || null
16516
- // Add receipt field
16517
- };
16518
- });
16519
- } else {
16520
- const methodName = jsData.method_name || jsData.methodName;
16521
- return [{
16522
- methodName,
16523
- methodABI: jsData.method_abi || null,
16524
- success: jsData.success,
16525
- error: jsData.error || "",
16526
- value: jsData.value,
16527
- receipt: jsData.receipt || null
16528
- // Add receipt field
16529
- }];
16530
- }
16532
+ const dataValue = contractWriteOutput.getData();
16533
+ return dataValue ? convertProtobufValueToJs(dataValue) : {};
16531
16534
  }
16532
16535
  };
16533
16536
  var contractWrite_default = ContractWriteNode2;
@@ -16614,9 +16617,9 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
16614
16617
  const config = new avs_pb11.GraphQLQueryNode.Config();
16615
16618
  config.setUrl(configData.url);
16616
16619
  config.setQuery(configData.query);
16617
- if (configData.variablesMap && configData.variablesMap.length > 0) {
16620
+ if (configData.variables && Object.keys(configData.variables).length > 0) {
16618
16621
  const variablesMap = config.getVariablesMap();
16619
- configData.variablesMap.forEach(([key, value]) => {
16622
+ Object.entries(configData.variables).forEach(([key, value]) => {
16620
16623
  variablesMap.set(key, value);
16621
16624
  });
16622
16625
  }
@@ -16625,10 +16628,20 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
16625
16628
  }
16626
16629
  static fromResponse(raw) {
16627
16630
  const obj = raw.toObject();
16631
+ const config = raw.getGraphqlQuery().getConfig();
16632
+ const variablesMap = config.getVariablesMap();
16633
+ const variables = {};
16634
+ variablesMap.forEach((value, key) => {
16635
+ variables[key] = value;
16636
+ });
16628
16637
  return new _GraphQLQueryNode({
16629
16638
  ...obj,
16630
16639
  type: NodeType5.GraphQLQuery,
16631
- data: raw.getGraphqlQuery().getConfig().toObject()
16640
+ data: {
16641
+ url: config.getUrl(),
16642
+ query: config.getQuery(),
16643
+ variables
16644
+ }
16632
16645
  });
16633
16646
  }
16634
16647
  toRequest() {
@@ -16717,7 +16730,6 @@ var RestAPINode2 = class _RestAPINode extends Node {
16717
16730
  static fromOutputData(outputData) {
16718
16731
  const restApiOutput = outputData.getRestApi();
16719
16732
  if (!restApiOutput) {
16720
- console.log("Debug RestAPI: No restApiOutput found");
16721
16733
  return null;
16722
16734
  }
16723
16735
  const rawData = restApiOutput.getData();
@@ -16756,7 +16768,7 @@ var ContractReadNode2 = class _ContractReadNode extends Node {
16756
16768
  return value;
16757
16769
  });
16758
16770
  config.setContractAbiList(abiValueList);
16759
- const methodCalls = configData.methodCalls || [];
16771
+ const methodCalls = configData.methodCalls;
16760
16772
  methodCalls.forEach((methodCall) => {
16761
16773
  const methodCallMsg = new avs_pb13.ContractReadNode.MethodCall();
16762
16774
  methodCallMsg.setMethodName(methodCall.methodName);
@@ -17135,7 +17147,7 @@ var LoopNode2 = class _LoopNode extends Node {
17135
17147
  const graphqlQuery = graphqlQuery_default.createProtobufNode({
17136
17148
  url: gqlConfig.url,
17137
17149
  query: gqlConfig.query,
17138
- variablesMap: gqlConfig.variablesMap
17150
+ variables: gqlConfig.variables
17139
17151
  });
17140
17152
  loopNode.setGraphqlDataQuery(graphqlQuery);
17141
17153
  break;
@@ -17477,6 +17489,22 @@ var Step = class _Step {
17477
17489
  static getOutput(step) {
17478
17490
  const outputData = this.extractOutputData(step);
17479
17491
  if (!outputData) return null;
17492
+ const outputCase = this.getOutputDataCase(step);
17493
+ if (outputCase === avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE || outputCase === avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ) {
17494
+ try {
17495
+ const result = {};
17496
+ if (typeof outputData.getData === "function") {
17497
+ result.data = convertProtobufValueToJs(outputData.getData());
17498
+ }
17499
+ if (typeof outputData.getMetadata === "function") {
17500
+ result.metadata = convertProtobufValueToJs(outputData.getMetadata());
17501
+ }
17502
+ return result;
17503
+ } catch (error) {
17504
+ console.warn("Failed to convert ContractWrite/ContractRead protobuf to JavaScript:", error);
17505
+ return outputData.getData ? outputData.getData() : null;
17506
+ }
17507
+ }
17480
17508
  if (typeof outputData.hasData === "function" && outputData.hasData()) {
17481
17509
  try {
17482
17510
  return convertProtobufValueToJs(outputData.getData());
@@ -17484,6 +17512,13 @@ var Step = class _Step {
17484
17512
  console.warn("Failed to convert protobuf Value to JavaScript:", error);
17485
17513
  return outputData.getData();
17486
17514
  }
17515
+ } else if (typeof outputData.getData === "function") {
17516
+ try {
17517
+ return convertProtobufValueToJs(outputData.getData());
17518
+ } catch (error) {
17519
+ console.warn("Failed to convert protobuf Value to JavaScript:", error);
17520
+ return outputData.getData();
17521
+ }
17487
17522
  } else if (outputData.data) {
17488
17523
  return typeof outputData.data.getKindCase === "function" ? convertProtobufValueToJs(outputData.data) : outputData.data;
17489
17524
  }
@@ -24,8 +24,8 @@ class ContractReadNode extends Node {
24
24
  return value;
25
25
  });
26
26
  config.setContractAbiList(abiValueList);
27
- // Handle method calls array
28
- const methodCalls = configData.methodCalls || [];
27
+ // Handle method calls array (now required)
28
+ const methodCalls = configData.methodCalls;
29
29
  methodCalls.forEach((methodCall) => {
30
30
  const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
31
31
  methodCallMsg.setMethodName(methodCall.methodName);
@@ -0,0 +1,17 @@
1
+ import Node from "./interface";
2
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
3
+ import { ContractWriteNodeData, ContractWriteNodeProps } from "@avaprotocol/types";
4
+ declare class ContractWriteNode extends Node {
5
+ constructor(props: ContractWriteNodeProps);
6
+ /**
7
+ * Create a protobuf ContractWriteNode from config data
8
+ * @param configData - The configuration data for the contract write node
9
+ * @returns Configured avs_pb.ContractWriteNode
10
+ */
11
+ static createProtobufNode(configData: ContractWriteNodeData): avs_pb.ContractWriteNode;
12
+ static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
13
+ toRequest(): avs_pb.TaskNode;
14
+ static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
15
+ }
16
+ export default ContractWriteNode;
17
+ //# sourceMappingURL=contractWrite.d.ts.map
@@ -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;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;CAuClF;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,GAAG;CAYrE;AAED,eAAe,iBAAiB,CAAC"}
@@ -25,8 +25,8 @@ class ContractWriteNode extends Node {
25
25
  return value;
26
26
  });
27
27
  config.setContractAbiList(abiValueList);
28
- // Handle method calls array
29
- const methodCalls = configData.methodCalls || [];
28
+ // Handle method calls array (now required)
29
+ const methodCalls = configData.methodCalls;
30
30
  methodCalls.forEach((methodCall) => {
31
31
  const methodCallMsg = new avs_pb.ContractWriteNode.MethodCall();
32
32
  // Set callData only if provided (now optional)
@@ -81,39 +81,12 @@ class ContractWriteNode extends Node {
81
81
  const contractWriteOutput = outputData.getContractWrite();
82
82
  if (!contractWriteOutput)
83
83
  return null;
84
- // Use the new getData() method instead of the old resultsList
85
- const data = contractWriteOutput.getData();
86
- if (!data)
87
- return null;
88
- // Convert protobuf Value to JavaScript object
89
- const jsData = convertProtobufValueToJs(data);
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
- receipt: result.receipt || null, // Add receipt field
102
- };
103
- });
104
- }
105
- else {
106
- // Single result - wrap in array for consistency
107
- const methodName = jsData.method_name || jsData.methodName;
108
- return [{
109
- methodName: methodName,
110
- methodABI: jsData.method_abi || null,
111
- success: jsData.success,
112
- error: jsData.error || "",
113
- value: jsData.value,
114
- receipt: jsData.receipt || null, // Add receipt field
115
- }];
116
- }
84
+ // ContractWrite decoded events are stored in data field (flattened object format)
85
+ // This contains parsed receipt logs/events, similar to ContractRead format
86
+ const dataValue = contractWriteOutput.getData();
87
+ // Convert protobuf Value to JavaScript object (decoded events object)
88
+ // Return empty object if no events were decoded from transaction receipts
89
+ return dataValue ? convertProtobufValueToJs(dataValue) : {};
117
90
  }
118
91
  }
119
92
  export default ContractWriteNode;
@@ -0,0 +1,21 @@
1
+ import Node from "./interface";
2
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
3
+ import { GraphQLQueryNodeProps } from "@avaprotocol/types";
4
+ declare class GraphQLQueryNode extends Node {
5
+ constructor(props: GraphQLQueryNodeProps);
6
+ /**
7
+ * Create a protobuf GraphQLQueryNode from config data
8
+ * @param configData - The configuration data for the GraphQL query node
9
+ * @returns Configured avs_pb.GraphQLQueryNode
10
+ */
11
+ static createProtobufNode(configData: {
12
+ url: string;
13
+ query: string;
14
+ variables?: Record<string, string>;
15
+ }): avs_pb.GraphQLQueryNode;
16
+ static fromResponse(raw: avs_pb.TaskNode): GraphQLQueryNode;
17
+ toRequest(): avs_pb.TaskNode;
18
+ static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): Record<string, unknown> | null;
19
+ }
20
+ export default GraphQLQueryNode;
21
+ //# sourceMappingURL=graphqlQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphqlQuery.d.ts","sourceRoot":"","sources":["../../../src/models/node/graphqlQuery.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;AAK5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAQxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;KACxC,GAAG,MAAM,CAAC,gBAAgB;IAkB3B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAc3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAcrE;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"graphqlQuery.d.ts","sourceRoot":"","sources":["../../../src/models/node/graphqlQuery.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;AAK5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAQxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACpC,GAAG,MAAM,CAAC,gBAAgB;IAkB3B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAuB3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAclC;AAED,eAAe,gBAAgB,CAAC"}
@@ -21,9 +21,9 @@ class GraphQLQueryNode extends Node {
21
21
  const config = new avs_pb.GraphQLQueryNode.Config();
22
22
  config.setUrl(configData.url);
23
23
  config.setQuery(configData.query);
24
- if (configData.variablesMap && configData.variablesMap.length > 0) {
24
+ if (configData.variables && Object.keys(configData.variables).length > 0) {
25
25
  const variablesMap = config.getVariablesMap();
26
- configData.variablesMap.forEach(([key, value]) => {
26
+ Object.entries(configData.variables).forEach(([key, value]) => {
27
27
  variablesMap.set(key, value);
28
28
  });
29
29
  }
@@ -33,13 +33,20 @@ class GraphQLQueryNode extends Node {
33
33
  static fromResponse(raw) {
34
34
  // Convert the raw object to GraphQLQueryNodeProps, which should keep name and id
35
35
  const obj = raw.toObject();
36
+ const config = raw.getGraphqlQuery().getConfig();
37
+ const variablesMap = config.getVariablesMap();
38
+ const variables = {};
39
+ variablesMap.forEach((value, key) => {
40
+ variables[key] = value;
41
+ });
36
42
  return new GraphQLQueryNode({
37
43
  ...obj,
38
44
  type: NodeType.GraphQLQuery,
39
- data: raw
40
- .getGraphqlQuery()
41
- .getConfig()
42
- .toObject(),
45
+ data: {
46
+ url: config.getUrl(),
47
+ query: config.getQuery(),
48
+ variables: variables,
49
+ },
43
50
  });
44
51
  }
45
52
  toRequest() {
@@ -166,7 +166,7 @@ class LoopNode extends Node {
166
166
  const graphqlQuery = GraphQLQueryNode.createProtobufNode({
167
167
  url: gqlConfig.url,
168
168
  query: gqlConfig.query,
169
- variablesMap: gqlConfig.variablesMap,
169
+ variables: gqlConfig.variables,
170
170
  });
171
171
  loopNode.setGraphqlDataQuery(graphqlQuery);
172
172
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"restApi.d.ts","sourceRoot":"","sources":["../../../src/models/node/restApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAS5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,MAAM,CAAC,WAAW;IAmBtB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,WAAW;IAuBtD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAelC;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"restApi.d.ts","sourceRoot":"","sources":["../../../src/models/node/restApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAS5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,MAAM,CAAC,WAAW;IAmBtB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,WAAW;IAuBtD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAe5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAclC;AAED,eAAe,WAAW,CAAC"}
@@ -59,7 +59,6 @@ class RestAPINode extends Node {
59
59
  static fromOutputData(outputData) {
60
60
  const restApiOutput = outputData.getRestApi();
61
61
  if (!restApiOutput) {
62
- console.log("Debug RestAPI: No restApiOutput found");
63
62
  return null;
64
63
  }
65
64
  // Use convertProtobufValueToJs to get clean JavaScript objects
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAMhD,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,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAc5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAgBnB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IAsB9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiEhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgChC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAqEvD;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;AAMhD,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,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAc5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAgBnB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IAwD9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiEhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgChC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAqEvD;AAED,eAAe,IAAI,CAAC"}
@@ -37,7 +37,30 @@ class Step {
37
37
  const outputData = this.extractOutputData(step);
38
38
  if (!outputData)
39
39
  return null;
40
- // STANDARDIZED Direct Mapping - ALL triggers and nodes use the same logic
40
+ const outputCase = this.getOutputDataCase(step);
41
+ // 🚀 Special handling for ContractWrite and ContractRead - return both data and metadata
42
+ if (outputCase === avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE ||
43
+ outputCase === avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ) {
44
+ try {
45
+ const result = {};
46
+ // Extract data field (decoded events/results)
47
+ if (typeof outputData.getData === "function") {
48
+ result.data = convertProtobufValueToJs(outputData.getData());
49
+ }
50
+ // Extract metadata field (method execution details)
51
+ if (typeof outputData.getMetadata === "function") {
52
+ result.metadata = convertProtobufValueToJs(outputData.getMetadata());
53
+ }
54
+ // Return both data and metadata for ContractWrite and ContractRead
55
+ // This ensures consistent structure between simulated and deployed workflow execution
56
+ return result;
57
+ }
58
+ catch (error) {
59
+ console.warn("Failed to convert ContractWrite/ContractRead protobuf to JavaScript:", error);
60
+ return outputData.getData ? outputData.getData() : null;
61
+ }
62
+ }
63
+ // STANDARDIZED Direct Mapping - ALL other triggers and nodes use the same logic
41
64
  if (typeof outputData.hasData === "function" && outputData.hasData()) {
42
65
  try {
43
66
  return convertProtobufValueToJs(outputData.getData());
@@ -47,6 +70,15 @@ class Step {
47
70
  return outputData.getData();
48
71
  }
49
72
  }
73
+ else if (typeof outputData.getData === "function") {
74
+ try {
75
+ return convertProtobufValueToJs(outputData.getData());
76
+ }
77
+ catch (error) {
78
+ console.warn("Failed to convert protobuf Value to JavaScript:", error);
79
+ return outputData.getData();
80
+ }
81
+ }
50
82
  else if (outputData.data) {
51
83
  // For plain objects, try to convert or use directly
52
84
  return typeof outputData.data.getKindCase === "function"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.6.10",
3
+ "version": "2.6.12",
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.9",
34
+ "@avaprotocol/types": "^2.4.10",
35
35
  "@grpc/grpc-js": "^1.11.3",
36
36
  "@grpc/proto-loader": "^0.7.13",
37
37
  "dotenv": "^16.4.5",