Skip to content

Commit 604f3f8

Browse files
changeset
1 parent 55dc3e4 commit 604f3f8

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

.changeset/chatty-candles-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Upgrade to wallet connect universal provider

packages/thirdweb/src/wallets/wallet-connect/controller.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff 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

packages/thirdweb/src/wallets/wallet-connect/types.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
// import type { UniversalProvider } from "@walletconnect/universal-provider"; // Types defined manually
21
import type { Chain } from "../../chains/types.js";
32
import type { ThirdwebClient } from "../../client/client.js";
43
import type { Prettify } from "../../utils/type-utils.js";
54
import 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-
226
type WalletConnectQRCodeModalOptions = {
237
themeMode?: "light" | "dark";
248
themeVariables?: Record<string, string>;

0 commit comments

Comments
 (0)