Skip to content

Commit 4b7acd9

Browse files
authored
Fix formatting & typecheck for the Add new Chain Canceled bug (#1286)
* Fix formatting and add return type * Cleanup imports
1 parent ec5dbbb commit 4b7acd9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/core/src/chain.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BehaviorSubject, firstValueFrom } from 'rxjs'
1+
import { firstValueFrom, Observable } from 'rxjs'
22
import { filter, map } from 'rxjs/operators'
33
import { Chain, ProviderRpcErrorCode } from '@web3-onboard/common'
44
import { addNewChain, switchChain } from './provider.js'
@@ -71,7 +71,12 @@ async function setChain(options: {
7171
code === ProviderRpcErrorCode.UNRECOGNIZED_CHAIN_ID
7272
) {
7373
// chain has not been added to wallet
74-
return chainNotInWallet(wallet, chain, switchChainModal$, chainIdHex)
74+
return chainNotInWallet(
75+
wallet,
76+
chain,
77+
switchChainModalClosed$,
78+
chainIdHex
79+
)
7580
}
7681

7782
if (code === ProviderRpcErrorCode.UNSUPPORTED_METHOD) {
@@ -87,11 +92,9 @@ async function setChain(options: {
8792
const chainNotInWallet = async (
8893
wallet: WalletState,
8994
chain: Chain,
90-
switchChainModalClosed$: BehaviorSubject<{
91-
chain: Chain
92-
}>,
95+
switchChainModalClosed$: Observable<boolean>,
9396
chainIdHex: string
94-
) => {
97+
): Promise<boolean> => {
9598
try {
9699
await addNewChain(wallet.provider, chain)
97100
await switchChain(wallet.provider, chainIdHex)

0 commit comments

Comments
 (0)