sdk-triggerx 0.1.5 → 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.
Files changed (94) hide show
  1. package/dist/api/jobs.d.ts +21 -9
  2. package/dist/api/jobs.js +195 -39
  3. package/dist/client.d.ts +4 -1
  4. package/dist/client.js +13 -3
  5. package/dist/contracts/JobRegistry.d.ts +3 -3
  6. package/dist/contracts/JobRegistry.js +2 -4
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.js +0 -1
  9. package/dist/types.d.ts +118 -20
  10. package/package.json +14 -10
  11. package/.eslintrc.json +0 -16
  12. package/dist/api/tasks.d.ts +0 -4
  13. package/dist/api/tasks.js +0 -13
  14. package/dist/src/api/jobs.d.ts +0 -27
  15. package/dist/src/api/jobs.js +0 -297
  16. package/dist/src/api/tasks.d.ts +0 -4
  17. package/dist/src/api/tasks.js +0 -13
  18. package/dist/src/client.d.ts +0 -10
  19. package/dist/src/client.js +0 -37
  20. package/dist/src/config.d.ts +0 -6
  21. package/dist/src/config.js +0 -10
  22. package/dist/src/contracts/JobRegistry.d.ts +0 -12
  23. package/dist/src/contracts/JobRegistry.js +0 -24
  24. package/dist/src/contracts/TriggerXContract.d.ts +0 -6
  25. package/dist/src/contracts/TriggerXContract.js +0 -14
  26. package/dist/src/contracts/abi/JobRegistry.json +0 -1554
  27. package/dist/src/contracts/index.d.ts +0 -1
  28. package/dist/src/contracts/index.js +0 -17
  29. package/dist/src/index.d.ts +0 -7
  30. package/dist/src/index.js +0 -25
  31. package/dist/src/types.d.ts +0 -232
  32. package/dist/src/types.js +0 -15
  33. package/dist/src/utils/errors.d.ts +0 -4
  34. package/dist/src/utils/errors.js +0 -17
  35. package/dist/test/createJobExample.d.ts +0 -1
  36. package/dist/test/createJobExample.js +0 -84
  37. package/dist/test/deleteJob.test.d.ts +0 -1
  38. package/dist/test/deleteJob.test.js +0 -22
  39. package/dist/test/example.test.d.ts +0 -1
  40. package/dist/test/example.test.js +0 -11
  41. package/dist/test/getJobDataById.test.d.ts +0 -1
  42. package/dist/test/getJobDataById.test.js +0 -23
  43. package/dist/test/getUserData.test.d.ts +0 -1
  44. package/dist/test/getUserData.test.js +0 -22
  45. package/dist/test/getjob.test.d.ts +0 -1
  46. package/dist/test/getjob.test.js +0 -21
  47. package/dist/test/testTgFunctions.d.ts +0 -1
  48. package/dist/test/testTgFunctions.js +0 -56
  49. package/jest.config.js +0 -7
  50. package/scripts/deploy.ts +0 -9
  51. package/src/api/checkTgBalance.ts +0 -27
  52. package/src/api/deleteJob.ts +0 -22
  53. package/src/api/getJobDataById.ts +0 -24
  54. package/src/api/getUserData.ts +0 -24
  55. package/src/api/getjob.ts +0 -26
  56. package/src/api/jobs.ts +0 -352
  57. package/src/api/topupTg.ts +0 -17
  58. package/src/api/withdrawTg.ts +0 -25
  59. package/src/client.ts +0 -38
  60. package/src/config.ts +0 -13
  61. package/src/contracts/JobRegistry.ts +0 -45
  62. package/src/contracts/TriggerXContract.ts +0 -14
  63. package/src/contracts/abi/.gitkeep +0 -1
  64. package/src/contracts/abi/GasRegistry.json +0 -607
  65. package/src/contracts/abi/JobRegistry.json +0 -1554
  66. package/src/contracts/index.ts +0 -1
  67. package/src/index.ts +0 -7
  68. package/src/types.ts +0 -249
  69. package/src/utils/errors.ts +0 -13
  70. package/test/createJobExample.ts +0 -91
  71. package/test/deleteJob.test.ts +0 -25
  72. package/test/example.test.d.ts +0 -1
  73. package/test/example.test.js +0 -11
  74. package/test/example.test.ts +0 -10
  75. package/test/getJobDataById.test.ts +0 -27
  76. package/test/getUserData.test.ts +0 -25
  77. package/test/getjob.test.ts +0 -23
  78. package/test/testTgFunctions.ts +0 -56
  79. package/tsconfig.json +0 -16
  80. /package/dist/{src/api → api}/checkTgBalance.d.ts +0 -0
  81. /package/dist/{src/api → api}/checkTgBalance.js +0 -0
  82. /package/dist/{src/api → api}/deleteJob.d.ts +0 -0
  83. /package/dist/{src/api → api}/deleteJob.js +0 -0
  84. /package/dist/{src/api → api}/getJobDataById.d.ts +0 -0
  85. /package/dist/{src/api → api}/getJobDataById.js +0 -0
  86. /package/dist/{src/api → api}/getUserData.d.ts +0 -0
  87. /package/dist/{src/api → api}/getUserData.js +0 -0
  88. /package/dist/{src/api → api}/getjob.d.ts +0 -0
  89. /package/dist/{src/api → api}/getjob.js +0 -0
  90. /package/dist/{src/api → api}/topupTg.d.ts +0 -0
  91. /package/dist/{src/api → api}/topupTg.js +0 -0
  92. /package/dist/{src/api → api}/withdrawTg.d.ts +0 -0
  93. /package/dist/{src/api → api}/withdrawTg.js +0 -0
  94. /package/dist/{src/contracts → contracts}/abi/GasRegistry.json +0 -0
@@ -1 +0,0 @@
1
- export * from './TriggerXContract';
@@ -1,17 +0,0 @@
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);
@@ -1,7 +0,0 @@
1
- export * from './client';
2
- export * from './config';
3
- export * from './types';
4
- export * from './api/jobs';
5
- export { createJobOnChain } from './contracts/JobRegistry';
6
- export * from './contracts';
7
- export * from './utils/errors';
package/dist/src/index.js DELETED
@@ -1,25 +0,0 @@
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);
@@ -1,232 +0,0 @@
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
- jobTitle: string;
32
- timeFrame: number;
33
- scheduleType: 'cron' | 'specific' | 'interval';
34
- timeInterval?: number;
35
- cronExpression?: string;
36
- specificSchedule?: string;
37
- timezone: string;
38
- chainId: string;
39
- targetContractAddress: string;
40
- targetFunction: string;
41
- abi: string;
42
- isImua?: boolean;
43
- arguments?: string[];
44
- dynamicArgumentsScriptUrl?: string;
45
- autotopupTG?: boolean;
46
- }
47
- export interface EventBasedJobInput {
48
- jobTitle: string;
49
- timeFrame: number;
50
- triggerChainId: string;
51
- triggerContractAddress: string;
52
- triggerEvent: string;
53
- timezone: string;
54
- recurring?: boolean;
55
- chainId: string;
56
- targetContractAddress: string;
57
- targetFunction: string;
58
- abi: string;
59
- isImua?: boolean;
60
- arguments?: string[];
61
- dynamicArgumentsScriptUrl?: string;
62
- autotopupTG?: boolean;
63
- }
64
- export interface ConditionBasedJobInput {
65
- jobTitle: string;
66
- timeFrame: number;
67
- conditionType: 'greater_than' | 'less_than' | 'between' | 'equals' | 'not_equals' | 'greater_equal' | 'less_equal';
68
- upperLimit: number;
69
- lowerLimit: number;
70
- valueSourceType: string;
71
- valueSourceUrl: string;
72
- timezone: string;
73
- recurring?: boolean;
74
- chainId: string;
75
- targetContractAddress: string;
76
- targetFunction: string;
77
- abi: string;
78
- isImua?: boolean;
79
- arguments?: string[];
80
- dynamicArgumentsScriptUrl?: string;
81
- autotopupTG?: boolean;
82
- }
83
- export interface CreateJobData {
84
- job_id: string;
85
- user_address: string;
86
- ether_balance: BigInt | number;
87
- token_balance: BigInt | number;
88
- job_title: string;
89
- task_definition_id: number;
90
- custom: boolean;
91
- time_frame: number;
92
- recurring: boolean;
93
- job_cost_prediction: number;
94
- timezone: string;
95
- created_chain_id: string;
96
- schedule_type?: string;
97
- time_interval?: number;
98
- cron_expression?: string;
99
- specific_schedule?: string;
100
- trigger_chain_id?: string;
101
- trigger_contract_address?: string;
102
- trigger_event?: string;
103
- condition_type?: string;
104
- upper_limit?: number;
105
- lower_limit?: number;
106
- value_source_type?: string;
107
- value_source_url?: string;
108
- target_chain_id: string;
109
- target_contract_address: string;
110
- target_function: string;
111
- abi: string;
112
- arg_type: number;
113
- arguments?: string[];
114
- dynamic_arguments_script_url?: string;
115
- is_imua: boolean;
116
- }
117
- export interface JobResponse {
118
- success: boolean;
119
- data?: any;
120
- error?: string;
121
- }
122
- export interface JobDataAPI {
123
- job_id: string;
124
- job_title: string;
125
- task_definition_id: number;
126
- user_id: number;
127
- link_job_id: string;
128
- chain_status: number;
129
- custom: boolean;
130
- time_frame: number;
131
- recurring: boolean;
132
- status: string;
133
- job_cost_prediction: number;
134
- job_cost_actual: number;
135
- task_ids: number[];
136
- created_at: Date;
137
- updated_at: Date;
138
- last_executed_at: Date;
139
- timezone: string;
140
- is_imua: boolean;
141
- created_chain_id: string;
142
- }
143
- export interface TimeJobData {
144
- job_id: string;
145
- task_definition_id: number;
146
- expiration_time: Date;
147
- created_at: Date;
148
- updated_at: Date;
149
- time_interval: number;
150
- schedule_type: string;
151
- cron_expression: string;
152
- specific_schedule: string;
153
- timezone: string;
154
- next_execution_timestamp: Date;
155
- target_chain_id: string;
156
- target_contract_address: string;
157
- target_function: string;
158
- abi: string;
159
- arg_type: number;
160
- arguments: string[];
161
- dynamic_arguments_script_url: string;
162
- is_completed: boolean;
163
- is_active: boolean;
164
- }
165
- export interface EventJobData {
166
- job_id: string;
167
- task_definition_id: number;
168
- expiration_time: Date;
169
- created_at: Date;
170
- updated_at: Date;
171
- recurring: boolean;
172
- trigger_chain_id: string;
173
- trigger_contract_address: string;
174
- trigger_event: string;
175
- timezone: string;
176
- target_chain_id: string;
177
- target_contract_address: string;
178
- target_function: string;
179
- abi: string;
180
- arg_type: number;
181
- arguments: string[];
182
- dynamic_arguments_script_url: string;
183
- is_completed: boolean;
184
- is_active: boolean;
185
- }
186
- export interface ConditionJobData {
187
- job_id: string;
188
- task_definition_id: number;
189
- expiration_time: Date;
190
- created_at: Date;
191
- updated_at: Date;
192
- recurring: boolean;
193
- condition_type: string;
194
- upper_limit: number;
195
- lower_limit: number;
196
- value_source_type: string;
197
- value_source_url: string;
198
- timezone: string;
199
- target_chain_id: string;
200
- target_contract_address: string;
201
- target_function: string;
202
- abi: string;
203
- arg_type: number;
204
- arguments: string[];
205
- dynamic_arguments_script_url: string;
206
- is_completed: boolean;
207
- is_active: boolean;
208
- }
209
- export interface JobResponseUser {
210
- success: boolean;
211
- error?: string;
212
- jobs?: JobResponseAPI;
213
- }
214
- export interface JobResponseAPI {
215
- job_data?: JobDataAPI;
216
- time_job_data?: TimeJobData;
217
- event_job_data?: EventJobData;
218
- condition_job_data?: ConditionJobData;
219
- }
220
- export interface UserData {
221
- user_id: number;
222
- user_address: string;
223
- job_ids: string[];
224
- ether_balance: BigInt | number;
225
- token_balance: BigInt | number;
226
- user_points: number;
227
- total_jobs: number;
228
- total_tasks: number;
229
- created_at: Date;
230
- last_updated_at: Date;
231
- email: string;
232
- }
package/dist/src/types.js DELETED
@@ -1,15 +0,0 @@
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 = {}));
@@ -1,4 +0,0 @@
1
- export declare class TriggerXError extends Error {
2
- constructor(message: string);
3
- }
4
- export declare function wrapError(error: unknown): TriggerXError;
@@ -1,17 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sdk_triggerx_1 = require("sdk-triggerx");
4
- const types_1 = require("../src/types");
5
- const ethers_1 = require("ethers");
6
- async function main() {
7
- const apiKey = 'TGRX-02c20872-4bdf-4fd9-9e74-556861b16690';
8
- const client = new sdk_triggerx_1.TriggerXClient(apiKey);
9
- // Example: Time-based static job
10
- const jobInput = {
11
- jobType: types_1.JobType.Time,
12
- argType: types_1.ArgType.Static,
13
- jobTitle: 'SDK Test Time Job for mainnet',
14
- timeFrame: 36,
15
- scheduleType: 'interval',
16
- timeInterval: 33,
17
- cronExpression: '0 0 * * *',
18
- specificSchedule: '2025-01-01 00:00:00',
19
- timezone: 'Asia/Calcutta',
20
- chainId: '421614',
21
- targetContractAddress: '0xDE85FE97A73B891f12CbBF1210cc225AF332C90B',
22
- targetFunction: 'helloWorld',
23
- 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"}]',
24
- isImua: false,
25
- arguments: ['3'],
26
- dynamicArgumentsScriptUrl: '',
27
- autotopupTG: true,
28
- };
29
- // // Example: Condition-based static job
30
- // const jobInput: CreateJobInput = {
31
- // jobType: JobType.Condition,
32
- // argType: ArgType.Static,
33
- // jobTitle: 'SDK Test Condition Job',
34
- // timeFrame: 48,
35
- // conditionType: 'greaterThan',
36
- // upperLimit: 100,
37
- // lowerLimit: 10,
38
- // valueSourceType: 'http',
39
- // valueSourceUrl: 'https://api.example.com/value',
40
- // timezone: 'Asia/Calcutta',
41
- // recurring: false,
42
- // chainId: '11155420',
43
- // targetContractAddress: '0x49a81A591afdDEF973e6e49aaEa7d76943ef234C',
44
- // targetFunction: 'incrementBy',
45
- // 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"}]',
46
- // isImua: true,
47
- // arguments: ['5'],
48
- // dynamicArgumentsScriptUrl: '',
49
- // };
50
- // // Example: Event-based static job
51
- // const eventJobInput: CreateJobInput = {
52
- // jobType: JobType.Event,
53
- // argType: ArgType.Static,
54
- // jobTitle: 'SDK Test Event Job',
55
- // timeFrame: 25,
56
- // triggerChainId: '11155420',
57
- // triggerContractAddress: '0x49a81A591afdDEF973e6e49aaEa7d76943ef234C',
58
- // triggerEvent: 'CounterIncremented(uint256,uint256,uint256)',
59
- // timezone: 'Asia/Calcutta',
60
- // chainId: '11155420',
61
- // targetContractAddress: '0x49a81A591afdDEF973e6e49aaEa7d76943ef234C',
62
- // targetFunction: 'incrementBy',
63
- // 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"}]',
64
- // };
65
- // To test, you can call createJob with this input as well:
66
- // const conditionResult = await createJob(client, {
67
- // jobInput: conditionJobInput,
68
- // signer,
69
- // });
70
- // console.log('Condition Job creation result:', conditionResult);
71
- // These would typically come from env/config/user input
72
- const privateKey = '0x3bd66a68dcde6ede3b38ced6de79489a447e0fac1648b749a5001b0aa167d089';
73
- const providerUrl = 'https://arb-sepolia.g.alchemy.com/v2/zU9y7U094z69CQwzpro2mCKnW3A8gtlx';
74
- const provider = new ethers_1.ethers.JsonRpcProvider(providerUrl);
75
- const signer = new ethers_1.ethers.Wallet(privateKey, provider);
76
- console.log('Job input:', client);
77
- const result = await (0, sdk_triggerx_1.createJob)(client, {
78
- jobInput: jobInput,
79
- // @ts-ignore
80
- signer: signer,
81
- });
82
- console.log('Job creation result:', result);
83
- }
84
- main().catch(console.error);
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
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);
@@ -1 +0,0 @@
1
- export {};
@@ -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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
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);
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
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);
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
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);
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +0,0 @@
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);
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- testMatch: ['**/test/**/*.test.ts'],
5
- moduleFileExtensions: ['ts', 'js', 'json'],
6
- roots: ['<rootDir>/src', '<rootDir>/test'],
7
- };
package/scripts/deploy.ts DELETED
@@ -1,9 +0,0 @@
1
- // scripts/deploy.ts
2
- // Script for deploying/testing contracts
3
-
4
- async function main() {
5
- // TODO: Implement contract deployment logic
6
- console.log('Deploy script placeholder');
7
- }
8
-
9
- main();
@@ -1,27 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import gasRegistryAbi from '../contracts/abi/GasRegistry.json';
3
-
4
- export const checkTgBalance = async (signer: ethers.Signer) => {
5
- const gasRegistryContractAddress = process.env.GAS_REGISTRY_CONTRACT_ADDRESS as string || '0x85ea3eB894105bD7e7e2A8D34cf66C8E8163CD2a';
6
- if (!gasRegistryContractAddress) {
7
- throw new Error('GAS_REGISTRY_CONTRACT_ADDRESS is not set in the environment variables');
8
- }
9
- const contract = new ethers.Contract(gasRegistryContractAddress, gasRegistryAbi, signer);
10
- const address = await signer.getAddress();
11
- const balance = await contract.balances(address);
12
- // balance is likely an array or object with ethSpent and TGbalance, both in wei
13
- // We'll convert TGbalance from wei to ETH
14
- // If balance is an array: [ethSpent, TGbalance]
15
- // If balance is an object: { ethSpent, TGbalance }
16
- let tgBalanceWei: bigint;
17
- if (Array.isArray(balance)) {
18
- tgBalanceWei = balance[1] as bigint;
19
- } else if (balance && balance.TGbalance !== undefined) {
20
- tgBalanceWei = balance.TGbalance as bigint;
21
- } else {
22
- throw new Error('Unexpected balance format');
23
- }
24
- const tgBalance = ethers.formatEther(tgBalanceWei);
25
- console.log('tgBalanceEth', tgBalance);
26
- return { tgBalanceWei, tgBalance };
27
- };