@@ -85,11 +85,10 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
8585 }
8686
8787 // initialize login modal
88- const currentChainConfig = this . getCurrentChainConfig ( ) ;
8988 this . loginModal = new LoginModal ( {
9089 ...this . options . uiConfig ,
9190 adapterListener : this ,
92- chainNamespace : currentChainConfig . chainNamespace ,
91+ chainNamespace : this . currentChainConfig . chainNamespace ,
9392 walletRegistry,
9493 } ) ;
9594 this . subscribeToLoginModalEvents ( ) ;
@@ -121,9 +120,9 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
121120 await this . loginModal . initModal ( ) ;
122121
123122 // load default adapters: auth, injected wallets
124- const adapterFns = await this . loadDefaultAdapters ( ) ;
123+ const adapterFns = await this . loadDefaultAdapters ( { projectConfig } ) ;
125124 adapterFns . map ( async ( adapterFn ) => {
126- const adapter = adapterFn ( { projectConfig, options : this . coreOptions , getCurrentChainConfig : this . getCurrentChainConfig } ) ;
125+ const adapter = adapterFn ( { projectConfig, coreOptions : this . coreOptions } ) ;
127126 if ( this . walletAdapters [ adapter . name ] ) return ;
128127 this . walletAdapters [ adapter . name ] = adapter ;
129128 } ) ;
@@ -199,7 +198,8 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
199198 // if adapter is configured then only initialize in app or cached adapter.
200199 // external wallets are initialized on INIT_EXTERNAL_WALLET event.
201200 this . subscribeToAdapterEvents ( connector ) ;
202- if ( connector . status === ADAPTER_STATUS . NOT_READY ) await connector . init ( { autoConnect : this . cachedAdapter === adapterName } ) ;
201+ if ( connector . status === ADAPTER_STATUS . NOT_READY )
202+ await connector . init ( { autoConnect : this . cachedAdapter === adapterName , chainId : this . currentChainConfig . chainId } ) ;
203203 // note: not adding cachedWallet to modal if it is external wallet.
204204 // adding it later if no in-app wallets are available.
205205 if ( connector . type === ADAPTER_CATEGORY . IN_APP ) {
@@ -210,7 +210,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
210210 }
211211 } ) ;
212212
213- this . commonJRPCProvider = await CommonJRPCProvider . getProviderInstance ( { chainConfig : this . getCurrentChainConfig ( ) } ) ;
213+ this . commonJRPCProvider = await CommonJRPCProvider . getProviderInstance ( { chainConfig : this . currentChainConfig } ) ;
214214 if ( typeof keyExportEnabled === "boolean" ) {
215215 // dont know if we need to do this.
216216 this . commonJRPCProvider . setKeyExportFlag ( keyExportEnabled ) ;
@@ -276,7 +276,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
276276 }
277277 if ( adapter . status === ADAPTER_STATUS . NOT_READY ) {
278278 await adapter
279- . init ( { autoConnect : this . cachedAdapter === adapterName } )
279+ . init ( { autoConnect : this . cachedAdapter === adapterName , chainId : this . currentChainConfig . chainId } )
280280 . then < undefined > ( ( ) => {
281281 const adapterModalConfig = ( this . modalConfig . adapters as Record < WALLET_ADAPTER_TYPE , ModalConfig > ) [ adapterName ] ;
282282 adaptersConfig [ adapterName ] = { ...adapterModalConfig , isInjected : adapter . isInjected } ;
@@ -340,7 +340,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
340340
341341 // refreshing session for wallet connect whenever modal is opened.
342342 try {
343- adapter . connect ( ) ;
343+ adapter . connect ( { chainId : this . currentChainConfig . chainId } ) ;
344344 } catch ( error ) {
345345 log . error ( `Error while disconnecting to wallet connect in core` , error ) ;
346346 }
0 commit comments