Skip to content

Commit 56660d3

Browse files
author
Nguyen Anh Tu
committed
fix switch chain use new chain id
1 parent 03e78a5 commit 56660d3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,12 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
250250

251251
public async switchChain(params: { chainId: string }, init = false): Promise<void> {
252252
super.checkSwitchChainRequirements(params, init);
253-
const currentChainId = this.provider.chainId;
254253
// TODO: handle when chainIds are the same
255254
// TODO: need to handle switching to a different chain namespace
256255

257-
const chainConfig = this.coreOptions.chains.find((x) => x.chainId === currentChainId);
258-
if (!chainConfig) throw WalletLoginError.connectionError("Chain config is not available");
259-
const { chainNamespace } = chainConfig;
256+
const newChain = this.getChain(params.chainId);
257+
if (!newChain) throw WalletLoginError.connectionError("Chain config is not available");
258+
const { chainNamespace } = newChain;
260259

261260
if (chainNamespace === CHAIN_NAMESPACES.EIP155) {
262261
await this.wsEmbedInstance.provider?.request({

0 commit comments

Comments
 (0)