sdk-triggerx 0.1.30 → 0.1.32
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/README.md +9 -8
- package/dist/api/checkBalance.d.ts +33 -0
- package/dist/api/checkBalance.js +68 -0
- package/dist/api/jobs.d.ts +6 -2
- package/dist/api/jobs.js +174 -108
- package/dist/api/topup.d.ts +20 -0
- package/dist/api/topup.js +102 -0
- package/dist/api/topupTg.js +4 -2
- package/dist/api/withdraw.d.ts +26 -0
- package/dist/api/withdraw.js +89 -0
- package/dist/api/withdrawTg.js +24 -2
- package/dist/config.js +5 -5
- package/dist/contracts/JobRegistry.js +5 -5
- package/dist/contracts/abi/GasRegistry.json +268 -423
- package/dist/contracts/abi/JobRegistry.json +710 -1524
- package/dist/contracts/contractUtils.d.ts +13 -0
- package/dist/contracts/contractUtils.js +41 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/types.d.ts +32 -1
- package/dist/types.js +1 -0
- package/dist/utils/validation.d.ts +2 -2
- package/dist/utils/validation.js +63 -3
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const depositEth: (ethAmount: bigint, signer: ethers.Signer) => Promise<{
|
|
3
|
+
success: boolean;
|
|
4
|
+
data?: any;
|
|
5
|
+
error?: string;
|
|
6
|
+
errorCode?: string;
|
|
7
|
+
errorType?: string;
|
|
8
|
+
details?: any;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use depositEth instead. This is an alias for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare const topupTg: (ethAmount: bigint, signer: ethers.Signer) => Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
data?: any;
|
|
16
|
+
error?: string;
|
|
17
|
+
errorCode?: string;
|
|
18
|
+
errorType?: string;
|
|
19
|
+
details?: any;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.topupTg = exports.depositEth = void 0;
|
|
7
|
+
const GasRegistry_json_1 = __importDefault(require("../contracts/abi/GasRegistry.json"));
|
|
8
|
+
const contractUtils_1 = require("../contracts/contractUtils");
|
|
9
|
+
const errors_1 = require("../utils/errors");
|
|
10
|
+
const depositEth = async (ethAmount, signer) => {
|
|
11
|
+
console.log('depositing ETH balance', ethAmount);
|
|
12
|
+
// Validate inputs
|
|
13
|
+
if (!ethAmount || ethAmount <= 0n) {
|
|
14
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('ethAmount', 'ETH amount must be a positive bigint'), 'Validation error');
|
|
15
|
+
}
|
|
16
|
+
if (!signer) {
|
|
17
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('signer', 'Signer is required'), 'Validation error');
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
// Get contract address and create contract instances with SDK RPC provider
|
|
21
|
+
// This ensures we can interact with the contract even if user's RPC fails
|
|
22
|
+
let gasRegistryContractAddress;
|
|
23
|
+
let contract;
|
|
24
|
+
let contractWithSigner;
|
|
25
|
+
let rpcProvider;
|
|
26
|
+
let resolvedChainId;
|
|
27
|
+
let signerAddress;
|
|
28
|
+
try {
|
|
29
|
+
// Get signer address (this doesn't require the signer's provider to work)
|
|
30
|
+
signerAddress = await signer.getAddress();
|
|
31
|
+
// Resolve chain ID from signer
|
|
32
|
+
resolvedChainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
33
|
+
// Get contract address
|
|
34
|
+
gasRegistryContractAddress = (0, contractUtils_1.getContractAddress)(resolvedChainId, 'gasRegistry');
|
|
35
|
+
// Create contract instances with SDK RPC provider
|
|
36
|
+
const contractInstances = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(gasRegistryContractAddress, GasRegistry_json_1.default, signer, resolvedChainId);
|
|
37
|
+
contract = contractInstances.contract;
|
|
38
|
+
contractWithSigner = contractInstances.contractWithSigner;
|
|
39
|
+
rpcProvider = contractInstances.rpcProvider;
|
|
40
|
+
}
|
|
41
|
+
catch (configError) {
|
|
42
|
+
if (configError instanceof errors_1.ConfigurationError) {
|
|
43
|
+
return (0, errors_1.createErrorResponse)(configError, 'Configuration error');
|
|
44
|
+
}
|
|
45
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ConfigurationError('Failed to initialize contract', { originalError: configError }), 'Configuration error');
|
|
46
|
+
}
|
|
47
|
+
// Convert ethAmount to wei if needed
|
|
48
|
+
console.log('ethAmount', ethAmount);
|
|
49
|
+
const amountInEthWei = typeof ethAmount === 'bigint' ? ethAmount : BigInt(ethAmount);
|
|
50
|
+
console.log('amountInEthWei', amountInEthWei);
|
|
51
|
+
// Estimate gas for the transaction using SDK RPC provider
|
|
52
|
+
// This ensures gas estimation works even if user's RPC fails
|
|
53
|
+
let estimatedGas;
|
|
54
|
+
try {
|
|
55
|
+
console.log('Estimating gas using SDK RPC provider...');
|
|
56
|
+
// Use contract instance with SDK RPC provider for estimation
|
|
57
|
+
// Specify the signer's address in the estimation options
|
|
58
|
+
estimatedGas = await contract.depositETH.estimateGas(amountInEthWei, {
|
|
59
|
+
value: amountInEthWei,
|
|
60
|
+
from: signerAddress // Specify the sender address for accurate estimation
|
|
61
|
+
});
|
|
62
|
+
console.log('Estimated gas (using SDK RPC):', estimatedGas.toString());
|
|
63
|
+
// Add 10% buffer to ensure transaction doesn't fail
|
|
64
|
+
const gasWithBuffer = (estimatedGas * BigInt(110)) / BigInt(100);
|
|
65
|
+
console.log('Gas with 10% buffer:', gasWithBuffer.toString());
|
|
66
|
+
// Execute transaction using signer (for signing)
|
|
67
|
+
const tx = await contractWithSigner.depositETH(amountInEthWei, {
|
|
68
|
+
value: amountInEthWei,
|
|
69
|
+
gasLimit: gasWithBuffer
|
|
70
|
+
});
|
|
71
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
72
|
+
return { success: true, data: tx };
|
|
73
|
+
}
|
|
74
|
+
catch (gasEstimateError) {
|
|
75
|
+
// If gas estimation fails, try without gas limit (let provider estimate)
|
|
76
|
+
console.warn('Gas estimation failed (using SDK RPC), proceeding without gas limit:', gasEstimateError);
|
|
77
|
+
const tx = await contractWithSigner.depositETH(amountInEthWei, { value: amountInEthWei });
|
|
78
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
79
|
+
return { success: true, data: tx };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('Error depositing ETH:', error);
|
|
84
|
+
if (error instanceof Error) {
|
|
85
|
+
if (error.message.includes('network') || error.message.includes('timeout')) {
|
|
86
|
+
return (0, errors_1.createErrorResponse)(new errors_1.NetworkError('Network error during ETH deposit', { originalError: error, ethAmount }), 'Network error');
|
|
87
|
+
}
|
|
88
|
+
else if (error.message.includes('contract') || error.message.includes('transaction')) {
|
|
89
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ContractError('Contract error during ETH deposit', { originalError: error, ethAmount }), 'Contract error');
|
|
90
|
+
}
|
|
91
|
+
else if (error.message.includes('insufficient funds') || error.message.includes('balance')) {
|
|
92
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('balance', 'Insufficient funds for ETH deposit', { originalError: error, ethAmount }), 'Validation error');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return (0, errors_1.createErrorResponse)(error, 'Failed to deposit ETH');
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.depositEth = depositEth;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use depositEth instead. This is an alias for backward compatibility.
|
|
101
|
+
*/
|
|
102
|
+
exports.topupTg = exports.depositEth;
|
package/dist/api/topupTg.js
CHANGED
|
@@ -22,6 +22,7 @@ const topupTg = async (tgAmount, signer) => {
|
|
|
22
22
|
let gasRegistryContractAddress;
|
|
23
23
|
let contract;
|
|
24
24
|
let contractWithSigner;
|
|
25
|
+
let rpcProvider;
|
|
25
26
|
let resolvedChainId;
|
|
26
27
|
let signerAddress;
|
|
27
28
|
try {
|
|
@@ -35,6 +36,7 @@ const topupTg = async (tgAmount, signer) => {
|
|
|
35
36
|
const contractInstances = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(gasRegistryContractAddress, GasRegistry_json_1.default, signer, resolvedChainId);
|
|
36
37
|
contract = contractInstances.contract;
|
|
37
38
|
contractWithSigner = contractInstances.contractWithSigner;
|
|
39
|
+
rpcProvider = contractInstances.rpcProvider;
|
|
38
40
|
}
|
|
39
41
|
catch (configError) {
|
|
40
42
|
if (configError instanceof errors_1.ConfigurationError) {
|
|
@@ -67,14 +69,14 @@ const topupTg = async (tgAmount, signer) => {
|
|
|
67
69
|
value: amountInEthWei,
|
|
68
70
|
gasLimit: gasWithBuffer
|
|
69
71
|
});
|
|
70
|
-
await
|
|
72
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
71
73
|
return { success: true, data: tx };
|
|
72
74
|
}
|
|
73
75
|
catch (gasEstimateError) {
|
|
74
76
|
// If gas estimation fails, try without gas limit (let provider estimate)
|
|
75
77
|
console.warn('Gas estimation failed (using SDK RPC), proceeding without gas limit:', gasEstimateError);
|
|
76
78
|
const tx = await contractWithSigner.purchaseTG(amountInEthWei, { value: amountInEthWei });
|
|
77
|
-
await
|
|
79
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
78
80
|
return { success: true, data: tx };
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Withdraw ETH from the Gas Registry.
|
|
4
|
+
* @param signer ethers.Signer instance
|
|
5
|
+
* @param amountETH The amount of ETH to withdraw (as a string or BigNumberish)
|
|
6
|
+
* @returns The transaction object or error response
|
|
7
|
+
*/
|
|
8
|
+
export declare const withdrawEth: (signer: ethers.Signer, amountETHwei: string | ethers.BigNumberish) => Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: any;
|
|
11
|
+
error?: string;
|
|
12
|
+
errorCode?: string;
|
|
13
|
+
errorType?: string;
|
|
14
|
+
details?: any;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use withdrawEth instead. This is an alias for backward compatibility.
|
|
18
|
+
*/
|
|
19
|
+
export declare const withdrawTg: (signer: ethers.Signer, amountETHwei: string | ethers.BigNumberish) => Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
data?: any;
|
|
22
|
+
error?: string;
|
|
23
|
+
errorCode?: string;
|
|
24
|
+
errorType?: string;
|
|
25
|
+
details?: any;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.withdrawTg = exports.withdrawEth = void 0;
|
|
7
|
+
const GasRegistry_json_1 = __importDefault(require("../contracts/abi/GasRegistry.json"));
|
|
8
|
+
const contractUtils_1 = require("../contracts/contractUtils");
|
|
9
|
+
const errors_1 = require("../utils/errors");
|
|
10
|
+
/**
|
|
11
|
+
* Withdraw ETH from the Gas Registry.
|
|
12
|
+
* @param signer ethers.Signer instance
|
|
13
|
+
* @param amountETH The amount of ETH to withdraw (as a string or BigNumberish)
|
|
14
|
+
* @returns The transaction object or error response
|
|
15
|
+
*/
|
|
16
|
+
const withdrawEth = async (signer, amountETHwei) => {
|
|
17
|
+
// Validate inputs
|
|
18
|
+
if (!signer) {
|
|
19
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('signer', 'Signer is required'), 'Validation error');
|
|
20
|
+
}
|
|
21
|
+
if (!amountETHwei || (typeof amountETHwei === 'string' && amountETHwei.trim() === '') || Number(amountETHwei) <= 0) {
|
|
22
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('amountETHwei', 'Amount must be a positive number'), 'Validation error');
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
// Resolve chain ID and create contract instances with SDK RPC provider
|
|
26
|
+
let resolvedChainId;
|
|
27
|
+
let contract;
|
|
28
|
+
let contractWithSigner;
|
|
29
|
+
let rpcProvider;
|
|
30
|
+
let signerAddress;
|
|
31
|
+
try {
|
|
32
|
+
// Resolve chain ID from signer
|
|
33
|
+
signerAddress = await signer.getAddress();
|
|
34
|
+
resolvedChainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
35
|
+
// Get contract address
|
|
36
|
+
const gasRegistryContractAddress = (0, contractUtils_1.getContractAddress)(resolvedChainId, 'gasRegistry');
|
|
37
|
+
// Create contract instances with SDK RPC provider
|
|
38
|
+
const contractInstances = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(gasRegistryContractAddress, GasRegistry_json_1.default, signer, resolvedChainId);
|
|
39
|
+
contract = contractInstances.contract;
|
|
40
|
+
contractWithSigner = contractInstances.contractWithSigner;
|
|
41
|
+
rpcProvider = contractInstances.rpcProvider;
|
|
42
|
+
}
|
|
43
|
+
catch (configError) {
|
|
44
|
+
if (configError instanceof errors_1.ConfigurationError) {
|
|
45
|
+
return (0, errors_1.createErrorResponse)(configError, 'Configuration error');
|
|
46
|
+
}
|
|
47
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ConfigurationError('Failed to initialize contract', { originalError: configError }), 'Configuration error');
|
|
48
|
+
}
|
|
49
|
+
let tx;
|
|
50
|
+
try {
|
|
51
|
+
console.log('Estimating gas for withdrawETHBalance using SDK RPC provider...');
|
|
52
|
+
const estimatedGas = await contract.withdrawETHBalance.estimateGas(amountETHwei, {
|
|
53
|
+
from: signerAddress,
|
|
54
|
+
});
|
|
55
|
+
console.log('Estimated gas (withdrawETHBalance):', estimatedGas.toString());
|
|
56
|
+
const gasWithBuffer = (estimatedGas * BigInt(110)) / BigInt(100);
|
|
57
|
+
console.log('Gas with 10% buffer (withdrawETHBalance):', gasWithBuffer.toString());
|
|
58
|
+
tx = await contractWithSigner.withdrawETHBalance(amountETHwei, {
|
|
59
|
+
gasLimit: gasWithBuffer,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (gasEstimateError) {
|
|
63
|
+
console.warn('Gas estimation failed for withdrawETHBalance (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
64
|
+
tx = await contractWithSigner.withdrawETHBalance(amountETHwei);
|
|
65
|
+
}
|
|
66
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
67
|
+
return { success: true, data: tx };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Error withdrawing ETH:', error);
|
|
71
|
+
if (error instanceof Error) {
|
|
72
|
+
if (error.message.includes('network') || error.message.includes('timeout')) {
|
|
73
|
+
return (0, errors_1.createErrorResponse)(new errors_1.NetworkError('Network error during ETH withdrawal', { originalError: error, amountETHwei }), 'Network error');
|
|
74
|
+
}
|
|
75
|
+
else if (error.message.includes('contract') || error.message.includes('transaction')) {
|
|
76
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ContractError('Contract error during ETH withdrawal', { originalError: error, amountETHwei }), 'Contract error');
|
|
77
|
+
}
|
|
78
|
+
else if (error.message.includes('insufficient') || error.message.includes('balance')) {
|
|
79
|
+
return (0, errors_1.createErrorResponse)(new errors_1.ValidationError('balance', 'Insufficient ETH balance for withdrawal', { originalError: error, amountETHwei }), 'Validation error');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (0, errors_1.createErrorResponse)(error, 'Failed to withdraw ETH');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.withdrawEth = withdrawEth;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use withdrawEth instead. This is an alias for backward compatibility.
|
|
88
|
+
*/
|
|
89
|
+
exports.withdrawTg = exports.withdrawEth;
|
package/dist/api/withdrawTg.js
CHANGED
|
@@ -25,15 +25,21 @@ const withdrawTg = async (signer, amountTG) => {
|
|
|
25
25
|
try {
|
|
26
26
|
// Resolve chain ID and create contract instances with SDK RPC provider
|
|
27
27
|
let resolvedChainId;
|
|
28
|
+
let contract;
|
|
28
29
|
let contractWithSigner;
|
|
30
|
+
let rpcProvider;
|
|
31
|
+
let signerAddress;
|
|
29
32
|
try {
|
|
30
33
|
// Resolve chain ID from signer
|
|
34
|
+
signerAddress = await signer.getAddress();
|
|
31
35
|
resolvedChainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
32
36
|
// Get contract address
|
|
33
37
|
const gasRegistryContractAddress = (0, contractUtils_1.getContractAddress)(resolvedChainId, 'gasRegistry');
|
|
34
38
|
// Create contract instances with SDK RPC provider
|
|
35
39
|
const contractInstances = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(gasRegistryContractAddress, GasRegistry_json_1.default, signer, resolvedChainId);
|
|
40
|
+
contract = contractInstances.contract;
|
|
36
41
|
contractWithSigner = contractInstances.contractWithSigner;
|
|
42
|
+
rpcProvider = contractInstances.rpcProvider;
|
|
37
43
|
}
|
|
38
44
|
catch (configError) {
|
|
39
45
|
if (configError instanceof errors_1.ConfigurationError) {
|
|
@@ -43,8 +49,24 @@ const withdrawTg = async (signer, amountTG) => {
|
|
|
43
49
|
}
|
|
44
50
|
// Assumes the contract has a function: claimEthForTg(uint256 amount)
|
|
45
51
|
const amountTGWei = ethers_1.ethers.parseEther(amountTG.toString());
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
let tx;
|
|
53
|
+
try {
|
|
54
|
+
console.log('Estimating gas for claimETHForTG using SDK RPC provider...');
|
|
55
|
+
const estimatedGas = await contract.claimETHForTG.estimateGas(amountTGWei, {
|
|
56
|
+
from: signerAddress,
|
|
57
|
+
});
|
|
58
|
+
console.log('Estimated gas (claimETHForTG):', estimatedGas.toString());
|
|
59
|
+
const gasWithBuffer = (estimatedGas * BigInt(110)) / BigInt(100);
|
|
60
|
+
console.log('Gas with 10% buffer (claimETHForTG):', gasWithBuffer.toString());
|
|
61
|
+
tx = await contractWithSigner.claimETHForTG(amountTGWei, {
|
|
62
|
+
gasLimit: gasWithBuffer,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (gasEstimateError) {
|
|
66
|
+
console.warn('Gas estimation failed for claimETHForTG (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
67
|
+
tx = await contractWithSigner.claimETHForTG(amountTGWei);
|
|
68
|
+
}
|
|
69
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
48
70
|
return { success: true, data: tx };
|
|
49
71
|
}
|
|
50
72
|
catch (error) {
|
package/dist/config.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
|
|
|
13
13
|
// TESTNET CONFIGURATIONS
|
|
14
14
|
// OP Sepolia (11155420) - Optimism Sepolia Testnet
|
|
15
15
|
'11155420': {
|
|
16
|
-
gasRegistry: '
|
|
16
|
+
gasRegistry: '0x248E9f1B99F1AC8068254233D1F271ed0e0903D6',
|
|
17
17
|
jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
|
|
18
18
|
safeFactory: '0x04359eDC46Cd6C6BD7F6359512984222BE10F8Be',
|
|
19
19
|
safeModule: '0xa0bC1477cfc452C05786262c377DE51FB8bc4669',
|
|
@@ -22,7 +22,7 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
|
|
|
22
22
|
},
|
|
23
23
|
// Ethereum Sepolia (11155111) - Ethereum Sepolia Testnet
|
|
24
24
|
'11155111': {
|
|
25
|
-
gasRegistry: '
|
|
25
|
+
gasRegistry: '0x248E9f1B99F1AC8068254233D1F271ed0e0903D6',
|
|
26
26
|
jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
|
|
27
27
|
safeFactory: '0xdf76E2A796a206D877086c717979054544B1D9Bc',
|
|
28
28
|
safeModule: '0xa0bC1477cfc452C05786262c377DE51FB8bc4669',
|
|
@@ -31,7 +31,7 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
|
|
|
31
31
|
},
|
|
32
32
|
// Arbitrum Sepolia (421614) - Arbitrum Sepolia Testnet
|
|
33
33
|
'421614': {
|
|
34
|
-
gasRegistry: '
|
|
34
|
+
gasRegistry: '0x248E9f1B99F1AC8068254233D1F271ed0e0903D6',
|
|
35
35
|
jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
|
|
36
36
|
safeFactory: '0x04359eDC46Cd6C6BD7F6359512984222BE10F8Be',
|
|
37
37
|
safeModule: '0xa0bC1477cfc452C05786262c377DE51FB8bc4669',
|
|
@@ -41,7 +41,7 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
|
|
|
41
41
|
},
|
|
42
42
|
// Base Sepolia (84532) - Base Sepolia Testnet
|
|
43
43
|
'84532': {
|
|
44
|
-
gasRegistry: '
|
|
44
|
+
gasRegistry: '0x248E9f1B99F1AC8068254233D1F271ed0e0903D6',
|
|
45
45
|
jobRegistry: '0x476ACc7949a95e31144cC84b8F6BC7abF0967E4b',
|
|
46
46
|
safeFactory: '0x04359eDC46Cd6C6BD7F6359512984222BE10F8Be',
|
|
47
47
|
safeModule: '0xa0bC1477cfc452C05786262c377DE51FB8bc4669',
|
|
@@ -51,7 +51,7 @@ exports.CONTRACT_ADDRESSES_BY_CHAIN = {
|
|
|
51
51
|
// MAINNET CONFIGURATIONS
|
|
52
52
|
// Arbitrum One (42161) - Mainnet
|
|
53
53
|
'42161': {
|
|
54
|
-
gasRegistry: '
|
|
54
|
+
gasRegistry: '0xe2AC670F7D66c69D547A44D08F9bA1Fc0Fc0f991',
|
|
55
55
|
jobRegistry: '0xAf1189aFd1F1880F09AeC3Cbc32cf415c735C710',
|
|
56
56
|
multisendCallOnly: '0x9641d764fc13c8B624c04430C7356C1C7C8102e2',
|
|
57
57
|
rpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
@@ -6,7 +6,7 @@ const contractUtils_1 = require("./contractUtils");
|
|
|
6
6
|
async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAddress, encodedData, contractAddress, abi, signer, }) {
|
|
7
7
|
// Resolve chain ID and create contract with SDK RPC provider
|
|
8
8
|
const chainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
9
|
-
const { contract, contractWithSigner } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi, signer, chainId);
|
|
9
|
+
const { contract, contractWithSigner, rpcProvider } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi, signer, chainId);
|
|
10
10
|
const signerAddress = await signer.getAddress();
|
|
11
11
|
let tx;
|
|
12
12
|
try {
|
|
@@ -27,7 +27,7 @@ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAd
|
|
|
27
27
|
console.warn('Gas estimation failed for createJob (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
28
28
|
tx = await contractWithSigner.createJob(jobTitle, jobType, timeFrame, targetContractAddress, encodedData);
|
|
29
29
|
}
|
|
30
|
-
const receipt = await
|
|
30
|
+
const receipt = await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
31
31
|
// Try to extract jobId from event logs (assume event is JobCreated(jobId,...))
|
|
32
32
|
// Use contract (with SDK RPC) for parsing logs
|
|
33
33
|
const event = receipt.logs
|
|
@@ -48,7 +48,7 @@ async function createJobOnChain({ jobTitle, jobType, timeFrame, targetContractAd
|
|
|
48
48
|
async function deleteJobOnChain({ jobId, contractAddress, abi, signer, }) {
|
|
49
49
|
// Resolve chain ID and create contract with SDK RPC provider
|
|
50
50
|
const chainId = await (0, contractUtils_1.resolveChainId)(signer);
|
|
51
|
-
const { contract, contractWithSigner } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi.abi || abi, signer, chainId);
|
|
51
|
+
const { contract, contractWithSigner, rpcProvider } = await (0, contractUtils_1.createContractWithSdkRpcAndSigner)(contractAddress, abi.abi || abi, signer, chainId);
|
|
52
52
|
const signerAddress = await signer.getAddress();
|
|
53
53
|
try {
|
|
54
54
|
console.log('Estimating gas for deleteJob using SDK RPC provider...');
|
|
@@ -61,11 +61,11 @@ async function deleteJobOnChain({ jobId, contractAddress, abi, signer, }) {
|
|
|
61
61
|
const tx = await contractWithSigner.deleteJob(jobId, {
|
|
62
62
|
gasLimit: gasWithBuffer,
|
|
63
63
|
});
|
|
64
|
-
await
|
|
64
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
65
65
|
}
|
|
66
66
|
catch (gasEstimateError) {
|
|
67
67
|
console.warn('Gas estimation failed for deleteJob (using SDK RPC), proceeding without explicit gas limit:', gasEstimateError);
|
|
68
68
|
const tx = await contractWithSigner.deleteJob(jobId);
|
|
69
|
-
await
|
|
69
|
+
await (0, contractUtils_1.waitForTransactionReceiptWithRpcFallback)(tx, rpcProvider);
|
|
70
70
|
}
|
|
71
71
|
}
|