sdk-triggerx 0.1.15 → 0.1.16

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.
@@ -1,2 +1,3 @@
1
1
  import { TriggerXClient } from '../client';
2
- export declare const deleteJob: (client: TriggerXClient, jobId: string) => Promise<void>;
2
+ import { Signer } from 'ethers';
3
+ export declare const deleteJob: (client: TriggerXClient, jobId: string, signer: Signer, chainId: string) => Promise<void>;
@@ -1,16 +1,38 @@
1
1
  "use strict";
2
2
  // sdk-triggerx/src/api/deleteJob.ts
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  exports.deleteJob = void 0;
5
- const deleteJob = async (client, jobId) => {
8
+ const JobRegistry_json_1 = __importDefault(require("../contracts/abi/JobRegistry.json"));
9
+ const JobRegistry_1 = require("../contracts/JobRegistry");
10
+ const config_1 = require("../config");
11
+ const deleteJob = async (client, jobId, signer, chainId) => {
6
12
  const apiKey = client.getApiKey(); // Assuming you have a method to get the API key
13
+ const { jobRegistry: jobRegistryAddress } = config_1.CONTRACT_ADDRESSES_BY_CHAIN[chainId];
14
+ if (!jobRegistryAddress) {
15
+ throw new Error(`No contract address found for chain ID: ${chainId}`);
16
+ }
7
17
  try {
18
+ console.log(`Deleting job ${jobId} on chain ${chainId}...`);
19
+ // First delete on-chain
20
+ await (0, JobRegistry_1.deleteJobOnChain)({
21
+ jobId,
22
+ contractAddress: jobRegistryAddress,
23
+ abi: JobRegistry_json_1.default,
24
+ signer,
25
+ });
26
+ console.log('On-chain deletion successful, updating API...');
27
+ // Then update the API
8
28
  await client.put(`api/jobs/delete/${jobId}`, {}, {
9
29
  headers: {
10
30
  'Content-Type': 'application/json',
11
31
  'X-API-KEY': apiKey,
12
32
  },
33
+ timeout: 30000, // 30 second timeout
13
34
  });
35
+ console.log('API update successful');
14
36
  }
15
37
  catch (error) {
16
38
  console.error('Error deleting job:', error);
package/dist/client.js CHANGED
@@ -12,6 +12,7 @@ class TriggerXClient {
12
12
  this.client = axios_1.default.create({
13
13
  baseURL: 'https://data.triggerx.network', //'http://localhost:9002', //'https://data.triggerx.network',
14
14
  headers: { 'Authorization': `Bearer ${this.apiKey}` }, // Set the API key here
15
+ timeout: 30000, // 30 second timeout
15
16
  ...config,
16
17
  });
17
18
  }
package/dist/config.js CHANGED
@@ -8,12 +8,29 @@ exports.getChainAddresses = getChainAddresses;
8
8
  // Contract addresses per chain
9
9
  // Keyed by chainId as string to avoid bigint conversions throughout the SDK
10
10
  exports.CONTRACT_ADDRESSES_BY_CHAIN = {
11
- // OP Sepolia? (used in examples) 11155420 - preserves previous defaults
11
+ // TESTNET CONFIGURATIONS
12
+ // OP Sepolia (11155420) - Optimism Sepolia Testnet
12
13
  '11155420': {
13
- gasRegistry: '0x204F9278D6BB7714D7A40842423dFd5A27cC1b88',
14
+ gasRegistry: '0x664CB20BCEEc9416D290AC820e5446e61a5c75e4',
14
15
  jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
15
16
  },
16
- // Arbitrum One (42161)
17
+ // Ethereum Sepolia (11155111) - Ethereum Sepolia Testnet
18
+ '11155111': {
19
+ gasRegistry: '0x664CB20BCEEc9416D290AC820e5446e61a5c75e4',
20
+ jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
21
+ },
22
+ // Arbitrum Sepolia (421614) - Arbitrum Sepolia Testnet
23
+ '421614': {
24
+ gasRegistry: '0x664CB20BCEEc9416D290AC820e5446e61a5c75e4',
25
+ jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
26
+ },
27
+ // Base Sepolia (84532) - Base Sepolia Testnet
28
+ '84532': {
29
+ gasRegistry: '0x664CB20BCEEc9416D290AC820e5446e61a5c75e4',
30
+ jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
31
+ },
32
+ // MAINNET CONFIGURATIONS
33
+ // Arbitrum One (42161) - Mainnet
17
34
  '42161': {
18
35
  gasRegistry: '0x93dDB2307F3Af5df85F361E5Cddd898Acd3d132d',
19
36
  jobRegistry: '0xAf1189aFd1F1880F09AeC3Cbc32cf415c735C710',
@@ -9,4 +9,11 @@ export interface CreateJobOnChainParams {
9
9
  abi: any;
10
10
  signer: Signer;
11
11
  }
12
+ export interface DeleteJobOnChainParams {
13
+ jobId: string;
14
+ contractAddress: string;
15
+ abi: any;
16
+ signer: Signer;
17
+ }
12
18
  export declare function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAddress, encodedData, contractAddress, abi, signer, }: CreateJobOnChainParams): Promise<string>;
19
+ export declare function deleteJobOnChain({ jobId, contractAddress, abi, signer, }: DeleteJobOnChainParams): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createJobOnChain = createJobOnChain;
4
+ exports.deleteJobOnChain = deleteJobOnChain;
4
5
  const ethers_1 = require("ethers");
5
6
  async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAddress, encodedData, contractAddress, abi, signer, }) {
6
7
  const contract = new ethers_1.ethers.Contract(contractAddress, abi, signer);
@@ -22,3 +23,8 @@ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAd
22
23
  }
23
24
  throw new Error('Job ID not found in contract events');
24
25
  }
26
+ async function deleteJobOnChain({ jobId, contractAddress, abi, signer, }) {
27
+ const contract = new ethers_1.ethers.Contract(contractAddress, abi.abi, signer);
28
+ const tx = await contract.deleteJob(jobId);
29
+ await tx.wait();
30
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,11 @@ export * from './client';
2
2
  export * from './config';
3
3
  export * from './types';
4
4
  export * from './api/jobs';
5
- export { createJobOnChain } from './contracts/JobRegistry';
5
+ export * from './api/getjob';
6
+ export * from './api/getUserData';
7
+ export * from './api/checkTgBalance';
8
+ export * from './api/topupTg';
9
+ export * from './api/deleteJob';
10
+ export * from './api/getJobDataById';
6
11
  export * from './contracts';
7
12
  export * from './utils/errors';
package/dist/index.js CHANGED
@@ -14,12 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createJobOnChain = void 0;
18
17
  __exportStar(require("./client"), exports);
19
18
  __exportStar(require("./config"), exports);
20
19
  __exportStar(require("./types"), exports);
21
20
  __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; } });
21
+ __exportStar(require("./api/getjob"), exports);
22
+ __exportStar(require("./api/getUserData"), exports);
23
+ __exportStar(require("./api/checkTgBalance"), exports);
24
+ __exportStar(require("./api/topupTg"), exports);
25
+ __exportStar(require("./api/deleteJob"), exports);
26
+ __exportStar(require("./api/getJobDataById"), exports);
27
+ // export { createJobOnChain } from './contracts/JobRegistry';
24
28
  __exportStar(require("./contracts"), exports);
25
29
  __exportStar(require("./utils/errors"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdk-triggerx",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "SDK for interacting with the TriggerX backend and smart contracts.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",