@avaprotocol/sdk-js 2.4.3 → 2.4.4

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/dist/index.mjs CHANGED
@@ -107,6 +107,7 @@ var require_avs_pb = __commonJS({
107
107
  goog.exportSymbol("proto.aggregator.Execution", null, global);
108
108
  goog.exportSymbol("proto.aggregator.Execution.Step", null, global);
109
109
  goog.exportSymbol("proto.aggregator.Execution.Step.OutputDataCase", null, global);
110
+ goog.exportSymbol("proto.aggregator.ExecutionMode", null, global);
110
111
  goog.exportSymbol("proto.aggregator.ExecutionReq", null, global);
111
112
  goog.exportSymbol("proto.aggregator.ExecutionStatus", null, global);
112
113
  goog.exportSymbol("proto.aggregator.ExecutionStatusResp", null, global);
@@ -7412,7 +7413,8 @@ var require_avs_pb = __commonJS({
7412
7413
  var f, obj = {
7413
7414
  sourceId: jspb.Message.getFieldWithDefault(msg, 1, ""),
7414
7415
  iterVal: jspb.Message.getFieldWithDefault(msg, 2, ""),
7415
- iterKey: jspb.Message.getFieldWithDefault(msg, 3, "")
7416
+ iterKey: jspb.Message.getFieldWithDefault(msg, 3, ""),
7417
+ executionMode: jspb.Message.getFieldWithDefault(msg, 4, 0)
7416
7418
  };
7417
7419
  if (includeInstance) {
7418
7420
  obj.$jspbMessageInstance = msg;
@@ -7453,6 +7455,13 @@ var require_avs_pb = __commonJS({
7453
7455
  );
7454
7456
  msg.setIterKey(value);
7455
7457
  break;
7458
+ case 4:
7459
+ var value = (
7460
+ /** @type {!proto.aggregator.ExecutionMode} */
7461
+ reader.readEnum()
7462
+ );
7463
+ msg.setExecutionMode(value);
7464
+ break;
7456
7465
  default:
7457
7466
  reader.skipField();
7458
7467
  break;
@@ -7488,6 +7497,13 @@ var require_avs_pb = __commonJS({
7488
7497
  f
7489
7498
  );
7490
7499
  }
7500
+ f = message.getExecutionMode();
7501
+ if (f !== 0) {
7502
+ writer.writeEnum(
7503
+ 4,
7504
+ f
7505
+ );
7506
+ }
7491
7507
  };
7492
7508
  proto.aggregator.LoopNode.Config.prototype.getSourceId = function() {
7493
7509
  return (
@@ -7516,6 +7532,15 @@ var require_avs_pb = __commonJS({
7516
7532
  proto.aggregator.LoopNode.Config.prototype.setIterKey = function(value) {
7517
7533
  return jspb.Message.setProto3StringField(this, 3, value);
7518
7534
  };
7535
+ proto.aggregator.LoopNode.Config.prototype.getExecutionMode = function() {
7536
+ return (
7537
+ /** @type {!proto.aggregator.ExecutionMode} */
7538
+ jspb.Message.getFieldWithDefault(this, 4, 0)
7539
+ );
7540
+ };
7541
+ proto.aggregator.LoopNode.Config.prototype.setExecutionMode = function(value) {
7542
+ return jspb.Message.setProto3EnumField(this, 4, value);
7543
+ };
7519
7544
  if (jspb.Message.GENERATE_TO_OBJECT) {
7520
7545
  proto.aggregator.LoopNode.Output.prototype.toObject = function(opt_includeInstance) {
7521
7546
  return proto.aggregator.LoopNode.Output.toObject(opt_includeInstance, this);
@@ -15775,6 +15800,10 @@ var require_avs_pb = __commonJS({
15775
15800
  NODE_TYPE_FILTER: 8,
15776
15801
  NODE_TYPE_LOOP: 9
15777
15802
  };
15803
+ proto.aggregator.ExecutionMode = {
15804
+ EXECUTION_MODE_SEQUENTIAL: 0,
15805
+ EXECUTION_MODE_PARALLEL: 1
15806
+ };
15778
15807
  proto.aggregator.Lang = {
15779
15808
  JAVASCRIPT: 0
15780
15809
  };
@@ -17427,6 +17456,29 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
17427
17456
  constructor(props) {
17428
17457
  super({ ...props, type: NodeType3.ContractWrite, data: props.data });
17429
17458
  }
17459
+ /**
17460
+ * Create a protobuf ContractWriteNode from config data
17461
+ * @param configData - The configuration data for the contract write node
17462
+ * @returns Configured avs_pb.ContractWriteNode
17463
+ */
17464
+ static createProtobufNode(configData) {
17465
+ const node = new avs_pb9.ContractWriteNode();
17466
+ const config = new avs_pb9.ContractWriteNode.Config();
17467
+ config.setContractAddress(configData.contractAddress);
17468
+ config.setCallData(configData.callData);
17469
+ config.setContractAbi(configData.contractAbi);
17470
+ const methodCalls = configData.methodCalls || [];
17471
+ methodCalls.forEach((methodCall) => {
17472
+ const methodCallMsg = new avs_pb9.ContractWriteNode.MethodCall();
17473
+ methodCallMsg.setCallData(methodCall.callData);
17474
+ if (methodCall.methodName) {
17475
+ methodCallMsg.setMethodName(methodCall.methodName);
17476
+ }
17477
+ config.addMethodCalls(methodCallMsg);
17478
+ });
17479
+ node.setConfig(config);
17480
+ return node;
17481
+ }
17430
17482
  static fromResponse(raw) {
17431
17483
  const obj = raw.toObject();
17432
17484
  const protobufData = raw.getContractWrite().getConfig().toObject();
@@ -17454,25 +17506,9 @@ var ContractWriteNode2 = class _ContractWriteNode extends Node {
17454
17506
  const request = new avs_pb9.TaskNode();
17455
17507
  request.setId(this.id);
17456
17508
  request.setName(this.name);
17457
- const node = new avs_pb9.ContractWriteNode();
17458
- const config = new avs_pb9.ContractWriteNode.Config();
17459
- config.setContractAddress(
17460
- this.data.contractAddress
17461
- );
17462
- config.setCallData(this.data.callData);
17463
- config.setContractAbi(this.data.contractAbi);
17464
- const methodCalls = this.data.methodCalls || [];
17465
- methodCalls.forEach(
17466
- (methodCall) => {
17467
- const methodCallMsg = new avs_pb9.ContractWriteNode.MethodCall();
17468
- methodCallMsg.setCallData(methodCall.callData);
17469
- if (methodCall.methodName) {
17470
- methodCallMsg.setMethodName(methodCall.methodName);
17471
- }
17472
- config.addMethodCalls(methodCallMsg);
17473
- }
17509
+ const node = _ContractWriteNode.createProtobufNode(
17510
+ this.data
17474
17511
  );
17475
- node.setConfig(config);
17476
17512
  const inputValue = convertInputToProtobuf(this.input);
17477
17513
  if (inputValue) {
17478
17514
  request.setInput(inputValue);
@@ -17500,6 +17536,19 @@ var CustomCodeNode2 = class _CustomCodeNode extends Node {
17500
17536
  constructor(props) {
17501
17537
  super({ ...props, type: NodeType4.CustomCode, data: props.data });
17502
17538
  }
17539
+ /**
17540
+ * Create a protobuf CustomCodeNode from config data
17541
+ * @param configData - The configuration data for the custom code node
17542
+ * @returns Configured avs_pb.CustomCodeNode
17543
+ */
17544
+ static createProtobufNode(configData) {
17545
+ const node = new avs_pb10.CustomCodeNode();
17546
+ const config = new avs_pb10.CustomCodeNode.Config();
17547
+ config.setLang(configData.lang);
17548
+ config.setSource(configData.source);
17549
+ node.setConfig(config);
17550
+ return node;
17551
+ }
17503
17552
  static fromResponse(raw) {
17504
17553
  const obj = raw.toObject();
17505
17554
  const rawConfig = raw.getCustomCode().getConfig().toObject();
@@ -17522,11 +17571,9 @@ var CustomCodeNode2 = class _CustomCodeNode extends Node {
17522
17571
  const request = new avs_pb10.TaskNode();
17523
17572
  request.setId(this.id);
17524
17573
  request.setName(this.name);
17525
- const node = new avs_pb10.CustomCodeNode();
17526
- const config = new avs_pb10.CustomCodeNode.Config();
17527
- config.setLang(this.data.lang);
17528
- config.setSource(this.data.source);
17529
- node.setConfig(config);
17574
+ const node = _CustomCodeNode.createProtobufNode(
17575
+ this.data
17576
+ );
17530
17577
  const inputValue = convertInputToProtobuf(this.input);
17531
17578
  if (inputValue) {
17532
17579
  request.setInput(inputValue);
@@ -17559,6 +17606,25 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
17559
17606
  data: props.data
17560
17607
  });
17561
17608
  }
17609
+ /**
17610
+ * Create a protobuf GraphQLQueryNode from config data
17611
+ * @param configData - The configuration data for the GraphQL query node
17612
+ * @returns Configured avs_pb.GraphQLQueryNode
17613
+ */
17614
+ static createProtobufNode(configData) {
17615
+ const node = new avs_pb11.GraphQLQueryNode();
17616
+ const config = new avs_pb11.GraphQLQueryNode.Config();
17617
+ config.setUrl(configData.url);
17618
+ config.setQuery(configData.query);
17619
+ if (configData.variablesMap && configData.variablesMap.length > 0) {
17620
+ const variablesMap = config.getVariablesMap();
17621
+ configData.variablesMap.forEach(([key, value]) => {
17622
+ variablesMap.set(key, value);
17623
+ });
17624
+ }
17625
+ node.setConfig(config);
17626
+ return node;
17627
+ }
17562
17628
  static fromResponse(raw) {
17563
17629
  const obj = raw.toObject();
17564
17630
  const input = extractInputFromProtobuf(raw.getGraphqlQuery()?.getInput());
@@ -17573,17 +17639,9 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
17573
17639
  const request = new avs_pb11.TaskNode();
17574
17640
  request.setId(this.id);
17575
17641
  request.setName(this.name);
17576
- const node = new avs_pb11.GraphQLQueryNode();
17577
- const config = new avs_pb11.GraphQLQueryNode.Config();
17578
- config.setUrl(this.data.url);
17579
- config.setQuery(this.data.query);
17580
- if (this.data.variablesMap && this.data.variablesMap.length > 0) {
17581
- const variablesMap = config.getVariablesMap();
17582
- this.data.variablesMap.forEach(([key, value]) => {
17583
- variablesMap.set(key, value);
17584
- });
17585
- }
17586
- node.setConfig(config);
17642
+ const node = _GraphQLQueryNode.createProtobufNode(
17643
+ this.data
17644
+ );
17587
17645
  const inputValue = convertInputToProtobuf(this.input);
17588
17646
  if (inputValue) {
17589
17647
  node.setInput(inputValue);
@@ -17607,6 +17665,26 @@ var RestAPINode2 = class _RestAPINode extends Node {
17607
17665
  constructor(props) {
17608
17666
  super({ ...props, type: NodeType6.RestAPI, data: props.data });
17609
17667
  }
17668
+ /**
17669
+ * Create a protobuf RestAPINode from config data
17670
+ * @param configData - The configuration data for the REST API node
17671
+ * @returns Configured avs_pb.RestAPINode
17672
+ */
17673
+ static createProtobufNode(configData) {
17674
+ const node = new avs_pb12.RestAPINode();
17675
+ const config = new avs_pb12.RestAPINode.Config();
17676
+ config.setUrl(configData.url);
17677
+ config.setMethod(configData.method);
17678
+ config.setBody(configData.body || "");
17679
+ if (configData.headersMap && configData.headersMap.length > 0) {
17680
+ const headersMap = config.getHeadersMap();
17681
+ configData.headersMap.forEach(([key, value]) => {
17682
+ headersMap.set(key, value);
17683
+ });
17684
+ }
17685
+ node.setConfig(config);
17686
+ return node;
17687
+ }
17610
17688
  static fromResponse(raw) {
17611
17689
  const obj = raw.toObject();
17612
17690
  let input = void 0;
@@ -17625,20 +17703,9 @@ var RestAPINode2 = class _RestAPINode extends Node {
17625
17703
  const request = new avs_pb12.TaskNode();
17626
17704
  request.setId(this.id);
17627
17705
  request.setName(this.name);
17628
- const nodeData = new avs_pb12.RestAPINode();
17629
- const config = new avs_pb12.RestAPINode.Config();
17630
- config.setUrl(this.data.url);
17631
- config.setMethod(this.data.method);
17632
- config.setBody(this.data.body || "");
17633
- if (this.data.headersMap && this.data.headersMap.length > 0) {
17634
- const headersMap = config.getHeadersMap();
17635
- this.data.headersMap.forEach(
17636
- ([key, value]) => {
17637
- headersMap.set(key, value);
17638
- }
17639
- );
17640
- }
17641
- nodeData.setConfig(config);
17706
+ const nodeData = _RestAPINode.createProtobufNode(
17707
+ this.data
17708
+ );
17642
17709
  const inputValue = convertInputToProtobuf(this.input);
17643
17710
  if (inputValue) {
17644
17711
  request.setInput(inputValue);
@@ -17670,6 +17737,31 @@ var ContractReadNode2 = class _ContractReadNode extends Node {
17670
17737
  constructor(props) {
17671
17738
  super({ ...props, type: NodeType7.ContractRead, data: props.data });
17672
17739
  }
17740
+ /**
17741
+ * Create a protobuf ContractReadNode from config data
17742
+ * @param configData - The configuration data for the contract read node
17743
+ * @returns Configured avs_pb.ContractReadNode
17744
+ */
17745
+ static createProtobufNode(configData) {
17746
+ const node = new avs_pb13.ContractReadNode();
17747
+ const config = new avs_pb13.ContractReadNode.Config();
17748
+ config.setContractAddress(configData.contractAddress);
17749
+ config.setContractAbi(configData.contractAbi);
17750
+ const methodCalls = configData.methodCalls || [];
17751
+ methodCalls.forEach((methodCall) => {
17752
+ const methodCallMsg = new avs_pb13.ContractReadNode.MethodCall();
17753
+ methodCallMsg.setCallData(methodCall.callData);
17754
+ if (methodCall.methodName) {
17755
+ methodCallMsg.setMethodName(methodCall.methodName);
17756
+ }
17757
+ if (methodCall.applyToFields) {
17758
+ methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
17759
+ }
17760
+ config.addMethodCalls(methodCallMsg);
17761
+ });
17762
+ node.setConfig(config);
17763
+ return node;
17764
+ }
17673
17765
  static fromResponse(raw) {
17674
17766
  const obj = raw.toObject();
17675
17767
  const protobufData = raw.getContractRead().getConfig().toObject();
@@ -17697,27 +17789,9 @@ var ContractReadNode2 = class _ContractReadNode extends Node {
17697
17789
  const request = new avs_pb13.TaskNode();
17698
17790
  request.setId(this.id);
17699
17791
  request.setName(this.name);
17700
- const node = new avs_pb13.ContractReadNode();
17701
- const config = new avs_pb13.ContractReadNode.Config();
17702
- config.setContractAddress(
17703
- this.data.contractAddress
17704
- );
17705
- config.setContractAbi(this.data.contractAbi);
17706
- const methodCalls = this.data.methodCalls || [];
17707
- methodCalls.forEach(
17708
- (methodCall) => {
17709
- const methodCallMsg = new avs_pb13.ContractReadNode.MethodCall();
17710
- methodCallMsg.setCallData(methodCall.callData);
17711
- if (methodCall.methodName) {
17712
- methodCallMsg.setMethodName(methodCall.methodName);
17713
- }
17714
- if (methodCall.applyToFields) {
17715
- methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
17716
- }
17717
- config.addMethodCalls(methodCallMsg);
17718
- }
17792
+ const node = _ContractReadNode.createProtobufNode(
17793
+ this.data
17719
17794
  );
17720
- node.setConfig(config);
17721
17795
  const inputValue = convertInputToProtobuf(this.input);
17722
17796
  if (inputValue) {
17723
17797
  request.setInput(inputValue);
@@ -17755,6 +17829,19 @@ var ETHTransferNode2 = class _ETHTransferNode extends Node {
17755
17829
  constructor(props) {
17756
17830
  super({ ...props, type: NodeType8.ETHTransfer, data: props.data });
17757
17831
  }
17832
+ /**
17833
+ * Create a protobuf ETHTransferNode from config data
17834
+ * @param configData - The configuration data for the ETH transfer node
17835
+ * @returns Configured avs_pb.ETHTransferNode
17836
+ */
17837
+ static createProtobufNode(configData) {
17838
+ const node = new avs_pb14.ETHTransferNode();
17839
+ const config = new avs_pb14.ETHTransferNode.Config();
17840
+ config.setDestination(configData.destination);
17841
+ config.setAmount(configData.amount);
17842
+ node.setConfig(config);
17843
+ return node;
17844
+ }
17758
17845
  static fromResponse(raw) {
17759
17846
  const obj = raw.toObject();
17760
17847
  const input = extractInputFromProtobuf(raw.getEthTransfer()?.getInput());
@@ -17769,11 +17856,9 @@ var ETHTransferNode2 = class _ETHTransferNode extends Node {
17769
17856
  const request = new avs_pb14.TaskNode();
17770
17857
  request.setId(this.id);
17771
17858
  request.setName(this.name);
17772
- const node = new avs_pb14.ETHTransferNode();
17773
- const config = new avs_pb14.ETHTransferNode.Config();
17774
- config.setDestination(this.data.destination);
17775
- config.setAmount(this.data.amount);
17776
- node.setConfig(config);
17859
+ const node = _ETHTransferNode.createProtobufNode(
17860
+ this.data
17861
+ );
17777
17862
  const inputValue = convertInputToProtobuf(this.input);
17778
17863
  if (inputValue) {
17779
17864
  node.setInput(inputValue);
@@ -17890,7 +17975,8 @@ var filter_default = FilterNode2;
17890
17975
  // src/models/node/loop.ts
17891
17976
  var avs_pb17 = __toESM(require_avs_pb());
17892
17977
  import {
17893
- NodeType as NodeType11
17978
+ NodeType as NodeType11,
17979
+ ExecutionMode
17894
17980
  } from "@avaprotocol/types";
17895
17981
  var LoopNode2 = class _LoopNode extends Node {
17896
17982
  constructor(props) {
@@ -17906,13 +17992,12 @@ var LoopNode2 = class _LoopNode extends Node {
17906
17992
  const loopNodeData = loopNode.toObject();
17907
17993
  const data = {
17908
17994
  ...configData,
17909
- // Keep the nested node structures from the full object
17910
- restApi: loopNodeData.restApi,
17911
- customCode: loopNodeData.customCode,
17912
- ethTransfer: loopNodeData.ethTransfer,
17913
- contractRead: loopNodeData.contractRead,
17914
- contractWrite: loopNodeData.contractWrite,
17915
- graphqlDataQuery: loopNodeData.graphqlDataQuery
17995
+ // Extract runner data from the oneof runner field
17996
+ runner: this.extractRunnerFromProtobuf(loopNodeData),
17997
+ // Map execution mode from protobuf enum to ExecutionMode enum
17998
+ executionMode: this.mapExecutionModeFromProtobuf(
17999
+ configData?.executionMode
18000
+ )
17916
18001
  };
17917
18002
  let input = void 0;
17918
18003
  if (raw.hasInput()) {
@@ -17925,6 +18010,54 @@ var LoopNode2 = class _LoopNode extends Node {
17925
18010
  input
17926
18011
  });
17927
18012
  }
18013
+ static extractRunnerFromProtobuf(loopNodeData) {
18014
+ if (loopNodeData.restApi) {
18015
+ return { type: "restApi", data: loopNodeData.restApi };
18016
+ } else if (loopNodeData.customCode) {
18017
+ return { type: "customCode", data: loopNodeData.customCode };
18018
+ } else if (loopNodeData.ethTransfer) {
18019
+ return { type: "ethTransfer", data: loopNodeData.ethTransfer };
18020
+ } else if (loopNodeData.contractRead) {
18021
+ return { type: "contractRead", data: loopNodeData.contractRead };
18022
+ } else if (loopNodeData.contractWrite) {
18023
+ return { type: "contractWrite", data: loopNodeData.contractWrite };
18024
+ } else if (loopNodeData.graphqlDataQuery) {
18025
+ return { type: "graphqlDataQuery", data: loopNodeData.graphqlDataQuery };
18026
+ }
18027
+ return null;
18028
+ }
18029
+ static mapExecutionModeFromProtobuf(executionMode) {
18030
+ switch (executionMode) {
18031
+ case 0:
18032
+ return ExecutionMode.Sequential;
18033
+ case 1:
18034
+ return ExecutionMode.Parallel;
18035
+ default:
18036
+ return ExecutionMode.Sequential;
18037
+ }
18038
+ }
18039
+ mapExecutionModeToProtobuf(executionMode) {
18040
+ if (!executionMode) {
18041
+ return 0;
18042
+ }
18043
+ if (typeof executionMode === "string") {
18044
+ switch (executionMode.toLowerCase()) {
18045
+ case "parallel":
18046
+ return 1;
18047
+ case "sequential":
18048
+ default:
18049
+ return 0;
18050
+ }
18051
+ } else {
18052
+ switch (executionMode) {
18053
+ case ExecutionMode.Parallel:
18054
+ return 1;
18055
+ case ExecutionMode.Sequential:
18056
+ default:
18057
+ return 0;
18058
+ }
18059
+ }
18060
+ }
17928
18061
  toRequest() {
17929
18062
  const node = new avs_pb17.TaskNode();
17930
18063
  const loopNode = new avs_pb17.LoopNode();
@@ -17935,113 +18068,103 @@ var LoopNode2 = class _LoopNode extends Node {
17935
18068
  config.setSourceId(data.sourceId || "");
17936
18069
  config.setIterVal(data.iterVal || "");
17937
18070
  config.setIterKey(data.iterKey || "");
18071
+ const executionMode = this.mapExecutionModeToProtobuf(data.executionMode);
18072
+ config.setExecutionMode(executionMode);
17938
18073
  loopNode.setConfig(config);
17939
18074
  const inputValue = convertInputToProtobuf(this.input);
17940
18075
  if (inputValue) {
17941
18076
  node.setInput(inputValue);
17942
18077
  }
17943
- if (data.ethTransfer) {
17944
- const ethTransfer = new avs_pb17.ETHTransferNode();
17945
- if (data.ethTransfer.config) {
17946
- const config2 = new avs_pb17.ETHTransferNode.Config();
17947
- config2.setDestination(data.ethTransfer.config.destination);
17948
- config2.setAmount(data.ethTransfer.config.amount);
17949
- ethTransfer.setConfig(config2);
17950
- }
17951
- loopNode.setEthTransfer(ethTransfer);
17952
- } else if (data.contractWrite) {
17953
- const contractWrite = new avs_pb17.ContractWriteNode();
17954
- if (data.contractWrite.config) {
17955
- const config2 = new avs_pb17.ContractWriteNode.Config();
17956
- config2.setContractAddress(
17957
- data.contractWrite.config.contractAddress
17958
- );
17959
- config2.setCallData(data.contractWrite.config.callData);
17960
- config2.setContractAbi(data.contractWrite.config.contractAbi);
17961
- const methodCalls = data.contractWrite.config.methodCallsList || [];
17962
- methodCalls.forEach(
17963
- (methodCall) => {
17964
- const methodCallMsg = new avs_pb17.ContractWriteNode.MethodCall();
17965
- methodCallMsg.setCallData(methodCall.callData);
17966
- if (methodCall.methodName) {
17967
- methodCallMsg.setMethodName(methodCall.methodName);
17968
- }
17969
- config2.addMethodCalls(methodCallMsg);
17970
- }
17971
- );
17972
- contractWrite.setConfig(config2);
17973
- }
17974
- loopNode.setContractWrite(contractWrite);
17975
- } else if (data.contractRead) {
17976
- const contractRead = new avs_pb17.ContractReadNode();
17977
- if (data.contractRead.config) {
17978
- const config2 = new avs_pb17.ContractReadNode.Config();
17979
- config2.setContractAddress(
17980
- data.contractRead.config.contractAddress
17981
- );
17982
- config2.setContractAbi(data.contractRead.config.contractAbi);
17983
- const methodCalls = data.contractRead.config.methodCallsList || [];
17984
- methodCalls.forEach(
17985
- (methodCall) => {
17986
- const methodCallMsg = new avs_pb17.ContractReadNode.MethodCall();
17987
- methodCallMsg.setCallData(methodCall.callData);
17988
- if (methodCall.methodName) {
17989
- methodCallMsg.setMethodName(methodCall.methodName);
17990
- }
17991
- if (methodCall.applyToFields) {
17992
- methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
17993
- }
17994
- config2.addMethodCalls(methodCallMsg);
17995
- }
17996
- );
17997
- contractRead.setConfig(config2);
17998
- }
17999
- loopNode.setContractRead(contractRead);
18000
- } else if (data.graphqlDataQuery) {
18001
- const graphqlQuery = new avs_pb17.GraphQLQueryNode();
18002
- if (data.graphqlDataQuery.config) {
18003
- const config2 = new avs_pb17.GraphQLQueryNode.Config();
18004
- config2.setUrl(data.graphqlDataQuery.config.url);
18005
- config2.setQuery(data.graphqlDataQuery.config.query);
18006
- if (data.graphqlDataQuery.config.variablesMap && data.graphqlDataQuery.config.variablesMap.length > 0) {
18007
- data.graphqlDataQuery.config.variablesMap.forEach(
18008
- ([key, value]) => {
18009
- config2.getVariablesMap().set(key, value);
18010
- }
18011
- );
18078
+ if (data.runner) {
18079
+ this.setRunnerOnProtobuf(loopNode, data.runner);
18080
+ }
18081
+ node.setLoop(loopNode);
18082
+ return node;
18083
+ }
18084
+ setRunnerOnProtobuf(loopNode, runner) {
18085
+ if (!runner || !runner.type || !runner.data) {
18086
+ return;
18087
+ }
18088
+ switch (runner.type) {
18089
+ case "ethTransfer": {
18090
+ const ethTransferData = runner.data;
18091
+ if (ethTransferData.config) {
18092
+ const ethConfig = ethTransferData.config;
18093
+ const ethTransfer = ethTransfer_default.createProtobufNode({
18094
+ destination: ethConfig.destination,
18095
+ amount: ethConfig.amount
18096
+ });
18097
+ loopNode.setEthTransfer(ethTransfer);
18012
18098
  }
18013
- graphqlQuery.setConfig(config2);
18014
- }
18015
- loopNode.setGraphqlDataQuery(graphqlQuery);
18016
- } else if (data.restApi) {
18017
- const restApi = new avs_pb17.RestAPINode();
18018
- if (data.restApi.config) {
18019
- const config2 = new avs_pb17.RestAPINode.Config();
18020
- config2.setUrl(data.restApi.config.url);
18021
- config2.setMethod(data.restApi.config.method);
18022
- config2.setBody(data.restApi.config.body || "");
18023
- if (data.restApi.config.headersMap && data.restApi.config.headersMap.length > 0) {
18024
- data.restApi.config.headersMap.forEach(
18025
- ([key, value]) => {
18026
- config2.getHeadersMap().set(key, value);
18027
- }
18028
- );
18099
+ break;
18100
+ }
18101
+ case "contractWrite": {
18102
+ const contractWriteData = runner.data;
18103
+ if (contractWriteData.config) {
18104
+ const writeConfig = contractWriteData.config;
18105
+ const contractWrite = contractWrite_default.createProtobufNode({
18106
+ contractAddress: writeConfig.contractAddress,
18107
+ callData: writeConfig.callData,
18108
+ contractAbi: writeConfig.contractAbi,
18109
+ methodCalls: writeConfig.methodCallsList || []
18110
+ });
18111
+ loopNode.setContractWrite(contractWrite);
18029
18112
  }
18030
- restApi.setConfig(config2);
18113
+ break;
18114
+ }
18115
+ case "contractRead": {
18116
+ const contractReadData = runner.data;
18117
+ if (contractReadData.config) {
18118
+ const readConfig = contractReadData.config;
18119
+ const contractRead = contractRead_default.createProtobufNode({
18120
+ contractAddress: readConfig.contractAddress,
18121
+ contractAbi: readConfig.contractAbi,
18122
+ methodCalls: readConfig.methodCallsList || []
18123
+ });
18124
+ loopNode.setContractRead(contractRead);
18125
+ }
18126
+ break;
18127
+ }
18128
+ case "graphqlDataQuery": {
18129
+ const graphqlData = runner.data;
18130
+ if (graphqlData.config) {
18131
+ const gqlConfig = graphqlData.config;
18132
+ const graphqlQuery = graphqlQuery_default.createProtobufNode({
18133
+ url: gqlConfig.url,
18134
+ query: gqlConfig.query,
18135
+ variablesMap: gqlConfig.variablesMap
18136
+ });
18137
+ loopNode.setGraphqlDataQuery(graphqlQuery);
18138
+ }
18139
+ break;
18031
18140
  }
18032
- loopNode.setRestApi(restApi);
18033
- } else if (data.customCode) {
18034
- const customCode = new avs_pb17.CustomCodeNode();
18035
- if (data.customCode.config) {
18036
- const config2 = new avs_pb17.CustomCodeNode.Config();
18037
- config2.setLang(data.customCode.config.lang);
18038
- config2.setSource(data.customCode.config.source);
18039
- customCode.setConfig(config2);
18141
+ case "restApi": {
18142
+ const restApiData = runner.data;
18143
+ if (restApiData.config) {
18144
+ const apiConfig = restApiData.config;
18145
+ const restApi = restApi_default.createProtobufNode({
18146
+ url: apiConfig.url,
18147
+ method: apiConfig.method,
18148
+ body: apiConfig.body || "",
18149
+ headersMap: apiConfig.headersMap
18150
+ });
18151
+ loopNode.setRestApi(restApi);
18152
+ }
18153
+ break;
18154
+ }
18155
+ case "customCode": {
18156
+ const customCodeData = runner.data;
18157
+ if (customCodeData.config) {
18158
+ const codeConfig = customCodeData.config;
18159
+ const customCode = customCode_default.createProtobufNode({
18160
+ lang: codeConfig.lang,
18161
+ source: codeConfig.source
18162
+ });
18163
+ loopNode.setCustomCode(customCode);
18164
+ }
18165
+ break;
18040
18166
  }
18041
- loopNode.setCustomCode(customCode);
18042
18167
  }
18043
- node.setLoop(loopNode);
18044
- return node;
18045
18168
  }
18046
18169
  static fromOutputData(outputData) {
18047
18170
  const customCodeOutput = outputData.getCustomCode();
@@ -18058,7 +18181,7 @@ var LoopNode2 = class _LoopNode extends Node {
18058
18181
  if (loopObj.data && typeof loopObj.data === "string") {
18059
18182
  try {
18060
18183
  return JSON.parse(loopObj.data);
18061
- } catch (e) {
18184
+ } catch {
18062
18185
  return loopObj.data;
18063
18186
  }
18064
18187
  }
@@ -3,6 +3,20 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
3
3
  import { ContractReadNodeProps } from "@avaprotocol/types";
4
4
  declare class ContractReadNode extends Node {
5
5
  constructor(props: ContractReadNodeProps);
6
+ /**
7
+ * Create a protobuf ContractReadNode from config data
8
+ * @param configData - The configuration data for the contract read node
9
+ * @returns Configured avs_pb.ContractReadNode
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;
6
20
  static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
7
21
  toRequest(): avs_pb.TaskNode;
8
22
  static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
@@ -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,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAgC3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgD5B,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;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;SAC1B,CAAC,CAAC;KACJ,GAAG,MAAM,CAAC,gBAAgB;IAyB3B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAgC3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAsB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAyBrE;AAED,eAAe,gBAAgB,CAAC"}