Skip to content

Commit 0ea25bb

Browse files
[SDK] Update walletconnect provider to universal (#7532)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 67293fc commit 0ea25bb

File tree

13 files changed

+399
-537
lines changed

13 files changed

+399
-537
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

apps/playground-web/src/app/connect/sign-in/button/RightSection.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import { XIcon } from "lucide-react";
33
import { usePathname } from "next/navigation";
44
import { useEffect, useState } from "react";
55
import {
6+
abstract,
7+
arbitrum,
68
arbitrumSepolia,
9+
base,
710
baseSepolia,
8-
defineChain,
11+
ethereum,
12+
optimism,
913
optimismSepolia,
14+
polygon,
1015
sepolia,
1116
} from "thirdweb/chains";
1217
import {
@@ -115,7 +120,12 @@ export function RightSection(props: {
115120
auth={connectOptions.enableAuth ? playgroundAuth : undefined}
116121
autoConnect={false}
117122
chains={[
118-
defineChain(578),
123+
base,
124+
ethereum,
125+
polygon,
126+
optimism,
127+
arbitrum,
128+
abstract,
119129
sepolia,
120130
baseSepolia,
121131
optimismSepolia,

apps/playground-web/src/components/styled-connect-button.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
import { useTheme } from "next-themes";
44
import {
55
abstract,
6+
arbitrum,
67
arbitrumSepolia,
8+
base,
79
baseSepolia,
10+
ethereum,
11+
optimism,
812
optimismSepolia,
13+
polygon,
914
polygonAmoy,
1015
sepolia,
1116
} from "thirdweb/chains";
@@ -28,6 +33,11 @@ export function StyledConnectButton(
2833
polygonAmoy,
2934
arbitrumSepolia,
3035
abstract,
36+
base,
37+
ethereum,
38+
polygon,
39+
optimism,
40+
arbitrum,
3141
]}
3242
client={THIRDWEB_CLIENT}
3343
theme={theme === "light" ? "light" : "dark"}

apps/playground-web/src/components/styled-connect-embed.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
import { useTheme } from "next-themes";
44
import {
5+
abstract,
6+
arbitrum,
57
arbitrumSepolia,
8+
base,
69
baseSepolia,
10+
ethereum,
11+
optimism,
712
optimismSepolia,
13+
polygon,
814
polygonAmoy,
915
sepolia,
1016
} from "thirdweb/chains";
@@ -30,11 +36,17 @@ export function StyledConnectEmbed(
3036
) : (
3137
<ConnectEmbed
3238
chains={[
39+
base,
40+
ethereum,
41+
polygon,
42+
optimism,
43+
arbitrum,
3344
sepolia,
3445
baseSepolia,
3546
optimismSepolia,
3647
polygonAmoy,
3748
arbitrumSepolia,
49+
abstract,
3850
]}
3951
client={THIRDWEB_CLIENT}
4052
theme={theme === "light" ? "light" : "dark"}

packages/thirdweb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"@tanstack/react-query": "5.81.5",
2626
"@thirdweb-dev/engine": "workspace:*",
2727
"@thirdweb-dev/insight": "workspace:*",
28-
"@walletconnect/ethereum-provider": "2.20.1",
2928
"@walletconnect/sign-client": "2.20.1",
29+
"@walletconnect/universal-provider": "2.21.4",
3030
"abitype": "1.0.8",
3131
"cross-spawn": "7.0.6",
3232
"fuse.js": "7.1.0",

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export function BuyWidget(props: BuyWidgetProps) {
282282
toChainId: props.chain.id,
283283
toToken: props.tokenAddress,
284284
});
285+
return true;
285286
},
286287
queryKey: ["buy_widget:render"],
287288
});

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
265265
toChainId: props.chain.id,
266266
toToken: props.tokenAddress,
267267
});
268+
return true;
268269
},
269270
queryKey: ["checkout_widget:render"],
270271
});

packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export function TransactionWidget(props: TransactionWidgetProps) {
292292
event: "ub:ui:transaction_widget:render",
293293
toToken: props.tokenAddress,
294294
});
295+
return true;
295296
},
296297
queryKey: ["transaction_widget:render"],
297298
});

packages/thirdweb/src/wallets/create-wallet.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,14 @@ export function createWallet<const ID extends WalletId>(
399399
getConfig: () => args[1],
400400
id,
401401
subscribe: emitter.subscribe,
402-
switchChain: (c) => handleSwitchChain(c),
402+
switchChain: async (c) => {
403+
try {
404+
await handleSwitchChain(c);
405+
chain = c;
406+
} catch (e) {
407+
console.error("Error switching chain", e);
408+
}
409+
},
403410
};
404411
return wallet;
405412
}

packages/thirdweb/src/wallets/native/create-wallet.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,14 @@ export function createWallet<const ID extends WalletId>(
230230
getConfig: () => args[1],
231231
id,
232232
subscribe: emitter.subscribe,
233-
switchChain: (c) => handleSwitchChain(c),
233+
switchChain: async (c) => {
234+
try {
235+
await handleSwitchChain(c);
236+
chain = c;
237+
} catch (e) {
238+
console.error("Error switching chain", e);
239+
}
240+
},
234241
};
235242
return wallet;
236243
}

0 commit comments

Comments
 (0)