@b3dotfun/sdk 0.0.35-alpha.3 → 0.0.35-alpha.5
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/bsmnt.d.ts +2 -0
- package/dist/cjs/global-account/bsmnt.js +42 -1
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +6 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +55 -0
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.d.ts +6 -0
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +108 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +9 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.d.ts +3 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +21 -11
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +16 -2
- package/dist/cjs/global-account/react/components/icons/AppleIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/AppleIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/DiscordIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/DiscordIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/FarcasterIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/FarcasterIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/GoogleIcon.d.ts +8 -0
- package/dist/cjs/global-account/react/components/icons/GoogleIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/XIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/XIcon.js +8 -0
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +3 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +7 -0
- package/dist/cjs/global-account/react/hooks/useProfile.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +11 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +7 -1
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +4 -0
- package/dist/cjs/global-account/react/utils/updateAvatar.js +54 -0
- package/dist/esm/global-account/bsmnt.d.ts +2 -0
- package/dist/esm/global-account/bsmnt.js +39 -0
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +6 -0
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +52 -0
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.d.ts +6 -0
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +102 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +9 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.d.ts +3 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +22 -12
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +17 -3
- package/dist/esm/global-account/react/components/icons/AppleIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/AppleIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/DiscordIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/DiscordIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/FarcasterIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/FarcasterIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/GoogleIcon.d.ts +8 -0
- package/dist/esm/global-account/react/components/icons/GoogleIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/XIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/XIcon.js +5 -0
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +7 -0
- package/dist/esm/global-account/react/hooks/useProfile.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useRPMToken.js +8 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +7 -1
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +4 -0
- package/dist/esm/global-account/react/utils/updateAvatar.js +18 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/global-account/bsmnt.d.ts +2 -0
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +6 -0
- package/dist/types/global-account/react/components/AvatarEditor/AvatarEditor.d.ts +6 -0
- package/dist/types/global-account/react/components/LinkAccount/LinkAccount.d.ts +3 -1
- package/dist/types/global-account/react/components/icons/AppleIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/DiscordIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/FarcasterIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/GoogleIcon.d.ts +8 -0
- package/dist/types/global-account/react/components/icons/XIcon.d.ts +9 -0
- package/dist/types/global-account/react/hooks/useProfile.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +7 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +7 -1
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +4 -0
- package/package.json +6 -5
- package/src/global-account/bsmnt.ts +47 -0
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +90 -0
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +233 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +27 -2
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +40 -18
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +25 -5
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +0 -1
- package/src/global-account/react/components/icons/AppleIcon.tsx +33 -0
- package/src/global-account/react/components/icons/DiscordIcon.tsx +32 -0
- package/src/global-account/react/components/icons/FarcasterIcon.tsx +37 -0
- package/src/global-account/react/components/icons/GoogleIcon.tsx +40 -0
- package/src/global-account/react/components/icons/XIcon.tsx +28 -0
- package/src/global-account/react/hooks/useAccountWallet.tsx +3 -2
- package/src/global-account/react/hooks/useAuthentication.ts +9 -0
- package/src/global-account/react/hooks/useProfile.ts +1 -1
- package/src/global-account/react/hooks/useRPMToken.ts +17 -0
- package/src/global-account/react/stores/useModalStore.ts +9 -1
- package/src/global-account/react/utils/updateAvatar.ts +21 -0
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Button,
|
|
3
3
|
CopyToClipboard,
|
|
4
4
|
useAuthentication,
|
|
5
|
+
useB3,
|
|
5
6
|
useB3BalanceFromAddresses,
|
|
6
7
|
useModalStore,
|
|
7
8
|
useNativeBalance,
|
|
@@ -11,6 +12,7 @@ import { BankIcon } from "@b3dotfun/sdk/global-account/react/components/icons/Ba
|
|
|
11
12
|
import { SignOutIcon } from "@b3dotfun/sdk/global-account/react/components/icons/SignOutIcon";
|
|
12
13
|
import { SwapIcon } from "@b3dotfun/sdk/global-account/react/components/icons/SwapIcon";
|
|
13
14
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
15
|
+
import { getIpfsUrl } from "@b3dotfun/sdk/shared/utils/ipfs";
|
|
14
16
|
import { Loader2, Pencil } from "lucide-react";
|
|
15
17
|
import { useEffect, useRef, useState } from "react";
|
|
16
18
|
import { useActiveAccount } from "thirdweb/react";
|
|
@@ -38,12 +40,27 @@ export function BalanceContent({ onLogout, partnerId, showDeposit = true, showSw
|
|
|
38
40
|
address: eoaAddress || account?.address,
|
|
39
41
|
fresh: true,
|
|
40
42
|
});
|
|
41
|
-
const {
|
|
43
|
+
const { user } = useB3();
|
|
44
|
+
const { setB3ModalOpen, setB3ModalContentType, navigateBack } = useModalStore();
|
|
42
45
|
const { logout } = useAuthentication(partnerId);
|
|
43
46
|
const [logoutLoading, setLogoutLoading] = useState(false);
|
|
44
47
|
const [openAccordions, setOpenAccordions] = useState<string[]>([]);
|
|
45
48
|
const hasExpandedRef = useRef(false);
|
|
46
49
|
|
|
50
|
+
const avatarUrl = user?.avatar ? getIpfsUrl(user?.avatar) : profile?.avatar;
|
|
51
|
+
|
|
52
|
+
const handleEditAvatar = () => {
|
|
53
|
+
setB3ModalOpen(true);
|
|
54
|
+
setB3ModalContentType({
|
|
55
|
+
type: "avatarEditor",
|
|
56
|
+
showBackButton: true,
|
|
57
|
+
onSuccess: () => {
|
|
58
|
+
// navigate back on success
|
|
59
|
+
navigateBack();
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
47
64
|
console.log("eoaAddress", eoaAddress);
|
|
48
65
|
console.log("account?.address", account?.address);
|
|
49
66
|
|
|
@@ -100,14 +117,17 @@ export function BalanceContent({ onLogout, partnerId, showDeposit = true, showSw
|
|
|
100
117
|
<div className="flex items-center justify-between">
|
|
101
118
|
<div className="global-account-profile flex items-center gap-4">
|
|
102
119
|
<div className="global-account-profile-avatar relative">
|
|
103
|
-
{
|
|
104
|
-
<img src={
|
|
120
|
+
{avatarUrl ? (
|
|
121
|
+
<img src={avatarUrl} alt="Profile" className="size-24 rounded-full" />
|
|
105
122
|
) : (
|
|
106
123
|
<div className="bg-b3-primary-wash size-24 rounded-full" />
|
|
107
124
|
)}
|
|
108
|
-
<
|
|
125
|
+
<button
|
|
126
|
+
onClick={handleEditAvatar}
|
|
127
|
+
className="bg-b3-grey border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-8 items-center justify-center rounded-full border-4 transition-colors"
|
|
128
|
+
>
|
|
109
129
|
<Pencil size={16} className="text-b3-background" />
|
|
110
|
-
</
|
|
130
|
+
</button>
|
|
111
131
|
</div>
|
|
112
132
|
<div className="global-account-profile-info">
|
|
113
133
|
<h2 className="text-b3-grey text-xl font-semibold">
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface AppleIconProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function AppleIcon({ className, size = 24, color = "currentColor", style }: AppleIconProps) {
|
|
11
|
+
return (
|
|
12
|
+
<svg
|
|
13
|
+
width={size}
|
|
14
|
+
height={size}
|
|
15
|
+
viewBox="0 0 41.5 51"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
className={className}
|
|
18
|
+
style={style}
|
|
19
|
+
>
|
|
20
|
+
<g>
|
|
21
|
+
<path
|
|
22
|
+
fill={color}
|
|
23
|
+
d="M40.2,17.4c-3.4,2.1-5.5,5.7-5.5,9.7c0,4.5,2.7,8.6,6.8,10.3c-0.8,2.6-2,5-3.5,7.2c-2.2,3.1-4.5,6.3-7.9,6.3s-4.4-2-8.4-2
|
|
24
|
+
c-3.9,0-5.3,2.1-8.5,2.1s-5.4-2.9-7.9-6.5C2,39.5,0.1,33.7,0,27.6c0-9.9,6.4-15.2,12.8-15.2c3.4,0,6.2,2.2,8.3,2.2
|
|
25
|
+
c2,0,5.2-2.3,9-2.3C34.1,12.2,37.9,14.1,40.2,17.4z M28.3,8.1C30,6.1,30.9,3.6,31,1c0-0.3,0-0.7-0.1-1c-2.9,0.3-5.6,1.7-7.5,3.9
|
|
26
|
+
c-1.7,1.9-2.7,4.3-2.8,6.9c0,0.3,0,0.6,0.1,0.9c0.2,0,0.5,0.1,0.7,0.1C24.1,11.6,26.6,10.2,28.3,8.1z"
|
|
27
|
+
/>
|
|
28
|
+
</g>
|
|
29
|
+
</svg>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default AppleIcon;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface DiscordIconProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function DiscordIcon({ className, size = 24, color = "#5865F2", style }: DiscordIconProps) {
|
|
11
|
+
return (
|
|
12
|
+
<svg
|
|
13
|
+
width={size}
|
|
14
|
+
height={size}
|
|
15
|
+
viewBox="0 -28.5 256 256"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
className={className}
|
|
18
|
+
style={style}
|
|
19
|
+
preserveAspectRatio="xMidYMid"
|
|
20
|
+
>
|
|
21
|
+
<g>
|
|
22
|
+
<path
|
|
23
|
+
d="M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z"
|
|
24
|
+
fill={color}
|
|
25
|
+
fillRule="nonzero"
|
|
26
|
+
/>
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default DiscordIcon;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface FarcasterIconProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function FarcasterIcon({ className, size = 24, color = "#855DCD", style }: FarcasterIconProps) {
|
|
11
|
+
return (
|
|
12
|
+
<svg
|
|
13
|
+
width={size}
|
|
14
|
+
height={size}
|
|
15
|
+
viewBox="0 0 1000 1000"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
className={className}
|
|
18
|
+
style={style}
|
|
19
|
+
>
|
|
20
|
+
<rect width="1000" height="1000" rx="200" fill={color} />
|
|
21
|
+
<path
|
|
22
|
+
d="M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889V844.444H257.778V155.556Z"
|
|
23
|
+
fill="white"
|
|
24
|
+
/>
|
|
25
|
+
<path
|
|
26
|
+
d="M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z"
|
|
27
|
+
fill="white"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
d="M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z"
|
|
31
|
+
fill="white"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default FarcasterIcon;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface GoogleIconProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function GoogleIcon({ className, size = 24, style }: GoogleIconProps) {
|
|
10
|
+
return (
|
|
11
|
+
<svg
|
|
12
|
+
width={size}
|
|
13
|
+
height={size}
|
|
14
|
+
viewBox="0 0 48 48"
|
|
15
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
16
|
+
className={className}
|
|
17
|
+
style={style}
|
|
18
|
+
>
|
|
19
|
+
<path
|
|
20
|
+
fill="#EA4335"
|
|
21
|
+
d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
fill="#4285F4"
|
|
25
|
+
d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"
|
|
26
|
+
/>
|
|
27
|
+
<path
|
|
28
|
+
fill="#FBBC05"
|
|
29
|
+
d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"
|
|
30
|
+
/>
|
|
31
|
+
<path
|
|
32
|
+
fill="#34A853"
|
|
33
|
+
d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"
|
|
34
|
+
/>
|
|
35
|
+
<path fill="none" d="M0 0h48v48H0z" />
|
|
36
|
+
</svg>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default GoogleIcon;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface XIconProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function XIcon({ className, size = 24, color = "currentColor", style }: XIconProps) {
|
|
11
|
+
return (
|
|
12
|
+
<svg
|
|
13
|
+
width={size}
|
|
14
|
+
height={size}
|
|
15
|
+
viewBox="0 0 300 300.251"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
className={className}
|
|
18
|
+
style={style}
|
|
19
|
+
>
|
|
20
|
+
<path
|
|
21
|
+
d="M178.57 127.15 290.27 0h-26.46l-97.03 110.38L89.34 0H0l117.13 166.93L0 300.25h26.46l102.4-116.59 81.8 116.59h89.34M36.01 19.54H76.66l187.13 262.13h-40.66"
|
|
22
|
+
fill={color}
|
|
23
|
+
/>
|
|
24
|
+
</svg>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default XIcon;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useB3, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
3
3
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
4
|
+
import { getIpfsUrl } from "@b3dotfun/sdk/shared/utils/ipfs";
|
|
4
5
|
import { useEffect, useMemo, useState } from "react";
|
|
5
6
|
import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
|
|
6
7
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
@@ -43,7 +44,7 @@ export function useAccountWallet(): {
|
|
|
43
44
|
eoaWalletIcon?: string;
|
|
44
45
|
smartWalletIcon?: string;
|
|
45
46
|
} {
|
|
46
|
-
const { account } = useB3();
|
|
47
|
+
const { account, user } = useB3();
|
|
47
48
|
|
|
48
49
|
const activeWallet = useActiveWallet();
|
|
49
50
|
const connectedWallets = useConnectedWallets();
|
|
@@ -72,7 +73,7 @@ export function useAccountWallet(): {
|
|
|
72
73
|
|
|
73
74
|
const { data: profileData } = useProfile({ address: account?.address });
|
|
74
75
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
75
|
-
const avatarUrl = profileData?.avatar;
|
|
76
|
+
const avatarUrl = user?.avatar ? getIpfsUrl(user?.avatar) : profileData?.avatar;
|
|
76
77
|
|
|
77
78
|
const res = useMemo(
|
|
78
79
|
() => ({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
+
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
2
3
|
import { useAuthStore, useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
3
4
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
4
5
|
import { b3MainnetThirdWeb } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
@@ -67,6 +68,10 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
67
68
|
setIsAuthenticated(true);
|
|
68
69
|
setIsAuthenticatingV2(false);
|
|
69
70
|
debug("Re-authenticated successfully", { userAuth });
|
|
71
|
+
|
|
72
|
+
// Authenticate on BSMNT with B3 JWT
|
|
73
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
74
|
+
console.log("@@b3Jwt", b3Jwt);
|
|
70
75
|
} catch (error) {
|
|
71
76
|
// If re-authentication fails, try fresh authentication
|
|
72
77
|
debug("Re-authentication failed, attempting fresh authentication");
|
|
@@ -75,6 +80,10 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
75
80
|
setIsAuthenticated(true);
|
|
76
81
|
setIsAuthenticatingV2(false);
|
|
77
82
|
debug("Fresh authentication successful", { userAuth });
|
|
83
|
+
|
|
84
|
+
// Authenticate on BSMNT with B3 JWT
|
|
85
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
86
|
+
console.log("@@b3Jwt", b3Jwt);
|
|
78
87
|
}
|
|
79
88
|
} catch (error) {
|
|
80
89
|
debug("Auto-connect authentication failed", { error });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useQueryBSMNT } from "@b3dotfun/sdk/global-account/react/hooks/useQueryBSMNT";
|
|
4
|
+
|
|
5
|
+
export function useRPMToken() {
|
|
6
|
+
const {
|
|
7
|
+
data,
|
|
8
|
+
runQuery: refetch,
|
|
9
|
+
isLoading,
|
|
10
|
+
error: isError,
|
|
11
|
+
} = useQueryBSMNT("profiles", "getReadyPlayerMeToken", undefined, true);
|
|
12
|
+
|
|
13
|
+
const token = data?.token || "";
|
|
14
|
+
const accountId = data?.accountId || "";
|
|
15
|
+
|
|
16
|
+
return { token, accountId, refetch, isLoading, isError };
|
|
17
|
+
}
|
|
@@ -309,6 +309,13 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
309
309
|
onSuccess?: (amount?: string) => void;
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
313
|
+
/** Modal type identifier */
|
|
314
|
+
type: "avatarEditor";
|
|
315
|
+
/** Callback function called when avatar is successfully set */
|
|
316
|
+
onSuccess?: () => void;
|
|
317
|
+
}
|
|
318
|
+
|
|
312
319
|
/**
|
|
313
320
|
* Union type of all possible modal content types
|
|
314
321
|
*/
|
|
@@ -327,7 +334,8 @@ export type ModalContentType =
|
|
|
327
334
|
| AnySpendSignatureMintProps
|
|
328
335
|
| AnySpendBondKitProps
|
|
329
336
|
| LinkAccountModalProps
|
|
330
|
-
| AnySpendDepositHypeProps
|
|
337
|
+
| AnySpendDepositHypeProps
|
|
338
|
+
| AvatarEditorModalProps;
|
|
331
339
|
// Add other modal types here like: | OtherModalProps | AnotherModalProps
|
|
332
340
|
|
|
333
341
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import app, { extractAvatarIdFromUrl } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
|
|
4
|
+
const debug = debugB3React("updateAvatar");
|
|
5
|
+
|
|
6
|
+
export async function updateAvatar(avatar: string) {
|
|
7
|
+
try {
|
|
8
|
+
// Extract avatar ID from URL
|
|
9
|
+
const avatarID = extractAvatarIdFromUrl(avatar);
|
|
10
|
+
|
|
11
|
+
if (!avatarID) {
|
|
12
|
+
throw new Error("Invalid avatar URL");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Set the avatar in the profiles service
|
|
16
|
+
return await app.service("profiles").setAvatar({ avatarUrl: String(avatar), avatarID: String(avatarID) }, {});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
debug("Failed to update avatar:", error);
|
|
19
|
+
throw error; // Re-throw to handle in component
|
|
20
|
+
}
|
|
21
|
+
}
|