Skip to content

Commit 36b94d6

Browse files
Merge pull request #2276 from Web3Auth/fix/merge-project-config
fix: merge auth config from user and dashboard
2 parents 0e51ff6 + 94f0138 commit 36b94d6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/modal/src/modalManager.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
375375
showOnModal: true,
376376
};
377377
}
378-
embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
378+
const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
379+
embedWalletConfigMap.set(id, authConnectionConfig);
379380
}
380381

381382
const dashboardConnectorConfig = {
@@ -397,13 +398,15 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
397398

398399
// only throw error if one of them is defined in the config.
399400
if (groupedAuthConnectionId || authConnectionId) {
400-
if (!embedWalletConfigMap.has(groupedAuthConnectionId || authConnectionId))
401+
const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
402+
if (!embedWalletConfigMap.has(id))
401403
throw WalletInitializationError.invalidParams(
402404
`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`
403405
);
404406

405-
const configFromDashboard = embedWalletConfigMap.get(groupedAuthConnectionId || authConnectionId);
407+
const configFromDashboard = embedWalletConfigMap.get(id);
406408
this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods[key as AUTH_CONNECTION_TYPE] = {
409+
...userConfig,
407410
authConnection: configFromDashboard.authConnection,
408411
authConnectionId: configFromDashboard.authConnectionId,
409412
groupedAuthConnectionId: configFromDashboard.groupedAuthConnectionId,
@@ -656,4 +659,12 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
656659
private getChainNamespaces = (): ChainNamespaceType[] => {
657660
return [...new Set(this.coreOptions.chains?.map((x) => x.chainNamespace) || [])];
658661
};
662+
663+
private getCombinedConnectionId(authConnectionId: string, groupedAuthConnectionId: string): string {
664+
let id = authConnectionId;
665+
if (groupedAuthConnectionId) {
666+
id = `${groupedAuthConnectionId}_${authConnectionId}`;
667+
}
668+
return id;
669+
}
659670
}

0 commit comments

Comments
 (0)