@avaprotocol/sdk-js 2.3.13-dev.0 → 2.3.13-dev.1
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.js +309 -248
- package/dist/index.mjs +309 -248
- 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 +300 -209
- 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 +4 -6
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { extractInputFromProtobuf } from "../../utils";
|
|
2
|
+
export default class Trigger {
|
|
2
3
|
/**
|
|
3
4
|
* Create an instance of Trigger from user inputs
|
|
4
5
|
* @param props
|
|
@@ -9,7 +10,7 @@ class Trigger {
|
|
|
9
10
|
this.type = props.type;
|
|
10
11
|
this.data = props.data;
|
|
11
12
|
this.output = props.output;
|
|
12
|
-
this.input = props.input;
|
|
13
|
+
this.input = props.input ? extractInputFromProtobuf(props.input) : undefined;
|
|
13
14
|
}
|
|
14
15
|
toRequest() {
|
|
15
16
|
throw new Error("Method not implemented.");
|
|
@@ -28,4 +29,3 @@ class Trigger {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
export default Trigger;
|
package/dist/utils.d.ts
CHANGED
|
@@ -73,8 +73,8 @@ export declare function convertInputToProtobuf(input?: Record<string, any>): Pro
|
|
|
73
73
|
* Pure utility function for extracting trigger/node input data from protobuf format.
|
|
74
74
|
* Can be used by both triggers and nodes.
|
|
75
75
|
*
|
|
76
|
-
* @param inputValue - protobuf Value from response, or undefined
|
|
76
|
+
* @param inputValue - protobuf Value from response, plain JavaScript object, or undefined
|
|
77
77
|
* @returns JavaScript object or undefined
|
|
78
78
|
*/
|
|
79
|
-
export declare function extractInputFromProtobuf(inputValue?: ProtobufValue): Record<string, any> | undefined;
|
|
79
|
+
export declare function extractInputFromProtobuf(inputValue?: ProtobufValue | Record<string, any>): Record<string, any> | undefined;
|
|
80
80
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAkDxD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CASzE;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ils.js
CHANGED
|
@@ -249,16 +249,34 @@ export function convertInputToProtobuf(input) {
|
|
|
249
249
|
* Pure utility function for extracting trigger/node input data from protobuf format.
|
|
250
250
|
* Can be used by both triggers and nodes.
|
|
251
251
|
*
|
|
252
|
-
* @param inputValue - protobuf Value from response, or undefined
|
|
252
|
+
* @param inputValue - protobuf Value from response, plain JavaScript object, or undefined
|
|
253
253
|
* @returns JavaScript object or undefined
|
|
254
254
|
*/
|
|
255
255
|
export function extractInputFromProtobuf(inputValue) {
|
|
256
256
|
if (!inputValue) {
|
|
257
257
|
return undefined;
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
return
|
|
259
|
+
// Check if it's already a plain JavaScript object
|
|
260
|
+
if (typeof inputValue === 'object' && !inputValue.toJavaScript) {
|
|
261
|
+
// It's a plain JavaScript object, return as-is
|
|
262
|
+
if (!Array.isArray(inputValue)) {
|
|
263
|
+
return inputValue;
|
|
264
|
+
}
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
// It's a protobuf Value object, convert it
|
|
268
|
+
try {
|
|
269
|
+
const protobufValue = inputValue;
|
|
270
|
+
const inputJavaScript = protobufValue.toJavaScript();
|
|
271
|
+
if (inputJavaScript && typeof inputJavaScript === 'object' && !Array.isArray(inputJavaScript)) {
|
|
272
|
+
return inputJavaScript;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
// If conversion fails, try to return the object as-is if it looks like a valid input object
|
|
277
|
+
if (typeof inputValue === 'object' && !Array.isArray(inputValue)) {
|
|
278
|
+
return inputValue;
|
|
279
|
+
}
|
|
262
280
|
}
|
|
263
281
|
return undefined;
|
|
264
282
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.3.13-dev.
|
|
3
|
+
"version": "2.3.13-dev.1",
|
|
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.2.
|
|
34
|
+
"@avaprotocol/types": "^2.2.10",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|