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.
Files changed (105) hide show
  1. package/.eslintrc.json +16 -0
  2. package/README.md +249 -0
  3. package/dist/api/jobs.d.ts +15 -0
  4. package/dist/api/jobs.js +138 -0
  5. package/dist/api/tasks.d.ts +4 -0
  6. package/dist/api/tasks.js +13 -0
  7. package/dist/client.d.ts +7 -0
  8. package/dist/client.js +27 -0
  9. package/dist/config.d.ts +6 -0
  10. package/dist/config.js +15 -0
  11. package/dist/contracts/JobRegistry.d.ts +12 -0
  12. package/dist/contracts/JobRegistry.js +26 -0
  13. package/dist/contracts/TriggerXContract.d.ts +6 -0
  14. package/dist/contracts/TriggerXContract.js +14 -0
  15. package/dist/contracts/abi/JobRegistry.json +1554 -0
  16. package/dist/contracts/index.d.ts +1 -0
  17. package/dist/contracts/index.js +17 -0
  18. package/dist/index.d.ts +8 -0
  19. package/dist/index.js +26 -0
  20. package/dist/src/api/checkTgBalance.d.ts +2 -0
  21. package/dist/src/api/checkTgBalance.js +35 -0
  22. package/dist/src/api/deleteJob.d.ts +2 -0
  23. package/dist/src/api/deleteJob.js +20 -0
  24. package/dist/src/api/getJobDataById.d.ts +3 -0
  25. package/dist/src/api/getJobDataById.js +21 -0
  26. package/dist/src/api/getUserData.d.ts +3 -0
  27. package/dist/src/api/getUserData.js +21 -0
  28. package/dist/src/api/getjob.d.ts +8 -0
  29. package/dist/src/api/getjob.js +23 -0
  30. package/dist/src/api/jobs.d.ts +18 -0
  31. package/dist/src/api/jobs.js +270 -0
  32. package/dist/src/api/tasks.d.ts +4 -0
  33. package/dist/src/api/tasks.js +13 -0
  34. package/dist/src/api/topupTg.d.ts +2 -0
  35. package/dist/src/api/topupTg.js +19 -0
  36. package/dist/src/api/withdrawTg.d.ts +8 -0
  37. package/dist/src/api/withdrawTg.js +27 -0
  38. package/dist/src/client.d.ts +10 -0
  39. package/dist/src/client.js +37 -0
  40. package/dist/src/config.d.ts +6 -0
  41. package/dist/src/config.js +15 -0
  42. package/dist/src/contracts/JobRegistry.d.ts +12 -0
  43. package/dist/src/contracts/JobRegistry.js +24 -0
  44. package/dist/src/contracts/TriggerXContract.d.ts +6 -0
  45. package/dist/src/contracts/TriggerXContract.js +14 -0
  46. package/dist/src/contracts/abi/GasRegistry.json +607 -0
  47. package/dist/src/contracts/abi/JobRegistry.json +1554 -0
  48. package/dist/src/contracts/index.d.ts +1 -0
  49. package/dist/src/contracts/index.js +17 -0
  50. package/dist/src/index.d.ts +7 -0
  51. package/dist/src/index.js +25 -0
  52. package/dist/src/types.d.ts +246 -0
  53. package/dist/src/types.js +15 -0
  54. package/dist/src/utils/errors.d.ts +4 -0
  55. package/dist/src/utils/errors.js +17 -0
  56. package/dist/test/createJobExample.d.ts +1 -0
  57. package/dist/test/createJobExample.js +77 -0
  58. package/dist/test/deleteJob.test.d.ts +1 -0
  59. package/dist/test/deleteJob.test.js +22 -0
  60. package/dist/test/example.test.d.ts +1 -0
  61. package/dist/test/example.test.js +11 -0
  62. package/dist/test/getJobDataById.test.d.ts +1 -0
  63. package/dist/test/getJobDataById.test.js +23 -0
  64. package/dist/test/getUserData.test.d.ts +1 -0
  65. package/dist/test/getUserData.test.js +22 -0
  66. package/dist/test/getjob.test.d.ts +1 -0
  67. package/dist/test/getjob.test.js +21 -0
  68. package/dist/test/testTgFunctions.d.ts +1 -0
  69. package/dist/test/testTgFunctions.js +56 -0
  70. package/dist/types.d.ts +134 -0
  71. package/dist/types.js +15 -0
  72. package/dist/utils/errors.d.ts +4 -0
  73. package/dist/utils/errors.js +17 -0
  74. package/jest.config.js +7 -0
  75. package/package.json +32 -0
  76. package/scripts/deploy.ts +9 -0
  77. package/src/api/checkTgBalance.ts +27 -0
  78. package/src/api/deleteJob.ts +22 -0
  79. package/src/api/getJobDataById.ts +24 -0
  80. package/src/api/getUserData.ts +24 -0
  81. package/src/api/getjob.ts +26 -0
  82. package/src/api/jobs.ts +303 -0
  83. package/src/api/topupTg.ts +17 -0
  84. package/src/api/withdrawTg.ts +25 -0
  85. package/src/client.ts +38 -0
  86. package/src/config.ts +16 -0
  87. package/src/contracts/JobRegistry.ts +45 -0
  88. package/src/contracts/TriggerXContract.ts +14 -0
  89. package/src/contracts/abi/.gitkeep +1 -0
  90. package/src/contracts/abi/GasRegistry.json +607 -0
  91. package/src/contracts/abi/JobRegistry.json +1554 -0
  92. package/src/contracts/index.ts +1 -0
  93. package/src/index.ts +7 -0
  94. package/src/types.ts +262 -0
  95. package/src/utils/errors.ts +13 -0
  96. package/test/createJobExample.ts +84 -0
  97. package/test/deleteJob.test.ts +25 -0
  98. package/test/example.test.d.ts +1 -0
  99. package/test/example.test.js +11 -0
  100. package/test/example.test.ts +10 -0
  101. package/test/getJobDataById.test.ts +27 -0
  102. package/test/getUserData.test.ts +25 -0
  103. package/test/getjob.test.ts +23 -0
  104. package/test/testTgFunctions.ts +56 -0
  105. package/tsconfig.json +16 -0
@@ -0,0 +1,12 @@
1
+ import { Signer } from 'ethers';
2
+ export interface CreateJobOnChainParams {
3
+ jobTitle: string;
4
+ jobType: number;
5
+ timeFrame: number;
6
+ targetContractAddress: string;
7
+ encodedData: string;
8
+ contractAddress: string;
9
+ abi: any;
10
+ signer: Signer;
11
+ }
12
+ export declare function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAddress, encodedData, contractAddress, abi, signer, }: CreateJobOnChainParams): Promise<string>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createJobOnChain = createJobOnChain;
4
+ const ethers_1 = require("ethers");
5
+ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAddress, encodedData, contractAddress, abi, signer, }) {
6
+ const contract = new ethers_1.ethers.Contract(contractAddress, abi, signer);
7
+ const tx = await contract.createJob(jobTitle, jobType, timeFrame, targetContractAddress, encodedData);
8
+ const receipt = await tx.wait();
9
+ // Try to extract jobId from event logs (assume event is JobCreated(jobId,...))
10
+ const event = receipt.logs
11
+ .map((log) => {
12
+ try {
13
+ return contract.interface.parseLog(log);
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ })
19
+ .find((e) => e && e.name === 'JobCreated');
20
+ if (event && event.args && event.args[0]) {
21
+ return event.args[0].toString();
22
+ }
23
+ throw new Error('Job ID not found in contract events');
24
+ }
@@ -0,0 +1,6 @@
1
+ import { Provider } from 'ethers';
2
+ export declare class TriggerXContract {
3
+ private contract;
4
+ constructor(address: string, abi: any, provider: Provider);
5
+ getTaskCount(): Promise<number>;
6
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriggerXContract = void 0;
4
+ const ethers_1 = require("ethers");
5
+ class TriggerXContract {
6
+ constructor(address, abi, provider) {
7
+ this.contract = new ethers_1.Contract(address, abi, provider);
8
+ }
9
+ async getTaskCount() {
10
+ // Placeholder for contract call
11
+ return this.contract.taskCount();
12
+ }
13
+ }
14
+ exports.TriggerXContract = TriggerXContract;
@@ -0,0 +1,607 @@
1
+ [
2
+ {
3
+ "inputs": [],
4
+ "stateMutability": "nonpayable",
5
+ "type": "constructor"
6
+ },
7
+ {
8
+ "inputs": [
9
+ {
10
+ "internalType": "address",
11
+ "name": "target",
12
+ "type": "address"
13
+ }
14
+ ],
15
+ "name": "AddressEmptyCode",
16
+ "type": "error"
17
+ },
18
+ {
19
+ "inputs": [
20
+ {
21
+ "internalType": "address",
22
+ "name": "implementation",
23
+ "type": "address"
24
+ }
25
+ ],
26
+ "name": "ERC1967InvalidImplementation",
27
+ "type": "error"
28
+ },
29
+ {
30
+ "inputs": [],
31
+ "name": "ERC1967NonPayable",
32
+ "type": "error"
33
+ },
34
+ {
35
+ "inputs": [],
36
+ "name": "FailedCall",
37
+ "type": "error"
38
+ },
39
+ {
40
+ "inputs": [],
41
+ "name": "InvalidInitialization",
42
+ "type": "error"
43
+ },
44
+ {
45
+ "inputs": [],
46
+ "name": "NotInitializing",
47
+ "type": "error"
48
+ },
49
+ {
50
+ "inputs": [
51
+ {
52
+ "internalType": "address",
53
+ "name": "owner",
54
+ "type": "address"
55
+ }
56
+ ],
57
+ "name": "OwnableInvalidOwner",
58
+ "type": "error"
59
+ },
60
+ {
61
+ "inputs": [
62
+ {
63
+ "internalType": "address",
64
+ "name": "account",
65
+ "type": "address"
66
+ }
67
+ ],
68
+ "name": "OwnableUnauthorizedAccount",
69
+ "type": "error"
70
+ },
71
+ {
72
+ "inputs": [],
73
+ "name": "ReentrancyGuardReentrantCall",
74
+ "type": "error"
75
+ },
76
+ {
77
+ "inputs": [],
78
+ "name": "UUPSUnauthorizedCallContext",
79
+ "type": "error"
80
+ },
81
+ {
82
+ "inputs": [
83
+ {
84
+ "internalType": "bytes32",
85
+ "name": "slot",
86
+ "type": "bytes32"
87
+ }
88
+ ],
89
+ "name": "UUPSUnsupportedProxiableUUID",
90
+ "type": "error"
91
+ },
92
+ {
93
+ "anonymous": false,
94
+ "inputs": [
95
+ {
96
+ "indexed": true,
97
+ "internalType": "address",
98
+ "name": "owner",
99
+ "type": "address"
100
+ },
101
+ {
102
+ "indexed": false,
103
+ "internalType": "uint256",
104
+ "name": "amount",
105
+ "type": "uint256"
106
+ },
107
+ {
108
+ "indexed": false,
109
+ "internalType": "string",
110
+ "name": "reason",
111
+ "type": "string"
112
+ }
113
+ ],
114
+ "name": "ETHWithdrawn",
115
+ "type": "event"
116
+ },
117
+ {
118
+ "anonymous": false,
119
+ "inputs": [
120
+ {
121
+ "indexed": false,
122
+ "internalType": "uint64",
123
+ "name": "version",
124
+ "type": "uint64"
125
+ }
126
+ ],
127
+ "name": "Initialized",
128
+ "type": "event"
129
+ },
130
+ {
131
+ "anonymous": false,
132
+ "inputs": [
133
+ {
134
+ "indexed": true,
135
+ "internalType": "address",
136
+ "name": "previousOwner",
137
+ "type": "address"
138
+ },
139
+ {
140
+ "indexed": true,
141
+ "internalType": "address",
142
+ "name": "newOwner",
143
+ "type": "address"
144
+ }
145
+ ],
146
+ "name": "OwnershipTransferred",
147
+ "type": "event"
148
+ },
149
+ {
150
+ "anonymous": false,
151
+ "inputs": [
152
+ {
153
+ "indexed": true,
154
+ "internalType": "address",
155
+ "name": "user",
156
+ "type": "address"
157
+ },
158
+ {
159
+ "indexed": false,
160
+ "internalType": "uint256",
161
+ "name": "reward",
162
+ "type": "uint256"
163
+ }
164
+ ],
165
+ "name": "RewardClaimed",
166
+ "type": "event"
167
+ },
168
+ {
169
+ "anonymous": false,
170
+ "inputs": [
171
+ {
172
+ "indexed": true,
173
+ "internalType": "address",
174
+ "name": "user",
175
+ "type": "address"
176
+ },
177
+ {
178
+ "indexed": false,
179
+ "internalType": "uint256",
180
+ "name": "amount",
181
+ "type": "uint256"
182
+ }
183
+ ],
184
+ "name": "TGBalanceDeducted",
185
+ "type": "event"
186
+ },
187
+ {
188
+ "anonymous": false,
189
+ "inputs": [
190
+ {
191
+ "indexed": true,
192
+ "internalType": "address",
193
+ "name": "user",
194
+ "type": "address"
195
+ },
196
+ {
197
+ "indexed": false,
198
+ "internalType": "uint256",
199
+ "name": "amount",
200
+ "type": "uint256"
201
+ },
202
+ {
203
+ "indexed": false,
204
+ "internalType": "string",
205
+ "name": "reason",
206
+ "type": "string"
207
+ }
208
+ ],
209
+ "name": "TGBalanceRemoved",
210
+ "type": "event"
211
+ },
212
+ {
213
+ "anonymous": false,
214
+ "inputs": [
215
+ {
216
+ "indexed": true,
217
+ "internalType": "address",
218
+ "name": "user",
219
+ "type": "address"
220
+ },
221
+ {
222
+ "indexed": false,
223
+ "internalType": "uint256",
224
+ "name": "amount",
225
+ "type": "uint256"
226
+ }
227
+ ],
228
+ "name": "TGClaimed",
229
+ "type": "event"
230
+ },
231
+ {
232
+ "anonymous": false,
233
+ "inputs": [
234
+ {
235
+ "indexed": false,
236
+ "internalType": "uint256",
237
+ "name": "tgPerEth",
238
+ "type": "uint256"
239
+ }
240
+ ],
241
+ "name": "TGPerETHUpdated",
242
+ "type": "event"
243
+ },
244
+ {
245
+ "anonymous": false,
246
+ "inputs": [
247
+ {
248
+ "indexed": true,
249
+ "internalType": "address",
250
+ "name": "user",
251
+ "type": "address"
252
+ },
253
+ {
254
+ "indexed": false,
255
+ "internalType": "uint256",
256
+ "name": "ethAmount",
257
+ "type": "uint256"
258
+ },
259
+ {
260
+ "indexed": false,
261
+ "internalType": "uint256",
262
+ "name": "tgAmount",
263
+ "type": "uint256"
264
+ }
265
+ ],
266
+ "name": "TGPurchased",
267
+ "type": "event"
268
+ },
269
+ {
270
+ "anonymous": false,
271
+ "inputs": [
272
+ {
273
+ "indexed": true,
274
+ "internalType": "address",
275
+ "name": "user",
276
+ "type": "address"
277
+ },
278
+ {
279
+ "indexed": false,
280
+ "internalType": "uint256",
281
+ "name": "amount",
282
+ "type": "uint256"
283
+ }
284
+ ],
285
+ "name": "TGRefunded",
286
+ "type": "event"
287
+ },
288
+ {
289
+ "anonymous": false,
290
+ "inputs": [
291
+ {
292
+ "indexed": true,
293
+ "internalType": "address",
294
+ "name": "user",
295
+ "type": "address"
296
+ },
297
+ {
298
+ "indexed": true,
299
+ "internalType": "address",
300
+ "name": "keeper",
301
+ "type": "address"
302
+ },
303
+ {
304
+ "indexed": false,
305
+ "internalType": "uint256",
306
+ "name": "amount",
307
+ "type": "uint256"
308
+ }
309
+ ],
310
+ "name": "TGTransferred",
311
+ "type": "event"
312
+ },
313
+ {
314
+ "anonymous": false,
315
+ "inputs": [
316
+ {
317
+ "indexed": true,
318
+ "internalType": "address",
319
+ "name": "user",
320
+ "type": "address"
321
+ },
322
+ {
323
+ "indexed": false,
324
+ "internalType": "uint256",
325
+ "name": "amount",
326
+ "type": "uint256"
327
+ }
328
+ ],
329
+ "name": "TaskFeeClaimed",
330
+ "type": "event"
331
+ },
332
+ {
333
+ "anonymous": false,
334
+ "inputs": [
335
+ {
336
+ "indexed": true,
337
+ "internalType": "address",
338
+ "name": "implementation",
339
+ "type": "address"
340
+ }
341
+ ],
342
+ "name": "Upgraded",
343
+ "type": "event"
344
+ },
345
+ {
346
+ "inputs": [],
347
+ "name": "TG_PER_ETH",
348
+ "outputs": [
349
+ {
350
+ "internalType": "uint256",
351
+ "name": "",
352
+ "type": "uint256"
353
+ }
354
+ ],
355
+ "stateMutability": "view",
356
+ "type": "function"
357
+ },
358
+ {
359
+ "inputs": [],
360
+ "name": "UPGRADE_INTERFACE_VERSION",
361
+ "outputs": [
362
+ {
363
+ "internalType": "string",
364
+ "name": "",
365
+ "type": "string"
366
+ }
367
+ ],
368
+ "stateMutability": "view",
369
+ "type": "function"
370
+ },
371
+ {
372
+ "inputs": [
373
+ {
374
+ "internalType": "address",
375
+ "name": "",
376
+ "type": "address"
377
+ }
378
+ ],
379
+ "name": "balances",
380
+ "outputs": [
381
+ {
382
+ "internalType": "uint256",
383
+ "name": "ethSpent",
384
+ "type": "uint256"
385
+ },
386
+ {
387
+ "internalType": "uint256",
388
+ "name": "TGbalance",
389
+ "type": "uint256"
390
+ }
391
+ ],
392
+ "stateMutability": "view",
393
+ "type": "function"
394
+ },
395
+ {
396
+ "inputs": [
397
+ {
398
+ "internalType": "uint256",
399
+ "name": "tgAmount",
400
+ "type": "uint256"
401
+ }
402
+ ],
403
+ "name": "claimETHForTG",
404
+ "outputs": [],
405
+ "stateMutability": "nonpayable",
406
+ "type": "function"
407
+ },
408
+ {
409
+ "inputs": [
410
+ {
411
+ "internalType": "address",
412
+ "name": "user",
413
+ "type": "address"
414
+ },
415
+ {
416
+ "internalType": "uint256",
417
+ "name": "tgAmount",
418
+ "type": "uint256"
419
+ }
420
+ ],
421
+ "name": "deductTGBalance",
422
+ "outputs": [],
423
+ "stateMutability": "nonpayable",
424
+ "type": "function"
425
+ },
426
+ {
427
+ "inputs": [
428
+ {
429
+ "internalType": "address",
430
+ "name": "user",
431
+ "type": "address"
432
+ }
433
+ ],
434
+ "name": "getBalance",
435
+ "outputs": [
436
+ {
437
+ "internalType": "uint256",
438
+ "name": "ethSpent",
439
+ "type": "uint256"
440
+ },
441
+ {
442
+ "internalType": "uint256",
443
+ "name": "tgBalance",
444
+ "type": "uint256"
445
+ }
446
+ ],
447
+ "stateMutability": "view",
448
+ "type": "function"
449
+ },
450
+ {
451
+ "inputs": [
452
+ {
453
+ "internalType": "address",
454
+ "name": "initialOwner",
455
+ "type": "address"
456
+ },
457
+ {
458
+ "internalType": "address",
459
+ "name": "_operator",
460
+ "type": "address"
461
+ },
462
+ {
463
+ "internalType": "uint256",
464
+ "name": "_tgPerEth",
465
+ "type": "uint256"
466
+ }
467
+ ],
468
+ "name": "initialize",
469
+ "outputs": [],
470
+ "stateMutability": "nonpayable",
471
+ "type": "function"
472
+ },
473
+ {
474
+ "inputs": [],
475
+ "name": "operatorRole",
476
+ "outputs": [
477
+ {
478
+ "internalType": "address",
479
+ "name": "",
480
+ "type": "address"
481
+ }
482
+ ],
483
+ "stateMutability": "view",
484
+ "type": "function"
485
+ },
486
+ {
487
+ "inputs": [],
488
+ "name": "owner",
489
+ "outputs": [
490
+ {
491
+ "internalType": "address",
492
+ "name": "",
493
+ "type": "address"
494
+ }
495
+ ],
496
+ "stateMutability": "view",
497
+ "type": "function"
498
+ },
499
+ {
500
+ "inputs": [],
501
+ "name": "proxiableUUID",
502
+ "outputs": [
503
+ {
504
+ "internalType": "bytes32",
505
+ "name": "",
506
+ "type": "bytes32"
507
+ }
508
+ ],
509
+ "stateMutability": "view",
510
+ "type": "function"
511
+ },
512
+ {
513
+ "inputs": [
514
+ {
515
+ "internalType": "uint256",
516
+ "name": "ethAmount",
517
+ "type": "uint256"
518
+ }
519
+ ],
520
+ "name": "purchaseTG",
521
+ "outputs": [],
522
+ "stateMutability": "payable",
523
+ "type": "function"
524
+ },
525
+ {
526
+ "inputs": [],
527
+ "name": "renounceOwnership",
528
+ "outputs": [],
529
+ "stateMutability": "nonpayable",
530
+ "type": "function"
531
+ },
532
+ {
533
+ "inputs": [
534
+ {
535
+ "internalType": "address",
536
+ "name": "_operatorRole",
537
+ "type": "address"
538
+ }
539
+ ],
540
+ "name": "setOperator",
541
+ "outputs": [],
542
+ "stateMutability": "nonpayable",
543
+ "type": "function"
544
+ },
545
+ {
546
+ "inputs": [
547
+ {
548
+ "internalType": "uint256",
549
+ "name": "_tgPerEth",
550
+ "type": "uint256"
551
+ }
552
+ ],
553
+ "name": "setTGPerETH",
554
+ "outputs": [],
555
+ "stateMutability": "nonpayable",
556
+ "type": "function"
557
+ },
558
+ {
559
+ "inputs": [
560
+ {
561
+ "internalType": "address",
562
+ "name": "newOwner",
563
+ "type": "address"
564
+ }
565
+ ],
566
+ "name": "transferOwnership",
567
+ "outputs": [],
568
+ "stateMutability": "nonpayable",
569
+ "type": "function"
570
+ },
571
+ {
572
+ "inputs": [
573
+ {
574
+ "internalType": "address",
575
+ "name": "newImplementation",
576
+ "type": "address"
577
+ },
578
+ {
579
+ "internalType": "bytes",
580
+ "name": "data",
581
+ "type": "bytes"
582
+ }
583
+ ],
584
+ "name": "upgradeToAndCall",
585
+ "outputs": [],
586
+ "stateMutability": "payable",
587
+ "type": "function"
588
+ },
589
+ {
590
+ "inputs": [
591
+ {
592
+ "internalType": "uint256",
593
+ "name": "amount",
594
+ "type": "uint256"
595
+ },
596
+ {
597
+ "internalType": "string",
598
+ "name": "reason",
599
+ "type": "string"
600
+ }
601
+ ],
602
+ "name": "withdrawETH",
603
+ "outputs": [],
604
+ "stateMutability": "nonpayable",
605
+ "type": "function"
606
+ }
607
+ ]