File tree Expand file tree Collapse file tree 3 files changed +8
-22
lines changed
packages/thirdweb/src/wallets/wallet-connect Expand file tree Collapse file tree 3 files changed +8
-22
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Upgrade to wallet connect universal provider
Original file line number Diff line number Diff line change @@ -148,23 +148,20 @@ export async function connectWC(
148148 chainsToRequest . map ( ( x ) => Number ( x . split ( ":" ) [ 1 ] ) ) ,
149149 storage ,
150150 ) ;
151- // If session exists and chains are authorized, enable provider for required chain
151+ const currentChainId = chainsToRequest [ 0 ] ?. split ( ":" ) [ 1 ] || 1 ;
152+ const providerChainId = normalizeChainId ( currentChainId ) ;
152153 const accounts : string [ ] = await provider . request (
153154 {
154155 method : "eth_requestAccounts" ,
155156 params : [ ] ,
156157 } ,
157- `eip155:${ chainToRequest ?. id } ` ,
158+ `eip155:${ providerChainId } ` ,
158159 ) ;
159160 const address = accounts [ 0 ] ;
160161 if ( ! address ) {
161162 throw new Error ( "No accounts found on provider." ) ;
162163 }
163164
164- // For UniversalProvider, get chainId from the session namespaces
165- const currentChainId = chainsToRequest [ 0 ] ?. split ( ":" ) [ 1 ] || 1 ;
166- const providerChainId = normalizeChainId ( currentChainId ) ;
167-
168165 const chain =
169166 options . chain && options . chain . id === providerChainId
170167 ? options . chain
Original file line number Diff line number Diff line change 1- // import type { UniversalProvider } from "@walletconnect/universal-provider"; // Types defined manually
21import type { Chain } from "../../chains/types.js" ;
32import type { ThirdwebClient } from "../../client/client.js" ;
43import type { Prettify } from "../../utils/type-utils.js" ;
54import type { AppMetadata } from "../types.js" ;
65
7- // For UniversalProvider, we need to define the options manually since it has a different API
8- export type UniversalProviderOptions = {
9- projectId : string ;
10- relayUrl ?: string ;
11- metadata ?: {
12- name : string ;
13- description : string ;
14- url : string ;
15- icons : string [ ] ;
16- } ;
17- logger ?: string ;
18- storage ?: Record < string , unknown > ;
19- storageOptions ?: Record < string , unknown > ;
20- } ;
21-
226type WalletConnectQRCodeModalOptions = {
237 themeMode ?: "light" | "dark" ;
248 themeVariables ?: Record < string , string > ;
You can’t perform that action at this time.
0 commit comments