sdk-triggerx 0.1.13 → 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.
- package/dist/api/deleteJob.d.ts +2 -1
- package/dist/api/deleteJob.js +23 -1
- package/dist/api/topupTg.js +2 -2
- package/dist/client.js +1 -0
- package/dist/config.js +20 -3
- package/dist/contracts/JobRegistry.d.ts +7 -0
- package/dist/contracts/JobRegistry.js +6 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -3
- package/package.json +8 -2
package/dist/api/deleteJob.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { TriggerXClient } from '../client';
|
|
2
|
-
|
|
2
|
+
import { Signer } from 'ethers';
|
|
3
|
+
export declare const deleteJob: (client: TriggerXClient, jobId: string, signer: Signer, chainId: string) => Promise<void>;
|
package/dist/api/deleteJob.js
CHANGED
|
@@ -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
|
|
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/api/topupTg.js
CHANGED
|
@@ -14,8 +14,8 @@ const topupTg = async (tgAmount, signer) => {
|
|
|
14
14
|
const gasRegistryContractAddress = gasRegistry;
|
|
15
15
|
const contract = new ethers_1.ethers.Contract(gasRegistryContractAddress, GasRegistry_json_1.default, signer);
|
|
16
16
|
// Each TG costs 0.001 ETH, so calculate the ETH required for the given TG amount
|
|
17
|
-
const
|
|
18
|
-
const amountInEthWei =
|
|
17
|
+
const amountInEthWei = tgAmount;
|
|
18
|
+
// const amountInEthWei = ethers.parseEther(amountInEth.toString());
|
|
19
19
|
const tx = await contract.purchaseTG(amountInEthWei, { value: amountInEthWei });
|
|
20
20
|
await tx.wait();
|
|
21
21
|
return tx;
|
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
|
-
//
|
|
11
|
+
// TESTNET CONFIGURATIONS
|
|
12
|
+
// OP Sepolia (11155420) - Optimism Sepolia Testnet
|
|
12
13
|
'11155420': {
|
|
13
|
-
gasRegistry: '
|
|
14
|
+
gasRegistry: '0x664CB20BCEEc9416D290AC820e5446e61a5c75e4',
|
|
14
15
|
jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
|
|
15
16
|
},
|
|
16
|
-
//
|
|
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
|
|
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
|
-
|
|
23
|
-
|
|
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.
|
|
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",
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/trigg3rX/triggerx-newSDK.git"
|
|
17
17
|
},
|
|
18
|
-
"keywords": [
|
|
18
|
+
"keywords": [
|
|
19
|
+
"triggerx",
|
|
20
|
+
"sdk",
|
|
21
|
+
"web3",
|
|
22
|
+
"blockchain",
|
|
23
|
+
"ethers"
|
|
24
|
+
],
|
|
19
25
|
"directories": {
|
|
20
26
|
"test": "test"
|
|
21
27
|
},
|