Skip to content

Commit 7e9a6fd

Browse files
Merge pull request #2097 from Web3Auth/feat/sdk-v10-chains
Feat/sdk v10 - Multi chains for Auth connector
2 parents 817cc82 + 06b3600 commit 7e9a6fd

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

packages/no-modal/src/base/core/IWeb3Auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { type WALLET_CONNECTOR_TYPE } from "../wallet";
2020

2121
export type WalletServicesConfig = Omit<
2222
WsEmbedParams,
23-
"buildEnv" | "enableLogging" | "chainConfig" | "confirmationStrategy" | "accountAbstractionConfig"
23+
"buildEnv" | "enableLogging" | "chainId" | "chains" | "confirmationStrategy" | "accountAbstractionConfig"
2424
> & {
2525
/**
2626
* Determines how to show confirmation screens

packages/no-modal/src/connectors/auth-connector/authConnector.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type EthereumProviderConfig } from "@toruslabs/ethereum-controllers";
1+
import { ProviderConfig } from "@toruslabs/base-controllers";
22
import { Auth, LOGIN_PROVIDER, LoginParams, SUPPORTED_KEY_CURVES, UX_MODE, WEB3AUTH_NETWORK } from "@web3auth/auth";
33
import { type default as WsEmbed } from "@web3auth/ws-embed";
44
import deepmerge from "deepmerge";
@@ -51,7 +51,7 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
5151

5252
private loginSettings: LoginSettings = { loginProvider: "" };
5353

54-
private wsSettings: WalletServicesSettings = {};
54+
private wsSettings: WalletServicesSettings;
5555

5656
private wsEmbedInstance: WsEmbed | null = null;
5757

@@ -60,7 +60,7 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
6060

6161
this.authOptions = params.connectorSettings;
6262
this.loginSettings = params.loginSettings || { loginProvider: "" };
63-
this.wsSettings = params.walletServicesSettings || {};
63+
this.wsSettings = params.walletServicesSettings;
6464
}
6565

6666
get provider(): IProvider | null {
@@ -81,7 +81,9 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
8181
}
8282

8383
async init(options: ConnectorInitOptions): Promise<void> {
84-
const chainConfig = this.coreOptions.chains.find((x) => x.chainId === options.chainId);
84+
const { chains } = this.coreOptions;
85+
const { chainId } = options;
86+
const chainConfig = chains.find((x) => x.chainId === chainId);
8587

8688
super.checkInitializationRequirements({ chainConfig });
8789
if (!this.coreOptions.clientId) throw WalletInitializationError.invalidParams("clientId is required before auth's initialization");
@@ -113,10 +115,13 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
113115
web3AuthNetwork,
114116
modalZIndex: this.wsSettings.modalZIndex,
115117
});
116-
// TODO: once support multiple chains, only pass chains of solana and EVM
118+
const wsSupportedChains = chains.filter(
119+
(x) => x.chainNamespace === CHAIN_NAMESPACES.EIP155 || x.chainNamespace === CHAIN_NAMESPACES.SOLANA
120+
);
117121
await this.wsEmbedInstance.init({
118122
...this.wsSettings,
119-
chainConfig: chainConfig as EthereumProviderConfig, // TODO: upgrade ws-embed to support custom chain config
123+
chains: wsSupportedChains as ProviderConfig[],
124+
chainId,
120125
whiteLabel: {
121126
...this.authOptions.whiteLabel,
122127
...this.wsSettings.whiteLabel,

packages/no-modal/src/connectors/auth-connector/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type LoginSettings = Partial<LoginParams> & Partial<BaseRedirectParams>;
77

88
export type PrivateKeyProvider = IBaseProvider<string>;
99

10-
export type WalletServicesSettings = WsEmbedParams & { modalZIndex?: number };
10+
export type WalletServicesSettings = Omit<WsEmbedParams, "chains" | "chainId"> & { modalZIndex?: number };
1111

1212
export interface AuthConnectorOptions extends BaseConnectorSettings {
1313
connectorSettings?: Omit<AuthOptions, "clientId" | "network">;

0 commit comments

Comments
 (0)