diff --git a/packages/core/src/chain.ts b/packages/core/src/chain.ts index 58409a2e2..ce4bf05ab 100644 --- a/packages/core/src/chain.ts +++ b/packages/core/src/chain.ts @@ -1,4 +1,4 @@ -import { BehaviorSubject, firstValueFrom } from 'rxjs' +import { firstValueFrom, Observable } from 'rxjs' import { filter, map } from 'rxjs/operators' import { Chain, ProviderRpcErrorCode } from '@web3-onboard/common' import { addNewChain, switchChain } from './provider.js' @@ -71,7 +71,12 @@ async function setChain(options: { code === ProviderRpcErrorCode.UNRECOGNIZED_CHAIN_ID ) { // chain has not been added to wallet - return chainNotInWallet(wallet, chain, switchChainModal$, chainIdHex) + return chainNotInWallet( + wallet, + chain, + switchChainModalClosed$, + chainIdHex + ) } if (code === ProviderRpcErrorCode.UNSUPPORTED_METHOD) { @@ -87,11 +92,9 @@ async function setChain(options: { const chainNotInWallet = async ( wallet: WalletState, chain: Chain, - switchChainModalClosed$: BehaviorSubject<{ - chain: Chain - }>, + switchChainModalClosed$: Observable, chainIdHex: string -) => { +): Promise => { try { await addNewChain(wallet.provider, chain) await switchChain(wallet.provider, chainIdHex)