sdk-triggerx 0.1.31 → 0.1.33
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 +9 -8
- package/dist/api/checkBalance.d.ts +33 -0
- package/dist/api/checkBalance.js +68 -0
- package/dist/api/jobs.d.ts +6 -2
- package/dist/api/jobs.js +181 -108
- package/dist/api/topup.d.ts +20 -0
- package/dist/api/topup.js +102 -0
- package/dist/api/withdraw.d.ts +26 -0
- package/dist/api/withdraw.js +89 -0
- package/dist/config.js +5 -5
- package/dist/contracts/abi/GasRegistry.json +268 -423
- package/dist/contracts/abi/JobRegistry.json +710 -1524
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/types.d.ts +34 -1
- package/dist/types.js +1 -0
- package/dist/utils/validation.d.ts +2 -2
- package/dist/utils/validation.js +63 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export * from './types';
|
|
|
4
4
|
export * from './api/jobs';
|
|
5
5
|
export * from './api/getjob';
|
|
6
6
|
export * from './api/getUserData';
|
|
7
|
-
export * from './api/
|
|
8
|
-
export * from './api/
|
|
7
|
+
export * from './api/checkBalance';
|
|
8
|
+
export * from './api/topup';
|
|
9
|
+
export * from './api/withdraw';
|
|
9
10
|
export * from './api/deleteJob';
|
|
10
11
|
export * from './api/getJobDataById';
|
|
11
12
|
export * from './api/safeWallet';
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,9 @@ __exportStar(require("./types"), exports);
|
|
|
20
20
|
__exportStar(require("./api/jobs"), exports);
|
|
21
21
|
__exportStar(require("./api/getjob"), exports);
|
|
22
22
|
__exportStar(require("./api/getUserData"), exports);
|
|
23
|
-
__exportStar(require("./api/
|
|
24
|
-
__exportStar(require("./api/
|
|
23
|
+
__exportStar(require("./api/checkBalance"), exports);
|
|
24
|
+
__exportStar(require("./api/topup"), exports);
|
|
25
|
+
__exportStar(require("./api/withdraw"), exports);
|
|
25
26
|
__exportStar(require("./api/deleteJob"), exports);
|
|
26
27
|
__exportStar(require("./api/getJobDataById"), exports);
|
|
27
28
|
__exportStar(require("./api/safeWallet"), exports);
|
package/dist/types.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export type ApiResult<T> = SuccessResponse<T> | ErrorResponse;
|
|
|
26
26
|
export declare enum JobType {
|
|
27
27
|
Time = "time",
|
|
28
28
|
Event = "event",
|
|
29
|
-
Condition = "condition"
|
|
29
|
+
Condition = "condition",
|
|
30
|
+
CustomScript = "custom_script"
|
|
30
31
|
}
|
|
31
32
|
export declare enum ArgType {
|
|
32
33
|
Static = "static",
|
|
@@ -47,6 +48,9 @@ export type CreateJobInput = (TimeBasedJobInput & {
|
|
|
47
48
|
}) | (ConditionBasedJobInput & {
|
|
48
49
|
jobType: JobType.Condition;
|
|
49
50
|
argType: ArgType.Static | ArgType.Dynamic;
|
|
51
|
+
}) | (CustomScriptJobInput & {
|
|
52
|
+
jobType: JobType.CustomScript;
|
|
53
|
+
argType: ArgType.Dynamic;
|
|
50
54
|
});
|
|
51
55
|
export interface TimeBasedJobInput {
|
|
52
56
|
jobTitle: string;
|
|
@@ -63,6 +67,8 @@ export interface TimeBasedJobInput {
|
|
|
63
67
|
isImua?: boolean;
|
|
64
68
|
arguments?: string[];
|
|
65
69
|
dynamicArgumentsScriptUrl?: string;
|
|
70
|
+
autotopupETH?: boolean;
|
|
71
|
+
/** @deprecated Use autotopupETH instead */
|
|
66
72
|
autotopupTG?: boolean;
|
|
67
73
|
walletMode?: WalletMode;
|
|
68
74
|
safeName?: string;
|
|
@@ -95,6 +101,8 @@ export interface EventBasedJobInput {
|
|
|
95
101
|
isImua?: boolean;
|
|
96
102
|
arguments?: string[];
|
|
97
103
|
dynamicArgumentsScriptUrl?: string;
|
|
104
|
+
autotopupETH?: boolean;
|
|
105
|
+
/** @deprecated Use autotopupETH instead */
|
|
98
106
|
autotopupTG?: boolean;
|
|
99
107
|
walletMode?: WalletMode;
|
|
100
108
|
safeName?: string;
|
|
@@ -129,6 +137,8 @@ export interface ConditionBasedJobInput {
|
|
|
129
137
|
isImua?: boolean;
|
|
130
138
|
arguments?: string[];
|
|
131
139
|
dynamicArgumentsScriptUrl?: string;
|
|
140
|
+
autotopupETH?: boolean;
|
|
141
|
+
/** @deprecated Use autotopupETH instead */
|
|
132
142
|
autotopupTG?: boolean;
|
|
133
143
|
walletMode?: WalletMode;
|
|
134
144
|
safeName?: string;
|
|
@@ -146,6 +156,27 @@ export interface ConditionBasedJobInput {
|
|
|
146
156
|
*/
|
|
147
157
|
safeTransactions?: SafeTransaction[];
|
|
148
158
|
}
|
|
159
|
+
export interface CustomScriptJobInput {
|
|
160
|
+
jobTitle: string;
|
|
161
|
+
timeFrame: number;
|
|
162
|
+
timeInterval: number;
|
|
163
|
+
timezone: string;
|
|
164
|
+
chainId: string;
|
|
165
|
+
targetContractAddress?: string;
|
|
166
|
+
targetFunction?: string;
|
|
167
|
+
abi?: string;
|
|
168
|
+
isImua?: boolean;
|
|
169
|
+
arguments?: string[];
|
|
170
|
+
dynamicArgumentsScriptUrl: string;
|
|
171
|
+
autotopupETH?: boolean;
|
|
172
|
+
/** @deprecated Use autotopupETH instead */
|
|
173
|
+
autotopupTG?: boolean;
|
|
174
|
+
walletMode?: WalletMode;
|
|
175
|
+
safeName?: string;
|
|
176
|
+
language: string;
|
|
177
|
+
recurring?: boolean;
|
|
178
|
+
safeAddress?: string;
|
|
179
|
+
}
|
|
149
180
|
export interface CreateJobData {
|
|
150
181
|
job_id: string;
|
|
151
182
|
user_address: string;
|
|
@@ -187,6 +218,8 @@ export interface CreateJobData {
|
|
|
187
218
|
export interface JobResponse {
|
|
188
219
|
success: boolean;
|
|
189
220
|
data?: any;
|
|
221
|
+
requiredETH?: bigint;
|
|
222
|
+
maxtotalFeeRaw?: bigint;
|
|
190
223
|
error?: string;
|
|
191
224
|
errorCode?: ApiErrorCode;
|
|
192
225
|
httpStatusCode?: HttpStatusCode;
|
package/dist/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TimeBasedJobInput, EventBasedJobInput, ConditionBasedJobInput } from '../types';
|
|
1
|
+
import { TimeBasedJobInput, EventBasedJobInput, ConditionBasedJobInput, CustomScriptJobInput } from '../types';
|
|
2
2
|
export declare function validateTimeBasedJobInput(input: TimeBasedJobInput, argType: 'static' | 'dynamic' | 1 | 2 | undefined): void;
|
|
3
3
|
export declare function validateEventBasedJobInput(input: EventBasedJobInput, argType: 'static' | 'dynamic' | 1 | 2 | undefined): void;
|
|
4
4
|
export declare function validateConditionBasedJobInput(input: ConditionBasedJobInput, argType: 'static' | 'dynamic' | 1 | 2 | undefined): void;
|
|
5
|
-
export declare function validateJobInput(jobInput: TimeBasedJobInput | EventBasedJobInput | ConditionBasedJobInput, argType?: 'static' | 'dynamic' | 1 | 2): void;
|
|
5
|
+
export declare function validateJobInput(jobInput: TimeBasedJobInput | EventBasedJobInput | ConditionBasedJobInput | CustomScriptJobInput, argType?: 'static' | 'dynamic' | 1 | 2): void;
|
package/dist/utils/validation.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.validateEventBasedJobInput = validateEventBasedJobInput;
|
|
|
5
5
|
exports.validateConditionBasedJobInput = validateConditionBasedJobInput;
|
|
6
6
|
exports.validateJobInput = validateJobInput;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
|
+
const types_1 = require("../types");
|
|
8
9
|
const errors_1 = require("./errors");
|
|
9
10
|
function isNonEmptyString(value) {
|
|
10
11
|
return typeof value === 'string' && value.trim().length > 0;
|
|
@@ -278,14 +279,73 @@ function validateConditionBasedJobInput(input, argType) {
|
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
}
|
|
282
|
+
function validateCustomScriptJobInput(input) {
|
|
283
|
+
if (!isNonEmptyString(input.jobTitle)) {
|
|
284
|
+
throw new errors_1.ValidationError('jobTitle', 'Job title is required.');
|
|
285
|
+
}
|
|
286
|
+
if (!input.timeFrame || input.timeFrame <= 0) {
|
|
287
|
+
throw new errors_1.ValidationError('timeframe', 'Timeframe must be a positive number of seconds.');
|
|
288
|
+
}
|
|
289
|
+
if (!input.timeInterval || input.timeInterval <= 0) {
|
|
290
|
+
throw new errors_1.ValidationError('timeInterval', 'timeInterval is required and must be > 0 for custom script jobs.');
|
|
291
|
+
}
|
|
292
|
+
if (input.timeInterval > input.timeFrame) {
|
|
293
|
+
throw new errors_1.ValidationError('timeInterval', 'timeInterval cannot exceed the timeframe for custom script jobs.');
|
|
294
|
+
}
|
|
295
|
+
if (!isNonEmptyString(input.timezone)) {
|
|
296
|
+
throw new errors_1.ValidationError('timezone', 'Timezone is required.');
|
|
297
|
+
}
|
|
298
|
+
if (!isNonEmptyString(input.chainId)) {
|
|
299
|
+
throw new errors_1.ValidationError('chainId', 'Chain ID is required.');
|
|
300
|
+
}
|
|
301
|
+
if (!isNonEmptyString(input.dynamicArgumentsScriptUrl) || !isValidUrl(input.dynamicArgumentsScriptUrl)) {
|
|
302
|
+
throw new errors_1.ValidationError('contractIpfs', 'dynamicArgumentsScriptUrl is required and must be a valid URL for custom script jobs.');
|
|
303
|
+
}
|
|
304
|
+
if (!isNonEmptyString(input.language)) {
|
|
305
|
+
throw new errors_1.ValidationError('language', 'language is required for custom script jobs.');
|
|
306
|
+
}
|
|
307
|
+
// if (input.walletMode === 'safe') {
|
|
308
|
+
// if (input.safeTransactions && input.safeTransactions.length > 0) {
|
|
309
|
+
// throw new ValidationError('safeTransactions', 'Custom script jobs only support dynamic arguments; remove safeTransactions.');
|
|
310
|
+
// }
|
|
311
|
+
// } else {
|
|
312
|
+
// validateContractBasics(input.targetContractAddress, input.abi, input.targetFunction, 'contract');
|
|
313
|
+
// }
|
|
314
|
+
}
|
|
315
|
+
function isTimeBasedJobInput(jobInput) {
|
|
316
|
+
return jobInput && typeof jobInput === 'object' && 'scheduleType' in jobInput;
|
|
317
|
+
}
|
|
318
|
+
function isEventBasedJobInput(jobInput) {
|
|
319
|
+
return jobInput && typeof jobInput === 'object' && 'triggerChainId' in jobInput;
|
|
320
|
+
}
|
|
321
|
+
function isConditionBasedJobInput(jobInput) {
|
|
322
|
+
return jobInput && typeof jobInput === 'object' && 'conditionType' in jobInput;
|
|
323
|
+
}
|
|
324
|
+
function isCustomScriptJobInput(jobInput) {
|
|
325
|
+
if (!jobInput || typeof jobInput !== 'object') {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
if ('scheduleType' in jobInput || 'triggerChainId' in jobInput || 'conditionType' in jobInput) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return 'language' in jobInput && 'timeInterval' in jobInput && 'dynamicArgumentsScriptUrl' in jobInput;
|
|
332
|
+
}
|
|
281
333
|
function validateJobInput(jobInput, argType) {
|
|
282
|
-
if (
|
|
334
|
+
if (jobInput.jobType === types_1.JobType.CustomScript || isCustomScriptJobInput(jobInput)) {
|
|
335
|
+
validateCustomScriptJobInput(jobInput);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (isTimeBasedJobInput(jobInput)) {
|
|
283
339
|
validateTimeBasedJobInput(jobInput, argType);
|
|
340
|
+
return;
|
|
284
341
|
}
|
|
285
|
-
|
|
342
|
+
if (isEventBasedJobInput(jobInput)) {
|
|
286
343
|
validateEventBasedJobInput(jobInput, argType);
|
|
344
|
+
return;
|
|
287
345
|
}
|
|
288
|
-
|
|
346
|
+
if (isConditionBasedJobInput(jobInput)) {
|
|
289
347
|
validateConditionBasedJobInput(jobInput, argType);
|
|
348
|
+
return;
|
|
290
349
|
}
|
|
350
|
+
throw new errors_1.ValidationError('jobType', 'Unsupported job input payload.');
|
|
291
351
|
}
|