1- import { type Address , type Chain , createPublicClient , createWalletClient , custom , type Hash , http , type RpcSchema as RpcSchemaGeneric , type SendTransactionParameters , type Transport , type WalletClient } from "viem" ;
1+ import { type Address , type Chain , createPublicClient , createWalletClient , custom , type Hash , http , type RpcSchema as RpcSchemaGeneric , type SendTransactionParameters , toHex , type Transport , type WalletClient } from "viem" ;
22import { type BundlerClient , createBundlerClient } from "viem/account-abstraction" ;
33
44import type { PaymasterConfig } from "../actions/sendUserOperation.js" ;
@@ -143,9 +143,8 @@ export class Signer implements SignerInterface {
143143 return this . bundlerClients [ chainId ] ;
144144 }
145145
146- // Try to create bundler client from chainsInfo if bundlerUrl is available
147146 const chainInfo = this . chainsInfo . find ( ( c ) => c . id === chainId ) ;
148- if ( ! chainInfo ?. bundlerUrl ) {
147+ if ( ! chainInfo ) {
149148 return undefined ;
150149 }
151150
@@ -154,6 +153,16 @@ export class Signer implements SignerInterface {
154153 return undefined ;
155154 }
156155
156+ // In prividium mode, use transport from constructor; otherwise use bundlerUrl
157+ const bundlerTransport = chainInfo . prividiumMode
158+ ? this . transports [ chainId ]
159+ : http ( chainInfo . bundlerUrl ) ;
160+
161+ if ( ! bundlerTransport ) {
162+ console . error ( `Prividium mode requires a transport for chain ${ chainId } ` ) ;
163+ return undefined ;
164+ }
165+
157166 const publicClient = createPublicClient ( {
158167 chain,
159168 transport : this . transports [ chain . id ] || http ( ) ,
@@ -162,7 +171,7 @@ export class Signer implements SignerInterface {
162171 this . bundlerClients [ chain . id ] = createBundlerClient ( {
163172 client : publicClient ,
164173 chain,
165- transport : http ( chainInfo . bundlerUrl ) ,
174+ transport : bundlerTransport ,
166175 userOperation : {
167176 // Use fixed gas values matching old Rust SDK implementation
168177 // (old SDK used: 2M callGas, 2M verificationGas, 1M preVerificationGas)
@@ -333,6 +342,9 @@ export class Signer implements SignerInterface {
333342 case "eth_accounts" : {
334343 return this . accounts as ExtractReturnType < TMethod > ;
335344 }
345+ case "eth_chainId" : {
346+ return toHex ( this . chain . id ) as ExtractReturnType < TMethod > ;
347+ }
336348 default :
337349 return undefined ;
338350 }
0 commit comments