@b3dotfun/sdk 0.1.69-alpha.24 → 0.1.69-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +4 -2
- package/dist/cjs/global-account/react/components/ManageAccount/Header.js +37 -4
- package/dist/cjs/global-account/react/components/ManageAccount/HomeContent.js +4 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +5 -3
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +25 -14
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +14 -4
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +5 -3
- package/dist/esm/global-account/react/components/ManageAccount/Header.js +38 -5
- package/dist/esm/global-account/react/components/ManageAccount/HomeContent.js +4 -1
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +6 -4
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +4 -2
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +25 -14
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +16 -6
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +3 -1
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +18 -14
- package/src/global-account/react/components/ManageAccount/Header.tsx +74 -4
- package/src/global-account/react/components/ManageAccount/HomeContent.tsx +25 -19
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +14 -7
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +18 -14
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +29 -20
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +43 -14
- package/src/shared/constants/index.ts +2 -0
|
@@ -4,16 +4,19 @@ import {
|
|
|
4
4
|
SignInWithB3ModalProps,
|
|
5
5
|
StyleRoot,
|
|
6
6
|
useAccountWallet,
|
|
7
|
+
useAuthStore,
|
|
7
8
|
useAuthentication,
|
|
8
9
|
useB3Config,
|
|
9
10
|
useIsMobile,
|
|
10
11
|
} from "@b3dotfun/sdk/global-account/react";
|
|
11
12
|
import Icon from "@b3dotfun/sdk/global-account/react/components/custom/Icon";
|
|
12
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
13
|
+
import { AVATAR_COLORS, ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
13
14
|
import { cn, truncateAddress } from "@b3dotfun/sdk/shared/utils";
|
|
14
15
|
import { Menu, MenuButton, MenuItems, Transition } from "@headlessui/react";
|
|
16
|
+
import Avatar from "boring-avatars";
|
|
15
17
|
import { ReactNode, useEffect } from "react";
|
|
16
18
|
import { useConnectedWallets, useSetActiveWallet, useWalletImage } from "thirdweb/react";
|
|
19
|
+
import { useUser } from "../../hooks/useUser";
|
|
17
20
|
import { ManageAccountButton } from "../custom/ManageAccountButton";
|
|
18
21
|
|
|
19
22
|
type SignInProps = {
|
|
@@ -30,7 +33,9 @@ type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackButton">
|
|
|
30
33
|
|
|
31
34
|
export function SignIn(props: SignInWithB3Props) {
|
|
32
35
|
const { className } = props;
|
|
33
|
-
const { automaticallySetFirstEoa, partnerId } = useB3Config();
|
|
36
|
+
const { automaticallySetFirstEoa, partnerId, authStrategy } = useB3Config();
|
|
37
|
+
const isBetterAuth = authStrategy === "better-auth";
|
|
38
|
+
|
|
34
39
|
const {
|
|
35
40
|
address: globalAddress,
|
|
36
41
|
ensName,
|
|
@@ -53,6 +58,11 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
53
58
|
|
|
54
59
|
const setActiveWallet = useSetActiveWallet();
|
|
55
60
|
|
|
61
|
+
// Better Auth state
|
|
62
|
+
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
63
|
+
const { user } = useUser();
|
|
64
|
+
const userDisplayName = user?.username || user?.email || "Account";
|
|
65
|
+
|
|
56
66
|
const handleSetActiveAccount = (selectedWalletId: string | undefined) => {
|
|
57
67
|
if (
|
|
58
68
|
!selectedWalletId ||
|
|
@@ -72,21 +82,29 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
72
82
|
}
|
|
73
83
|
}, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
|
|
74
84
|
|
|
85
|
+
const isLoggedIn = isBetterAuth ? isAuthenticated : !!globalAddress;
|
|
86
|
+
|
|
75
87
|
// Desktop version - original dropdown menu
|
|
76
88
|
return (
|
|
77
89
|
<StyleRoot>
|
|
78
90
|
<Menu className={`relative flex items-center ${className || ""}`} as="div">
|
|
79
|
-
{
|
|
91
|
+
{isLoggedIn ? (
|
|
80
92
|
<>
|
|
81
93
|
<MenuButton className="bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3 focus:outline-none">
|
|
82
|
-
{
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
{isBetterAuth ? (
|
|
95
|
+
<Avatar name={userDisplayName} variant="beam" size={24} colors={AVATAR_COLORS} />
|
|
96
|
+
) : (
|
|
97
|
+
!!walletImage && (
|
|
98
|
+
<IPFSMediaRenderer
|
|
99
|
+
src={walletImage}
|
|
100
|
+
alt="Wallet Image"
|
|
101
|
+
className="bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100"
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
88
104
|
)}
|
|
89
|
-
<div className="text-as-primary">
|
|
105
|
+
<div className="text-as-primary">
|
|
106
|
+
{isBetterAuth ? userDisplayName : ensName ? ensName : truncateAddress(globalAddress ?? "")}
|
|
107
|
+
</div>
|
|
90
108
|
</MenuButton>
|
|
91
109
|
<Transition
|
|
92
110
|
enter="duration-200 ease-out"
|
|
@@ -103,7 +121,16 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
103
121
|
anchor={isMobile ? "top end" : undefined}
|
|
104
122
|
>
|
|
105
123
|
<div className="bg-b3-react-background">
|
|
106
|
-
{
|
|
124
|
+
{isBetterAuth ? (
|
|
125
|
+
/* Better Auth: show user info instead of wallet switching */
|
|
126
|
+
<div className="flex items-center gap-3 rounded-xl p-3">
|
|
127
|
+
<Avatar name={userDisplayName} variant="beam" size={48} colors={AVATAR_COLORS} />
|
|
128
|
+
<div className="flex flex-col gap-0.5">
|
|
129
|
+
{user?.username && <div className="text-b3-react-primary font-semibold">{user.username}</div>}
|
|
130
|
+
{user?.email && <div className="text-b3-react-secondary text-sm">{user.email}</div>}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
) : connectedEOAWallet ? (
|
|
107
134
|
<div
|
|
108
135
|
className={cn(
|
|
109
136
|
"border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3",
|
|
@@ -118,7 +145,7 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
118
145
|
/>
|
|
119
146
|
<div className="ml-4 grow">
|
|
120
147
|
{ensName && <div>{ensName}</div>}
|
|
121
|
-
<div>{truncateAddress(globalAddress)}</div>
|
|
148
|
+
<div>{truncateAddress(globalAddress ?? "")}</div>
|
|
122
149
|
{/* <div>{walletInfo?.name}</div> */}
|
|
123
150
|
</div>
|
|
124
151
|
</div>
|
|
@@ -143,7 +170,7 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
143
170
|
/>
|
|
144
171
|
<div className="grow pl-4">
|
|
145
172
|
{ensName && <div>{ensName}</div>}
|
|
146
|
-
<div>{truncateAddress(globalAddress)}</div>
|
|
173
|
+
<div>{truncateAddress(globalAddress ?? "")}</div>
|
|
147
174
|
<div>Smart wallet</div>
|
|
148
175
|
</div>
|
|
149
176
|
</div>
|
|
@@ -159,7 +186,9 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
159
186
|
<button className="mb-2 w-full space-y-1" onClick={onDisconnect}>
|
|
160
187
|
<div className="hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors">
|
|
161
188
|
<Icon className="fill-b3-react-primary mr-4 shrink-0 transition-colors" name="logout" />
|
|
162
|
-
<div className="text-b3-react-primary mr-auto transition-colors">
|
|
189
|
+
<div className="text-b3-react-primary mr-auto transition-colors">
|
|
190
|
+
{isBetterAuth ? "Sign out" : "Disconnect"}
|
|
191
|
+
</div>
|
|
163
192
|
</div>
|
|
164
193
|
</button>
|
|
165
194
|
</div>
|
|
@@ -32,3 +32,5 @@ export const B3_AUTH_COOKIE_NAME = "b3-auth";
|
|
|
32
32
|
export const ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
|
|
33
33
|
|
|
34
34
|
export const PUBLIC_BASE_RPC_URL = "https://base-rpc.publicnode.com";
|
|
35
|
+
|
|
36
|
+
export const AVATAR_COLORS = ["#3368ef", "#272727", "#6366f1", "#06b6d4", "#eeb0d9", "#ba3fbf", "#ff777b", "#dfbb53"];
|