@@ -2,7 +2,8 @@ import * as core from '@actions/core';
22import SafeApiKit from "@safe-global/api-kit" ;
33import Safe from "@safe-global/protocol-kit" ;
44import { OperationType , MetaTransactionData } from "@safe-global/types-kit" ;
5- import { Wallet , JsonRpcProvider } from "ethers" ;
5+ import { createPublicClient , http } from "viem" ;
6+ import { privateKeyToAccount } from "viem/accounts" ;
67
78async function run ( ) {
89 try {
@@ -31,15 +32,16 @@ async function run() {
3132 core . info ( `π― Target Address: ${ transactionTo } ` ) ;
3233
3334 // Initialize wallet
34- const wallet = new Wallet ( proposerPrivateKey ) ;
35- core . info ( `π Proposer Address: ${ wallet . address } ` ) ;
35+ const account = privateKeyToAccount ( proposerPrivateKey as `0x${ string } ` ) ;
36+ core . info ( `π Proposer Address: ${ account . address } ` ) ;
3637
3738 // Detect chainId from RPC
3839 core . info ( `π Detecting chain ID from RPC...` ) ;
39- const provider = new JsonRpcProvider ( rpcUrl ) ;
40- const network = await provider . getNetwork ( ) ;
41- const chainId = network . chainId . toString ( ) ;
42- core . info ( `π Detected Chain ID: ${ chainId } ` ) ;
40+ const publicClient = createPublicClient ( {
41+ transport : http ( rpcUrl ) ,
42+ } ) ;
43+ const chainId = await publicClient . getChainId ( ) ;
44+ core . info ( `π Detected Chain ID: ${ chainId . toString ( ) } ` ) ;
4345
4446 // Initialize API Kit
4547 const apiKit = new SafeApiKit ( {
@@ -81,7 +83,7 @@ async function run() {
8183 safeAddress : safeAddress ,
8284 safeTransactionData : safeTransaction . data ,
8385 safeTxHash : safeTxHash ,
84- senderAddress : wallet . address ,
86+ senderAddress : account . address ,
8587 senderSignature : signature . data ,
8688 origin : "GitHub Action - Safe Transaction" ,
8789 } ) ;
0 commit comments