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