sdk-triggerx 0.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/.eslintrc.json +16 -0
- package/README.md +249 -0
- package/dist/api/jobs.d.ts +15 -0
- package/dist/api/jobs.js +138 -0
- package/dist/api/tasks.d.ts +4 -0
- package/dist/api/tasks.js +13 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +27 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +15 -0
- package/dist/contracts/JobRegistry.d.ts +12 -0
- package/dist/contracts/JobRegistry.js +26 -0
- package/dist/contracts/TriggerXContract.d.ts +6 -0
- package/dist/contracts/TriggerXContract.js +14 -0
- package/dist/contracts/abi/JobRegistry.json +1554 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +17 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/src/api/checkTgBalance.d.ts +2 -0
- package/dist/src/api/checkTgBalance.js +35 -0
- package/dist/src/api/deleteJob.d.ts +2 -0
- package/dist/src/api/deleteJob.js +20 -0
- package/dist/src/api/getJobDataById.d.ts +3 -0
- package/dist/src/api/getJobDataById.js +21 -0
- package/dist/src/api/getUserData.d.ts +3 -0
- package/dist/src/api/getUserData.js +21 -0
- package/dist/src/api/getjob.d.ts +8 -0
- package/dist/src/api/getjob.js +23 -0
- package/dist/src/api/jobs.d.ts +18 -0
- package/dist/src/api/jobs.js +270 -0
- package/dist/src/api/tasks.d.ts +4 -0
- package/dist/src/api/tasks.js +13 -0
- package/dist/src/api/topupTg.d.ts +2 -0
- package/dist/src/api/topupTg.js +19 -0
- package/dist/src/api/withdrawTg.d.ts +8 -0
- package/dist/src/api/withdrawTg.js +27 -0
- package/dist/src/client.d.ts +10 -0
- package/dist/src/client.js +37 -0
- package/dist/src/config.d.ts +6 -0
- package/dist/src/config.js +15 -0
- package/dist/src/contracts/JobRegistry.d.ts +12 -0
- package/dist/src/contracts/JobRegistry.js +24 -0
- package/dist/src/contracts/TriggerXContract.d.ts +6 -0
- package/dist/src/contracts/TriggerXContract.js +14 -0
- package/dist/src/contracts/abi/GasRegistry.json +607 -0
- package/dist/src/contracts/abi/JobRegistry.json +1554 -0
- package/dist/src/contracts/index.d.ts +1 -0
- package/dist/src/contracts/index.js +17 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.js +25 -0
- package/dist/src/types.d.ts +246 -0
- package/dist/src/types.js +15 -0
- package/dist/src/utils/errors.d.ts +4 -0
- package/dist/src/utils/errors.js +17 -0
- package/dist/test/createJobExample.d.ts +1 -0
- package/dist/test/createJobExample.js +77 -0
- package/dist/test/deleteJob.test.d.ts +1 -0
- package/dist/test/deleteJob.test.js +22 -0
- package/dist/test/example.test.d.ts +1 -0
- package/dist/test/example.test.js +11 -0
- package/dist/test/getJobDataById.test.d.ts +1 -0
- package/dist/test/getJobDataById.test.js +23 -0
- package/dist/test/getUserData.test.d.ts +1 -0
- package/dist/test/getUserData.test.js +22 -0
- package/dist/test/getjob.test.d.ts +1 -0
- package/dist/test/getjob.test.js +21 -0
- package/dist/test/testTgFunctions.d.ts +1 -0
- package/dist/test/testTgFunctions.js +56 -0
- package/dist/types.d.ts +134 -0
- package/dist/types.js +15 -0
- package/dist/utils/errors.d.ts +4 -0
- package/dist/utils/errors.js +17 -0
- package/jest.config.js +7 -0
- package/package.json +32 -0
- package/scripts/deploy.ts +9 -0
- package/src/api/checkTgBalance.ts +27 -0
- package/src/api/deleteJob.ts +22 -0
- package/src/api/getJobDataById.ts +24 -0
- package/src/api/getUserData.ts +24 -0
- package/src/api/getjob.ts +26 -0
- package/src/api/jobs.ts +303 -0
- package/src/api/topupTg.ts +17 -0
- package/src/api/withdrawTg.ts +25 -0
- package/src/client.ts +38 -0
- package/src/config.ts +16 -0
- package/src/contracts/JobRegistry.ts +45 -0
- package/src/contracts/TriggerXContract.ts +14 -0
- package/src/contracts/abi/.gitkeep +1 -0
- package/src/contracts/abi/GasRegistry.json +607 -0
- package/src/contracts/abi/JobRegistry.json +1554 -0
- package/src/contracts/index.ts +1 -0
- package/src/index.ts +7 -0
- package/src/types.ts +262 -0
- package/src/utils/errors.ts +13 -0
- package/test/createJobExample.ts +84 -0
- package/test/deleteJob.test.ts +25 -0
- package/test/example.test.d.ts +1 -0
- package/test/example.test.js +11 -0
- package/test/example.test.ts +10 -0
- package/test/getJobDataById.test.ts +27 -0
- package/test/getUserData.test.ts +25 -0
- package/test/getjob.test.ts +23 -0
- package/test/testTgFunctions.ts +56 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TriggerXContract';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./TriggerXContract"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createJobOnChain = void 0;
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./api/jobs"), exports);
|
|
22
|
+
var JobRegistry_1 = require("./contracts/JobRegistry");
|
|
23
|
+
Object.defineProperty(exports, "createJobOnChain", { enumerable: true, get: function () { return JobRegistry_1.createJobOnChain; } });
|
|
24
|
+
__exportStar(require("./contracts"), exports);
|
|
25
|
+
__exportStar(require("./utils/errors"), exports);
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
export interface Task {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
status: 'pending' | 'completed' | 'failed';
|
|
5
|
+
createdAt: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ApiResponse<T> {
|
|
8
|
+
data: T;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare enum JobType {
|
|
12
|
+
Time = "time",
|
|
13
|
+
Event = "event",
|
|
14
|
+
Condition = "condition"
|
|
15
|
+
}
|
|
16
|
+
export declare enum ArgType {
|
|
17
|
+
Static = "static",
|
|
18
|
+
Dynamic = "dynamic"
|
|
19
|
+
}
|
|
20
|
+
export type CreateJobInput = (TimeBasedJobInput & {
|
|
21
|
+
jobType: JobType.Time;
|
|
22
|
+
argType: ArgType.Static | ArgType.Dynamic;
|
|
23
|
+
}) | (EventBasedJobInput & {
|
|
24
|
+
jobType: JobType.Event;
|
|
25
|
+
argType: ArgType.Static | ArgType.Dynamic;
|
|
26
|
+
}) | (ConditionBasedJobInput & {
|
|
27
|
+
jobType: JobType.Condition;
|
|
28
|
+
argType: ArgType.Static | ArgType.Dynamic;
|
|
29
|
+
});
|
|
30
|
+
export interface TimeBasedJobInput {
|
|
31
|
+
userAddress: string;
|
|
32
|
+
etherBalance: BigInt | number;
|
|
33
|
+
tokenBalance: BigInt | number;
|
|
34
|
+
jobTitle: string;
|
|
35
|
+
timeFrame: number;
|
|
36
|
+
scheduleType: 'cron' | 'specific' | 'interval';
|
|
37
|
+
timeInterval?: number;
|
|
38
|
+
cronExpression?: string;
|
|
39
|
+
specificSchedule?: string;
|
|
40
|
+
timezone: string;
|
|
41
|
+
recurring?: boolean;
|
|
42
|
+
jobCostPrediction: number;
|
|
43
|
+
createdChainId: string;
|
|
44
|
+
targetChainId: string;
|
|
45
|
+
targetContractAddress: string;
|
|
46
|
+
targetFunction: string;
|
|
47
|
+
abi: string;
|
|
48
|
+
isImua?: boolean;
|
|
49
|
+
arguments?: string[];
|
|
50
|
+
dynamicArgumentsScriptUrl?: string;
|
|
51
|
+
autotopupTG?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface EventBasedJobInput {
|
|
54
|
+
userAddress: string;
|
|
55
|
+
etherBalance: BigInt | number;
|
|
56
|
+
tokenBalance: BigInt | number;
|
|
57
|
+
jobTitle: string;
|
|
58
|
+
timeFrame: number;
|
|
59
|
+
triggerChainId: string;
|
|
60
|
+
triggerContractAddress: string;
|
|
61
|
+
triggerEvent: string;
|
|
62
|
+
timezone: string;
|
|
63
|
+
recurring?: boolean;
|
|
64
|
+
jobCostPrediction: number;
|
|
65
|
+
createdChainId: string;
|
|
66
|
+
targetChainId: string;
|
|
67
|
+
targetContractAddress: string;
|
|
68
|
+
targetFunction: string;
|
|
69
|
+
abi: string;
|
|
70
|
+
isImua?: boolean;
|
|
71
|
+
arguments?: string[];
|
|
72
|
+
dynamicArgumentsScriptUrl?: string;
|
|
73
|
+
autotopupTG?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface ConditionBasedJobInput {
|
|
76
|
+
userAddress: string;
|
|
77
|
+
etherBalance: BigInt | number;
|
|
78
|
+
tokenBalance: BigInt | number;
|
|
79
|
+
jobTitle: string;
|
|
80
|
+
timeFrame: number;
|
|
81
|
+
conditionType: string;
|
|
82
|
+
upperLimit: number;
|
|
83
|
+
lowerLimit: number;
|
|
84
|
+
valueSourceType: string;
|
|
85
|
+
valueSourceUrl: string;
|
|
86
|
+
timezone: string;
|
|
87
|
+
recurring?: boolean;
|
|
88
|
+
jobCostPrediction: number;
|
|
89
|
+
createdChainId: string;
|
|
90
|
+
targetChainId: string;
|
|
91
|
+
targetContractAddress: string;
|
|
92
|
+
targetFunction: string;
|
|
93
|
+
abi: string;
|
|
94
|
+
isImua?: boolean;
|
|
95
|
+
arguments?: string[];
|
|
96
|
+
dynamicArgumentsScriptUrl?: string;
|
|
97
|
+
autotopupTG?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface CreateJobData {
|
|
100
|
+
job_id: string;
|
|
101
|
+
user_address: string;
|
|
102
|
+
ether_balance: BigInt | number;
|
|
103
|
+
token_balance: BigInt | number;
|
|
104
|
+
job_title: string;
|
|
105
|
+
task_definition_id: number;
|
|
106
|
+
custom: boolean;
|
|
107
|
+
time_frame: number;
|
|
108
|
+
recurring: boolean;
|
|
109
|
+
job_cost_prediction: number;
|
|
110
|
+
timezone: string;
|
|
111
|
+
created_chain_id: string;
|
|
112
|
+
schedule_type?: string;
|
|
113
|
+
time_interval?: number;
|
|
114
|
+
cron_expression?: string;
|
|
115
|
+
specific_schedule?: string;
|
|
116
|
+
trigger_chain_id?: string;
|
|
117
|
+
trigger_contract_address?: string;
|
|
118
|
+
trigger_event?: string;
|
|
119
|
+
condition_type?: string;
|
|
120
|
+
upper_limit?: number;
|
|
121
|
+
lower_limit?: number;
|
|
122
|
+
value_source_type?: string;
|
|
123
|
+
value_source_url?: string;
|
|
124
|
+
target_chain_id: string;
|
|
125
|
+
target_contract_address: string;
|
|
126
|
+
target_function: string;
|
|
127
|
+
abi: string;
|
|
128
|
+
arg_type: number;
|
|
129
|
+
arguments?: string[];
|
|
130
|
+
dynamic_arguments_script_url?: string;
|
|
131
|
+
is_imua: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface JobResponse {
|
|
134
|
+
success: boolean;
|
|
135
|
+
data?: any;
|
|
136
|
+
error?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface JobDataAPI {
|
|
139
|
+
job_id: string;
|
|
140
|
+
job_title: string;
|
|
141
|
+
task_definition_id: number;
|
|
142
|
+
user_id: number;
|
|
143
|
+
link_job_id: string;
|
|
144
|
+
chain_status: number;
|
|
145
|
+
custom: boolean;
|
|
146
|
+
time_frame: number;
|
|
147
|
+
recurring: boolean;
|
|
148
|
+
status: string;
|
|
149
|
+
job_cost_prediction: number;
|
|
150
|
+
job_cost_actual: number;
|
|
151
|
+
task_ids: number[];
|
|
152
|
+
created_at: Date;
|
|
153
|
+
updated_at: Date;
|
|
154
|
+
last_executed_at: Date;
|
|
155
|
+
timezone: string;
|
|
156
|
+
is_imua: boolean;
|
|
157
|
+
created_chain_id: string;
|
|
158
|
+
}
|
|
159
|
+
export interface TimeJobData {
|
|
160
|
+
job_id: string;
|
|
161
|
+
task_definition_id: number;
|
|
162
|
+
expiration_time: Date;
|
|
163
|
+
created_at: Date;
|
|
164
|
+
updated_at: Date;
|
|
165
|
+
time_interval: number;
|
|
166
|
+
schedule_type: string;
|
|
167
|
+
cron_expression: string;
|
|
168
|
+
specific_schedule: string;
|
|
169
|
+
timezone: string;
|
|
170
|
+
next_execution_timestamp: Date;
|
|
171
|
+
target_chain_id: string;
|
|
172
|
+
target_contract_address: string;
|
|
173
|
+
target_function: string;
|
|
174
|
+
abi: string;
|
|
175
|
+
arg_type: number;
|
|
176
|
+
arguments: string[];
|
|
177
|
+
dynamic_arguments_script_url: string;
|
|
178
|
+
is_completed: boolean;
|
|
179
|
+
is_active: boolean;
|
|
180
|
+
}
|
|
181
|
+
export interface EventJobData {
|
|
182
|
+
job_id: string;
|
|
183
|
+
task_definition_id: number;
|
|
184
|
+
expiration_time: Date;
|
|
185
|
+
created_at: Date;
|
|
186
|
+
updated_at: Date;
|
|
187
|
+
recurring: boolean;
|
|
188
|
+
trigger_chain_id: string;
|
|
189
|
+
trigger_contract_address: string;
|
|
190
|
+
trigger_event: string;
|
|
191
|
+
target_chain_id: string;
|
|
192
|
+
target_contract_address: string;
|
|
193
|
+
target_function: string;
|
|
194
|
+
abi: string;
|
|
195
|
+
arg_type: number;
|
|
196
|
+
arguments: string[];
|
|
197
|
+
dynamic_arguments_script_url: string;
|
|
198
|
+
is_completed: boolean;
|
|
199
|
+
is_active: boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface ConditionJobData {
|
|
202
|
+
job_id: string;
|
|
203
|
+
task_definition_id: number;
|
|
204
|
+
expiration_time: Date;
|
|
205
|
+
created_at: Date;
|
|
206
|
+
updated_at: Date;
|
|
207
|
+
recurring: boolean;
|
|
208
|
+
condition_type: string;
|
|
209
|
+
upper_limit: number;
|
|
210
|
+
lower_limit: number;
|
|
211
|
+
value_source_type: string;
|
|
212
|
+
value_source_url: string;
|
|
213
|
+
target_chain_id: string;
|
|
214
|
+
target_contract_address: string;
|
|
215
|
+
target_function: string;
|
|
216
|
+
abi: string;
|
|
217
|
+
arg_type: number;
|
|
218
|
+
arguments: string[];
|
|
219
|
+
dynamic_arguments_script_url: string;
|
|
220
|
+
is_completed: boolean;
|
|
221
|
+
is_active: boolean;
|
|
222
|
+
}
|
|
223
|
+
export interface JobResponseUser {
|
|
224
|
+
success: boolean;
|
|
225
|
+
error?: string;
|
|
226
|
+
jobs?: JobResponseAPI;
|
|
227
|
+
}
|
|
228
|
+
export interface JobResponseAPI {
|
|
229
|
+
job_data?: JobDataAPI;
|
|
230
|
+
time_job_data?: TimeJobData;
|
|
231
|
+
event_job_data?: EventJobData;
|
|
232
|
+
condition_job_data?: ConditionJobData;
|
|
233
|
+
}
|
|
234
|
+
export interface UserData {
|
|
235
|
+
user_id: number;
|
|
236
|
+
user_address: string;
|
|
237
|
+
job_ids: string[];
|
|
238
|
+
ether_balance: BigInt | number;
|
|
239
|
+
token_balance: BigInt | number;
|
|
240
|
+
user_points: number;
|
|
241
|
+
total_jobs: number;
|
|
242
|
+
total_tasks: number;
|
|
243
|
+
created_at: Date;
|
|
244
|
+
last_updated_at: Date;
|
|
245
|
+
email: string;
|
|
246
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArgType = exports.JobType = void 0;
|
|
4
|
+
// Enums for job type and argument type
|
|
5
|
+
var JobType;
|
|
6
|
+
(function (JobType) {
|
|
7
|
+
JobType["Time"] = "time";
|
|
8
|
+
JobType["Event"] = "event";
|
|
9
|
+
JobType["Condition"] = "condition";
|
|
10
|
+
})(JobType || (exports.JobType = JobType = {}));
|
|
11
|
+
var ArgType;
|
|
12
|
+
(function (ArgType) {
|
|
13
|
+
ArgType["Static"] = "static";
|
|
14
|
+
ArgType["Dynamic"] = "dynamic";
|
|
15
|
+
})(ArgType || (exports.ArgType = ArgType = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TriggerXError = void 0;
|
|
4
|
+
exports.wrapError = wrapError;
|
|
5
|
+
class TriggerXError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'TriggerXError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.TriggerXError = TriggerXError;
|
|
12
|
+
function wrapError(error) {
|
|
13
|
+
if (error instanceof Error) {
|
|
14
|
+
return new TriggerXError(error.message);
|
|
15
|
+
}
|
|
16
|
+
return new TriggerXError('Unknown error');
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const src_1 = require("../src");
|
|
4
|
+
const types_1 = require("../src/types");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
async function main() {
|
|
7
|
+
const apiKey = 'TGRX-ece02db8-f676-4a9f-a4f8-a95f59e755d8';
|
|
8
|
+
const client = new src_1.TriggerXClient(apiKey);
|
|
9
|
+
// // Example: Time-based static job
|
|
10
|
+
// const jobInput: CreateJobInput = {
|
|
11
|
+
// jobType: JobType.Time,
|
|
12
|
+
// argType: ArgType.Static,
|
|
13
|
+
// userAddress: '0x7Db951c0E6D8906687B459427eA3F3F2b456473B',
|
|
14
|
+
// etherBalance: 50000000000000000,
|
|
15
|
+
// tokenBalance: 50000000000000000000,
|
|
16
|
+
// jobTitle: 'SDK Test Time Job',
|
|
17
|
+
// timeFrame: 36,
|
|
18
|
+
// scheduleType: 'interval',
|
|
19
|
+
// timeInterval: 33,
|
|
20
|
+
// cronExpression: '0 0 * * *',
|
|
21
|
+
// specificSchedule: '2025-01-01 00:00:00',
|
|
22
|
+
// timezone: 'Asia/Calcutta',
|
|
23
|
+
// recurring: false,
|
|
24
|
+
// jobCostPrediction: 0.1,
|
|
25
|
+
// createdChainId: '11155420',
|
|
26
|
+
// targetChainId: '11155420',
|
|
27
|
+
// targetContractAddress: '0x49a81A591afdDEF973e6e49aaEa7d76943ef234C',
|
|
28
|
+
// targetFunction: 'incrementBy',
|
|
29
|
+
// abi: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"incrementAmount","type":"uint256"}],"name":"CounterIncremented","type":"event"},{"inputs":[],"name":"getCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"incrementBy","outputs":[],"stateMutability":"nonpayable","type":"function"}]',
|
|
30
|
+
// isImua: true,
|
|
31
|
+
// arguments: ['3'],
|
|
32
|
+
// dynamicArgumentsScriptUrl: '',
|
|
33
|
+
// };
|
|
34
|
+
// Example: Condition-based static job
|
|
35
|
+
const jobInput = {
|
|
36
|
+
jobType: types_1.JobType.Condition,
|
|
37
|
+
argType: types_1.ArgType.Static,
|
|
38
|
+
userAddress: '0x7Db951c0E6D8906687B459427eA3F3F2b456473B',
|
|
39
|
+
etherBalance: 50000000000000000,
|
|
40
|
+
tokenBalance: 50000000000000000000,
|
|
41
|
+
jobTitle: 'SDK Test Condition Job',
|
|
42
|
+
timeFrame: 48,
|
|
43
|
+
conditionType: 'greaterThan',
|
|
44
|
+
upperLimit: 100,
|
|
45
|
+
lowerLimit: 10,
|
|
46
|
+
valueSourceType: 'http',
|
|
47
|
+
valueSourceUrl: 'https://api.example.com/value',
|
|
48
|
+
timezone: 'Asia/Calcutta',
|
|
49
|
+
recurring: false,
|
|
50
|
+
jobCostPrediction: 0.1,
|
|
51
|
+
createdChainId: '11155420',
|
|
52
|
+
targetChainId: '11155420',
|
|
53
|
+
targetContractAddress: '0x49a81A591afdDEF973e6e49aaEa7d76943ef234C',
|
|
54
|
+
targetFunction: 'incrementBy',
|
|
55
|
+
abi: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"incrementAmount","type":"uint256"}],"name":"CounterIncremented","type":"event"},{"inputs":[],"name":"getCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"incrementBy","outputs":[],"stateMutability":"nonpayable","type":"function"}]',
|
|
56
|
+
isImua: true,
|
|
57
|
+
arguments: ['5'],
|
|
58
|
+
dynamicArgumentsScriptUrl: '',
|
|
59
|
+
};
|
|
60
|
+
// To test, you can call createJob with this input as well:
|
|
61
|
+
// const conditionResult = await createJob(client, {
|
|
62
|
+
// jobInput: conditionJobInput,
|
|
63
|
+
// signer,
|
|
64
|
+
// });
|
|
65
|
+
// console.log('Condition Job creation result:', conditionResult);
|
|
66
|
+
// These would typically come from env/config/user input
|
|
67
|
+
const privateKey = '';
|
|
68
|
+
const providerUrl = 'https://opt-sepolia.g.alchemy.com/v2/m7cIDXzatSUYoiuE1xSY_TnUrK5j9-1W';
|
|
69
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(providerUrl);
|
|
70
|
+
const signer = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
71
|
+
const result = await (0, src_1.createJob)(client, {
|
|
72
|
+
jobInput,
|
|
73
|
+
signer,
|
|
74
|
+
});
|
|
75
|
+
console.log('Job creation result:', result);
|
|
76
|
+
}
|
|
77
|
+
main().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// sdk-triggerx/test/deleteJob.test.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const client_1 = require("../src/client");
|
|
5
|
+
const deleteJob_1 = require("../src/api/deleteJob");
|
|
6
|
+
async function main() {
|
|
7
|
+
// The user should provide their actual API key here
|
|
8
|
+
const apiKey = 'TGRX-ece02db8-f676-4a9f-a4f8-a95f59e755d8';
|
|
9
|
+
// Create the client with the API key
|
|
10
|
+
const client = new client_1.TriggerXClient(apiKey);
|
|
11
|
+
// Specify the job ID to delete
|
|
12
|
+
const jobId = 'YOUR_JOB_ID'; // Replace with an actual job ID for testing
|
|
13
|
+
try {
|
|
14
|
+
// Call the SDK function to delete the job
|
|
15
|
+
await (0, deleteJob_1.deleteJob)(client, jobId);
|
|
16
|
+
console.log(`Job with ID ${jobId} deleted successfully.`);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('Error deleting job:', error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
main().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const errors_1 = require("../src/utils/errors");
|
|
4
|
+
describe('wrapError', () => {
|
|
5
|
+
it('should wrap a standard error', () => {
|
|
6
|
+
const err = new Error('fail');
|
|
7
|
+
const wrapped = (0, errors_1.wrapError)(err);
|
|
8
|
+
expect(wrapped).toBeInstanceOf(Error);
|
|
9
|
+
expect(wrapped.message).toBe('fail');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// sdk-triggerx/test/getJobDataById.test.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const client_1 = require("../src/client");
|
|
5
|
+
const getJobDataById_1 = require("../src/api/getJobDataById");
|
|
6
|
+
async function main() {
|
|
7
|
+
// The user should provide their actual API key here
|
|
8
|
+
const apiKey = 'TGRX-ece02db8-f676-4a9f-a4f8-a95f59e755d8'; // Use a mock API key
|
|
9
|
+
// Create the client with the API key
|
|
10
|
+
const client = new client_1.TriggerXClient(apiKey);
|
|
11
|
+
// Define a job ID for testing
|
|
12
|
+
const jobId = 'YOUR_JOB_ID'; // Replace with a valid job ID for testing
|
|
13
|
+
try {
|
|
14
|
+
// Call the SDK function to get job data
|
|
15
|
+
const response = await (0, getJobDataById_1.getJobDataById)(client, jobId);
|
|
16
|
+
// Log the response
|
|
17
|
+
console.log('Job Data:', response);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Error fetching job data:', error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
main().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// sdk-triggerx/test/getUserData.test.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const client_1 = require("../src/client");
|
|
5
|
+
const getUserData_1 = require("../src/api/getUserData");
|
|
6
|
+
async function main() {
|
|
7
|
+
// The user should provide their actual API key here
|
|
8
|
+
const apiKey = 'TGRX-ece02db8-f676-4a9f-a4f8-a95f59e755d8';
|
|
9
|
+
// Create the client with the API key
|
|
10
|
+
const client = new client_1.TriggerXClient(apiKey);
|
|
11
|
+
// Specify the user address to fetch data for
|
|
12
|
+
const userAddress = 'YOUR_USER_ADDRESS'; // Replace with an actual user address for testing
|
|
13
|
+
try {
|
|
14
|
+
// Call the SDK function to get user data
|
|
15
|
+
const userData = await (0, getUserData_1.getUserData)(client, userAddress);
|
|
16
|
+
console.log('User Data:', userData);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('Error fetching user data:', error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
main().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_1 = require("../src/client");
|
|
4
|
+
const getjob_1 = require("../src/api/getjob");
|
|
5
|
+
async function main() {
|
|
6
|
+
// The user should provide their actual API key here
|
|
7
|
+
const apiKey = 'TGRX-ece02db8-f676-4a9f-a4f8-a95f59e755d8';
|
|
8
|
+
// Create the client with the API key
|
|
9
|
+
const client = new client_1.TriggerXClient(apiKey);
|
|
10
|
+
// Call the SDK function to get job data
|
|
11
|
+
const response = await (0, getjob_1.getJobData)(client);
|
|
12
|
+
if (response.success) {
|
|
13
|
+
// Access job_data from the response
|
|
14
|
+
const jobData = response.jobs; // Use optional chaining in case job_data is undefined
|
|
15
|
+
console.log('Job Data:', jobData);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.error('Error fetching jobs:', response.error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
main().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const topupTg_1 = require("../src/api/topupTg");
|
|
5
|
+
const checkTgBalance_1 = require("../src/api/checkTgBalance");
|
|
6
|
+
const withdrawTg_1 = require("../src/api/withdrawTg");
|
|
7
|
+
async function main() {
|
|
8
|
+
// Replace with your actual provider URL and private key
|
|
9
|
+
const providerUrl = 'https://opt-sepolia.g.alchemy.com/v2/m7cIDXzatSUYoiuE1xSY_TnUrK5j9-1W';
|
|
10
|
+
const privateKey = ''; // Replace with your private key
|
|
11
|
+
const provider = new ethers_1.ethers.JsonRpcProvider(providerUrl);
|
|
12
|
+
const signer = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
13
|
+
// Test the checkTgBalance function
|
|
14
|
+
try {
|
|
15
|
+
const balance = await (0, checkTgBalance_1.checkTgBalance)(signer);
|
|
16
|
+
console.log('TG Balance:', balance);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('Error checking TG balance:', error);
|
|
20
|
+
}
|
|
21
|
+
// Test the topupTg function
|
|
22
|
+
const tgAmountToTopup = 1; // Amount of TG to purchase
|
|
23
|
+
try {
|
|
24
|
+
const txTopup = await (0, topupTg_1.topupTg)(tgAmountToTopup, signer);
|
|
25
|
+
console.log('Topup Transaction:', txTopup);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error during topup:', error);
|
|
29
|
+
}
|
|
30
|
+
// Test the checkTgBalance function
|
|
31
|
+
try {
|
|
32
|
+
const balance = await (0, checkTgBalance_1.checkTgBalance)(signer);
|
|
33
|
+
console.log('TG Balance:', balance);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error checking TG balance:', error);
|
|
37
|
+
}
|
|
38
|
+
// Test the withdrawTg function
|
|
39
|
+
const tgAmountToWithdraw = '1'; // Amount of TG to withdraw
|
|
40
|
+
try {
|
|
41
|
+
const txWithdraw = await (0, withdrawTg_1.withdrawTg)(signer, tgAmountToWithdraw);
|
|
42
|
+
console.log('Withdraw Transaction:', txWithdraw);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Error during withdrawal:', error);
|
|
46
|
+
}
|
|
47
|
+
// Test the checkTgBalance function
|
|
48
|
+
try {
|
|
49
|
+
const balance = await (0, checkTgBalance_1.checkTgBalance)(signer);
|
|
50
|
+
console.log('TG Balance:', balance);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Error checking TG balance:', error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
main().catch(console.error);
|