Skip to content

Commit e342ecb

Browse files
committed
refactor: simplify wallet and Safe initialization by removing unnecessary dependencies and parameters
1 parent 775d3d7 commit e342ecb

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

safe-transaction/src/index.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const core = require('@actions/core');
22
const SafeApiKit = require('@safe-global/api-kit').default;
3-
const Safe = require('@safe-global/protocol-kit').default;
4-
const { EthersAdapter } = require("@safe-global/protocol-kit");
3+
const Safe = require("@safe-global/protocol-kit").default;
54
const { OperationType } = require('@safe-global/types-kit');
6-
const { Wallet, JsonRpcProvider, ethers } = require("ethers");
5+
const { Wallet } = require("ethers");
76

87
async function run() {
98
try {
@@ -21,17 +20,10 @@ async function run() {
2120
core.info(`📍 Safe Address: ${safeAddress}`);
2221
core.info(`🎯 Target Address: ${transactionTargetAddress}`);
2322

24-
// Initialize wallet and provider
25-
const provider = new JsonRpcProvider(rpcUrl);
26-
const wallet = new Wallet(proposerPrivateKey, provider);
23+
// Initialize wallet
24+
const wallet = new Wallet(proposerPrivateKey);
2725
core.info(`👤 Proposer Address: ${wallet.address}`);
2826

29-
// Initialize EthAdapter
30-
const ethAdapter = new EthersAdapter({
31-
ethers,
32-
signerOrProvider: wallet,
33-
});
34-
3527
// Initialize API Kit
3628
const apiKit = new SafeApiKit({
3729
chainId: chainId,
@@ -42,8 +34,9 @@ async function run() {
4234
core.info(`🔧 API Kit initialized with chainId: ${chainId}`);
4335

4436
// Initialize Protocol Kit
45-
const protocolKit = await Safe.create({
46-
ethAdapter,
37+
const protocolKit = await Safe.init({
38+
provider: rpcUrl,
39+
signer: proposerPrivateKey,
4740
safeAddress: safeAddress,
4841
});
4942

@@ -74,9 +67,8 @@ async function run() {
7467
)}`
7568
);
7669

77-
// Debug: Log API Kit state
78-
core.info(`🔧 API Kit chainId: ${apiKit.chainId}`);
79-
core.info(`🔧 API Kit txServiceUrl: ${apiKit.txServiceUrl}`);
70+
// Debug: API Kit initialized successfully
71+
core.info(`🔧 API Kit initialized for chainId: ${chainId}`);
8072

8173
// Propose transaction to the service
8274
await apiKit.proposeTransaction({

0 commit comments

Comments
 (0)