otomato-sdk 2.0.21 → 2.0.22
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/src/constants/Blocks.js +135 -1
- package/dist/src/constants/version.js +1 -1
- package/dist/src/models/Workflow.js +44 -6
- package/dist/types/src/constants/Blocks.d.ts +64 -0
- package/dist/types/src/constants/version.d.ts +1 -1
- package/dist/types/src/models/Workflow.d.ts +17 -1
- package/package.json +1 -1
|
@@ -2575,6 +2575,139 @@ export const TRIGGERS = {
|
|
|
2575
2575
|
};
|
|
2576
2576
|
export const ACTIONS = {
|
|
2577
2577
|
"CORE": {
|
|
2578
|
+
"EMPTYBLOCK": {
|
|
2579
|
+
"image": "",
|
|
2580
|
+
"description": "",
|
|
2581
|
+
"chains": [],
|
|
2582
|
+
"EMPTYBLOCK": {
|
|
2583
|
+
"name": "Odos swap",
|
|
2584
|
+
"description": "Swap on Odos to get the best market rates accross multiple pools",
|
|
2585
|
+
"type": 1,
|
|
2586
|
+
"requiredApprovals": [
|
|
2587
|
+
{
|
|
2588
|
+
"address": "{{parameters.tokenIn}}",
|
|
2589
|
+
"amount": "{{parameters.amount}}",
|
|
2590
|
+
"to": "{{before.contractAddress}}"
|
|
2591
|
+
}
|
|
2592
|
+
],
|
|
2593
|
+
"checks": [
|
|
2594
|
+
{
|
|
2595
|
+
"type": 0,
|
|
2596
|
+
"chainId": "{{parameters.chainId}}",
|
|
2597
|
+
"contractAddress": "{{parameters.tokenIn}}",
|
|
2598
|
+
"amount": "{{parameters.amount}}"
|
|
2599
|
+
}
|
|
2600
|
+
],
|
|
2601
|
+
"output": {
|
|
2602
|
+
"amountIn": "uint256",
|
|
2603
|
+
"tokenIn": "erc20",
|
|
2604
|
+
"amountOut": "uint256",
|
|
2605
|
+
"tokenOut": "erc20",
|
|
2606
|
+
"transactionHash": "string"
|
|
2607
|
+
},
|
|
2608
|
+
"frontendHelpers": {
|
|
2609
|
+
"output": {
|
|
2610
|
+
"amountIn": {
|
|
2611
|
+
"erc20Token": {
|
|
2612
|
+
"contractAddress": "{{output.tokenIn}}",
|
|
2613
|
+
"chainId": "{{parameters.chainId}}"
|
|
2614
|
+
}
|
|
2615
|
+
},
|
|
2616
|
+
"amountOut": {
|
|
2617
|
+
"erc20Token": {
|
|
2618
|
+
"contractAddress": "{{output.tokenOut}}",
|
|
2619
|
+
"chainId": "{{parameters.chainId}}"
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
},
|
|
2624
|
+
"parameters": [
|
|
2625
|
+
{
|
|
2626
|
+
"key": "chainId",
|
|
2627
|
+
"type": "chainId",
|
|
2628
|
+
"description": "Chain ID of the network",
|
|
2629
|
+
"mandatory": true,
|
|
2630
|
+
"category": 0
|
|
2631
|
+
},
|
|
2632
|
+
{
|
|
2633
|
+
"key": "tokenIn",
|
|
2634
|
+
"type": "erc20",
|
|
2635
|
+
"description": "Token to sell",
|
|
2636
|
+
"mandatory": true,
|
|
2637
|
+
"category": 0
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
"key": "tokenOut",
|
|
2641
|
+
"type": "erc20",
|
|
2642
|
+
"description": "Token to buy",
|
|
2643
|
+
"mandatory": true,
|
|
2644
|
+
"category": 0
|
|
2645
|
+
},
|
|
2646
|
+
{
|
|
2647
|
+
"key": "amount",
|
|
2648
|
+
"type": "uint256",
|
|
2649
|
+
"description": "Amount to sell",
|
|
2650
|
+
"mandatory": true,
|
|
2651
|
+
"category": 0,
|
|
2652
|
+
"erc20FormattedAmount": {
|
|
2653
|
+
"contractAddress": "{{parameters.tokenIn}}",
|
|
2654
|
+
"chain": "{{parameters.chainId}}"
|
|
2655
|
+
}
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
"key": "slippage",
|
|
2659
|
+
"type": "percentage",
|
|
2660
|
+
"description": "The maximum allowable difference between the expected price and the actual price at the time of execution, expressed as a percentage. This protects the transaction from significant price fluctuations.",
|
|
2661
|
+
"value": 1,
|
|
2662
|
+
"mandatory": true,
|
|
2663
|
+
"category": 1
|
|
2664
|
+
},
|
|
2665
|
+
],
|
|
2666
|
+
"examples": [
|
|
2667
|
+
{
|
|
2668
|
+
"name": "Swap USDC to WETH",
|
|
2669
|
+
"description": "Swap 100 USDC to WETH on Mode Network using Odos",
|
|
2670
|
+
"parameters": [
|
|
2671
|
+
{
|
|
2672
|
+
"key": "chainId",
|
|
2673
|
+
"value": 34443
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
"key": "tokenIn",
|
|
2677
|
+
"value": "0xd988097fb8612cc24eeC14542bC03424c656005f"
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
"key": "tokenOut",
|
|
2681
|
+
"value": "0x4200000000000000000000000000000000000006"
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
"key": "amount",
|
|
2685
|
+
"value": "100000000n"
|
|
2686
|
+
},
|
|
2687
|
+
{
|
|
2688
|
+
"key": "slippage",
|
|
2689
|
+
"value": 1
|
|
2690
|
+
}
|
|
2691
|
+
]
|
|
2692
|
+
}
|
|
2693
|
+
],
|
|
2694
|
+
"permissions": {
|
|
2695
|
+
"chainId": "{{parameters.chainId}}",
|
|
2696
|
+
"approvedTargets": [
|
|
2697
|
+
"{{before.contractAddress}}",
|
|
2698
|
+
"{{parameters.tokenIn}}"
|
|
2699
|
+
],
|
|
2700
|
+
"label": [
|
|
2701
|
+
"Swap {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenIn}})}} to {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenOut}})}}"
|
|
2702
|
+
],
|
|
2703
|
+
"labelNotAuthorized": [
|
|
2704
|
+
"Transfer ETH"
|
|
2705
|
+
]
|
|
2706
|
+
},
|
|
2707
|
+
"blockId": 0,
|
|
2708
|
+
"image": ""
|
|
2709
|
+
}
|
|
2710
|
+
},
|
|
2578
2711
|
"DELAY": {
|
|
2579
2712
|
"description": "Set of functions to delay the executions of the following blocks.",
|
|
2580
2713
|
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png",
|
|
@@ -3409,7 +3542,8 @@ export const ACTIONS = {
|
|
|
3409
3542
|
"permissions": {
|
|
3410
3543
|
"chainId": "{{parameters.chainId}}",
|
|
3411
3544
|
"approvedTargets": [
|
|
3412
|
-
"{{before.contractAddress}}"
|
|
3545
|
+
"{{before.contractAddress}}",
|
|
3546
|
+
"{{parameters.tokenToRepay}}"
|
|
3413
3547
|
],
|
|
3414
3548
|
"label": [
|
|
3415
3549
|
"Repay {{tokenSymbol({{parameters.chainId}}, {{parameters.tokenToRepay}})}} on IONIC"
|
|
@@ -59,17 +59,42 @@ export class Workflow {
|
|
|
59
59
|
// Recalculate positions
|
|
60
60
|
positionWorkflowNodesAvoidOverlap(this);
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Inserts a new node into the workflow:
|
|
64
|
+
* - If both nodeBefore and nodeAfter are provided, we expect an existing edge
|
|
65
|
+
* from nodeBefore -> nodeAfter, which gets replaced by two edges:
|
|
66
|
+
* nodeBefore -> nodeToInsert and nodeToInsert -> nodeAfter.
|
|
67
|
+
*
|
|
68
|
+
* - If nodeAfter is NOT provided, we create a single edge from nodeBefore
|
|
69
|
+
* to nodeToInsert. The user can optionally provide `edgeLabel` and `edgeValue`
|
|
70
|
+
* in that scenario only.
|
|
71
|
+
*
|
|
72
|
+
* @param nodeToInsert The node you want to insert
|
|
73
|
+
* @param nodeBefore The existing node in the workflow that precedes `nodeToInsert`
|
|
74
|
+
* @param nodeAfter (Optional) The existing node that should follow `nodeToInsert`
|
|
75
|
+
* @param edgeLabel (Optional) Label for the edge, only allowed if `nodeAfter` is not provided
|
|
76
|
+
* @param edgeValue (Optional) Value for the edge, only allowed if `nodeAfter` is not provided
|
|
77
|
+
*/
|
|
78
|
+
insertNode(nodeToInsert, nodeBefore, nodeAfter, edgeLabel = null, edgeValue = null) {
|
|
63
79
|
// Ensure nodeBefore exists in the workflow
|
|
64
80
|
if (!this.nodes.includes(nodeBefore)) {
|
|
65
81
|
throw new Error('The nodeBefore must exist in the workflow.');
|
|
66
82
|
}
|
|
83
|
+
// If nodeAfter is provided, disallow edgeLabel/edgeValue
|
|
84
|
+
if (nodeAfter && (edgeLabel !== null || edgeValue !== null)) {
|
|
85
|
+
throw new Error('Cannot provide edgeLabel/edgeValue if nodeAfter is specified.');
|
|
86
|
+
}
|
|
67
87
|
// If nodeAfter is not provided, insert the new node as a child of nodeBefore
|
|
68
88
|
if (!nodeAfter) {
|
|
69
89
|
// Add the new node to the workflow
|
|
70
90
|
this.addNode(nodeToInsert);
|
|
71
|
-
// Add a new edge between nodeBefore and nodeToInsert
|
|
72
|
-
const newEdge = new Edge({
|
|
91
|
+
// Add a new edge between nodeBefore and nodeToInsert (with optional label/value)
|
|
92
|
+
const newEdge = new Edge({
|
|
93
|
+
source: nodeBefore,
|
|
94
|
+
target: nodeToInsert,
|
|
95
|
+
label: edgeLabel !== null && edgeLabel !== void 0 ? edgeLabel : undefined,
|
|
96
|
+
value: edgeValue !== null && edgeValue !== void 0 ? edgeValue : undefined
|
|
97
|
+
});
|
|
73
98
|
this.addEdge(newEdge);
|
|
74
99
|
// Recalculate positions
|
|
75
100
|
positionWorkflowNodesAvoidOverlap(this);
|
|
@@ -167,6 +192,19 @@ export class Workflow {
|
|
|
167
192
|
return this.notes.map(note => note.toJSON());
|
|
168
193
|
}
|
|
169
194
|
toJSON() {
|
|
195
|
+
// 1. Create a new Workflow instance, copying only the nodes, edges, and notes
|
|
196
|
+
const clonedWorkflow = new Workflow(this.name, // same name
|
|
197
|
+
[...this.nodes], // shallow copy of nodes
|
|
198
|
+
[...this.edges] // shallow copy of edges
|
|
199
|
+
);
|
|
200
|
+
clonedWorkflow.notes = [...this.notes]; // shallow copy of notes array
|
|
201
|
+
// 2. Identify any empty nodes (blockId === 0), then delete them from the clone
|
|
202
|
+
const emptyNodes = clonedWorkflow.nodes.filter(node => node.blockId === 0);
|
|
203
|
+
for (const emptyNode of emptyNodes) {
|
|
204
|
+
clonedWorkflow.deleteNode(emptyNode);
|
|
205
|
+
}
|
|
206
|
+
// 3. Return JSON using 'this' for top-level info (id, state, etc.),
|
|
207
|
+
// but using the clonedWorkflow's nodes, edges, and notes
|
|
170
208
|
return {
|
|
171
209
|
id: this.id,
|
|
172
210
|
name: this.name,
|
|
@@ -174,9 +212,9 @@ export class Workflow {
|
|
|
174
212
|
dateCreated: this.dateCreated,
|
|
175
213
|
dateModified: this.dateModified,
|
|
176
214
|
executionId: this.executionId,
|
|
177
|
-
nodes:
|
|
178
|
-
edges:
|
|
179
|
-
notes:
|
|
215
|
+
nodes: clonedWorkflow.nodes.map(node => node.toJSON()),
|
|
216
|
+
edges: clonedWorkflow.edges.map(edge => edge.toJSON()),
|
|
217
|
+
notes: clonedWorkflow.getNotes(),
|
|
180
218
|
};
|
|
181
219
|
}
|
|
182
220
|
create() {
|
|
@@ -1067,6 +1067,70 @@ export declare const TRIGGERS: {
|
|
|
1067
1067
|
};
|
|
1068
1068
|
export declare const ACTIONS: {
|
|
1069
1069
|
CORE: {
|
|
1070
|
+
EMPTYBLOCK: {
|
|
1071
|
+
image: string;
|
|
1072
|
+
description: string;
|
|
1073
|
+
chains: never[];
|
|
1074
|
+
EMPTYBLOCK: {
|
|
1075
|
+
name: string;
|
|
1076
|
+
description: string;
|
|
1077
|
+
type: number;
|
|
1078
|
+
requiredApprovals: {
|
|
1079
|
+
address: string;
|
|
1080
|
+
amount: string;
|
|
1081
|
+
to: string;
|
|
1082
|
+
}[];
|
|
1083
|
+
checks: {
|
|
1084
|
+
type: number;
|
|
1085
|
+
chainId: string;
|
|
1086
|
+
contractAddress: string;
|
|
1087
|
+
amount: string;
|
|
1088
|
+
}[];
|
|
1089
|
+
output: {
|
|
1090
|
+
amountIn: string;
|
|
1091
|
+
tokenIn: string;
|
|
1092
|
+
amountOut: string;
|
|
1093
|
+
tokenOut: string;
|
|
1094
|
+
transactionHash: string;
|
|
1095
|
+
};
|
|
1096
|
+
frontendHelpers: {
|
|
1097
|
+
output: {
|
|
1098
|
+
amountIn: {
|
|
1099
|
+
erc20Token: {
|
|
1100
|
+
contractAddress: string;
|
|
1101
|
+
chainId: string;
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
amountOut: {
|
|
1105
|
+
erc20Token: {
|
|
1106
|
+
contractAddress: string;
|
|
1107
|
+
chainId: string;
|
|
1108
|
+
};
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
parameters: Parameter[];
|
|
1113
|
+
examples: {
|
|
1114
|
+
name: string;
|
|
1115
|
+
description: string;
|
|
1116
|
+
parameters: ({
|
|
1117
|
+
key: string;
|
|
1118
|
+
value: number;
|
|
1119
|
+
} | {
|
|
1120
|
+
key: string;
|
|
1121
|
+
value: string;
|
|
1122
|
+
})[];
|
|
1123
|
+
}[];
|
|
1124
|
+
permissions: {
|
|
1125
|
+
chainId: string;
|
|
1126
|
+
approvedTargets: string[];
|
|
1127
|
+
label: string[];
|
|
1128
|
+
labelNotAuthorized: string[];
|
|
1129
|
+
};
|
|
1130
|
+
blockId: number;
|
|
1131
|
+
image: string;
|
|
1132
|
+
};
|
|
1133
|
+
};
|
|
1070
1134
|
DELAY: {
|
|
1071
1135
|
description: string;
|
|
1072
1136
|
image: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.22";
|
|
2
2
|
export declare function compareVersions(v1: string, v2: string): number;
|
|
@@ -18,7 +18,23 @@ export declare class Workflow {
|
|
|
18
18
|
addNode(node: Node): void;
|
|
19
19
|
addNodes(nodes: Node[]): void;
|
|
20
20
|
deleteNode(nodeToDelete: Node): void;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Inserts a new node into the workflow:
|
|
23
|
+
* - If both nodeBefore and nodeAfter are provided, we expect an existing edge
|
|
24
|
+
* from nodeBefore -> nodeAfter, which gets replaced by two edges:
|
|
25
|
+
* nodeBefore -> nodeToInsert and nodeToInsert -> nodeAfter.
|
|
26
|
+
*
|
|
27
|
+
* - If nodeAfter is NOT provided, we create a single edge from nodeBefore
|
|
28
|
+
* to nodeToInsert. The user can optionally provide `edgeLabel` and `edgeValue`
|
|
29
|
+
* in that scenario only.
|
|
30
|
+
*
|
|
31
|
+
* @param nodeToInsert The node you want to insert
|
|
32
|
+
* @param nodeBefore The existing node in the workflow that precedes `nodeToInsert`
|
|
33
|
+
* @param nodeAfter (Optional) The existing node that should follow `nodeToInsert`
|
|
34
|
+
* @param edgeLabel (Optional) Label for the edge, only allowed if `nodeAfter` is not provided
|
|
35
|
+
* @param edgeValue (Optional) Value for the edge, only allowed if `nodeAfter` is not provided
|
|
36
|
+
*/
|
|
37
|
+
insertNode(nodeToInsert: Node, nodeBefore: Node, nodeAfter?: Node, edgeLabel?: string | null, edgeValue?: any | null): void;
|
|
22
38
|
swapNode(oldNode: Node, newNode: Node): void;
|
|
23
39
|
addEdge(edge: Edge): void;
|
|
24
40
|
updateEdge(edgeId: string, newEdge: Edge): void;
|