File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,9 @@ export interface IWeb3AuthCoreOptions {
5959 chains ?: CustomChainConfig [ ] ;
6060
6161 /**
62- * TODO: should we make this mandatory? Is it possible to configure it from Dashboard?
6362 * default chain Id to use
6463 */
65- defaultChainId : string ;
64+ defaultChainId ? : string ;
6665
6766 /**
6867 * setting to true will enable logs
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
8383 } ) ) ,
8484 } ;
8585
86- this . currentChainId = options . defaultChainId ;
86+ this . currentChainId = options . defaultChainId || chains [ 0 ] . chainId ;
8787 }
8888
8989 get currentChain ( ) : CustomChainConfig {
@@ -230,10 +230,10 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
230230
231231 protected initCachedConnectorAndChainId ( ) {
232232 this . cachedConnector = storageAvailable ( this . storage ) ? window [ this . storage ] . getItem ( CONNECTOR_CACHE_KEY ) : null ;
233- // init chainId using cached chainId if it exists and is valid, otherwise use the first chain
233+ // init chainId using cached chainId if it exists and is valid, otherwise use the defaultChainId or the first chain
234234 const cachedChainId = storageAvailable ( this . storage ) ? window [ this . storage ] . getItem ( CURRENT_CHAIN_CACHE_KEY ) : null ;
235235 const isCachedChainIdValid = cachedChainId && this . coreOptions . chains . some ( ( chain ) => chain . chainId === cachedChainId ) ;
236- this . currentChainId = isCachedChainIdValid ? cachedChainId : this . coreOptions . defaultChainId ;
236+ this . currentChainId = isCachedChainIdValid ? cachedChainId : this . coreOptions . defaultChainId || this . coreOptions . chains [ 0 ] . chainId ;
237237 }
238238
239239 protected async setupCommonJRPCProvider ( ) {
You can’t perform that action at this time.
0 commit comments