Skip to content

Commit 5b0dca7

Browse files
refactor: consolidate ecosystem auth and smart account options
1 parent 364d97e commit 5b0dca7

File tree

8 files changed

+428
-216
lines changed

8 files changed

+428
-216
lines changed

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

Lines changed: 405 additions & 193 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Skeleton } from "@/components/ui/skeleton";
21
import type { Ecosystem } from "../../../../types";
32
import {
43
AuthOptionsForm,
@@ -10,15 +9,11 @@ export function AuthOptionsSection({ ecosystem }: { ecosystem?: Ecosystem }) {
109
<section className="flex flex-col gap-4 md:gap-8">
1110
<div className="flex flex-col gap-1">
1211
<h4 className="font-semibold text-2xl text-foreground">
13-
Authentication Options
12+
Authentication
1413
</h4>
15-
{ecosystem ? (
16-
<p className="text-muted-foreground text-sm">
17-
Configure the authentication options your ecosystem supports.
18-
</p>
19-
) : (
20-
<Skeleton className="h-6 w-[300px]" />
21-
)}
14+
<p className="text-muted-foreground text-sm">
15+
Configure the authentication options your ecosystem supports.
16+
</p>
2217
</div>
2318
{ecosystem ? (
2419
<AuthOptionsForm ecosystem={ecosystem} />

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export const authOptions = [
2+
"email",
3+
"phone",
24
"google",
35
"facebook",
46
"x",
@@ -7,12 +9,10 @@ export const authOptions = [
79
"telegram",
810
"github",
911
"twitch",
10-
"phone",
11-
"email",
12-
"guest",
1312
"apple",
1413
"coinbase",
1514
"line",
15+
"guest",
1616
] as const;
1717

1818
export type Ecosystem = {
@@ -31,12 +31,12 @@ export type Ecosystem = {
3131
jwksUri: string;
3232
aud: string;
3333
};
34-
};
34+
} | null;
3535
smartAccountOptions?: {
3636
chainIds: number[];
3737
sponsorGas: boolean;
3838
accountFactoryAddress: string;
39-
};
39+
} | null;
4040
url: string;
4141
status: "active" | "requested" | "paymentFailed";
4242
createdAt: string;

packages/thirdweb/src/exports/wallets/in-app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ export type {
2121

2222
export { hasStoredPasskey } from "../../wallets/in-app/web/lib/auth/passkeys.js";
2323

24-
export { socialIcons } from "../../react/core/utils/walletIcon.js";
24+
export {
25+
socialIcons,
26+
getSocialIcon,
27+
} from "../../react/core/utils/walletIcon.js";

packages/thirdweb/src/react/core/utils/walletIcon.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AuthOption } from "../../../wallets/types.js";
2+
13
// TODO make the social icons usable in RN too
24
const googleIconUri =
35
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3MDUuNiIgaGVpZ2h0PSI3MjAiIHZpZXdCb3g9IjAgMCAxODYuNjkgMTkwLjUiIHhtbG5zOnY9Imh0dHBzOi8vdmVjdGEuaW8vbmFubyI+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTE4NC41ODMgNzY1LjE3MSkiPjxwYXRoIGNsaXAtcGF0aD0ibm9uZSIgbWFzaz0ibm9uZSIgZD0iTS0xMDg5LjMzMy02ODcuMjM5djM2Ljg4OGg1MS4yNjJjLTIuMjUxIDExLjg2My05LjAwNiAyMS45MDgtMTkuMTM3IDI4LjY2MmwzMC45MTMgMjMuOTg2YzE4LjAxMS0xNi42MjUgMjguNDAyLTQxLjA0NCAyOC40MDItNzAuMDUyIDAtNi43NTQtLjYwNi0xMy4yNDktMS43MzItMTkuNDgzeiIgZmlsbD0iIzQyODVmNCIvPjxwYXRoIGNsaXAtcGF0aD0ibm9u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
};
5052

5153
// TODO: this should return actual <svg> elements so they can be themed
52-
export function getWalletIcon(provider: string) {
54+
export function getSocialIcon(provider: AuthOption | ({} & string)) {
5355
switch (provider) {
5456
case "google":
5557
return googleIconUri;

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { shortenAddress } from "../../../../../utils/address.js";
44
import type { Profile } from "../../../../../wallets/in-app/core/authentication/types.js";
55
import { fontSize, iconSize } from "../../../../core/design-system/index.js";
66
import { useSocialProfiles } from "../../../../core/social/useSocialProfiles.js";
7-
import { getWalletIcon } from "../../../../core/utils/walletIcon.js";
7+
import { getSocialIcon } from "../../../../core/utils/walletIcon.js";
88
import { useProfiles } from "../../../hooks/wallets/useProfiles.js";
99
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
1010
import { Img } from "../../components/Img.js";
@@ -149,7 +149,7 @@ function LinkedProfile({
149149
</Container>
150150
) : (
151151
<Img
152-
src={getWalletIcon(profile.type)}
152+
src={getSocialIcon(profile.type)}
153153
width={iconSize.lg}
154154
height={iconSize.lg}
155155
loading="eager"

packages/thirdweb/src/react/web/ui/components/WalletImage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getLastAuthProvider } from "../../../core/utils/storage.js";
1111
import { useWalletImage } from "../../../core/utils/wallet.js";
1212
import {
1313
genericWalletIcon,
14-
getWalletIcon,
14+
getSocialIcon,
1515
} from "../../../core/utils/walletIcon.js";
1616
import { Img } from "./Img.js";
1717

@@ -43,7 +43,7 @@ export function WalletImage(props: {
4343
// when showing an active wallet icon - check last auth provider and override the IAW icon
4444
const lastAuthProvider = await getLastAuthProvider(storage);
4545
image = lastAuthProvider
46-
? getWalletIcon(lastAuthProvider)
46+
? getSocialIcon(lastAuthProvider)
4747
: genericWalletIcon;
4848
} else {
4949
const mipdImage = getInstalledWalletProviders().find(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import { setLastAuthProvider } from "../../../core/utils/storage.js";
2727
import {
2828
emailIcon,
29-
getWalletIcon,
29+
getSocialIcon,
3030
passkeyIcon,
3131
phoneIcon,
3232
socialIcons,
@@ -471,7 +471,7 @@ export const ConnectWalletSocialOptions = (
471471
{guestEnabled && (
472472
<WalletTypeRowButton
473473
client={props.client}
474-
icon={getWalletIcon("guest")}
474+
icon={getSocialIcon("guest")}
475475
onClick={() => {
476476
handleGuestLogin();
477477
}}
@@ -483,7 +483,7 @@ export const ConnectWalletSocialOptions = (
483483
{props.isLinking && (
484484
<WalletTypeRowButton
485485
client={props.client}
486-
icon={getWalletIcon("")}
486+
icon={getSocialIcon("")}
487487
onClick={() => {
488488
handleWalletLogin();
489489
}}

0 commit comments

Comments
 (0)