1
- import { BehaviorSubject , firstValueFrom } from 'rxjs'
1
+ import { firstValueFrom , Observable } from 'rxjs'
2
2
import { filter , map } from 'rxjs/operators'
3
3
import { Chain , ProviderRpcErrorCode } from '@web3-onboard/common'
4
4
import { addNewChain , switchChain } from './provider.js'
@@ -71,7 +71,12 @@ async function setChain(options: {
71
71
code === ProviderRpcErrorCode . UNRECOGNIZED_CHAIN_ID
72
72
) {
73
73
// 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
+ )
75
80
}
76
81
77
82
if ( code === ProviderRpcErrorCode . UNSUPPORTED_METHOD ) {
@@ -87,11 +92,9 @@ async function setChain(options: {
87
92
const chainNotInWallet = async (
88
93
wallet : WalletState ,
89
94
chain : Chain ,
90
- switchChainModalClosed$ : BehaviorSubject < {
91
- chain : Chain
92
- } > ,
95
+ switchChainModalClosed$ : Observable < boolean > ,
93
96
chainIdHex : string
94
- ) => {
97
+ ) : Promise < boolean > => {
95
98
try {
96
99
await addNewChain ( wallet . provider , chain )
97
100
await switchChain ( wallet . provider , chainIdHex )
0 commit comments