sdk-triggerx 0.1.29 → 0.1.30
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/jobs.js +1 -1
- package/dist/contracts/JobRegistry.js +40 -6
- package/package.json +1 -1
package/dist/api/jobs.js
CHANGED
|
@@ -497,7 +497,7 @@ async function createJob(client, params) {
|
|
|
497
497
|
ether_balance: typeof jobData.ether_balance === 'bigint' ? Number(jobData.ether_balance) : Number(jobData.ether_balance),
|
|
498
498
|
token_balance: typeof jobData.token_balance === 'bigint' ? Number(jobData.token_balance) : Number(jobData.token_balance),
|
|
499
499
|
};
|
|
500
|
-
console.log('jobDataForApi', jobDataForApi);
|
|
500
|
+
// console.log('jobDataForApi', jobDataForApi);
|
|
501
501
|
const res = await client.post('/api/jobs', [jobDataForApi], {
|
|
502
502
|
headers: { 'Content-Type': 'application/json', 'X-API-KEY': apiKey },
|
|
503
503
|
});
|
|
@@ -7,9 +7,26 @@ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAd
|
|
|
7
7
|
// Resolve chain ID and create contract with SDK RPC provider
|
|
8
8
|
const chainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
9
9
|
const { contract, contractWithSigner } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi, signer, chainId);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const signerAddress = await signer.getAddress();
|
|
11
|
+
let tx;
|
|
12
|
+
try {
|
|
13
|
+
console.log('Estimating gas for createJob using SDK RPC provider...');
|
|
14
|
+
const estimatedGas = await contract.createJob.estimateGas(jobTitle, jobType, timeFrame, targetContractAddress, encodedData, {
|
|
15
|
+
from: signerAddress,
|
|
16
|
+
});
|
|
17
|
+
console.log('Estimated gas (createJob):', estimatedGas.toString());
|
|
18
|
+
const gasWithBuffer = (estimatedGas * BigInt(110)) / BigInt(100);
|
|
19
|
+
console.log('Gas with 10% buffer (createJob):', gasWithBuffer.toString());
|
|
20
|
+
// Use contractWithSigner for transaction (signing)
|
|
21
|
+
// Use contract for reading/parsing logs (SDK RPC)
|
|
22
|
+
tx = await contractWithSigner.createJob(jobTitle, jobType, timeFrame, targetContractAddress, encodedData, {
|
|
23
|
+
gasLimit: gasWithBuffer,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (gasEstimateError) {
|
|
27
|
+
console.warn('Gas estimation failed for createJob (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
28
|
+
tx = await contractWithSigner.createJob(jobTitle, jobType, timeFrame, targetContractAddress, encodedData);
|
|
29
|
+
}
|
|
13
30
|
const receipt = await tx.wait();
|
|
14
31
|
// Try to extract jobId from event logs (assume event is JobCreated(jobId,...))
|
|
15
32
|
// Use contract (with SDK RPC) for parsing logs
|
|
@@ -31,7 +48,24 @@ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAd
|
|
|
31
48
|
async function deleteJobOnChain({ jobId, contractAddress, abi, signer, }) {
|
|
32
49
|
// Resolve chain ID and create contract with SDK RPC provider
|
|
33
50
|
const chainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
34
|
-
const { contractWithSigner } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi.abi || abi, signer, chainId);
|
|
35
|
-
const
|
|
36
|
-
|
|
51
|
+
const { contract, contractWithSigner } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi.abi || abi, signer, chainId);
|
|
52
|
+
const signerAddress = await signer.getAddress();
|
|
53
|
+
try {
|
|
54
|
+
console.log('Estimating gas for deleteJob using SDK RPC provider...');
|
|
55
|
+
const estimatedGas = await contract.deleteJob.estimateGas(jobId, {
|
|
56
|
+
from: signerAddress,
|
|
57
|
+
});
|
|
58
|
+
console.log('Estimated gas (deleteJob):', estimatedGas.toString());
|
|
59
|
+
const gasWithBuffer = (estimatedGas * BigInt(110)) / BigInt(100);
|
|
60
|
+
console.log('Gas with 10% buffer (deleteJob):', gasWithBuffer.toString());
|
|
61
|
+
const tx = await contractWithSigner.deleteJob(jobId, {
|
|
62
|
+
gasLimit: gasWithBuffer,
|
|
63
|
+
});
|
|
64
|
+
await tx.wait();
|
|
65
|
+
}
|
|
66
|
+
catch (gasEstimateError) {
|
|
67
|
+
console.warn('Gas estimation failed for deleteJob (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
68
|
+
const tx = await contractWithSigner.deleteJob(jobId);
|
|
69
|
+
await tx.wait();
|
|
70
|
+
}
|
|
37
71
|
}
|