otomato-sdk 1.0.1 → 1.1.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-action.js +21 -0
- package/dist/examples/create-automation.js +24 -0
- package/dist/src/constants/Blocks.js +391 -0
- package/dist/src/constants/tokens.js +40 -0
- package/dist/src/index.js +2 -2
- package/dist/src/models/Action.js +6 -1
- package/dist/src/models/Automation.js +38 -1
- package/dist/src/models/Node.js +73 -0
- package/dist/src/models/Trigger.js +3 -88
- package/dist/src/services/ApiService.js +39 -1
- package/dist/src/utils/typeValidator.js +70 -0
- package/dist/test/action.spec.js +74 -0
- package/dist/test/automation.spec.js +63 -0
- package/dist/test/node.spec.js +112 -0
- package/dist/test/trigger.spec.js +3 -3
- package/dist/test/typeValidator.spec.js +59 -0
- package/dist/types/examples/create-action.d.ts +1 -0
- package/dist/types/examples/create-automation.d.ts +1 -0
- package/dist/types/src/constants/Blocks.d.ts +118 -0
- package/dist/types/src/constants/tokens.d.ts +9 -0
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/models/Action.d.ts +11 -5
- package/dist/types/src/models/Automation.d.ts +20 -5
- package/dist/types/src/models/Node.d.ts +35 -0
- package/dist/types/src/models/Trigger.d.ts +4 -24
- package/dist/types/src/services/ApiService.d.ts +3 -6
- package/dist/types/src/utils/typeValidator.d.ts +4 -0
- package/dist/types/test/action.spec.d.ts +1 -0
- package/dist/types/test/automation.spec.d.ts +1 -0
- package/dist/types/test/node.spec.d.ts +1 -0
- package/dist/types/test/typeValidator.spec.d.ts +1 -0
- package/examples/create-action.ts +28 -0
- package/examples/create-automation.ts +21 -0
- package/package.json +1 -1
- package/src/constants/{ActionBlocks.ts → Blocks.ts} +73 -2
- package/src/constants/chains.ts +1 -1
- package/src/constants/tokens.ts +56 -0
- package/src/index.ts +2 -2
- package/src/models/Action.ts +8 -6
- package/src/models/Automation.ts +39 -6
- package/src/models/Node.ts +87 -0
- package/src/models/Trigger.ts +4 -100
- package/src/services/ApiService.ts +31 -6
- package/src/utils/typeValidator.ts +65 -0
- package/test/action.spec.ts +90 -0
- package/test/automation.spec.ts +80 -0
- package/test/node.spec.ts +131 -0
- package/test/trigger.spec.ts +3 -3
- package/test/typeValidator.spec.ts +71 -0
- package/src/services/AutomationService.ts +0 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ACTIONS, getToken, CHAINS, Action } from '../src/index.js';
|
|
2
|
+
const createAction = () => {
|
|
3
|
+
// Create an ERC20 transfer action
|
|
4
|
+
const transferAction = new Action(ACTIONS.TOKENS.ERC20.TRANSFER);
|
|
5
|
+
transferAction.setChainId(CHAINS.ETHEREUM);
|
|
6
|
+
transferAction.setParams("value", 1000);
|
|
7
|
+
transferAction.setParams("to", "0xe1432599B51d9BE1b5A27E2A2FB8e5dF684749C6");
|
|
8
|
+
transferAction.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
|
|
9
|
+
console.log(transferAction.toJSON());
|
|
10
|
+
// Create an SMS notification action
|
|
11
|
+
const smsAction = new Action(ACTIONS.NOTIFICATIONS.SMS);
|
|
12
|
+
smsAction.setParams("phoneNumber", "+1234567890");
|
|
13
|
+
smsAction.setParams("text", "This is a test message");
|
|
14
|
+
console.log(smsAction.toJSON());
|
|
15
|
+
// Create a Slack notification action
|
|
16
|
+
const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK);
|
|
17
|
+
slackAction.setParams("webhook", "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
|
|
18
|
+
slackAction.setParams("text", "This is a test message");
|
|
19
|
+
console.log(slackAction.toJSON());
|
|
20
|
+
};
|
|
21
|
+
createAction();
|
|
@@ -0,0 +1,24 @@
|
|
|
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, Automation, CHAINS, getToken } from '../src/index.js';
|
|
11
|
+
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const usdcTransferTrigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
|
|
13
|
+
usdcTransferTrigger.setChainId(CHAINS.ETHEREUM);
|
|
14
|
+
usdcTransferTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
|
|
15
|
+
usdcTransferTrigger.setCoordinates(0, 0);
|
|
16
|
+
const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK);
|
|
17
|
+
slackAction.setParams("webhook", "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
|
|
18
|
+
slackAction.setParams("text", "USDC has been transferred!");
|
|
19
|
+
slackAction.setCoordinates(0, -10);
|
|
20
|
+
const automation = new Automation("USDC Transfer Notification", usdcTransferTrigger, [slackAction]);
|
|
21
|
+
console.log(JSON.stringify(automation.toJSON(), null, 2));
|
|
22
|
+
yield automation.save();
|
|
23
|
+
});
|
|
24
|
+
main();
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { CHAINS } from './chains.js';
|
|
2
|
+
const TRIGGER_TYPE = {
|
|
3
|
+
SUBSCRIPTION: 0,
|
|
4
|
+
POLLING: 1,
|
|
5
|
+
};
|
|
6
|
+
export const TRIGGERS = {
|
|
7
|
+
TOKENS: {
|
|
8
|
+
ERC20: {
|
|
9
|
+
CHAINS: [CHAINS.ALL],
|
|
10
|
+
TRANSFER: {
|
|
11
|
+
id: 1,
|
|
12
|
+
name: "Transfer token",
|
|
13
|
+
description: "Transfer an ERC-20 token",
|
|
14
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
15
|
+
parameters: [
|
|
16
|
+
{
|
|
17
|
+
key: "chainId",
|
|
18
|
+
type: "chainId",
|
|
19
|
+
description: "Chain ID of the ETH blockchain"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: "abiParams.value",
|
|
23
|
+
type: "uint256",
|
|
24
|
+
description: "Amount of crypto to transfer"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "abiParams.to",
|
|
28
|
+
type: "address",
|
|
29
|
+
description: "Address to transfer crypto to"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: "contractAddress",
|
|
33
|
+
type: "address",
|
|
34
|
+
description: "The contract address of the ERC20"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
BALANCE: {
|
|
39
|
+
id: 1000,
|
|
40
|
+
name: "ERC20 balance check",
|
|
41
|
+
description: "Fetches the balance of an ERC20 and checks it against the specified condition.",
|
|
42
|
+
type: TRIGGER_TYPE.POLLING,
|
|
43
|
+
parameters: [
|
|
44
|
+
{
|
|
45
|
+
key: "chainId",
|
|
46
|
+
type: "chainId",
|
|
47
|
+
description: "Chain ID of the ETH blockchain"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "abiParams.account",
|
|
51
|
+
type: "address",
|
|
52
|
+
description: "Amount of crypto to transfer"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "contractAddress",
|
|
56
|
+
type: "address",
|
|
57
|
+
description: "The contract address of the ERC20"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: "condition",
|
|
61
|
+
type: "logic_operator",
|
|
62
|
+
description: "Logic operator used for the comparison: <, >, <=, >=, ==, ..."
|
|
63
|
+
},
|
|
64
|
+
// todo: it should be in the same type as the output of the function
|
|
65
|
+
{
|
|
66
|
+
key: "comparisonValue",
|
|
67
|
+
type: "any",
|
|
68
|
+
description: "The value to compare to"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
key: "interval",
|
|
72
|
+
type: "integer",
|
|
73
|
+
description: "The waiting time between each polling"
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
YIELD: {
|
|
80
|
+
SPLICE_FI: {
|
|
81
|
+
CHAINS: [CHAINS.MODE],
|
|
82
|
+
SWAP: {
|
|
83
|
+
id: 2,
|
|
84
|
+
name: "Splice Finance Swap",
|
|
85
|
+
description: "Swap in Splice Finance",
|
|
86
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
87
|
+
parameters: [
|
|
88
|
+
{
|
|
89
|
+
key: "abiParams.caller",
|
|
90
|
+
type: "address",
|
|
91
|
+
description: "Caller address"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: "abiParams.market",
|
|
95
|
+
type: "address",
|
|
96
|
+
description: "Market address"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: "abiParams.receiver",
|
|
100
|
+
type: "address",
|
|
101
|
+
description: "Receiver address"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: "abiParams.netPtToAccount",
|
|
105
|
+
type: "int256",
|
|
106
|
+
description: "Net PT to account"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: "abiParams.netSyToAccount",
|
|
110
|
+
type: "int256",
|
|
111
|
+
description: "Net SY to account"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
LIQUIDITY_REMOVED: {
|
|
116
|
+
id: 6,
|
|
117
|
+
name: "Liquidity Removed",
|
|
118
|
+
description: "Liquidity removed in Splice Finance",
|
|
119
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
120
|
+
parameters: [
|
|
121
|
+
{
|
|
122
|
+
key: "abiParams.caller",
|
|
123
|
+
type: "address",
|
|
124
|
+
description: "Caller address"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
key: "abiParams.market",
|
|
128
|
+
type: "address",
|
|
129
|
+
description: "Market address"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "abiParams.receiver",
|
|
133
|
+
type: "address",
|
|
134
|
+
description: "Receiver address"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: "abiParams.netLpToRemove",
|
|
138
|
+
type: "uint256",
|
|
139
|
+
description: "Net LP to remove"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "abiParams.netPtOut",
|
|
143
|
+
type: "uint256",
|
|
144
|
+
description: "Net PT out"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
key: "abiParams.netSyOut",
|
|
148
|
+
type: "uint256",
|
|
149
|
+
description: "Net SY out"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
MARKET_CREATION: {
|
|
154
|
+
id: 7,
|
|
155
|
+
name: "Market Creation",
|
|
156
|
+
description: "Market creation in Splice Finance",
|
|
157
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
158
|
+
parameters: [
|
|
159
|
+
{
|
|
160
|
+
key: "abiParams.market",
|
|
161
|
+
type: "address",
|
|
162
|
+
description: "Market address"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
key: "abiParams.PT",
|
|
166
|
+
type: "address",
|
|
167
|
+
description: "PT address"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "abiParams.scalarRoot",
|
|
171
|
+
type: "int256",
|
|
172
|
+
description: "Scalar root"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
key: "abiParams.initialAnchor",
|
|
176
|
+
type: "int256",
|
|
177
|
+
description: "Initial anchor"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
key: "abiParams.lnFeeRateRoot",
|
|
181
|
+
type: "uint256",
|
|
182
|
+
description: "LN fee rate root"
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
INTEREST_RATE_UPDATE: {
|
|
187
|
+
id: 9,
|
|
188
|
+
name: "Interest Rate Update",
|
|
189
|
+
description: "Interest rate update in Splice Finance",
|
|
190
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
191
|
+
parameters: [
|
|
192
|
+
{
|
|
193
|
+
key: "abiParams.timestamp",
|
|
194
|
+
type: "uint256",
|
|
195
|
+
description: "Timestamp"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
key: "abiParams.lastLnImpliedRate",
|
|
199
|
+
type: "int256",
|
|
200
|
+
description: "Last LN implied rate"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
key: "contractAddress",
|
|
204
|
+
type: "address",
|
|
205
|
+
description: "Contract address to monitor",
|
|
206
|
+
enum: [
|
|
207
|
+
"0xDE95511418EBD8Bd36294B11C86314DdFA50e212", // wrsETH
|
|
208
|
+
"0x34cf9BF641bd5f34197060A3f3478a1f97f78f0a", // ezETH
|
|
209
|
+
"0xb950A73Ea0842B0Cd06D0e369aE974799BB346f1", // MODE
|
|
210
|
+
"0xbF14932e1A7962C77D0b31be80075936bE1A43D4" // weETH
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
LENDING: {
|
|
218
|
+
ASTARIA: {
|
|
219
|
+
CHAINS: [CHAINS.MODE],
|
|
220
|
+
LEND_RECALLED: {
|
|
221
|
+
id: 8,
|
|
222
|
+
name: "Lend Recalled",
|
|
223
|
+
description: "Lend recalled in Astaria",
|
|
224
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
225
|
+
parameters: [
|
|
226
|
+
{
|
|
227
|
+
key: "abiParams.loanId",
|
|
228
|
+
type: "uint256",
|
|
229
|
+
description: "Loan ID"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: "abiParams.recaller",
|
|
233
|
+
type: "address",
|
|
234
|
+
description: "Recaller address"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
key: "abiParams.end",
|
|
238
|
+
type: "uint256",
|
|
239
|
+
description: "End time"
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
DEXES: {
|
|
246
|
+
ODOS: {
|
|
247
|
+
CHAINS: [CHAINS.MODE, CHAINS.ETHEREUM],
|
|
248
|
+
SWAP: {
|
|
249
|
+
id: 4,
|
|
250
|
+
name: "Odos Swap",
|
|
251
|
+
description: "Swap on Odos",
|
|
252
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
253
|
+
parameters: [
|
|
254
|
+
{
|
|
255
|
+
key: "chainId",
|
|
256
|
+
type: "int",
|
|
257
|
+
description: "Chain ID of the ETH blockchain"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
key: "abiParams.sender",
|
|
261
|
+
type: "address",
|
|
262
|
+
description: "Sender address"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: "abiParams.inputAmount",
|
|
266
|
+
type: "uint256",
|
|
267
|
+
description: "Input amount"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
key: "abiParams.inputToken",
|
|
271
|
+
type: "address",
|
|
272
|
+
description: "Input token address"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
key: "abiParams.amountOut",
|
|
276
|
+
type: "uint256",
|
|
277
|
+
description: "Output amount"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "abiParams.outputToken",
|
|
281
|
+
type: "address",
|
|
282
|
+
description: "Output token address"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: "abiParams.exchangeRate",
|
|
286
|
+
type: "float",
|
|
287
|
+
description: "Exchange rate"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
SOCIALS: {
|
|
294
|
+
MODE_NAME_SERVICE: {
|
|
295
|
+
CHAINS: [CHAINS.MODE],
|
|
296
|
+
NAME_REGISTERED: {
|
|
297
|
+
id: 3,
|
|
298
|
+
name: "Name Registered",
|
|
299
|
+
description: "Name registered in Mode Name Service",
|
|
300
|
+
type: TRIGGER_TYPE.SUBSCRIPTION,
|
|
301
|
+
parameters: [
|
|
302
|
+
{
|
|
303
|
+
key: "abiParams.id",
|
|
304
|
+
type: "uint256",
|
|
305
|
+
description: "ID of the name registered"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: "abiParams.owner",
|
|
309
|
+
type: "address",
|
|
310
|
+
description: "Owner address"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: "abiParams.expires",
|
|
314
|
+
type: "uint256",
|
|
315
|
+
description: "Expiration time"
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
export const ACTIONS = {
|
|
323
|
+
TOKENS: {
|
|
324
|
+
ERC20: {
|
|
325
|
+
CHAINS: [CHAINS.ALL],
|
|
326
|
+
TRANSFER: {
|
|
327
|
+
id: 1,
|
|
328
|
+
name: "Transfer ERC-20 Token",
|
|
329
|
+
description: "Transfer an ERC-20 token",
|
|
330
|
+
parameters: [
|
|
331
|
+
{
|
|
332
|
+
key: "chainId",
|
|
333
|
+
type: "chainId",
|
|
334
|
+
description: "Chain ID of the blockchain"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: "abiParams.value",
|
|
338
|
+
type: "uint256",
|
|
339
|
+
description: "Amount of crypto to transfer"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
key: "abiParams.to",
|
|
343
|
+
type: "address",
|
|
344
|
+
description: "Address to transfer crypto to"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
key: "contractAddress",
|
|
348
|
+
type: "address",
|
|
349
|
+
description: "The contract address of the ERC-20 token"
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
NOTIFICATIONS: {
|
|
356
|
+
SMS: {
|
|
357
|
+
id: 3,
|
|
358
|
+
name: "Send SMS",
|
|
359
|
+
description: "Send an SMS notification to a specified phone number",
|
|
360
|
+
parameters: [
|
|
361
|
+
{
|
|
362
|
+
key: "phoneNumber",
|
|
363
|
+
type: "phone_number",
|
|
364
|
+
description: "Phone number to send the message to"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
key: "text",
|
|
368
|
+
type: "paragraph",
|
|
369
|
+
description: "Content of the SMS message"
|
|
370
|
+
},
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
SLACK: {
|
|
374
|
+
id: 4,
|
|
375
|
+
name: "Send Slack Message",
|
|
376
|
+
description: "Send a message to a specified Slack channel via webhook",
|
|
377
|
+
parameters: [
|
|
378
|
+
{
|
|
379
|
+
key: "webhook",
|
|
380
|
+
type: "url",
|
|
381
|
+
description: "Slack channel webhook URL"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
key: "text",
|
|
385
|
+
type: "paragraph",
|
|
386
|
+
description: "Content of the Slack message"
|
|
387
|
+
},
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
}
|
|
391
|
+
};
|
|
@@ -70,6 +70,36 @@ export const TOKENS = {
|
|
|
70
70
|
},
|
|
71
71
|
]
|
|
72
72
|
};
|
|
73
|
+
export const NFTS = {
|
|
74
|
+
1: [
|
|
75
|
+
{
|
|
76
|
+
contractAddress: "0x60e4d786628fea6478f785a6d7e704777c86a7c6",
|
|
77
|
+
name: "MutantApeYachtClub"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
contractAddress: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
|
|
81
|
+
name: "BoredApeYachtClub"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
contractAddress: "0xbd3531da5cf5857e7cfaa92426877b022e612cf8",
|
|
85
|
+
name: "Pudgy Penguins"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
contractAddress: "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
|
89
|
+
name: "Doodles"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
contractAddress: "0x524cab2ec69124574082676e6f654a18df49a048",
|
|
93
|
+
name: "Lil Pudgies"
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
43334: [
|
|
97
|
+
{
|
|
98
|
+
contractAddress: "0x2ad86eeec513ac16804bb05310214c3fd496835b",
|
|
99
|
+
name: "Space id"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
};
|
|
73
103
|
export function getToken(chain, symbol) {
|
|
74
104
|
if (!(chain in TOKENS)) {
|
|
75
105
|
throw new Error(`Unsupported chain: ${chain}`);
|
|
@@ -80,3 +110,13 @@ export function getToken(chain, symbol) {
|
|
|
80
110
|
}
|
|
81
111
|
return token;
|
|
82
112
|
}
|
|
113
|
+
export function getNFT(chain, name) {
|
|
114
|
+
if (!(chain in NFTS)) {
|
|
115
|
+
throw new Error(`Unsupported chain: ${chain}`);
|
|
116
|
+
}
|
|
117
|
+
const nft = NFTS[chain].find(nft => nft.name === name);
|
|
118
|
+
if (!nft) {
|
|
119
|
+
throw new Error(`NFT ${name} not found on chain ${chain}`);
|
|
120
|
+
}
|
|
121
|
+
return nft;
|
|
122
|
+
}
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Exporting constants
|
|
2
|
-
export * from './constants/
|
|
2
|
+
export * from './constants/Blocks.js';
|
|
3
3
|
export * from './constants/chains.js';
|
|
4
4
|
export * from './constants/tokens.js';
|
|
5
5
|
// Exporting models
|
|
@@ -8,6 +8,6 @@ export * from './models/Automation.js';
|
|
|
8
8
|
export * from './models/Condition.js';
|
|
9
9
|
export * from './models/Parameter.js';
|
|
10
10
|
export * from './models/Trigger.js';
|
|
11
|
+
export * from './models/Node.js';
|
|
11
12
|
// Exporting services
|
|
12
13
|
export * from './services/ApiService.js';
|
|
13
|
-
export * from './services/AutomationService.js';
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
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 { apiServices } from '../services/ApiService.js';
|
|
11
|
+
export class Automation {
|
|
12
|
+
constructor(name, trigger, actions = []) {
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.trigger = trigger;
|
|
15
|
+
this.actions = actions;
|
|
16
|
+
}
|
|
17
|
+
setName(name) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
}
|
|
20
|
+
addTrigger(trigger) {
|
|
21
|
+
this.trigger = trigger;
|
|
22
|
+
}
|
|
23
|
+
addAction(action) {
|
|
24
|
+
this.actions.push(action);
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
name: this.name,
|
|
29
|
+
trigger: this.trigger.toJSON(),
|
|
30
|
+
actions: this.actions.map(action => action.toJSON()),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
save() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return apiServices.post('/workflows', this.toJSON());
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { validateType } from '../utils/typeValidator.js';
|
|
2
|
+
export class Node {
|
|
3
|
+
constructor(node) {
|
|
4
|
+
this.id = node.id;
|
|
5
|
+
this.name = node.name;
|
|
6
|
+
this.description = node.description;
|
|
7
|
+
this.parameters = {};
|
|
8
|
+
this.keyMap = {};
|
|
9
|
+
node.parameters.forEach(param => {
|
|
10
|
+
this.parameters[param.key] = Object.assign(Object.assign({}, param), { value: null });
|
|
11
|
+
const simplifiedKey = this.getSimplifiedKey(param.key);
|
|
12
|
+
this.keyMap[simplifiedKey] = param.key;
|
|
13
|
+
});
|
|
14
|
+
this.x = node.x;
|
|
15
|
+
this.y = node.y;
|
|
16
|
+
}
|
|
17
|
+
setChainId(value) {
|
|
18
|
+
this.setParameter('chainId', value);
|
|
19
|
+
}
|
|
20
|
+
setContractAddress(value) {
|
|
21
|
+
this.setParameter('contractAddress', value);
|
|
22
|
+
}
|
|
23
|
+
setParams(key, value) {
|
|
24
|
+
const fullKey = this.parameters[`abiParams.${key}`] ? `abiParams.${key}` : key;
|
|
25
|
+
this.setParameter(fullKey, value);
|
|
26
|
+
}
|
|
27
|
+
setCoordinates(x, y) {
|
|
28
|
+
this.x = x;
|
|
29
|
+
this.y = y;
|
|
30
|
+
}
|
|
31
|
+
setParameter(key, value) {
|
|
32
|
+
if (key in this.parameters) {
|
|
33
|
+
const param = this.parameters[key];
|
|
34
|
+
if (validateType(param.type, value)) {
|
|
35
|
+
this.parameters[key].value = value;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error(`Invalid type for parameter ${key}. Expected ${param.type}.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error(`Parameter with key ${key} not found`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getParameter(key) {
|
|
46
|
+
if (key in this.parameters) {
|
|
47
|
+
return this.parameters[key].value;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new Error(`Parameter with key ${key} not found`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getParameters() {
|
|
54
|
+
return Object.keys(this.parameters).reduce((acc, key) => {
|
|
55
|
+
acc[key] = this.parameters[key].value;
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
}
|
|
59
|
+
toJSON() {
|
|
60
|
+
const json = {
|
|
61
|
+
id: this.id,
|
|
62
|
+
parameters: this.getParameters(),
|
|
63
|
+
};
|
|
64
|
+
if (this.x !== undefined)
|
|
65
|
+
json.x = this.x;
|
|
66
|
+
if (this.y !== undefined)
|
|
67
|
+
json.y = this.y;
|
|
68
|
+
return json;
|
|
69
|
+
}
|
|
70
|
+
getSimplifiedKey(key) {
|
|
71
|
+
return key.replace(/[.\[\]]/g, '_');
|
|
72
|
+
}
|
|
73
|
+
}
|