@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.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +317 -252
- package/dist/index.mjs +317 -252
- package/dist/models/node/branch.js +4 -4
- package/dist/models/node/contractRead.js +4 -4
- package/dist/models/node/contractWrite.js +4 -4
- package/dist/models/node/customCode.js +4 -4
- package/dist/models/node/ethTransfer.js +4 -4
- package/dist/models/node/filter.js +4 -4
- package/dist/models/node/graphqlQuery.js +4 -4
- package/dist/models/node/interface.d.ts +2 -2
- package/dist/models/node/interface.d.ts.map +1 -1
- package/dist/models/node/interface.js +17 -3
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +314 -212
- package/dist/models/trigger/block.d.ts.map +1 -1
- package/dist/models/trigger/block.js +1 -1
- package/dist/models/trigger/event.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/interface.d.ts +2 -5
- package/dist/models/trigger/interface.d.ts.map +1 -1
- package/dist/models/trigger/interface.js +3 -3
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +22 -4
- package/package.json +2 -2
package/dist/models/step.js
CHANGED
|
@@ -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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
51
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
173
|
-
return
|
|
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
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
211
|
-
|
|
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.
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
264
|
-
return { data: parsedData };
|
|
307
|
+
return outputObj;
|
|
265
308
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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: ${
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
287
|
-
type: convertProtobufStepTypeToSdk(
|
|
288
|
-
name:
|
|
289
|
-
success:
|
|
290
|
-
error:
|
|
291
|
-
log:
|
|
292
|
-
inputsList:
|
|
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:
|
|
296
|
-
endAt:
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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;
|
|
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"}
|