@avaprotocol/sdk-js 2.3.13-dev.0 → 2.3.13

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,5 +1,4 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
3
2
  import { convertProtobufValueToJs, convertProtobufStepTypeToSdk, } from "../utils";
4
3
  class Step {
5
4
  constructor(props) {
@@ -35,265 +34,368 @@ class Step {
35
34
  };
36
35
  }
37
36
  static getOutput(step) {
38
- const outputDataType = step.getOutputDataCase();
39
- let nodeOutputMessage;
40
- switch (outputDataType) {
37
+ // Handle both protobuf instances and plain objects
38
+ const getOutputDataCase = () => {
39
+ if (typeof step.getOutputDataCase === "function") {
40
+ return step.getOutputDataCase();
41
+ }
42
+ // For plain objects, determine the case by checking which properties exist
43
+ const stepObj = step;
44
+ if (stepObj.blockTrigger)
45
+ return avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
46
+ if (stepObj.fixedTimeTrigger)
47
+ return avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
48
+ if (stepObj.cronTrigger)
49
+ return avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER;
50
+ if (stepObj.eventTrigger)
51
+ return avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER;
52
+ if (stepObj.manualTrigger)
53
+ return avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
54
+ if (stepObj.ethTransfer)
55
+ return avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER;
56
+ if (stepObj.graphql)
57
+ return avs_pb.Execution.Step.OutputDataCase.GRAPHQL;
58
+ if (stepObj.contractRead)
59
+ return avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ;
60
+ if (stepObj.contractWrite)
61
+ return avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE;
62
+ if (stepObj.customCode)
63
+ return avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE;
64
+ if (stepObj.restApi)
65
+ return avs_pb.Execution.Step.OutputDataCase.REST_API;
66
+ if (stepObj.branch)
67
+ return avs_pb.Execution.Step.OutputDataCase.BRANCH;
68
+ if (stepObj.filter)
69
+ return avs_pb.Execution.Step.OutputDataCase.FILTER;
70
+ if (stepObj.loop)
71
+ return avs_pb.Execution.Step.OutputDataCase.LOOP;
72
+ return avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
73
+ };
74
+ switch (getOutputDataCase()) {
41
75
  case avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
42
76
  return undefined;
43
77
  // Trigger outputs
44
78
  case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
45
- const blockOutput = step.getBlockTrigger()?.toObject();
46
- return blockOutput
47
- ? { blockNumber: blockOutput.blockNumber }
48
- : undefined;
79
+ return typeof step.getBlockTrigger === "function"
80
+ ? step.getBlockTrigger()?.toObject()
81
+ : step.blockTrigger;
49
82
  case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
50
- const fixedTimeOutput = step.getFixedTimeTrigger()?.toObject();
51
- return fixedTimeOutput
52
- ? {
53
- timestamp: fixedTimeOutput.timestamp,
54
- timestampIso: fixedTimeOutput.timestampIso,
55
- }
56
- : undefined;
83
+ return typeof step.getFixedTimeTrigger === "function"
84
+ ? step.getFixedTimeTrigger()?.toObject()
85
+ : step.fixedTimeTrigger;
57
86
  case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
58
- const cronOutput = step.getCronTrigger()?.toObject();
59
- return cronOutput
60
- ? {
61
- timestamp: cronOutput.timestamp,
62
- timestampIso: cronOutput.timestampIso,
63
- }
64
- : undefined;
87
+ return typeof step.getCronTrigger === "function"
88
+ ? step.getCronTrigger()?.toObject()
89
+ : step.cronTrigger;
65
90
  case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
66
- const eventTrigger = step.getEventTrigger();
91
+ const eventTrigger = typeof step.getEventTrigger === "function"
92
+ ? step.getEventTrigger()
93
+ : step.eventTrigger;
67
94
  if (eventTrigger) {
68
- if (eventTrigger.hasEvmLog()) {
95
+ if (typeof eventTrigger.hasEvmLog === "function" &&
96
+ eventTrigger.hasEvmLog()) {
69
97
  return eventTrigger.getEvmLog()?.toObject();
70
98
  }
71
- else if (eventTrigger.hasTransferLog()) {
99
+ else if (typeof eventTrigger.hasTransferLog === "function" &&
100
+ eventTrigger.hasTransferLog()) {
72
101
  return eventTrigger.getTransferLog()?.toObject();
73
102
  }
103
+ else if (eventTrigger.evmLog) {
104
+ return eventTrigger.evmLog;
105
+ }
106
+ else if (eventTrigger.transferLog) {
107
+ return eventTrigger.transferLog;
108
+ }
74
109
  }
75
110
  return undefined;
76
111
  case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
77
- const manualOutput = step.getManualTrigger()?.toObject();
78
- return manualOutput || undefined;
79
- // Node outputs
112
+ return typeof step.getManualTrigger === "function"
113
+ ? step.getManualTrigger()?.toObject() || undefined
114
+ : step.manualTrigger;
115
+ // Node outputs - RESTORE MISSING CASES
80
116
  case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
81
- const ethTransferOutput = step.getEthTransfer()?.toObject();
82
- return ethTransferOutput
83
- ? {
84
- transactionHash: ethTransferOutput.transactionHash,
117
+ return typeof step.getEthTransfer === "function"
118
+ ? step.getEthTransfer()?.toObject()
119
+ : step.ethTransfer;
120
+ case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
121
+ const customCodeOutput = typeof step.getCustomCode === "function"
122
+ ? step.getCustomCode()
123
+ : step.customCode;
124
+ if (customCodeOutput) {
125
+ if (typeof customCodeOutput.hasData === "function" &&
126
+ customCodeOutput.hasData()) {
127
+ try {
128
+ return convertProtobufValueToJs(customCodeOutput.getData());
129
+ }
130
+ catch {
131
+ // Fallback: if conversion fails, return the raw data
132
+ return customCodeOutput.getData();
133
+ }
85
134
  }
86
- : undefined;
87
- case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
88
- nodeOutputMessage = step.getGraphql();
89
- return nodeOutputMessage && nodeOutputMessage.hasData()
90
- ? nodeOutputMessage.getData()
91
- : undefined;
92
- case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
93
- nodeOutputMessage = step.getContractRead();
94
- if (nodeOutputMessage) {
95
- const results = nodeOutputMessage.getResultsList();
96
- if (results && results.length > 0) {
97
- // Always return wrapped format { results: [...] } to match ContractReadNode.fromOutputData
98
- const resultArray = results.map((result) => {
99
- // Match the exact format from ContractReadNode.fromOutputData
100
- const dataFields = result.getDataList().map((field) => ({
101
- name: field.getName(),
102
- type: field.getType(),
103
- value: field.getValue()
104
- }));
105
- return {
106
- methodName: result.getMethodName(),
107
- success: result.getSuccess(),
108
- error: result.getError(),
109
- data: dataFields,
110
- };
111
- });
112
- // Return wrapped format consistently for all cases
113
- return { results: resultArray };
135
+ else if (customCodeOutput.data) {
136
+ // For plain objects, try to convert or use directly
137
+ return typeof customCodeOutput.data.getKindCase === "function"
138
+ ? convertProtobufValueToJs(customCodeOutput.data)
139
+ : customCodeOutput.data;
114
140
  }
115
141
  }
116
142
  return undefined;
117
- case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
118
- nodeOutputMessage = step.getContractWrite();
119
- if (nodeOutputMessage) {
120
- const results = nodeOutputMessage.getResultsList();
121
- if (results && results.length > 0) {
122
- // Transform enhanced results structure
123
- const transformedResults = results.map((result) => ({
124
- methodName: result.getMethodName(),
125
- success: result.getSuccess(),
126
- transaction: result.getTransaction() ? {
127
- hash: result.getTransaction()?.getHash(),
128
- status: result.getTransaction()?.getStatus(),
129
- blockNumber: result.getTransaction()?.getBlockNumber(),
130
- blockHash: result.getTransaction()?.getBlockHash(),
131
- gasUsed: result.getTransaction()?.getGasUsed(),
132
- gasLimit: result.getTransaction()?.getGasLimit(),
133
- gasPrice: result.getTransaction()?.getGasPrice(),
134
- effectiveGasPrice: result.getTransaction()?.getEffectiveGasPrice(),
135
- from: result.getTransaction()?.getFrom(),
136
- to: result.getTransaction()?.getTo(),
137
- value: result.getTransaction()?.getValue(),
138
- nonce: result.getTransaction()?.getNonce(),
139
- transactionIndex: result.getTransaction()?.getTransactionIndex(),
140
- confirmations: result.getTransaction()?.getConfirmations(),
141
- timestamp: result.getTransaction()?.getTimestamp(),
142
- } : null,
143
- events: result.getEventsList().map((event) => ({
144
- eventName: event.getEventName(),
145
- address: event.getAddress(),
146
- topics: event.getTopicsList(),
147
- data: event.getData(),
148
- decoded: event.getDecodedMap() ? Object.fromEntries(event.getDecodedMap().toArray()) : {},
149
- })),
150
- error: result.getError() ? {
151
- code: result.getError()?.getCode(),
152
- message: result.getError()?.getMessage(),
153
- revertReason: result.getError()?.getRevertReason(),
154
- } : null,
155
- returnData: result.getReturnData() ? {
156
- name: result.getReturnData()?.getName(),
157
- type: result.getReturnData()?.getType(),
158
- value: result.getReturnData()?.getValue(),
159
- } : null,
160
- inputData: result.getInputData(),
161
- }));
162
- // For single result, also provide legacy fields for backward compatibility
163
- if (transformedResults.length === 1) {
164
- return {
165
- results: transformedResults,
166
- // Legacy compatibility fields
167
- transaction: transformedResults[0].transaction,
168
- success: transformedResults[0].success,
169
- hash: transformedResults[0].transaction?.hash,
170
- };
143
+ case avs_pb.Execution.Step.OutputDataCase.REST_API:
144
+ const restApiOutput = typeof step.getRestApi === "function"
145
+ ? step.getRestApi()
146
+ : step.restApi;
147
+ if (restApiOutput) {
148
+ if (typeof restApiOutput.hasData === "function" &&
149
+ restApiOutput.hasData()) {
150
+ try {
151
+ return convertProtobufValueToJs(restApiOutput.getData());
171
152
  }
172
- else {
173
- return { results: transformedResults };
153
+ catch {
154
+ // Fallback: if conversion fails, return the raw data
155
+ return restApiOutput.getData();
174
156
  }
175
157
  }
158
+ else if (restApiOutput.data) {
159
+ // For plain objects, try to convert or use directly
160
+ return typeof restApiOutput.data.getKindCase === "function"
161
+ ? convertProtobufValueToJs(restApiOutput.data)
162
+ : restApiOutput.data;
163
+ }
176
164
  }
177
165
  return undefined;
178
- case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
179
- nodeOutputMessage = step.getCustomCode();
180
- return nodeOutputMessage && nodeOutputMessage.hasData()
181
- ? convertProtobufValueToJs(nodeOutputMessage.getData())
182
- : undefined;
183
- case avs_pb.Execution.Step.OutputDataCase.REST_API:
184
- nodeOutputMessage = step.getRestApi();
185
- return nodeOutputMessage && nodeOutputMessage.hasData()
186
- ? convertProtobufValueToJs(nodeOutputMessage.getData())
187
- : undefined;
188
166
  case avs_pb.Execution.Step.OutputDataCase.BRANCH:
189
- return step.getBranch()?.toObject();
190
- case avs_pb.Execution.Step.OutputDataCase.FILTER:
191
- nodeOutputMessage = step.getFilter();
192
- if (nodeOutputMessage && nodeOutputMessage.hasData()) {
193
- const rawData = nodeOutputMessage.getData();
194
- if (rawData) {
195
- // Handle Any wrapper - need to unpack it first
196
- if (typeof rawData.unpack === 'function') {
197
- try {
198
- // For Any types, unpack to Value and then convert
199
- const unpackedValue = rawData.unpack(ProtobufValue.deserializeBinary, 'google.protobuf.Value');
200
- if (unpackedValue) {
201
- return convertProtobufValueToJs(unpackedValue);
202
- }
203
- }
204
- catch (error) {
205
- // If unpacking fails, log error and return undefined
206
- console.warn('Failed to unpack FilterNode Any wrapper:', error);
207
- return undefined;
208
- }
167
+ return typeof step.getBranch === "function"
168
+ ? step.getBranch()?.toObject()
169
+ : step.branch;
170
+ case avs_pb.Execution.Step.OutputDataCase.LOOP:
171
+ const loopOutput = typeof step.getLoop === "function"
172
+ ? step.getLoop()
173
+ : step.loop;
174
+ if (loopOutput) {
175
+ if (typeof loopOutput.getData === "function" &&
176
+ loopOutput.getData()) {
177
+ try {
178
+ return JSON.parse(loopOutput.getData());
209
179
  }
210
- // If no unpack method, this is unexpected for FilterNode
211
- console.warn('FilterNode output data is not an Any wrapper - this is unexpected');
180
+ catch {
181
+ return loopOutput.getData();
182
+ }
183
+ }
184
+ else if (loopOutput.data) {
185
+ // For plain objects
186
+ try {
187
+ return typeof loopOutput.data === "string"
188
+ ? JSON.parse(loopOutput.data)
189
+ : loopOutput.data;
190
+ }
191
+ catch {
192
+ return loopOutput.data;
193
+ }
194
+ }
195
+ }
196
+ return undefined;
197
+ case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
198
+ const graphqlOutput = typeof step.getGraphql === "function"
199
+ ? step.getGraphql()
200
+ : step.graphql;
201
+ if (graphqlOutput) {
202
+ try {
203
+ return typeof graphqlOutput.toObject === "function"
204
+ ? graphqlOutput.toObject()
205
+ : graphqlOutput;
206
+ }
207
+ catch {
212
208
  return undefined;
213
209
  }
214
210
  }
215
211
  return undefined;
216
- case avs_pb.Execution.Step.OutputDataCase.LOOP:
217
- const loopOutput = step.getLoop();
218
- if (!loopOutput)
219
- return undefined;
220
- const loopData = loopOutput.getData();
221
- if (!loopData)
222
- return undefined;
223
- // Loop nodes return an array of results from child node executions
224
- // The backend should serialize this as JSON, but may have issues
225
- // Try to parse as JSON first (expected format for array of child results)
226
- try {
227
- const parsedData = JSON.parse(loopData);
228
- // If it's an array, process each item with appropriate child node conversion
229
- if (Array.isArray(parsedData)) {
230
- return parsedData.map((item, index) => {
231
- if (!item || typeof item !== 'object') {
232
- return item; // Primitive values, return as-is
233
- }
234
- // Apply child node-specific conversions based on detected structure
235
- // REST API child output (has statusCode, body, headers)
236
- if (item.statusCode !== undefined && (item.body !== undefined || item.headers !== undefined)) {
237
- return item; // Already in raw format
238
- }
239
- // Custom Code child output (arbitrary object structure)
240
- if (item.result !== undefined || item.output !== undefined || item.error !== undefined) {
241
- return item; // Already processed by convertProtobufValueToJs in backend
242
- }
243
- // ETH Transfer child output (has transactionHash)
244
- if (item.transactionHash !== undefined) {
245
- return { transactionHash: item.transactionHash };
246
- }
247
- // Contract Read child output (has methodName and data)
248
- if (item.methodName !== undefined && item.data !== undefined) {
249
- return item; // Already in structured format
250
- }
251
- // GraphQL child output (has data field)
252
- if (item.data !== undefined && typeof item.data === 'object') {
253
- return item; // Already processed
254
- }
255
- // Generic object - return as-is (might be custom structure)
256
- return item;
257
- });
212
+ case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
213
+ const contractReadOutput = typeof step.getContractRead === "function"
214
+ ? step.getContractRead()
215
+ : step.contractRead;
216
+ if (contractReadOutput) {
217
+ // Get the raw output object
218
+ const outputObj = typeof contractReadOutput.toObject === "function"
219
+ ? contractReadOutput.toObject()
220
+ : contractReadOutput;
221
+ // Convert resultsList to results for consistency with ContractReadNode.fromOutputData
222
+ if (outputObj && outputObj.resultsList) {
223
+ // Exclude resultsList from the spread to avoid duplication
224
+ const { resultsList, ...cleanOutputObj } = outputObj;
225
+ return {
226
+ ...cleanOutputObj,
227
+ results: resultsList.map((result) => ({
228
+ methodName: result.methodName,
229
+ success: result.success,
230
+ error: result.error,
231
+ data: result.dataList || [],
232
+ })),
233
+ };
258
234
  }
259
- // Single object result (not an array)
260
- if (parsedData && typeof parsedData === 'object') {
261
- return parsedData;
235
+ return outputObj;
236
+ }
237
+ return undefined;
238
+ case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
239
+ const contractWriteOutput = typeof step.getContractWrite === "function"
240
+ ? step.getContractWrite()
241
+ : step.contractWrite;
242
+ if (contractWriteOutput) {
243
+ // Get the raw output object
244
+ const outputObj = typeof contractWriteOutput.toObject === "function"
245
+ ? contractWriteOutput.toObject()
246
+ : contractWriteOutput;
247
+ // Convert resultsList to results for consistency with ContractWriteNode.fromOutputData
248
+ if (outputObj && outputObj.resultsList) {
249
+ const transformedResults = outputObj.resultsList.map((result) => ({
250
+ methodName: result.methodName,
251
+ success: result.success,
252
+ transaction: result.transaction
253
+ ? {
254
+ hash: result.transaction.hash,
255
+ status: result.transaction.status,
256
+ blockNumber: result.transaction.blockNumber,
257
+ blockHash: result.transaction.blockHash,
258
+ gasUsed: result.transaction.gasUsed,
259
+ gasLimit: result.transaction.gasLimit,
260
+ gasPrice: result.transaction.gasPrice,
261
+ effectiveGasPrice: result.transaction.effectiveGasPrice,
262
+ from: result.transaction.from,
263
+ to: result.transaction.to,
264
+ value: result.transaction.value,
265
+ nonce: result.transaction.nonce,
266
+ transactionIndex: result.transaction.transactionIndex,
267
+ confirmations: result.transaction.confirmations,
268
+ timestamp: result.transaction.timestamp,
269
+ }
270
+ : null,
271
+ events: result.eventsList?.map((event) => ({
272
+ eventName: event.eventName,
273
+ address: event.address,
274
+ topics: event.topicsList || [],
275
+ data: event.data,
276
+ decoded: event.decodedMap || {},
277
+ })) || [],
278
+ error: result.error
279
+ ? {
280
+ code: result.error.code,
281
+ message: result.error.message,
282
+ revertReason: result.error.revertReason,
283
+ }
284
+ : null,
285
+ returnData: result.returnData
286
+ ? {
287
+ name: result.returnData.name,
288
+ type: result.returnData.type,
289
+ value: result.returnData.value,
290
+ }
291
+ : null,
292
+ inputData: result.inputData,
293
+ }));
294
+ // Exclude resultsList from the spread to avoid duplication
295
+ const { resultsList, ...cleanOutputObj } = outputObj;
296
+ return {
297
+ ...cleanOutputObj,
298
+ results: transformedResults,
299
+ // For backward compatibility, provide legacy fields from first result
300
+ ...(transformedResults.length > 0 && {
301
+ transaction: transformedResults[0].transaction,
302
+ success: transformedResults[0].success,
303
+ hash: transformedResults[0].transaction?.hash,
304
+ }),
305
+ };
262
306
  }
263
- // Parsed successfully but primitive value
264
- return { data: parsedData };
307
+ return outputObj;
265
308
  }
266
- catch (e) {
267
- // Not JSON or parsing failed - could be a simple string result
268
- // This might happen if backend has serialization issues
269
- return { data: loopData };
309
+ return undefined;
310
+ case avs_pb.Execution.Step.OutputDataCase.FILTER:
311
+ const filterOutput = typeof step.getFilter === "function"
312
+ ? step.getFilter()
313
+ : step.filter;
314
+ if (filterOutput) {
315
+ try {
316
+ return typeof filterOutput.toObject === "function"
317
+ ? filterOutput.toObject()
318
+ : filterOutput;
319
+ }
320
+ catch {
321
+ return undefined;
322
+ }
270
323
  }
324
+ return undefined;
271
325
  default:
272
- console.warn(`Unhandled output data type in Step.getOutput: ${outputDataType}`);
326
+ console.warn(`Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`);
273
327
  return undefined;
274
328
  }
275
329
  }
276
330
  static fromResponse(step) {
277
- // Extract input data if present
331
+ // Extract input data if present - USE PROPER PROTOBUF GETTER
278
332
  let inputData = undefined;
279
- if (step.hasInput()) {
333
+ // Check for input using proper protobuf methods
334
+ if (typeof step.hasInput === "function" &&
335
+ step.hasInput()) {
280
336
  const inputValue = step.getInput();
281
337
  if (inputValue) {
282
- inputData = convertProtobufValueToJs(inputValue);
338
+ // If it's a protobuf Value instance, convert it
339
+ try {
340
+ inputData = convertProtobufValueToJs(inputValue);
341
+ }
342
+ catch (error) {
343
+ console.warn("Failed to convert protobuf input value:", error);
344
+ // Fallback: if conversion fails, use the raw value
345
+ inputData = inputValue;
346
+ }
347
+ }
348
+ }
349
+ else if (step.input) {
350
+ // Fallback for plain objects (from .toObject() calls)
351
+ const inputValue = step.input;
352
+ // If it's already a plain JavaScript object, use it directly
353
+ if (typeof inputValue === "object" && !inputValue.getKindCase) {
354
+ inputData = inputValue;
355
+ }
356
+ else {
357
+ // If it's a protobuf Value instance, convert it
358
+ try {
359
+ inputData = convertProtobufValueToJs(inputValue);
360
+ }
361
+ catch (error) {
362
+ // Fallback: if conversion fails, use the raw value
363
+ inputData = inputValue;
364
+ }
283
365
  }
284
366
  }
367
+ // Handle method calls safely for both protobuf instances and plain objects
368
+ const getId = () => typeof step.getId === "function" ? step.getId() : step.id;
369
+ const getType = () => typeof step.getType === "function" ? step.getType() : step.type;
370
+ const getName = () => typeof step.getName === "function" ? step.getName() : step.name;
371
+ const getSuccess = () => typeof step.getSuccess === "function"
372
+ ? step.getSuccess()
373
+ : step.success;
374
+ const getError = () => typeof step.getError === "function"
375
+ ? step.getError()
376
+ : step.error;
377
+ const getLog = () => typeof step.getLog === "function" ? step.getLog() : step.log;
378
+ const getInputsList = () => typeof step.getInputsList === "function"
379
+ ? step.getInputsList()
380
+ : step.inputsList || [];
381
+ const getStartAt = () => typeof step.getStartAt === "function"
382
+ ? step.getStartAt()
383
+ : step.startAt;
384
+ const getEndAt = () => typeof step.getEndAt === "function"
385
+ ? step.getEndAt()
386
+ : step.endAt;
285
387
  return new Step({
286
- id: step.getId(),
287
- type: convertProtobufStepTypeToSdk(step.getType()),
288
- name: step.getName(),
289
- success: step.getSuccess(),
290
- error: step.getError(),
291
- log: step.getLog(),
292
- inputsList: step.getInputsList(),
388
+ id: getId(),
389
+ type: convertProtobufStepTypeToSdk(getType()),
390
+ name: getName(),
391
+ success: getSuccess(),
392
+ error: getError(),
393
+ log: getLog(),
394
+ inputsList: getInputsList(),
293
395
  input: inputData,
294
396
  output: Step.getOutput(step),
295
- startAt: step.getStartAt(),
296
- endAt: step.getEndAt(),
397
+ startAt: getStartAt(),
398
+ endAt: getEndAt(),
297
399
  });
298
400
  }
299
401
  }
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAA0B,MAAM,aAAa,CAAC;AAErD,OAAO,EAAqC,kBAAkB,EAAE,iBAAiB,EAAgB,MAAM,oBAAoB,CAAC;AAK5H,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IA+B1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAI9D;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAqC,kBAAkB,EAAE,iBAAiB,EAA+B,MAAM,oBAAoB,CAAC;AAM3I,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IA+B1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAI9D;AAED,eAAe,YAAY,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger from "./interface";
3
- import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
4
3
  import { TriggerType } from "@avaprotocol/types";
4
+ import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
5
5
  // Required props for constructor: id, name, type and data: { interval }
6
6
  class BlockTrigger extends Trigger {
7
7
  constructor(props) {
@@ -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,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA6C5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IA4D/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAuD1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;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;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,oBAAoB,CAAC;AA8C5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IA4D/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAuD1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAAyC,sBAAsB,EAAE,qBAAqB,EAAgB,MAAM,oBAAoB,CAAC;AAKxI,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAoB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAyC,sBAAsB,EAAE,qBAAqB,EAA+B,MAAM,oBAAoB,CAAC;AAMvJ,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAoB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,8 +1,6 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { TriggerType, TriggerProps } from "@avaprotocol/types";
3
- export type TriggerData = avs_pb.FixedTimeTrigger.AsObject | avs_pb.CronTrigger.AsObject | avs_pb.BlockTrigger.AsObject | avs_pb.EventTrigger.AsObject | Record<string, any> | null;
4
- export type TriggerOutput = avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.BlockTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | avs_pb.ManualTrigger.Output.AsObject | null;
5
- declare class Trigger implements TriggerProps {
2
+ import { TriggerType, TriggerProps, TriggerData, TriggerOutput } from "@avaprotocol/types";
3
+ export default abstract class Trigger implements TriggerProps {
6
4
  id: string;
7
5
  name: string;
8
6
  type: TriggerType;
@@ -18,5 +16,4 @@ declare class Trigger implements TriggerProps {
18
16
  getOutput(): TriggerOutput | undefined;
19
17
  toJson(): TriggerProps;
20
18
  }
21
- export default Trigger;
22
19
  //# sourceMappingURL=interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,MAAM,WAAW,GACnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,GACvC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,GAClC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GACpC,IAAI,CAAC;AAIT,cAAM,OAAQ,YAAW,YAAY;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5B;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAS/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,SAAS,IAAI,aAAa,GAAG,SAAS;IAItC,MAAM,IAAI,YAAY;CAUvB;AAED,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EACL,WAAW,EAGX,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,oBAAoB,CAAC;AAI5B,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,OAAQ,YAAW,YAAY;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5B;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAS/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,SAAS,IAAI,aAAa,GAAG,SAAS;IAItC,MAAM,IAAI,YAAY;CAUvB"}