sdk-triggerx 0.1.19 → 0.1.21
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.
|
@@ -26,8 +26,15 @@ async function createSafeWalletForUser(factoryAddress, signer, user) {
|
|
|
26
26
|
}
|
|
27
27
|
})
|
|
28
28
|
.find((e) => e && e.name === 'SafeWalletCreated');
|
|
29
|
+
let safeAddress;
|
|
29
30
|
if (evt && evt.args && evt.args.safeWallet) {
|
|
30
|
-
|
|
31
|
+
safeAddress = evt.args.safeWallet;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
else {
|
|
34
|
+
safeAddress = await factory.latestSafeWallet(user);
|
|
35
|
+
}
|
|
36
|
+
// Wait a bit for the Safe contract to be fully initialized
|
|
37
|
+
// This is important because Safe proxy contracts need time to be set up
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
39
|
+
return safeAddress;
|
|
33
40
|
}
|
|
@@ -54,23 +54,37 @@ async function enableSafeModule(safeAddress, signer, moduleAddress) {
|
|
|
54
54
|
if (!provider)
|
|
55
55
|
throw new Error('Signer provider is required');
|
|
56
56
|
const safeProxy = new ethers_1.ethers.Contract(safeAddress, exports.SAFE_ABI, provider);
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
// Check if contract is deployed and initialized
|
|
58
|
+
try {
|
|
59
|
+
// If already enabled, exit early
|
|
60
|
+
const already = await safeProxy.isModuleEnabled(moduleAddress);
|
|
61
|
+
if (already) {
|
|
62
|
+
console.log('Module is already enabled');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// If we can't decode the result, the Safe might not be fully initialized
|
|
68
|
+
if (error.code === 'BAD_DATA' && error.value === '0x') {
|
|
69
|
+
console.log('Safe wallet not fully initialized yet, waiting a moment...');
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
|
-
//
|
|
76
|
+
// Verify Safe is properly initialized by checking owners and threshold
|
|
64
77
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
const [owners, threshold] = await Promise.all([
|
|
79
|
+
safeProxy.getOwners(),
|
|
80
|
+
safeProxy.getThreshold(),
|
|
81
|
+
]);
|
|
82
|
+
const signerAddress = await signer.getAddress();
|
|
83
|
+
console.log(`Safe has ${owners.length} owner(s), threshold: ${threshold}`);
|
|
84
|
+
console.log(`Signer: ${signerAddress}, Owners: ${owners.join(', ')}`);
|
|
71
85
|
}
|
|
72
86
|
catch (error) {
|
|
73
|
-
console.log('
|
|
87
|
+
console.log('Could not verify Safe owners, proceeding anyway...');
|
|
74
88
|
}
|
|
75
89
|
// If direct call fails, use execTransaction with proper signature
|
|
76
90
|
const safeNonce = await safeProxy.nonce();
|
|
@@ -99,11 +113,17 @@ async function enableSafeModule(safeAddress, signer, moduleAddress) {
|
|
|
99
113
|
// Execute the transaction through Safe's execTransaction
|
|
100
114
|
const safeProxyWithSigner = new ethers_1.ethers.Contract(safeAddress, exports.SAFE_ABI, signer);
|
|
101
115
|
const tx = await safeProxyWithSigner.execTransaction(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signature);
|
|
102
|
-
|
|
116
|
+
console.log('Waiting for transaction confirmation...');
|
|
117
|
+
const receipt = await tx.wait();
|
|
118
|
+
console.log(`Transaction confirmed in block ${receipt.blockNumber}`);
|
|
119
|
+
// Wait a bit for state to propagate
|
|
120
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
103
121
|
// Verify module is enabled
|
|
104
122
|
const isNowEnabled = await safeProxy.isModuleEnabled(moduleAddress);
|
|
105
123
|
if (!isNowEnabled) {
|
|
124
|
+
console.error('Module is still not enabled after transaction');
|
|
125
|
+
console.error(`Transaction hash: ${receipt.hash}`);
|
|
106
126
|
throw new Error("Module verification failed");
|
|
107
127
|
}
|
|
108
|
-
console.log('Module enabled successfully via execTransaction');
|
|
128
|
+
console.log('✅ Module enabled successfully via execTransaction');
|
|
109
129
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./api/checkTgBalance"), exports);
|
|
|
24
24
|
__exportStar(require("./api/topupTg"), exports);
|
|
25
25
|
__exportStar(require("./api/deleteJob"), exports);
|
|
26
26
|
__exportStar(require("./api/getJobDataById"), exports);
|
|
27
|
+
__exportStar(require("./api/safeWallet"), exports);
|
|
27
28
|
// export { createJobOnChain } from './contracts/JobRegistry';
|
|
28
29
|
__exportStar(require("./contracts"), exports);
|
|
29
30
|
__exportStar(require("./utils/errors"), exports);
|