Skip to content

Commit d5c00aa

Browse files
feat: enable sign in with wallet for ecosystems
1 parent 9fadbcc commit d5c00aa

File tree

21 files changed

+75
-20
lines changed

21 files changed

+75
-20
lines changed

.changeset/fifty-houses-punch.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+
Enable Sign in with Wallet for ecosystems

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/auth-options-form.client.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ export function AuthOptionsForm({ ecosystem }: { ecosystem: Ecosystem }) {
227227
className="h-6 w-6"
228228
/>
229229
<p className="text-center font-normal">
230-
{option.slice(0, 1).toUpperCase() + option.slice(1)}
230+
{option === "siwe"
231+
? "Wallet"
232+
: option.slice(0, 1).toUpperCase() +
233+
option.slice(1)}
231234
</p>
232235
<div className="flex-1" />
233236
<FormControl>

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const authOptions = [
22
"email",
33
"phone",
4+
"passkey",
5+
"siwe",
6+
"guest",
47
"google",
58
"facebook",
69
"x",
@@ -12,7 +15,6 @@ export const authOptions = [
1215
"apple",
1316
"coinbase",
1417
"line",
15-
"guest",
1618
] as const;
1719

1820
export type Ecosystem = {

apps/playground-web/src/components/in-app-wallet/ecosystem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const getEcosystem = () => {
88
process.env.NEXT_PUBLIC_IN_APP_WALLET_URL?.endsWith(".thirdweb-dev.com")
99
) {
1010
// dev ecosystem
11-
return "ecosystem.bonfire-development";
11+
return "ecosystem.catlovers";
1212
}
1313
// prod ecosystem
1414
return "ecosystem.new-age";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function EcosystemWalletConnectUI(props: {
129129
done={done}
130130
onBack={goBackToMain || (() => setSelectionData({}))}
131131
locale={props.connectLocale}
132+
isLinking={state.walletLogin.linking}
132133
/>
133134
);
134135
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function InAppWalletConnectUI(props: {
116116
done={done}
117117
onBack={goBackToMain || (() => setSelectionData({}))}
118118
locale={props.connectLocale}
119+
isLinking={state.walletLogin.linking}
119120
/>
120121
);
121122
}

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function WalletAuth(props: {
2828
inAppLocale: InAppWalletLocale;
2929
onBack: () => void;
3030
walletConnect: { projectId?: string } | undefined;
31+
isLinking: boolean;
3132
meta?: {
3233
title?: string;
3334
titleIconUrl?: string;
@@ -61,16 +62,25 @@ export function WalletAuth(props: {
6162
setStatus("loading");
6263
walletToConnect.current = walletToLink;
6364
try {
64-
await linkProfile({
65-
client: props.client,
66-
strategy: "wallet",
67-
wallet: walletToLink,
68-
chain: wallet.getChain() || defineChain(1),
69-
ecosystem,
70-
}).catch((e) => {
71-
setError(e.message);
72-
throw e;
73-
});
65+
if (props.isLinking) {
66+
await linkProfile({
67+
client: props.client,
68+
strategy: "wallet",
69+
wallet: walletToLink,
70+
chain: wallet.getChain() || defineChain(1),
71+
ecosystem,
72+
}).catch((e) => {
73+
setError(e.message);
74+
throw e;
75+
});
76+
} else {
77+
await wallet.connect({
78+
client: props.client,
79+
strategy: "wallet",
80+
wallet: walletToLink,
81+
chain: walletToLink.getChain() || defineChain(1),
82+
});
83+
}
7484
addConnectedWallet(walletToLink);
7585
done();
7686
} catch {

packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export type ConnectWalletSelectUIState =
5757
connectionPromise: Promise<Account | Profile[]>;
5858
};
5959
passkeyLogin?: boolean;
60-
walletLogin?: boolean;
60+
walletLogin?: {
61+
linking: boolean;
62+
};
6163
};
6264

6365
const defaultAuthOptions: AuthOption[] = [
@@ -186,6 +188,7 @@ export const ConnectWalletSocialOptions = (
186188

187189
const passKeyEnabled = authOptions.includes("passkey");
188190
const guestEnabled = authOptions.includes("guest");
191+
const siweEnabled = authOptions.includes("wallet");
189192

190193
const placeholder =
191194
inputMode === "email" ? locale.emailPlaceholder : locale.phonePlaceholder;
@@ -306,7 +309,9 @@ export const ConnectWalletSocialOptions = (
306309

307310
function handleWalletLogin() {
308311
setData({
309-
walletLogin: true,
312+
walletLogin: {
313+
linking: props.isLinking || false,
314+
},
310315
});
311316
props.select();
312317
}
@@ -467,6 +472,18 @@ export const ConnectWalletSocialOptions = (
467472
/>
468473
)}
469474

475+
{/* SIWE login */}
476+
{siweEnabled && (
477+
<WalletTypeRowButton
478+
client={props.client}
479+
icon={getSocialIcon("")}
480+
onClick={() => {
481+
handleWalletLogin();
482+
}}
483+
title={locale.signInWithWallet}
484+
/>
485+
)}
486+
470487
{/* Guest login */}
471488
{guestEnabled && (
472489
<WalletTypeRowButton

packages/thirdweb/src/react/web/wallets/shared/locale/de.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ export default {
5858
passkey: "Passkey",
5959
linkWallet: "Verknüpfen Sie eine Brieftasche",
6060
loginAsGuest: "Melden Sie sich als Gast an",
61+
signInWithWallet: "Mit Wallet anmelden",
6162
} satisfies InAppWalletLocale;

packages/thirdweb/src/react/web/wallets/shared/locale/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default {
5555
signInWithPhone: "Sign in with phone number",
5656
phoneRequired: "Phone number is required",
5757
passkey: "Passkey",
58+
signInWithWallet: "Sign in with Wallet",
5859
linkWallet: "Link a Wallet",
5960
loginAsGuest: "Continue as guest",
6061
} satisfies InAppWalletLocale;

0 commit comments

Comments
 (0)