@@ -62,62 +62,57 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
6262 }
6363
6464 public async initModal ( options ?: { signal ?: AbortSignal } ) : Promise < void > {
65- try {
66- const { signal } = options || { } ;
67-
68- super . checkInitRequirements ( ) ;
69- // get project config and wallet registry
70- const { projectConfig, walletRegistry } = await this . getProjectAndWalletConfig ( ) ;
71-
72- // init config
73- this . initUIConfig ( projectConfig ) ;
74- super . initAccountAbstractionConfig ( projectConfig ) ;
75- super . initChainsConfig ( projectConfig ) ;
76- super . initCachedConnectorAndChainId ( ) ;
77-
78- // init login modal
79- const { filteredWalletRegistry, disabledExternalWallets } = this . filterWalletRegistry ( walletRegistry , projectConfig ) ;
80- this . loginModal = new LoginModal (
81- {
82- ...this . options . uiConfig ,
83- connectorListener : this ,
84- web3authClientId : this . options . clientId ,
85- web3authNetwork : this . options . web3AuthNetwork ,
86- authBuildEnv : this . options . authBuildEnv ,
87- chainNamespaces : this . getChainNamespaces ( ) ,
88- walletRegistry : filteredWalletRegistry ,
89- } ,
90- {
91- onInitExternalWallets : this . onInitExternalWallets ,
92- onSocialLogin : this . onSocialLogin ,
93- onExternalWalletLogin : this . onExternalWalletLogin ,
94- onModalVisibility : this . onModalVisibility ,
95- }
96- ) ;
97- await withAbort ( ( ) => this . loginModal . initModal ( ) , signal ) ;
65+ const { signal } = options || { } ;
66+
67+ super . checkInitRequirements ( ) ;
68+ // get project config and wallet registry
69+ const { projectConfig, walletRegistry } = await this . getProjectAndWalletConfig ( ) ;
70+
71+ // init config
72+ this . initUIConfig ( projectConfig ) ;
73+ super . initAccountAbstractionConfig ( projectConfig ) ;
74+ super . initChainsConfig ( projectConfig ) ;
75+ super . initCachedConnectorAndChainId ( ) ;
76+
77+ // init login modal
78+ const { filteredWalletRegistry, disabledExternalWallets } = this . filterWalletRegistry ( walletRegistry , projectConfig ) ;
79+ this . loginModal = new LoginModal (
80+ {
81+ ...this . options . uiConfig ,
82+ connectorListener : this ,
83+ web3authClientId : this . options . clientId ,
84+ web3authNetwork : this . options . web3AuthNetwork ,
85+ authBuildEnv : this . options . authBuildEnv ,
86+ chainNamespaces : this . getChainNamespaces ( ) ,
87+ walletRegistry : filteredWalletRegistry ,
88+ } ,
89+ {
90+ onInitExternalWallets : this . onInitExternalWallets ,
91+ onSocialLogin : this . onSocialLogin ,
92+ onExternalWalletLogin : this . onExternalWalletLogin ,
93+ onModalVisibility : this . onModalVisibility ,
94+ }
95+ ) ;
96+ await withAbort ( ( ) => this . loginModal . initModal ( ) , signal ) ;
9897
99- // setup common JRPC provider
100- await withAbort ( ( ) => this . setupCommonJRPCProvider ( ) , signal ) ;
98+ // setup common JRPC provider
99+ await withAbort ( ( ) => this . setupCommonJRPCProvider ( ) , signal ) ;
101100
102- // initialize connectors
103- this . on ( CONNECTOR_EVENTS . CONNECTORS_UPDATED , ( { connectors : newConnectors } ) => {
104- const onAbortHandler = ( ) => {
105- log . debug ( "init aborted" ) ;
106- if ( this . connectors ?. length > 0 ) {
107- super . cleanup ( ) ;
108- }
109- } ;
110- withAbort ( ( ) => this . initConnectors ( { connectors : newConnectors , projectConfig, disabledExternalWallets } ) , signal , onAbortHandler ) ;
111- } ) ;
101+ // initialize connectors
102+ this . on ( CONNECTOR_EVENTS . CONNECTORS_UPDATED , ( { connectors : newConnectors } ) => {
103+ const onAbortHandler = ( ) => {
104+ log . debug ( "init aborted" ) ;
105+ if ( this . connectors ?. length > 0 ) {
106+ super . cleanup ( ) ;
107+ }
108+ } ;
109+ withAbort ( ( ) => this . initConnectors ( { connectors : newConnectors , projectConfig, disabledExternalWallets } ) , signal , onAbortHandler ) ;
110+ } ) ;
112111
113- await withAbort ( ( ) => super . loadConnectors ( { projectConfig, modalMode : true } ) , signal ) ;
112+ await withAbort ( ( ) => super . loadConnectors ( { projectConfig, modalMode : true } ) , signal ) ;
114113
115- // initialize plugins
116- await withAbort ( ( ) => super . initPlugins ( ) , signal ) ;
117- } catch ( error ) {
118- log . error ( "Failed to initialize modal" , error ) ;
119- throw error ;
120- }
114+ // initialize plugins
115+ await withAbort ( ( ) => super . initPlugins ( ) , signal ) ;
121116 }
122117
123118 public async connect ( ) : Promise < IProvider | null > {
0 commit comments