@avaprotocol/sdk-js 2.14.2 → 2.16.0
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 +53 -0
- package/README.md +15 -0
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +807 -684
- package/dist/index.mjs +807 -684
- package/dist/models/execution.d.ts +4 -7
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/execution.js +40 -16
- package/dist/models/workflow.d.ts +6 -1
- package/dist/models/workflow.d.ts.map +1 -1
- package/dist/models/workflow.js +6 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import { ExecutionProps, ExecutionStatus, type
|
|
2
|
+
import { ExecutionProps, ExecutionStatus, type Fee, type NodeCOGS, type ValueFee } from "@avaprotocol/types";
|
|
3
3
|
import Step from "./step";
|
|
4
4
|
declare class Execution implements ExecutionProps {
|
|
5
5
|
id: string;
|
|
@@ -9,13 +9,10 @@ declare class Execution implements ExecutionProps {
|
|
|
9
9
|
error: string;
|
|
10
10
|
index: number;
|
|
11
11
|
steps: Step[];
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
executionFee?: Fee;
|
|
13
|
+
cogs: NodeCOGS[];
|
|
14
|
+
valueFee?: ValueFee;
|
|
14
15
|
constructor(props: ExecutionProps);
|
|
15
|
-
/**
|
|
16
|
-
* Convert Execution instance to plain object (ExecutionProps)
|
|
17
|
-
* This is useful for serialization, especially with Next.js Server Components
|
|
18
|
-
*/
|
|
19
16
|
toJson(): ExecutionProps;
|
|
20
17
|
static fromResponse(execution: avs_pb.Execution): Execution;
|
|
21
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,cAAc,EAEd,eAAe,EACf,KAAK,
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,cAAc,EAEd,eAAe,EACf,KAAK,GAAG,EAER,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAwD1B,cAAM,SAAU,YAAW,cAAc;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAER,KAAK,EAAE,cAAc;IAajC,MAAM,IAAI,cAAc;IAexB,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS;CAgB5D;AAED,eAAe,SAAS,CAAC"}
|
package/dist/models/execution.js
CHANGED
|
@@ -19,6 +19,37 @@ function convertProtobufExecutionStatusToTypes(protobufStatus) {
|
|
|
19
19
|
return ExecutionStatus.Unspecified;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
function convertFee(feePb) {
|
|
23
|
+
if (!feePb)
|
|
24
|
+
return undefined;
|
|
25
|
+
return {
|
|
26
|
+
amount: feePb.getAmount(),
|
|
27
|
+
unit: feePb.getUnit(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function convertNodeCOGS(cogsPb) {
|
|
31
|
+
return {
|
|
32
|
+
nodeId: cogsPb.getNodeId(),
|
|
33
|
+
costType: cogsPb.getCostType(),
|
|
34
|
+
fee: convertFee(cogsPb.getFee()) || { amount: "0", unit: "WEI" },
|
|
35
|
+
gasUnits: cogsPb.getGasUnits() || undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function convertExecutionTier(tier) {
|
|
39
|
+
return avs_pb.ExecutionTier[tier] ?? tier.toString();
|
|
40
|
+
}
|
|
41
|
+
function convertValueFee(valuePb) {
|
|
42
|
+
if (!valuePb)
|
|
43
|
+
return undefined;
|
|
44
|
+
return {
|
|
45
|
+
fee: convertFee(valuePb.getFee()) || { amount: "0", unit: "PERCENTAGE" },
|
|
46
|
+
tier: convertExecutionTier(valuePb.getTier()),
|
|
47
|
+
valueBase: valuePb.getValueBase() || undefined,
|
|
48
|
+
classificationMethod: valuePb.getClassificationMethod(),
|
|
49
|
+
confidence: valuePb.getConfidence(),
|
|
50
|
+
reason: valuePb.getReason(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
22
53
|
class Execution {
|
|
23
54
|
constructor(props) {
|
|
24
55
|
this.id = props.id;
|
|
@@ -28,13 +59,10 @@ class Execution {
|
|
|
28
59
|
this.error = props.error;
|
|
29
60
|
this.index = props.index;
|
|
30
61
|
this.steps = props.steps.map(s => new Step(s));
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
62
|
+
this.executionFee = props.executionFee;
|
|
63
|
+
this.cogs = props.cogs || [];
|
|
64
|
+
this.valueFee = props.valueFee;
|
|
33
65
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Convert Execution instance to plain object (ExecutionProps)
|
|
36
|
-
* This is useful for serialization, especially with Next.js Server Components
|
|
37
|
-
*/
|
|
38
66
|
toJson() {
|
|
39
67
|
return {
|
|
40
68
|
id: this.id,
|
|
@@ -44,17 +72,12 @@ class Execution {
|
|
|
44
72
|
error: this.error,
|
|
45
73
|
index: this.index,
|
|
46
74
|
steps: this.steps.map(step => step.toJson()),
|
|
47
|
-
...(this.
|
|
48
|
-
|
|
75
|
+
...(this.executionFee && { executionFee: this.executionFee }),
|
|
76
|
+
cogs: this.cogs,
|
|
77
|
+
...(this.valueFee && { valueFee: this.valueFee }),
|
|
49
78
|
};
|
|
50
79
|
}
|
|
51
80
|
static fromResponse(execution) {
|
|
52
|
-
const automationFeePb = typeof execution.getAutomationFee === 'function'
|
|
53
|
-
? execution.getAutomationFee()
|
|
54
|
-
: undefined;
|
|
55
|
-
const automationFee = automationFeePb
|
|
56
|
-
? automationFeePb.toObject()
|
|
57
|
-
: undefined;
|
|
58
81
|
return new Execution({
|
|
59
82
|
id: execution.getId(),
|
|
60
83
|
startAt: execution.getStartAt(),
|
|
@@ -62,8 +85,9 @@ class Execution {
|
|
|
62
85
|
status: convertProtobufExecutionStatusToTypes(execution.getStatus()),
|
|
63
86
|
error: execution.getError(),
|
|
64
87
|
index: execution.getIndex(),
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
executionFee: convertFee(execution.getExecutionFee()),
|
|
89
|
+
cogs: execution.getCogsList().map(convertNodeCOGS),
|
|
90
|
+
valueFee: convertValueFee(execution.getValueFee()),
|
|
67
91
|
steps: execution
|
|
68
92
|
.getStepsList()
|
|
69
93
|
.map((step) => Step.fromResponse(step)),
|
|
@@ -2,7 +2,12 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
|
2
2
|
import Node from "./node/interface";
|
|
3
3
|
import Edge from "./edge";
|
|
4
4
|
import Trigger from "./trigger/interface";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Default value for workflow expiration. A value of 0 or negative means the
|
|
7
|
+
* workflow never expires. The backend only enforces expiration when
|
|
8
|
+
* `expiredAt > 0` (interpreted as a Unix timestamp in milliseconds).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DefaultExpiredAt = 0;
|
|
6
11
|
import { WorkflowStatus, WorkflowProps, InputVariables } from "@avaprotocol/types";
|
|
7
12
|
export declare function convertStatusToString(status: avs_pb.TaskStatus): WorkflowStatus;
|
|
8
13
|
declare class Workflow implements WorkflowProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAInF,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,UAAU,GACxB,cAAc,CAgBhB;AAED,cAAM,QAAS,YAAW,aAAa;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,IAAI,EAAE,MAAM,CAAC;IAGb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;gBACS,KAAK,EAAE,aAAa;IA2BhC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IA4C/C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAmCnD,SAAS,IAAI,MAAM,CAAC,aAAa;IAsEjC;;;OAGG;IACH,MAAM,IAAI,aAAa;CAmBxB;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/models/workflow.js
CHANGED
|
@@ -3,7 +3,12 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
|
3
3
|
import Edge from "./edge";
|
|
4
4
|
import TriggerFactory from "./trigger/factory";
|
|
5
5
|
import NodeFactory from "./node/factory";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Default value for workflow expiration. A value of 0 or negative means the
|
|
8
|
+
* workflow never expires. The backend only enforces expiration when
|
|
9
|
+
* `expiredAt > 0` (interpreted as a Unix timestamp in milliseconds).
|
|
10
|
+
*/
|
|
11
|
+
export const DefaultExpiredAt = 0;
|
|
7
12
|
import { WorkflowStatus } from "@avaprotocol/types";
|
|
8
13
|
import { convertJSValueToProtobuf } from "../utils";
|
|
9
14
|
// Function to convert TaskStatus to string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
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.
|
|
34
|
+
"@avaprotocol/types": "2.12.0",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|