otomato-sdk 1.5.39 → 1.5.40
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/README.md +1 -1
- package/dist/src/constants/Blocks.js +32 -25
- package/dist/src/constants/WorkflowTemplates.js +1 -1
- package/dist/src/models/Action.js +55 -0
- package/dist/src/models/Node.js +15 -4
- package/dist/src/models/SessionKeyPermission.js +28 -9
- package/dist/src/utils/typeValidator.js +3 -21
- package/dist/types/src/constants/Blocks.d.ts +40 -8
- package/dist/types/src/models/Action.d.ts +5 -0
- package/dist/types/src/utils/typeValidator.d.ts +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Here's how to create a trigger using the Otomato SDK:
|
|
|
24
24
|
```typescript
|
|
25
25
|
import { Trigger, TRIGGERS, CHAINS, getTokenFromSymbol } from 'otomato-sdk';
|
|
26
26
|
|
|
27
|
-
const transferTrigger = new Trigger(TRIGGERS.TOKENS.
|
|
27
|
+
const transferTrigger = new Trigger(TRIGGERS.TOKENS.TRANSFER.TRANSFER);
|
|
28
28
|
transferTrigger.setChainId(CHAINS.ETHEREUM);
|
|
29
29
|
transferTrigger.setParams("value", 1000);
|
|
30
30
|
transferTrigger.setParams("to", "0xe1432599B51d9BE1b5A27E2A2FB8e5dF684749C6");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const TRIGGERS = {
|
|
2
2
|
"TOKENS": {
|
|
3
|
-
"
|
|
4
|
-
"description": "
|
|
3
|
+
"TRANSFER": {
|
|
4
|
+
"description": "Monitors token transfers",
|
|
5
5
|
"chains": [
|
|
6
6
|
0
|
|
7
7
|
],
|
|
8
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
8
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenTransfer.png",
|
|
9
9
|
"TRANSFER": {
|
|
10
10
|
"name": "Transfer token",
|
|
11
11
|
"description": "This block gets triggered when someone transfers the ERC20 configured in the params",
|
|
@@ -71,8 +71,15 @@ export const TRIGGERS = {
|
|
|
71
71
|
}
|
|
72
72
|
],
|
|
73
73
|
"blockId": 1,
|
|
74
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
75
|
-
}
|
|
74
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenTransfer.png"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"BALANCE": {
|
|
78
|
+
"description": "Monitors token balance of selected addresses",
|
|
79
|
+
"chains": [
|
|
80
|
+
0
|
|
81
|
+
],
|
|
82
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenBalance.png",
|
|
76
83
|
"BALANCE": {
|
|
77
84
|
"name": "ERC20 balance check",
|
|
78
85
|
"description": "Fetches the balance of an ERC20 and checks it against the specified condition.",
|
|
@@ -98,7 +105,7 @@ export const TRIGGERS = {
|
|
|
98
105
|
},
|
|
99
106
|
{
|
|
100
107
|
"key": "contractAddress",
|
|
101
|
-
"type": "
|
|
108
|
+
"type": "erc20",
|
|
102
109
|
"description": "The contract address of the ERC20",
|
|
103
110
|
"mandatory": true,
|
|
104
111
|
"category": 0
|
|
@@ -151,7 +158,7 @@ export const TRIGGERS = {
|
|
|
151
158
|
}
|
|
152
159
|
],
|
|
153
160
|
"blockId": 5,
|
|
154
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
161
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenBalance.png"
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
164
|
},
|
|
@@ -463,7 +470,9 @@ export const TRIGGERS = {
|
|
|
463
470
|
"blockId": 9,
|
|
464
471
|
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/splicefi.png"
|
|
465
472
|
}
|
|
466
|
-
}
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
"LENDING": {
|
|
467
476
|
"IONIC": {
|
|
468
477
|
"description": "#1 money market for Yield Bearing Assets on the OP Superchain",
|
|
469
478
|
"chains": [
|
|
@@ -530,15 +539,14 @@ export const TRIGGERS = {
|
|
|
530
539
|
]
|
|
531
540
|
}
|
|
532
541
|
],
|
|
542
|
+
"before": "\n async (env) => {\n const otomatoSdk = await import('otomato-sdk');\n \n if (!env.parameters.chainId)\n throw new Error('You need to provide the chainId first');\n \n const getIonicTokenFromToken = (chain, tokenAddress) => {\n const CHAINS = otomatoSdk.CHAINS;\n if (chain == CHAINS.MODE) {\n switch (tokenAddress.toLowerCase()) {\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDT').contractAddress.toLowerCase():\n return '0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'USDC').contractAddress.toLowerCase():\n return '0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'ezETH').contractAddress.toLowerCase():\n return '0x59e710215d45F584f44c0FEe83DA6d43D762D857';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WETH').contractAddress.toLowerCase():\n return '0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'WBTC').contractAddress.toLowerCase():\n return '0xd70254C3baD29504789714A7c69d60Ec1127375C';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'STONE').contractAddress.toLowerCase():\n return '0x959FA710CCBb22c7Ce1e59Da82A247e686629310';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'wrsETH').contractAddress.toLowerCase():\n return '0x49950319aBE7CE5c3A6C90698381b45989C99b46';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'weETH.mode').contractAddress.toLowerCase():\n return '0xA0D844742B4abbbc43d8931a6Edb00C56325aA18';\n case otomatoSdk.getTokenFromSymbol(CHAINS.MODE, 'M-BTC').contractAddress.toLowerCase():\n return '0x19F245782b1258cf3e11Eda25784A378cC18c108';\n\n default: throw new Error('This asset is not available on Ionic');\n }\n }\n}\n \n let ionicTokenContractAddress = getIonicTokenFromToken(\n env.parameters.chainId,\n env.parameters.token.toLowerCase()\n );\n return {\n contractAddress: ionicTokenContractAddress\n };\n }",
|
|
533
543
|
"output": {
|
|
534
544
|
"lendingRate": "float"
|
|
535
545
|
},
|
|
536
546
|
"blockId": 15,
|
|
537
547
|
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/ionic.jpg"
|
|
538
548
|
}
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
"LENDING": {
|
|
549
|
+
},
|
|
542
550
|
"ASTARIA": {
|
|
543
551
|
"description": "Astaria is an oracle-less, intent-based, fixed-rate lending protocol supporting unlimited loan durations for any asset",
|
|
544
552
|
"chains": [
|
|
@@ -1121,8 +1129,8 @@ export const ACTIONS = {
|
|
|
1121
1129
|
"chains": [
|
|
1122
1130
|
34443
|
|
1123
1131
|
],
|
|
1124
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/delay.png",
|
|
1125
1132
|
"SWAP": {
|
|
1133
|
+
"id": 100005,
|
|
1126
1134
|
"name": "Swap",
|
|
1127
1135
|
"description": "Swap two assets using the best market rates accross multiple pools",
|
|
1128
1136
|
"type": 1,
|
|
@@ -1189,7 +1197,7 @@ export const ACTIONS = {
|
|
|
1189
1197
|
"value": 0.3,
|
|
1190
1198
|
"mandatory": true,
|
|
1191
1199
|
"category": 1
|
|
1192
|
-
}
|
|
1200
|
+
}
|
|
1193
1201
|
],
|
|
1194
1202
|
"examples": [
|
|
1195
1203
|
{
|
|
@@ -1231,10 +1239,9 @@ export const ACTIONS = {
|
|
|
1231
1239
|
"Transfer ETH"
|
|
1232
1240
|
]
|
|
1233
1241
|
},
|
|
1234
|
-
"duplicate": true
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1242
|
+
"duplicate": true
|
|
1243
|
+
},
|
|
1244
|
+
"blockId": 100013
|
|
1238
1245
|
}
|
|
1239
1246
|
},
|
|
1240
1247
|
"NOTIFICATIONS": {
|
|
@@ -1355,12 +1362,12 @@ export const ACTIONS = {
|
|
|
1355
1362
|
}
|
|
1356
1363
|
},
|
|
1357
1364
|
"TOKENS": {
|
|
1358
|
-
"
|
|
1359
|
-
"description": "
|
|
1365
|
+
"TRANSFER": {
|
|
1366
|
+
"description": "Transfer token",
|
|
1360
1367
|
"chains": [
|
|
1361
1368
|
34443
|
|
1362
1369
|
],
|
|
1363
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
1370
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenTransfer.png",
|
|
1364
1371
|
"TRANSFER": {
|
|
1365
1372
|
"name": "Transfer token",
|
|
1366
1373
|
"description": "Transfers an ERC20 token",
|
|
@@ -1408,7 +1415,7 @@ export const ACTIONS = {
|
|
|
1408
1415
|
"type": 0,
|
|
1409
1416
|
"chainId": "{{parameters.chainId}}",
|
|
1410
1417
|
"contractAddress": "{{parameters.contractAddress}}",
|
|
1411
|
-
"amount": "{{parameters.abi.parameters.
|
|
1418
|
+
"amount": "{{parameters.abi.parameters.value}}"
|
|
1412
1419
|
}
|
|
1413
1420
|
],
|
|
1414
1421
|
"examples": [
|
|
@@ -1447,7 +1454,7 @@ export const ACTIONS = {
|
|
|
1447
1454
|
]
|
|
1448
1455
|
},
|
|
1449
1456
|
"blockId": 100004,
|
|
1450
|
-
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/
|
|
1457
|
+
"image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/tokenTransfer.png"
|
|
1451
1458
|
}
|
|
1452
1459
|
}
|
|
1453
1460
|
},
|
|
@@ -1809,7 +1816,7 @@ export const ACTIONS = {
|
|
|
1809
1816
|
},
|
|
1810
1817
|
{
|
|
1811
1818
|
"key": "abiParams.tokens",
|
|
1812
|
-
"type": "
|
|
1819
|
+
"type": "addresses_array",
|
|
1813
1820
|
"description": "List of collaterals",
|
|
1814
1821
|
"mandatory": true,
|
|
1815
1822
|
"category": 0
|
|
@@ -1821,10 +1828,10 @@ export const ACTIONS = {
|
|
|
1821
1828
|
"0xFB3323E24743Caf4ADD0fDCCFB268565c0685556"
|
|
1822
1829
|
],
|
|
1823
1830
|
"label": [
|
|
1824
|
-
"
|
|
1831
|
+
"Enable {{tokenSymbol({{parameters.chainId}}, {{parameters.abi.parameters.tokens[0]}})}} as collateral on IONIC"
|
|
1825
1832
|
],
|
|
1826
1833
|
"labelNotAuthorized": [
|
|
1827
|
-
"Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.
|
|
1834
|
+
"Transfer {{tokenSymbol({{parameters.chainId}}, {{parameters.abi.parameters.tokens[0]}})}}"
|
|
1828
1835
|
]
|
|
1829
1836
|
},
|
|
1830
1837
|
"blockId": 100012,
|
|
@@ -15,7 +15,7 @@ export const WORKFLOW_TEMPLATES_TAGS = {
|
|
|
15
15
|
ON_CHAIN_MONITORING: 'On-chain monitoring'
|
|
16
16
|
};
|
|
17
17
|
const createModeTransferNotificationWorkflow = () => {
|
|
18
|
-
const modeTransferTrigger = new Trigger(TRIGGERS.TOKENS.
|
|
18
|
+
const modeTransferTrigger = new Trigger(TRIGGERS.TOKENS.TRANSFER.TRANSFER);
|
|
19
19
|
modeTransferTrigger.setChainId(CHAINS.MODE);
|
|
20
20
|
modeTransferTrigger.setContractAddress(getTokenFromSymbol(CHAINS.MODE, 'MODE').contractAddress);
|
|
21
21
|
modeTransferTrigger.setParams('from', '0x74B847b308BD89Ef15639E6e4a2544E4b8b8C6B4');
|
|
@@ -23,12 +23,67 @@ export class Action extends Node {
|
|
|
23
23
|
const permissions = SessionKeyPermission.fromJSON(parentBlock.permissions);
|
|
24
24
|
permissions.fillParameters(this.getParameters());
|
|
25
25
|
permissions.fillMethod();
|
|
26
|
+
// Handle 'before' code for the main action
|
|
26
27
|
if (parentBlock.before) {
|
|
27
28
|
yield permissions.fillBeforeVariables(parentBlock.before, this.getParameters());
|
|
28
29
|
}
|
|
30
|
+
// Handle batchWith: for any batched actions, merge their permissions
|
|
31
|
+
if (parentBlock.batchWith && parentBlock.batchWith.length > 0) {
|
|
32
|
+
for (const batch of parentBlock.batchWith) {
|
|
33
|
+
const batchedAction = findActionByBlockId(batch.id).block;
|
|
34
|
+
if (batchedAction.permissions) {
|
|
35
|
+
const batchedActionInstance = new Action(batchedAction);
|
|
36
|
+
// Replace placeholders in parameters
|
|
37
|
+
const resolvedBatchParams = batch.parameters;
|
|
38
|
+
Object.keys(resolvedBatchParams).forEach(key => {
|
|
39
|
+
var _a;
|
|
40
|
+
// If it's an ABI parameter, handle it separately
|
|
41
|
+
if (key === 'abi' && ((_a = resolvedBatchParams.abi) === null || _a === void 0 ? void 0 : _a.parameters)) {
|
|
42
|
+
Object.keys(resolvedBatchParams.abi.parameters).forEach(abiKey => {
|
|
43
|
+
const abiValue = this.replaceVariables(resolvedBatchParams.abi.parameters[abiKey]);
|
|
44
|
+
batchedActionInstance.setParams(`${abiKey}`, abiValue);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
let value = this.replaceVariables(resolvedBatchParams[key]);
|
|
49
|
+
batchedActionInstance.setParams(key, value);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Get batched permissions
|
|
53
|
+
const batchedPermissions = yield batchedActionInstance.getSessionKeyPermissions();
|
|
54
|
+
if (!batchedPermissions)
|
|
55
|
+
continue;
|
|
56
|
+
batchedPermissions.fillParameters(batch.parameters); // Pass batched action parameters
|
|
57
|
+
batchedPermissions.fillMethod();
|
|
58
|
+
// Handle 'before' code for the batched action
|
|
59
|
+
if (batchedAction.before) {
|
|
60
|
+
yield batchedPermissions.fillBeforeVariables(batchedAction.before, batch.parameters);
|
|
61
|
+
}
|
|
62
|
+
// Merge the batched action's permissions with the main action's permissions
|
|
63
|
+
permissions.merge(batchedPermissions);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
29
67
|
return permissions;
|
|
30
68
|
});
|
|
31
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Replace any placeholders like {{parameters.tokenToDeposit}} with actual values
|
|
72
|
+
* from the parameters of the current action. Supports both strings and arrays.
|
|
73
|
+
*/
|
|
74
|
+
replaceVariables(value) {
|
|
75
|
+
if (typeof value === 'string') {
|
|
76
|
+
return value.replace(/\{\{parameters\.(.*?)\}\}/g, (_, key) => {
|
|
77
|
+
console.log(`Looking for ${key} parameter`);
|
|
78
|
+
return this.getParameter(key) || '';
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
return value.map(item => this.replaceVariables(item)); // Recursively handle each array element
|
|
83
|
+
}
|
|
84
|
+
// Return the value unchanged if it's neither a string nor an array
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
32
87
|
static fromJSON(json) {
|
|
33
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
89
|
const enriched = findActionByBlockId(json.blockId);
|
package/dist/src/models/Node.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { validateType,
|
|
10
|
+
import { validateType, typeIsNumber } from '../utils/typeValidator.js';
|
|
11
11
|
import { apiServices } from '../services/ApiService.js';
|
|
12
12
|
let nodeCounter = 0;
|
|
13
13
|
const generatedRefs = new Set();
|
|
@@ -73,11 +73,22 @@ export class Node {
|
|
|
73
73
|
if (key in this.parameters) {
|
|
74
74
|
const param = this.parameters[key];
|
|
75
75
|
try {
|
|
76
|
-
//
|
|
77
|
-
if (
|
|
76
|
+
// BigInt conversion
|
|
77
|
+
if (typeIsNumber(param.type) && typeof value === 'string' && value.endsWith('n')) {
|
|
78
78
|
value = BigInt(value.substring(0, value.length - 1));
|
|
79
|
+
}
|
|
80
|
+
// String to integer conversion
|
|
81
|
+
if (typeIsNumber(param.type) && typeof value === 'string') {
|
|
82
|
+
const parsedValue = parseInt(value, 10);
|
|
83
|
+
if (!isNaN(parsedValue)) {
|
|
84
|
+
value = parsedValue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.error(`Error processing parameter ${key}:`, e);
|
|
79
90
|
}
|
|
80
|
-
|
|
91
|
+
// Validate the value type
|
|
81
92
|
if (validateType(param.type, value)) {
|
|
82
93
|
this.parameters[key].value = value;
|
|
83
94
|
}
|
|
@@ -14,12 +14,13 @@ export class SessionKeyPermission {
|
|
|
14
14
|
this.label = label;
|
|
15
15
|
this.labelNotAuthorized = labelNotAuthorized;
|
|
16
16
|
}
|
|
17
|
-
// Existing method to replace placeholders with actual values
|
|
18
17
|
fill(key, value) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Escape special regex characters in the key
|
|
19
|
+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\[\]]/g, '\\$&');
|
|
20
|
+
const placeholder = new RegExp(`{{${escapedKey}}}`, 'g');
|
|
21
|
+
// Function to replace placeholders in a target string
|
|
22
|
+
const replacePlaceholder = (target) => target.replace(placeholder, value);
|
|
23
|
+
// Apply the placeholder replacement logic
|
|
23
24
|
this.approvedTargets = this.approvedTargets.map(replacePlaceholder);
|
|
24
25
|
this.label = this.label.map(replacePlaceholder);
|
|
25
26
|
this.labelNotAuthorized = this.labelNotAuthorized.map(replacePlaceholder);
|
|
@@ -61,16 +62,34 @@ export class SessionKeyPermission {
|
|
|
61
62
|
// The rest of your existing code
|
|
62
63
|
fillParameters(params) {
|
|
63
64
|
var _a;
|
|
64
|
-
//
|
|
65
|
+
// Helper to handle the replacement in case of arrays
|
|
66
|
+
const fillArray = (key, array) => {
|
|
67
|
+
array.forEach((item, index) => {
|
|
68
|
+
if (typeof item === 'string') {
|
|
69
|
+
this.fill(`${key}[${index}]`, item);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
// 1. Replace non-ABI params
|
|
65
74
|
for (let key in params) {
|
|
66
75
|
if (key !== 'abi') {
|
|
67
|
-
|
|
76
|
+
if (Array.isArray(params[key])) {
|
|
77
|
+
fillArray(`parameters.${key}`, params[key]);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.fill(`parameters.${key}`, params[key]);
|
|
81
|
+
}
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
|
-
// 2.
|
|
84
|
+
// 2. Replace ABI params
|
|
71
85
|
const abiParams = (_a = params.abi) === null || _a === void 0 ? void 0 : _a.parameters;
|
|
72
86
|
for (let key in abiParams) {
|
|
73
|
-
|
|
87
|
+
if (Array.isArray(abiParams[key])) {
|
|
88
|
+
fillArray(`parameters.abi.parameters.${key}`, abiParams[key]);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.fill(`parameters.abi.parameters.${key}`, abiParams[key]);
|
|
92
|
+
}
|
|
74
93
|
}
|
|
75
94
|
}
|
|
76
95
|
fillMethod() {
|
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
export function isANumber(type) {
|
|
3
|
-
switch (type) {
|
|
4
|
-
case 'integer':
|
|
5
|
-
return true;
|
|
6
|
-
case 'int8':
|
|
7
|
-
case 'int16':
|
|
8
|
-
case 'int32':
|
|
9
|
-
case 'int64':
|
|
10
|
-
case 'int128':
|
|
11
|
-
case 'int256':
|
|
12
|
-
return true;
|
|
13
|
-
case 'uint8':
|
|
14
|
-
case 'uint16':
|
|
15
|
-
case 'uint32':
|
|
16
|
-
case 'uint64':
|
|
17
|
-
case 'uint128':
|
|
18
|
-
case 'uint256':
|
|
19
|
-
return true;
|
|
20
|
-
default: return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
2
|
export function validateType(expectedType, value) {
|
|
24
3
|
switch (expectedType) {
|
|
25
4
|
case 'bool':
|
|
@@ -62,6 +41,9 @@ export function validateType(expectedType, value) {
|
|
|
62
41
|
case 'logic_operator':
|
|
63
42
|
const validOperators = new Set(['gte', 'gt', 'lte', 'lt', 'eq', 'neq']);
|
|
64
43
|
return typeof value === 'string' && validOperators.has(value);
|
|
44
|
+
case 'addresses_array':
|
|
45
|
+
// Ensure value is an array, and each element is a valid address
|
|
46
|
+
return Array.isArray(value) && value.every(isAddress);
|
|
65
47
|
case 'any':
|
|
66
48
|
return true;
|
|
67
49
|
default:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Parameter } from '../models/Parameter.js';
|
|
2
2
|
export declare const TRIGGERS: {
|
|
3
3
|
TOKENS: {
|
|
4
|
-
|
|
4
|
+
TRANSFER: {
|
|
5
5
|
description: string;
|
|
6
6
|
chains: number[];
|
|
7
7
|
image: string;
|
|
@@ -30,6 +30,11 @@ export declare const TRIGGERS: {
|
|
|
30
30
|
blockId: number;
|
|
31
31
|
image: string;
|
|
32
32
|
};
|
|
33
|
+
};
|
|
34
|
+
BALANCE: {
|
|
35
|
+
description: string;
|
|
36
|
+
chains: number[];
|
|
37
|
+
image: string;
|
|
33
38
|
BALANCE: {
|
|
34
39
|
name: string;
|
|
35
40
|
description: string;
|
|
@@ -183,6 +188,8 @@ export declare const TRIGGERS: {
|
|
|
183
188
|
image: string;
|
|
184
189
|
};
|
|
185
190
|
};
|
|
191
|
+
};
|
|
192
|
+
LENDING: {
|
|
186
193
|
IONIC: {
|
|
187
194
|
description: string;
|
|
188
195
|
chains: number[];
|
|
@@ -204,6 +211,7 @@ export declare const TRIGGERS: {
|
|
|
204
211
|
value: string;
|
|
205
212
|
})[];
|
|
206
213
|
}[];
|
|
214
|
+
before: string;
|
|
207
215
|
output: {
|
|
208
216
|
lendingRate: string;
|
|
209
217
|
};
|
|
@@ -211,8 +219,6 @@ export declare const TRIGGERS: {
|
|
|
211
219
|
image: string;
|
|
212
220
|
};
|
|
213
221
|
};
|
|
214
|
-
};
|
|
215
|
-
LENDING: {
|
|
216
222
|
ASTARIA: {
|
|
217
223
|
description: string;
|
|
218
224
|
chains: number[];
|
|
@@ -452,8 +458,8 @@ export declare const ACTIONS: {
|
|
|
452
458
|
SWAP: {
|
|
453
459
|
description: string;
|
|
454
460
|
chains: number[];
|
|
455
|
-
image: string;
|
|
456
461
|
SWAP: {
|
|
462
|
+
id: number;
|
|
457
463
|
name: string;
|
|
458
464
|
description: string;
|
|
459
465
|
type: number;
|
|
@@ -476,7 +482,34 @@ export declare const ACTIONS: {
|
|
|
476
482
|
tokenOut: string;
|
|
477
483
|
transactionHash: string;
|
|
478
484
|
};
|
|
479
|
-
parameters:
|
|
485
|
+
parameters: ({
|
|
486
|
+
key: string;
|
|
487
|
+
type: string;
|
|
488
|
+
description: string;
|
|
489
|
+
mandatory: boolean;
|
|
490
|
+
category: number;
|
|
491
|
+
erc20FormattedAmount?: undefined;
|
|
492
|
+
value?: undefined;
|
|
493
|
+
} | {
|
|
494
|
+
key: string;
|
|
495
|
+
type: string;
|
|
496
|
+
description: string;
|
|
497
|
+
mandatory: boolean;
|
|
498
|
+
category: number;
|
|
499
|
+
erc20FormattedAmount: {
|
|
500
|
+
contractAddress: string;
|
|
501
|
+
chain: string;
|
|
502
|
+
};
|
|
503
|
+
value?: undefined;
|
|
504
|
+
} | {
|
|
505
|
+
key: string;
|
|
506
|
+
type: string;
|
|
507
|
+
description: string;
|
|
508
|
+
value: number;
|
|
509
|
+
mandatory: boolean;
|
|
510
|
+
category: number;
|
|
511
|
+
erc20FormattedAmount?: undefined;
|
|
512
|
+
})[];
|
|
480
513
|
examples: {
|
|
481
514
|
name: string;
|
|
482
515
|
description: string;
|
|
@@ -494,9 +527,8 @@ export declare const ACTIONS: {
|
|
|
494
527
|
labelNotAuthorized: string[];
|
|
495
528
|
};
|
|
496
529
|
duplicate: boolean;
|
|
497
|
-
blockId: number;
|
|
498
|
-
image: string;
|
|
499
530
|
};
|
|
531
|
+
blockId: number;
|
|
500
532
|
};
|
|
501
533
|
};
|
|
502
534
|
NOTIFICATIONS: {
|
|
@@ -569,7 +601,7 @@ export declare const ACTIONS: {
|
|
|
569
601
|
};
|
|
570
602
|
};
|
|
571
603
|
TOKENS: {
|
|
572
|
-
|
|
604
|
+
TRANSFER: {
|
|
573
605
|
description: string;
|
|
574
606
|
chains: number[];
|
|
575
607
|
image: string;
|
|
@@ -17,6 +17,11 @@ export declare class Action extends Node {
|
|
|
17
17
|
state?: NodeState;
|
|
18
18
|
});
|
|
19
19
|
getSessionKeyPermissions(): Promise<SessionKeyPermission | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Replace any placeholders like {{parameters.tokenToDeposit}} with actual values
|
|
22
|
+
* from the parameters of the current action. Supports both strings and arrays.
|
|
23
|
+
*/
|
|
24
|
+
replaceVariables(value: any): any;
|
|
20
25
|
static fromJSON(json: {
|
|
21
26
|
[key: string]: any;
|
|
22
27
|
}): Promise<Action>;
|