@@ -63,12 +63,9 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
6363 super . checkInitRequirements ( ) ;
6464 // get project config and wallet registry
6565 const { projectConfig, walletRegistry } = await this . getProjectAndWalletConfig ( ) ;
66- this . options . uiConfig = deepmerge ( cloneDeep ( projectConfig . whitelabel || { } ) , this . options . uiConfig || { } ) ;
67- if ( ! this . options . uiConfig . defaultLanguage ) this . options . uiConfig . defaultLanguage = getUserLanguage ( this . options . uiConfig . defaultLanguage ) ;
68- if ( ! this . options . uiConfig . mode ) this . options . uiConfig . mode = "light" ;
69- this . options . uiConfig = deepmerge ( projectConfig . loginModal || { } , this . options . uiConfig || { } ) ;
7066
7167 // init config
68+ this . initUIConfig ( projectConfig ) ;
7269 super . initAccountAbstractionConfig ( projectConfig ) ;
7370 super . initChainsConfig ( projectConfig ) ;
7471 super . initCachedConnectorAndChainId ( ) ;
@@ -194,6 +191,25 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
194191 return { projectConfig, walletRegistry } ;
195192 }
196193
194+ private initUIConfig ( projectConfig : ProjectConfig ) {
195+ this . options . uiConfig = deepmerge ( cloneDeep ( projectConfig . whitelabel || { } ) , this . options . uiConfig || { } ) ;
196+ if ( ! this . options . uiConfig . defaultLanguage ) this . options . uiConfig . defaultLanguage = getUserLanguage ( this . options . uiConfig . defaultLanguage ) ;
197+ if ( ! this . options . uiConfig . mode ) this . options . uiConfig . mode = "light" ;
198+ this . options . uiConfig = deepmerge ( projectConfig . loginModal || { } , this . options . uiConfig ) ;
199+
200+ // merge login methods order from project config and user config, with user config taking precedence
201+ const defaultAuthConnections = projectConfig . embeddedWalletAuth . filter ( ( x ) => x . isDefault ) . map ( ( x ) => x . authConnection ) ;
202+ const mergedAuthConnections = [ ...( this . options . uiConfig . loginMethodsOrder || [ ] ) , ...defaultAuthConnections ] ;
203+ const loginMethodsOrder = [ ] ;
204+ const authConnectionSet = new Set ( ) ;
205+ for ( const authConnection of mergedAuthConnections ) {
206+ if ( authConnectionSet . has ( authConnection ) ) continue ;
207+ authConnectionSet . add ( authConnection ) ;
208+ loginMethodsOrder . push ( authConnection ) ;
209+ }
210+ this . options . uiConfig . loginMethodsOrder = loginMethodsOrder ;
211+ }
212+
197213 private async initConnectors ( {
198214 connectors,
199215 projectConfig,
0 commit comments