Skip to content

Commit dede1f4

Browse files
committed
refactor: enhance wallet initialization with provider and integrate EthersAdapter for improved functionality
1 parent 3937ebf commit dede1f4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

safe-transaction/src/index.js

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

78
async function run() {
89
try {
@@ -20,10 +21,17 @@ async function run() {
2021
core.info(`📍 Safe Address: ${safeAddress}`);
2122
core.info(`🎯 Target Address: ${transactionTargetAddress}`);
2223

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

29+
// Initialize EthAdapter
30+
const ethAdapter = new EthersAdapter({
31+
ethers,
32+
signerOrProvider: wallet,
33+
});
34+
2735
// Initialize API Kit
2836
const apiKit = new SafeApiKit({
2937
chainId: chainId,
@@ -32,8 +40,7 @@ async function run() {
3240

3341
// Initialize Protocol Kit
3442
const protocolKit = await Safe.create({
35-
provider: rpcUrl,
36-
signer: proposerPrivateKey,
43+
ethAdapter,
3744
safeAddress: safeAddress,
3845
});
3946

0 commit comments

Comments
 (0)