@@ -65,7 +65,7 @@ const storageKeys = {
65
65
export async function connectWC (
66
66
options : WCConnectOptions ,
67
67
emitter : WalletEmitter < WCSupportedWalletIds > ,
68
- walletId : WCSupportedWalletIds ,
68
+ walletId : WCSupportedWalletIds | "walletConnect" ,
69
69
) : Promise < ReturnType < typeof onConnect > > {
70
70
const provider = await initProvider ( options , walletId ) ;
71
71
@@ -140,7 +140,7 @@ export async function connectWC(
140
140
export async function autoConnectWC (
141
141
options : WCAutoConnectOptions ,
142
142
emitter : WalletEmitter < WCSupportedWalletIds > ,
143
- walletId : WCSupportedWalletIds ,
143
+ walletId : WCSupportedWalletIds | "walletConnect" ,
144
144
) : Promise < ReturnType < typeof onConnect > > {
145
145
const savedConnectParams : SavedConnectParams | null = asyncLocalStorage
146
146
? await getSavedConnectParamsFromStorage ( asyncLocalStorage , walletId )
@@ -196,7 +196,7 @@ export async function autoConnectWC(
196
196
197
197
async function initProvider (
198
198
options : WCConnectOptions ,
199
- walletId : WCSupportedWalletIds ,
199
+ walletId : WCSupportedWalletIds | "walletConnect" ,
200
200
isAutoConnect = false ,
201
201
) {
202
202
const walletInfo = await getWalletInfo ( walletId ) ;
@@ -257,33 +257,41 @@ async function initProvider(
257
257
}
258
258
}
259
259
260
- function handleSessionRequest ( ) {
261
- if ( typeof window === "undefined" ) {
262
- return ;
263
- }
260
+ if ( walletId !== "walletConnect" ) {
261
+ function handleSessionRequest ( ) {
262
+ if ( typeof window === "undefined" ) {
263
+ return ;
264
+ }
264
265
265
- if ( ! isMobile ( ) ) {
266
- return ;
267
- }
266
+ if ( ! isMobile ( ) ) {
267
+ return ;
268
+ }
268
269
269
- const preferUniversal =
270
- walletInfo . mobile . universal || walletInfo . mobile . native || "" ;
271
- const preferNative =
272
- walletInfo . mobile . native || walletInfo . mobile . universal || "" ;
270
+ const preferUniversal =
271
+ walletInfo . mobile . universal || walletInfo . mobile . native ;
272
+ const preferNative =
273
+ walletInfo . mobile . native || walletInfo . mobile . universal ;
273
274
274
- if ( isAndroid ( ) ) {
275
- openWindow ( preferUniversal ) ;
276
- } else if ( isIOS ( ) ) {
277
- openWindow ( preferNative ) ;
278
- } else {
279
- openWindow ( preferUniversal ) ;
275
+ if ( isAndroid ( ) ) {
276
+ if ( preferUniversal ) {
277
+ openWindow ( preferUniversal ) ;
278
+ }
279
+ } else if ( isIOS ( ) ) {
280
+ if ( preferNative ) {
281
+ openWindow ( preferNative ) ;
282
+ }
283
+ } else {
284
+ if ( preferUniversal ) {
285
+ openWindow ( preferUniversal ) ;
286
+ }
287
+ }
280
288
}
281
- }
282
289
283
- provider . signer . client . on ( "session_request_sent" , handleSessionRequest ) ;
284
- provider . events . addListener ( "disconnect" , ( ) => {
285
- provider . signer . client . off ( "session_request_sent" , handleSessionRequest ) ;
286
- } ) ;
290
+ provider . signer . client . on ( "session_request_sent" , handleSessionRequest ) ;
291
+ provider . events . addListener ( "disconnect" , ( ) => {
292
+ provider . signer . client . off ( "session_request_sent" , handleSessionRequest ) ;
293
+ } ) ;
294
+ }
287
295
288
296
// try switching to correct chain
289
297
if ( options ?. chain && provider . chainId !== options ?. chain . id ) {
0 commit comments