otomato-sdk 1.2.1 → 1.3.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/dist/examples/create-workflow.js +44 -0
- package/dist/examples/load-workflow.js +16 -0
- package/dist/examples/sandbox.js +18 -9
- package/dist/src/constants/Blocks.js +69 -35
- package/dist/src/index.js +1 -1
- package/dist/src/models/Edge.js +6 -1
- package/dist/src/models/Node.js +68 -2
- package/dist/src/models/Workflow.js +67 -0
- package/dist/src/services/ApiService.js +24 -18
- package/dist/test/action.spec.js +1 -1
- package/dist/test/automation.spec.js +19 -19
- package/dist/test/node.spec.js +26 -18
- package/dist/test/trigger.spec.js +1 -1
- package/dist/types/examples/create-workflow.d.ts +1 -0
- package/dist/types/examples/load-workflow.d.ts +1 -0
- package/dist/types/src/constants/Blocks.d.ts +55 -21
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/models/Action.d.ts +2 -1
- package/dist/types/src/models/Edge.d.ts +3 -0
- package/dist/types/src/models/Node.d.ts +9 -2
- package/dist/types/src/models/Trigger.d.ts +2 -1
- package/dist/types/src/models/Workflow.d.ts +26 -0
- package/dist/types/src/services/ApiService.d.ts +8 -3
- package/examples/create-workflow.ts +44 -0
- package/examples/load-workflow.ts +10 -0
- package/package.json +2 -3
- package/src/constants/Blocks.ts +69 -35
- package/src/index.ts +1 -1
- package/src/models/Action.ts +1 -1
- package/src/models/Condition.ts +5 -5
- package/src/models/Edge.ts +8 -2
- package/src/models/Node.ts +80 -6
- package/src/models/Parameter.ts +5 -5
- package/src/models/Trigger.ts +1 -1
- package/src/models/Workflow.ts +69 -0
- package/src/services/ApiService.ts +26 -19
- package/test/action.spec.ts +1 -1
- package/test/automation.spec.ts +20 -20
- package/test/node.spec.ts +26 -18
- package/test/trigger.spec.ts +1 -1
- package/examples/create-automation.ts +0 -35
- package/examples/sandbox.ts +0 -12
- package/src/models/Automation.ts +0 -47
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ACTIONS, Action, TRIGGERS, Trigger, Workflow, CHAINS, getToken, Edge, apiServices } from '../src/index.js';
|
|
11
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
apiServices.setCookie("eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweDdjRUI4ZDgxNDdBYWE5ZEI4MUFjQkRGRTVjMzA1MERGQ2ZGMTg1MzciLCJzdWIiOiIweDg3RkU4YjRmMkZlODM3MGY2Y0M5YTk2MzQ0MmYwN0IwMmY0OTA5QTciLCJhdWQiOiJvdG9tYXRvLXRlc3QubmV0bGlmeS5hcHAiLCJleHAiOjE3MjMzODMxOTksIm5iZiI6MTcyMDc4OTM5OSwiaWF0IjoxNzIwNzkxMTk5LCJqdGkiOiIweDY4ZDkxOWEyMGZiYjIyNDUwZDZmOTFjMzM2ZTBmYjBjMmYyYTc3MmU3Zjg4NWU1ZjRmNzg1NTM2ZGIyYTY5YTAiLCJjdHgiOnt9fQ.MHgyOTM1NTM3MWYwOWM1YzllNWE3YjI4MjVkZTNjMDljZTkwMTQ3OTQwZmU1ZWRlMjM5YTk0MmFjYTQ5YTcwZWI0MGJlNmJiZDk2MDA4ZTIxMzJmNGM3ZTVlZGIzZDZiZjYyMDE4Mzc1MzUwMTRmNTc0ODM0ZDk4YWU3NDQwNDQzOTFi");
|
|
13
|
+
const usdcTransferTrigger = new Trigger({
|
|
14
|
+
blockId: TRIGGERS.TOKENS.ERC20.TRANSFER.blockId,
|
|
15
|
+
name: TRIGGERS.TOKENS.ERC20.TRANSFER.name,
|
|
16
|
+
description: TRIGGERS.TOKENS.ERC20.TRANSFER.description,
|
|
17
|
+
type: TRIGGERS.TOKENS.ERC20.TRANSFER.type,
|
|
18
|
+
parameters: TRIGGERS.TOKENS.ERC20.TRANSFER.parameters,
|
|
19
|
+
image: TRIGGERS.TOKENS.ERC20.TRANSFER.image,
|
|
20
|
+
ref: 'n-1',
|
|
21
|
+
});
|
|
22
|
+
usdcTransferTrigger.setChainId(CHAINS.ETHEREUM);
|
|
23
|
+
usdcTransferTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
|
|
24
|
+
usdcTransferTrigger.setPosition(0, 0);
|
|
25
|
+
const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
|
|
26
|
+
slackAction.setParams("webhook", "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
|
|
27
|
+
slackAction.setParams("message", "USDC has been transferred!");
|
|
28
|
+
slackAction.setPosition(0, -10);
|
|
29
|
+
const workflow = new Workflow("USDC Transfer Notification", [usdcTransferTrigger, slackAction]);
|
|
30
|
+
const edge = new Edge({
|
|
31
|
+
source: usdcTransferTrigger,
|
|
32
|
+
target: slackAction,
|
|
33
|
+
});
|
|
34
|
+
workflow.addEdge(edge);
|
|
35
|
+
// console.log(JSON.stringify(workflow.toJSON(), null, 2));
|
|
36
|
+
return;
|
|
37
|
+
const res = yield workflow.create();
|
|
38
|
+
console.log(res);
|
|
39
|
+
console.log(`Workflow ID: ${workflow.id}`); // This will print the ID of the created workflow
|
|
40
|
+
workflow.nodes.forEach(node => {
|
|
41
|
+
console.log(`Node ${node.getRef()} ID: ${node.id}`);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
main();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Workflow, apiServices } from '../src/index.js';
|
|
11
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
apiServices.setCookie("eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweDdjRUI4ZDgxNDdBYWE5ZEI4MUFjQkRGRTVjMzA1MERGQ2ZGMTg1MzciLCJzdWIiOiIweDg3RkU4YjRmMkZlODM3MGY2Y0M5YTk2MzQ0MmYwN0IwMmY0OTA5QTciLCJhdWQiOiJvdG9tYXRvLXRlc3QubmV0bGlmeS5hcHAiLCJleHAiOjE3MjMzODMxOTksIm5iZiI6MTcyMDc4OTM5OSwiaWF0IjoxNzIwNzkxMTk5LCJqdGkiOiIweDY4ZDkxOWEyMGZiYjIyNDUwZDZmOTFjMzM2ZTBmYjBjMmYyYTc3MmU3Zjg4NWU1ZjRmNzg1NTM2ZGIyYTY5YTAiLCJjdHgiOnt9fQ.MHgyOTM1NTM3MWYwOWM1YzllNWE3YjI4MjVkZTNjMDljZTkwMTQ3OTQwZmU1ZWRlMjM5YTk0MmFjYTQ5YTcwZWI0MGJlNmJiZDk2MDA4ZTIxMzJmNGM3ZTVlZGIzZDZiZjYyMDE4Mzc1MzUwMTRmNTc0ODM0ZDk4YWU3NDQwNDQzOTFi");
|
|
13
|
+
const workflow = yield new Workflow().load("0b9bd533-339c-42b5-9ed3-a6a40fcfa8d3");
|
|
14
|
+
console.log(workflow);
|
|
15
|
+
});
|
|
16
|
+
main();
|
package/dist/examples/sandbox.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Workflow, apiServices } from '../src/index.js';
|
|
11
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
apiServices.setCookie("eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweDdjRUI4ZDgxNDdBYWE5ZEI4MUFjQkRGRTVjMzA1MERGQ2ZGMTg1MzciLCJzdWIiOiIweDg3RkU4YjRmMkZlODM3MGY2Y0M5YTk2MzQ0MmYwN0IwMmY0OTA5QTciLCJhdWQiOiJvdG9tYXRvLXRlc3QubmV0bGlmeS5hcHAiLCJleHAiOjE3MjMzODMxOTksIm5iZiI6MTcyMDc4OTM5OSwiaWF0IjoxNzIwNzkxMTk5LCJqdGkiOiIweDY4ZDkxOWEyMGZiYjIyNDUwZDZmOTFjMzM2ZTBmYjBjMmYyYTc3MmU3Zjg4NWU1ZjRmNzg1NTM2ZGIyYTY5YTAiLCJjdHgiOnt9fQ.MHgyOTM1NTM3MWYwOWM1YzllNWE3YjI4MjVkZTNjMDljZTkwMTQ3OTQwZmU1ZWRlMjM5YTk0MmFjYTQ5YTcwZWI0MGJlNmJiZDk2MDA4ZTIxMzJmNGM3ZTVlZGIzZDZiZjYyMDE4Mzc1MzUwMTRmNTc0ODM0ZDk4YWU3NDQwNDQzOTFi");
|
|
13
|
+
const workflow = yield new Workflow().load("0b9bd533-339c-42b5-9ed3-a6a40fcfa8d3");
|
|
14
|
+
console.log(workflow.nodes[0]);
|
|
15
|
+
console.log(workflow.nodes[0].keyMap);
|
|
16
|
+
console.log(workflow.nodes[0].parameters);
|
|
17
|
+
});
|
|
18
|
+
main();
|
|
@@ -5,11 +5,12 @@ const TRIGGER_TYPE = {
|
|
|
5
5
|
export const TRIGGERS = {
|
|
6
6
|
"TOKENS": {
|
|
7
7
|
"ERC20": {
|
|
8
|
-
"
|
|
8
|
+
"description": "The most used standard for tokens on ethereum compatible blockchains",
|
|
9
|
+
"chains": [
|
|
9
10
|
0
|
|
10
11
|
],
|
|
12
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp",
|
|
11
13
|
"TRANSFER": {
|
|
12
|
-
"id": 1,
|
|
13
14
|
"name": "Transfer token",
|
|
14
15
|
"description": "This block gets triggered when someone transfers the ERC20 configured in the params",
|
|
15
16
|
"type": 0,
|
|
@@ -41,10 +42,11 @@ export const TRIGGERS = {
|
|
|
41
42
|
"description": "The contract address of the ERC20",
|
|
42
43
|
"mandatory": true
|
|
43
44
|
},
|
|
44
|
-
]
|
|
45
|
+
],
|
|
46
|
+
"blockId": 1,
|
|
47
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp"
|
|
45
48
|
},
|
|
46
49
|
"BALANCE": {
|
|
47
|
-
"id": 5,
|
|
48
50
|
"name": "ERC20 balance check",
|
|
49
51
|
"description": "Fetches the balance of an ERC20 and checks it against the specified condition.",
|
|
50
52
|
"type": 1,
|
|
@@ -81,17 +83,20 @@ export const TRIGGERS = {
|
|
|
81
83
|
"type": "integer",
|
|
82
84
|
"description": "The waiting time between each polling"
|
|
83
85
|
},
|
|
84
|
-
]
|
|
86
|
+
],
|
|
87
|
+
"blockId": 5,
|
|
88
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp"
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
92
|
"YIELD": {
|
|
89
93
|
"SPLICE_FI": {
|
|
90
|
-
"
|
|
94
|
+
"description": "Split any yield-bearing asset into separate yield and principal components",
|
|
95
|
+
"chains": [
|
|
91
96
|
43334
|
|
92
97
|
],
|
|
98
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png",
|
|
93
99
|
"SWAP": {
|
|
94
|
-
"id": 2,
|
|
95
100
|
"name": "Splice Finance Swap",
|
|
96
101
|
"description": "Swap in Splice Finance",
|
|
97
102
|
"type": 0,
|
|
@@ -122,10 +127,11 @@ export const TRIGGERS = {
|
|
|
122
127
|
"type": "int256",
|
|
123
128
|
"description": "Net SY to account"
|
|
124
129
|
},
|
|
125
|
-
]
|
|
130
|
+
],
|
|
131
|
+
"blockId": 2,
|
|
132
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png"
|
|
126
133
|
},
|
|
127
134
|
"LIQUIDITY_REMOVED": {
|
|
128
|
-
"id": 6,
|
|
129
135
|
"name": "Liquidity Removed",
|
|
130
136
|
"description": "Liquidity removed in Splice Finance",
|
|
131
137
|
"type": 0,
|
|
@@ -161,10 +167,11 @@ export const TRIGGERS = {
|
|
|
161
167
|
"type": "uint256",
|
|
162
168
|
"description": "Net SY out"
|
|
163
169
|
},
|
|
164
|
-
]
|
|
170
|
+
],
|
|
171
|
+
"blockId": 6,
|
|
172
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png"
|
|
165
173
|
},
|
|
166
174
|
"MARKET_CREATION": {
|
|
167
|
-
"id": 7,
|
|
168
175
|
"name": "Market Creation",
|
|
169
176
|
"description": "Market creation in Splice Finance",
|
|
170
177
|
"type": 0,
|
|
@@ -195,10 +202,11 @@ export const TRIGGERS = {
|
|
|
195
202
|
"type": "uint256",
|
|
196
203
|
"description": "LN fee rate root"
|
|
197
204
|
},
|
|
198
|
-
]
|
|
205
|
+
],
|
|
206
|
+
"blockId": 7,
|
|
207
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png"
|
|
199
208
|
},
|
|
200
209
|
"INTEREST_RATE_UPDATE": {
|
|
201
|
-
"id": 9,
|
|
202
210
|
"name": "Interest Rate Update",
|
|
203
211
|
"description": "Interest rate update in Splice Finance",
|
|
204
212
|
"type": 0,
|
|
@@ -226,17 +234,20 @@ export const TRIGGERS = {
|
|
|
226
234
|
"0xbF14932e1A7962C77D0b31be80075936bE1A43D4"
|
|
227
235
|
]
|
|
228
236
|
},
|
|
229
|
-
]
|
|
237
|
+
],
|
|
238
|
+
"blockId": 9,
|
|
239
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png"
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
242
|
},
|
|
233
243
|
"LENDING": {
|
|
234
244
|
"ASTARIA": {
|
|
235
|
-
"
|
|
245
|
+
"description": "Astaria is an oracle-less, intent-based, fixed-rate lending protocol supporting unlimited loan durations for any asset",
|
|
246
|
+
"chains": [
|
|
236
247
|
43334
|
|
237
248
|
],
|
|
249
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/astaria.png",
|
|
238
250
|
"LEND_RECALLED": {
|
|
239
|
-
"id": 8,
|
|
240
251
|
"name": "Lend Recalled",
|
|
241
252
|
"description": "Lend recalled in Astaria",
|
|
242
253
|
"type": 0,
|
|
@@ -257,18 +268,21 @@ export const TRIGGERS = {
|
|
|
257
268
|
"type": "uint256",
|
|
258
269
|
"description": "End time"
|
|
259
270
|
},
|
|
260
|
-
]
|
|
271
|
+
],
|
|
272
|
+
"blockId": 8,
|
|
273
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/astaria.png"
|
|
261
274
|
}
|
|
262
275
|
}
|
|
263
276
|
},
|
|
264
277
|
"DEXES": {
|
|
265
278
|
"ODOS": {
|
|
266
|
-
"
|
|
279
|
+
"description": "Smart Order Routing across multiple blockchain protocols, 700+ Liquidity Sources and thousands of token pairs, delivering ultimate savings to users",
|
|
280
|
+
"chains": [
|
|
267
281
|
43334,
|
|
268
282
|
1
|
|
269
283
|
],
|
|
284
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/odos.jpg",
|
|
270
285
|
"SWAP": {
|
|
271
|
-
"id": 4,
|
|
272
286
|
"name": "Odos Swap",
|
|
273
287
|
"description": "Swap on Odos",
|
|
274
288
|
"type": 0,
|
|
@@ -305,17 +319,20 @@ export const TRIGGERS = {
|
|
|
305
319
|
"type": "address",
|
|
306
320
|
"description": "Output token address"
|
|
307
321
|
},
|
|
308
|
-
]
|
|
322
|
+
],
|
|
323
|
+
"blockId": 4,
|
|
324
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/odos.jpg"
|
|
309
325
|
}
|
|
310
326
|
}
|
|
311
327
|
},
|
|
312
328
|
"SOCIALS": {
|
|
313
329
|
"MODE_NAME_SERVICE": {
|
|
314
|
-
"
|
|
330
|
+
"description": "Next generation of Mode Mainnet Domains",
|
|
331
|
+
"chains": [
|
|
315
332
|
43334
|
|
316
333
|
],
|
|
334
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/modens.png",
|
|
317
335
|
"NAME_REGISTERED": {
|
|
318
|
-
"id": 3,
|
|
319
336
|
"name": "Name Registered",
|
|
320
337
|
"description": "Name registered in Mode Name Service",
|
|
321
338
|
"type": 0,
|
|
@@ -336,17 +353,20 @@ export const TRIGGERS = {
|
|
|
336
353
|
"type": "uint256",
|
|
337
354
|
"description": "Expiration time"
|
|
338
355
|
},
|
|
339
|
-
]
|
|
356
|
+
],
|
|
357
|
+
"blockId": 3,
|
|
358
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/modens.png"
|
|
340
359
|
}
|
|
341
360
|
}
|
|
342
361
|
},
|
|
343
362
|
"PRICE_ACTION": {
|
|
344
363
|
"ON_CHAIN_PRICE_MOVEMENT": {
|
|
345
|
-
"
|
|
364
|
+
"description": "Triggers based on the movement of on-chain prices against specified currencies",
|
|
365
|
+
"chains": [
|
|
346
366
|
0
|
|
347
367
|
],
|
|
368
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/trend-up.png",
|
|
348
369
|
"PRICE_MOVEMENT_AGAINST_CURRENCY": {
|
|
349
|
-
"id": 10,
|
|
350
370
|
"name": "On-Chain Price Movement Against Fiat Currency",
|
|
351
371
|
"description": "This trigger activates when the on-chain price of an asset moves against a specified currency based on the given condition.",
|
|
352
372
|
"type": 2,
|
|
@@ -379,7 +399,9 @@ export const TRIGGERS = {
|
|
|
379
399
|
"type": "erc20",
|
|
380
400
|
"description": "The asset that you want to track"
|
|
381
401
|
},
|
|
382
|
-
]
|
|
402
|
+
],
|
|
403
|
+
"blockId": 10,
|
|
404
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/trend-up.png"
|
|
383
405
|
}
|
|
384
406
|
}
|
|
385
407
|
}
|
|
@@ -387,8 +409,9 @@ export const TRIGGERS = {
|
|
|
387
409
|
export const ACTIONS = {
|
|
388
410
|
"NOTIFICATIONS": {
|
|
389
411
|
"SLACK": {
|
|
412
|
+
"description": "Slack is a messaging app for businesses that connects people to the information they need.",
|
|
413
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/slack.png",
|
|
390
414
|
"SEND_MESSAGE": {
|
|
391
|
-
"id": 100002,
|
|
392
415
|
"name": "Send message",
|
|
393
416
|
"type": 0,
|
|
394
417
|
"description": "Notifies you by sending a Slack message to the channel of your choice",
|
|
@@ -403,12 +426,15 @@ export const ACTIONS = {
|
|
|
403
426
|
"type": "paragraph",
|
|
404
427
|
"description": "The text content to send"
|
|
405
428
|
},
|
|
406
|
-
]
|
|
429
|
+
],
|
|
430
|
+
"blockId": 100002,
|
|
431
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/slack.png"
|
|
407
432
|
}
|
|
408
433
|
},
|
|
409
434
|
"DISCORD": {
|
|
435
|
+
"description": "Discord is a communication service to talk with your favorite communities.",
|
|
436
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png",
|
|
410
437
|
"SEND_MESSAGE": {
|
|
411
|
-
"id": 100003,
|
|
412
438
|
"name": "Send message",
|
|
413
439
|
"type": 0,
|
|
414
440
|
"description": "Notifies you by sending a Discord message to the channel of your choice",
|
|
@@ -423,12 +449,15 @@ export const ACTIONS = {
|
|
|
423
449
|
"type": "paragraph",
|
|
424
450
|
"description": "The text content to send"
|
|
425
451
|
},
|
|
426
|
-
]
|
|
452
|
+
],
|
|
453
|
+
"blockId": 100003,
|
|
454
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/discord.png"
|
|
427
455
|
}
|
|
428
456
|
},
|
|
429
457
|
"TELEGRAM": {
|
|
458
|
+
"description": "Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.",
|
|
459
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/telegram.jpeg",
|
|
430
460
|
"SEND_MESSAGE": {
|
|
431
|
-
"id": 100001,
|
|
432
461
|
"name": "Send message",
|
|
433
462
|
"type": 0,
|
|
434
463
|
"description": "Notifies you by sending a Telegram message to the chat of your choice",
|
|
@@ -443,17 +472,20 @@ export const ACTIONS = {
|
|
|
443
472
|
"type": "paragraph",
|
|
444
473
|
"description": "The text content to send"
|
|
445
474
|
},
|
|
446
|
-
]
|
|
475
|
+
],
|
|
476
|
+
"blockId": 100001,
|
|
477
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/telegram.jpeg"
|
|
447
478
|
}
|
|
448
479
|
}
|
|
449
480
|
},
|
|
450
481
|
"TOKENS": {
|
|
451
482
|
"ERC20": {
|
|
452
|
-
"
|
|
483
|
+
"description": "The most used standard for tokens on ethereum compatible blockchains",
|
|
484
|
+
"chains": [
|
|
453
485
|
0
|
|
454
486
|
],
|
|
487
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp",
|
|
455
488
|
"TRANSFER": {
|
|
456
|
-
"id": 100004,
|
|
457
489
|
"name": "Transfer token",
|
|
458
490
|
"description": "Transfers an ERC20 token",
|
|
459
491
|
"type": 1,
|
|
@@ -479,7 +511,9 @@ export const ACTIONS = {
|
|
|
479
511
|
"type": "erc20",
|
|
480
512
|
"description": "The contract address of the ERC20"
|
|
481
513
|
},
|
|
482
|
-
]
|
|
514
|
+
],
|
|
515
|
+
"blockId": 100004,
|
|
516
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ethereum.webp"
|
|
483
517
|
}
|
|
484
518
|
}
|
|
485
519
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export * from './constants/chains.js';
|
|
|
4
4
|
export * from './constants/tokens.js';
|
|
5
5
|
// Exporting models
|
|
6
6
|
export * from './models/Action.js';
|
|
7
|
-
export * from './models/
|
|
7
|
+
export * from './models/Workflow.js';
|
|
8
8
|
export * from './models/Condition.js';
|
|
9
9
|
export * from './models/Parameter.js';
|
|
10
10
|
export * from './models/Trigger.js';
|
package/dist/src/models/Edge.js
CHANGED
|
@@ -17,9 +17,14 @@ export class Edge {
|
|
|
17
17
|
}
|
|
18
18
|
toJSON() {
|
|
19
19
|
return {
|
|
20
|
-
id: this.id,
|
|
21
20
|
source: this.source.getRef(),
|
|
22
21
|
target: this.target.getRef(),
|
|
23
22
|
};
|
|
24
23
|
}
|
|
24
|
+
static fromJSON(json) {
|
|
25
|
+
return new Edge({
|
|
26
|
+
source: json.source,
|
|
27
|
+
target: json.target,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
25
30
|
}
|
package/dist/src/models/Node.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
// Assuming you have the ACTIONS constant defined as you provided
|
|
1
2
|
import { validateType } from '../utils/typeValidator.js';
|
|
3
|
+
import { ACTIONS, TRIGGERS } from '../constants/Blocks.js';
|
|
2
4
|
let nodeCounter = 0;
|
|
3
5
|
const generatedRefs = new Set();
|
|
4
6
|
export class Node {
|
|
5
7
|
constructor(node) {
|
|
6
|
-
this.id =
|
|
8
|
+
this.id = null;
|
|
9
|
+
this.id = null;
|
|
10
|
+
this.blockId = node.blockId;
|
|
7
11
|
this.name = node.name;
|
|
8
12
|
this.description = node.description;
|
|
13
|
+
this.image = node.image;
|
|
9
14
|
this.parameters = {};
|
|
10
15
|
this.keyMap = {};
|
|
11
|
-
this.class = node.class;
|
|
16
|
+
this.class = node.class;
|
|
12
17
|
if (node.ref) {
|
|
13
18
|
this.ref = node.ref;
|
|
14
19
|
}
|
|
@@ -28,6 +33,9 @@ export class Node {
|
|
|
28
33
|
this.position = node.position;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
36
|
+
setId(id) {
|
|
37
|
+
this.id = id;
|
|
38
|
+
}
|
|
31
39
|
setChainId(value) {
|
|
32
40
|
this.setParameter('chainId', value);
|
|
33
41
|
}
|
|
@@ -85,6 +93,7 @@ export class Node {
|
|
|
85
93
|
const json = {
|
|
86
94
|
id: this.id,
|
|
87
95
|
ref: this.ref,
|
|
96
|
+
blockId: this.blockId,
|
|
88
97
|
type: this.class,
|
|
89
98
|
parameters: this.getParameters(),
|
|
90
99
|
};
|
|
@@ -96,4 +105,61 @@ export class Node {
|
|
|
96
105
|
getSimplifiedKey(key) {
|
|
97
106
|
return key.replace(/[.\[\]]/g, '_');
|
|
98
107
|
}
|
|
108
|
+
static fromJSON(json) {
|
|
109
|
+
let enriched = findActionByBlockId(json.blockId);
|
|
110
|
+
if (!enriched)
|
|
111
|
+
enriched = findTriggerByBlockId(json.blockId);
|
|
112
|
+
if (!enriched)
|
|
113
|
+
enriched = { name: "Unknown", description: "Unknown", image: "Unknown" };
|
|
114
|
+
const parameters = Object.keys(json.parameters).map(key => ({
|
|
115
|
+
key,
|
|
116
|
+
type: typeof json.parameters[key], // Assuming type can be derived from the value's type
|
|
117
|
+
description: '', // Add appropriate description if needed
|
|
118
|
+
value: json.parameters[key]
|
|
119
|
+
}));
|
|
120
|
+
const node = new Node({
|
|
121
|
+
blockId: json.blockId,
|
|
122
|
+
name: enriched.name,
|
|
123
|
+
description: enriched.description,
|
|
124
|
+
image: enriched.image,
|
|
125
|
+
parameters,
|
|
126
|
+
ref: json.ref,
|
|
127
|
+
position: json.position,
|
|
128
|
+
class: json.type
|
|
129
|
+
});
|
|
130
|
+
node.setId(json.id);
|
|
131
|
+
return node;
|
|
132
|
+
}
|
|
99
133
|
}
|
|
134
|
+
const findActionByBlockId = (blockId) => {
|
|
135
|
+
for (const category in ACTIONS) {
|
|
136
|
+
for (const service in ACTIONS[category]) {
|
|
137
|
+
for (const actionKey in ACTIONS[category][service]) {
|
|
138
|
+
if (ACTIONS[category][service][actionKey].blockId === blockId) {
|
|
139
|
+
return {
|
|
140
|
+
name: ACTIONS[category][service][actionKey].name,
|
|
141
|
+
description: ACTIONS[category][service][actionKey].description,
|
|
142
|
+
image: ACTIONS[category][service][actionKey].image,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
};
|
|
150
|
+
const findTriggerByBlockId = (blockId) => {
|
|
151
|
+
for (const category in TRIGGERS) {
|
|
152
|
+
for (const service in TRIGGERS[category]) {
|
|
153
|
+
for (const triggerKey in TRIGGERS[category][service]) {
|
|
154
|
+
if (TRIGGERS[category][service][triggerKey].blockId === blockId) {
|
|
155
|
+
return {
|
|
156
|
+
name: TRIGGERS[category][service][triggerKey].name,
|
|
157
|
+
description: TRIGGERS[category][service][triggerKey].description,
|
|
158
|
+
image: TRIGGERS[category][service][triggerKey].image,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Node } from './Node.js';
|
|
11
|
+
import { Edge } from './Edge.js';
|
|
12
|
+
import { apiServices } from '../services/ApiService.js';
|
|
13
|
+
export class Workflow {
|
|
14
|
+
constructor(name = '', nodes = [], edges = []) {
|
|
15
|
+
this.id = null;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.nodes = nodes;
|
|
18
|
+
this.edges = edges;
|
|
19
|
+
}
|
|
20
|
+
setName(name) {
|
|
21
|
+
this.name = name;
|
|
22
|
+
}
|
|
23
|
+
addNode(node) {
|
|
24
|
+
this.nodes.push(node);
|
|
25
|
+
}
|
|
26
|
+
addNodes(nodes) {
|
|
27
|
+
this.nodes.push(...nodes);
|
|
28
|
+
}
|
|
29
|
+
addEdge(edge) {
|
|
30
|
+
this.edges.push(edge);
|
|
31
|
+
}
|
|
32
|
+
addEdges(edges) {
|
|
33
|
+
this.edges.push(...edges);
|
|
34
|
+
}
|
|
35
|
+
toJSON() {
|
|
36
|
+
return {
|
|
37
|
+
id: this.id,
|
|
38
|
+
name: this.name,
|
|
39
|
+
nodes: this.nodes.map(node => node.toJSON()),
|
|
40
|
+
edges: this.edges.map(edge => edge.toJSON()),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
create() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const response = yield apiServices.post('/workflows', this.toJSON());
|
|
46
|
+
this.id = response.id; // Assign the returned ID to the workflow instance
|
|
47
|
+
// Assign IDs to the nodes based on the response
|
|
48
|
+
response.nodes.forEach((nodeResponse) => {
|
|
49
|
+
const node = this.nodes.find(n => n.getRef() === nodeResponse.ref);
|
|
50
|
+
if (node) {
|
|
51
|
+
node.setId(nodeResponse.id);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return response;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
load(workflowId) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const response = yield apiServices.get(`/workflows/${workflowId}`);
|
|
60
|
+
this.id = response.id;
|
|
61
|
+
this.name = response.name;
|
|
62
|
+
this.nodes = response.nodes.map((nodeData) => Node.fromJSON(nodeData));
|
|
63
|
+
this.edges = response.edges.map((edgeData) => Edge.fromJSON(edgeData));
|
|
64
|
+
return this;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -10,30 +10,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
// networkService.ts
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
const API_CONFIG = {
|
|
13
|
-
BASE_URL: '
|
|
13
|
+
BASE_URL: 'https://staging-api.otomato.xyz/api',
|
|
14
14
|
HEADERS: {
|
|
15
|
-
'Content-Type': 'application/json'
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
const axiosInstance = axios.create({
|
|
19
19
|
baseURL: API_CONFIG.BASE_URL,
|
|
20
20
|
headers: API_CONFIG.HEADERS
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
class ApiServices {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.cookie = null;
|
|
25
|
+
// You can add other methods (get, put, delete) similarly
|
|
26
|
+
}
|
|
27
|
+
setCookie(cookie) {
|
|
28
|
+
this.cookie = `token=${cookie}`;
|
|
29
|
+
}
|
|
30
|
+
post(url, data) {
|
|
24
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error('Network request failed', error);
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
32
|
+
const headers = this.cookie ? { 'Cookie': this.cookie } : {};
|
|
33
|
+
const response = yield axiosInstance.post(url, data, { headers });
|
|
34
|
+
return response.data;
|
|
33
35
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
}
|
|
37
|
+
get(url) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const headers = this.cookie ? { 'Cookie': this.cookie } : {};
|
|
40
|
+
const response = yield axiosInstance.get(url, { headers });
|
|
41
|
+
return response.data;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export const apiServices = new ApiServices();
|
package/dist/test/action.spec.js
CHANGED
|
@@ -30,7 +30,7 @@ describe('Action Class', () => {
|
|
|
30
30
|
transferAction.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
|
|
31
31
|
const json = transferAction.toJSON();
|
|
32
32
|
expect(json).to.deep.equal({
|
|
33
|
-
|
|
33
|
+
blockId: ACTIONS.TOKENS.ERC20.TRANSFER.blockId,
|
|
34
34
|
ref: transferAction.getRef(),
|
|
35
35
|
type: 'action',
|
|
36
36
|
parameters: {
|