Skip to content

Commit e10c1e6

Browse files
[SDK] Pass through desired chain when signing in with wallet for ecosystems (#6686)
1 parent a230532 commit e10c1e6

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.changeset/orange-suns-attack.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+
Pass through desired chain when signing in with wallet for ecosystems

packages/thirdweb/src/react/web/wallets/ecosystem/EcosystemWalletConnectUI.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function EcosystemWalletConnectUI(props: {
121121
return (
122122
<WalletAuth
123123
meta={props.meta}
124+
chain={props.chain}
124125
inAppLocale={locale}
125126
walletConnect={props.walletConnect}
126127
wallet={props.wallet}

packages/thirdweb/src/react/web/wallets/in-app/InAppWalletConnectUI.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function InAppWalletConnectUI(props: {
113113
wallet={props.wallet}
114114
client={props.client}
115115
size={props.size}
116+
chain={props.chain}
116117
done={done}
117118
onBack={goBackToMain || (() => setSelectionData({}))}
118119
locale={props.connectLocale}

packages/thirdweb/src/react/web/wallets/in-app/WalletAuth.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Suspense, useRef, useState } from "react";
2+
import type { Chain } from "../../../../chains/types.js";
23
import { defineChain } from "../../../../chains/utils.js";
34
import type { ThirdwebClient } from "../../../../client/client.js";
45
import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
@@ -21,6 +22,7 @@ import type { InAppWalletLocale } from "../shared/locale/types.js";
2122

2223
export function WalletAuth(props: {
2324
wallet: Wallet<"inApp" | EcosystemWalletId>;
25+
chain: Chain | undefined;
2426
client: ThirdwebClient;
2527
done: () => void;
2628
size: "compact" | "wide";
@@ -60,30 +62,29 @@ export function WalletAuth(props: {
6062

6163
async function login(walletToLink: Wallet) {
6264
setStatus("loading");
65+
setError(undefined);
6366
walletToConnect.current = walletToLink;
6467
try {
6568
if (props.isLinking) {
6669
await linkProfile({
6770
client: props.client,
6871
strategy: "wallet",
6972
wallet: walletToLink,
70-
chain: wallet.getChain() || defineChain(1),
73+
chain: props.chain || wallet.getChain() || defineChain(1),
7174
ecosystem,
72-
}).catch((e) => {
73-
setError(e.message);
74-
throw e;
7575
});
7676
} else {
7777
await wallet.connect({
7878
client: props.client,
7979
strategy: "wallet",
8080
wallet: walletToLink,
81-
chain: walletToLink.getChain() || defineChain(1),
81+
chain: props.chain || walletToLink.getChain() || defineChain(1),
8282
});
8383
}
8484
addConnectedWallet(walletToLink);
8585
done();
86-
} catch {
86+
} catch (e) {
87+
setError(e instanceof Error ? e.message : "Unknown error");
8788
setStatus("error");
8889
}
8990
}

0 commit comments

Comments
 (0)