@b3dotfun/sdk 0.1.69-alpha.10 → 0.1.69-alpha.12
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 +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +8 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -9
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -5
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +12 -6
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +14 -20
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +41 -45
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -7
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// "use client";
|
|
3
|
-
// import { AnimatePresence, motion } from "motion/react";
|
|
4
|
-
// import { useEffect, useState } from "react";
|
|
5
|
-
// import ClientOnly from "./custom/ClientOnly.js";
|
|
6
|
-
// interface ProfileAvatarProps {
|
|
7
|
-
// avatarId: string;
|
|
8
|
-
// timestamp?: number;
|
|
9
|
-
// }
|
|
10
|
-
// // this function was taken from b3-shared
|
|
11
|
-
// function createUrlFromAvatarId(avatarId: string, extension: string = "png"): string {
|
|
12
|
-
// if (extension === "png") {
|
|
13
|
-
// return `https://avatars.basement.fun/${avatarId}.png`;
|
|
14
|
-
// }
|
|
15
|
-
// return `https://models.readyplayer.me/${avatarId}.${extension}`;
|
|
16
|
-
// }
|
|
17
|
-
// // Sub component for the avatar image
|
|
18
|
-
// const ProfileAvatar = ({ avatarId, timestamp }: ProfileAvatarProps) => {
|
|
19
|
-
// const [avatarLoading, setAvatarLoading] = useState(true);
|
|
20
|
-
// const [avatarError, setAvatarError] = useState(false);
|
|
21
|
-
// const [ReadyPlayerMeAvatar, setReadyPlayerMeAvatar] = useState<any>(null);
|
|
22
|
-
// const [Vector3, setVector3] = useState<any>(null);
|
|
23
|
-
// const [dependenciesLoaded, setDependenciesLoaded] = useState(false);
|
|
24
|
-
// // Dynamically import dependencies only when component is used
|
|
25
|
-
// useEffect(() => {
|
|
26
|
-
// let isMounted = true;
|
|
27
|
-
// const loadDependencies = async () => {
|
|
28
|
-
// try {
|
|
29
|
-
// const [visageModule, threeModule] = await Promise.all([
|
|
30
|
-
// // @ts-ignore - Optional peer dependency
|
|
31
|
-
// import("@readyplayerme/visage"),
|
|
32
|
-
// // @ts-ignore - Optional peer dependency
|
|
33
|
-
// import("three")
|
|
34
|
-
// ]);
|
|
35
|
-
// if (isMounted) {
|
|
36
|
-
// setReadyPlayerMeAvatar(() => visageModule.Avatar);
|
|
37
|
-
// setVector3(() => threeModule.Vector3);
|
|
38
|
-
// setDependenciesLoaded(true);
|
|
39
|
-
// }
|
|
40
|
-
// } catch (error) {
|
|
41
|
-
// console.warn("ProfileAvatar: 3D dependencies not available, falling back to 2D avatar:", error);
|
|
42
|
-
// if (isMounted) {
|
|
43
|
-
// setAvatarLoading(false);
|
|
44
|
-
// setDependenciesLoaded(false);
|
|
45
|
-
// }
|
|
46
|
-
// }
|
|
47
|
-
// };
|
|
48
|
-
// loadDependencies();
|
|
49
|
-
// return () => {
|
|
50
|
-
// isMounted = false;
|
|
51
|
-
// };
|
|
52
|
-
// }, []);
|
|
53
|
-
// if (!avatarId) {
|
|
54
|
-
// return (
|
|
55
|
-
// <div className="flex h-full w-full items-center justify-center">
|
|
56
|
-
// <p className="text-white/50">No avatar available</p>
|
|
57
|
-
// </div>
|
|
58
|
-
// );
|
|
59
|
-
// }
|
|
60
|
-
// return (
|
|
61
|
-
// <AnimatePresence mode="wait">
|
|
62
|
-
// {(avatarLoading || !dependenciesLoaded) && !avatarError && (
|
|
63
|
-
// <motion.img
|
|
64
|
-
// key="avatar-image"
|
|
65
|
-
// src={`https://models.readyplayer.me/${avatarId}.png?camera=fullbody&size=1024&expression=happy&t=${timestamp || ""}`}
|
|
66
|
-
// alt="avatar"
|
|
67
|
-
// className="absolute left-0 top-0 h-full w-full object-cover"
|
|
68
|
-
// initial={{ opacity: 0 }}
|
|
69
|
-
// animate={{ opacity: 1 }}
|
|
70
|
-
// exit={{ opacity: 0 }}
|
|
71
|
-
// transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
72
|
-
// onError={() => setAvatarError(true)}
|
|
73
|
-
// />
|
|
74
|
-
// )}
|
|
75
|
-
// {dependenciesLoaded && (
|
|
76
|
-
// <ClientOnly>
|
|
77
|
-
// <motion.div
|
|
78
|
-
// key={`avatar-3d-${timestamp}`}
|
|
79
|
-
// className="absolute left-0 top-0 h-full w-full"
|
|
80
|
-
// initial={{ opacity: 0 }}
|
|
81
|
-
// animate={{ opacity: avatarLoading ? 0 : 1 }}
|
|
82
|
-
// exit={{ opacity: 0 }}
|
|
83
|
-
// transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
84
|
-
// >
|
|
85
|
-
// {ReadyPlayerMeAvatar && Vector3 && (
|
|
86
|
-
// <ReadyPlayerMeAvatar
|
|
87
|
-
// animationSrc="https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-idle.glb"
|
|
88
|
-
// onLoadedAnimation={{
|
|
89
|
-
// src: "https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-spawn-animation.fbx",
|
|
90
|
-
// loop: 4
|
|
91
|
-
// }}
|
|
92
|
-
// modelSrc={createUrlFromAvatarId(avatarId, "glb")}
|
|
93
|
-
// idleRotation={true}
|
|
94
|
-
// headMovement={true}
|
|
95
|
-
// scale={0.9}
|
|
96
|
-
// keyLightColor="#bca1f4"
|
|
97
|
-
// keyLightIntensity={1}
|
|
98
|
-
// fillLightColor="#8d4cf6"
|
|
99
|
-
// fov={50}
|
|
100
|
-
// emotion={{
|
|
101
|
-
// browInnerUp: 0.3,
|
|
102
|
-
// browOuterUpLeft: 0.37,
|
|
103
|
-
// browOuterUpRight: 0.49,
|
|
104
|
-
// eyeSquintLeft: 0.4,
|
|
105
|
-
// eyeSquintRight: 0.2,
|
|
106
|
-
// mouthShrugUpper: 0.27,
|
|
107
|
-
// mouthSmileLeft: 0.37,
|
|
108
|
-
// mouthSmileRight: 0.36
|
|
109
|
-
// }}
|
|
110
|
-
// cameraZoomTarget={new Vector3(0, 0.1, 3.2)}
|
|
111
|
-
// cameraInitialDistance={3.2}
|
|
112
|
-
// cameraTarget={1.55}
|
|
113
|
-
// className="h-full w-full"
|
|
114
|
-
// onLoaded={() => {
|
|
115
|
-
// setAvatarLoading(false);
|
|
116
|
-
// setAvatarError(false);
|
|
117
|
-
// }}
|
|
118
|
-
// shadows
|
|
119
|
-
// />
|
|
120
|
-
// )}
|
|
121
|
-
// </motion.div>
|
|
122
|
-
// </ClientOnly>
|
|
123
|
-
// )}
|
|
124
|
-
// </AnimatePresence>
|
|
125
|
-
// );
|
|
126
|
-
// };
|
|
127
|
-
// export default ProfileAvatar;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useQueryBSMNT } from "../../../global-account/react/hooks/useQueryBSMNT.js";
|
|
3
|
-
export function useRPMToken() {
|
|
4
|
-
const { data, runQuery: refetch, isLoading, error: isError, } = useQueryBSMNT("profiles", "getReadyPlayerMeToken", undefined, true);
|
|
5
|
-
const token = data?.token || "";
|
|
6
|
-
const accountId = data?.accountId || "";
|
|
7
|
-
return { token, accountId, refetch, isLoading, isError };
|
|
8
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import app, { extractAvatarIdFromUrl } from "../../../global-account/bsmnt.js";
|
|
2
|
-
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
|
-
const debug = debugB3React("updateAvatar");
|
|
4
|
-
export async function updateAvatar(avatar) {
|
|
5
|
-
try {
|
|
6
|
-
// Extract avatar ID from URL
|
|
7
|
-
const avatarID = extractAvatarIdFromUrl(avatar);
|
|
8
|
-
if (!avatarID) {
|
|
9
|
-
throw new Error("Invalid avatar URL");
|
|
10
|
-
}
|
|
11
|
-
// Set the avatar in the profiles service
|
|
12
|
-
return await app.service("profiles").setAvatar({ avatarUrl: String(avatar), avatarID: String(avatarID) }, {});
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
debug("Failed to update avatar:", error);
|
|
16
|
-
throw error; // Re-throw to handle in component
|
|
17
|
-
}
|
|
18
|
-
}
|
|
File without changes
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { toast, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { useRPMToken } from "@b3dotfun/sdk/global-account/react/hooks/useRPMToken";
|
|
5
|
-
import { updateAvatar } from "@b3dotfun/sdk/global-account/react/utils/updateAvatar";
|
|
6
|
-
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
7
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
8
|
-
import {
|
|
9
|
-
AvatarCreatorConfig,
|
|
10
|
-
AvatarCreator as AvatarCreatorRPM,
|
|
11
|
-
AvatarExportedEvent,
|
|
12
|
-
} from "@readyplayerme/react-avatar-creator";
|
|
13
|
-
import { useState } from "react";
|
|
14
|
-
|
|
15
|
-
import { useActiveAccount } from "thirdweb/react";
|
|
16
|
-
|
|
17
|
-
const debug = debugB3React("AvatarCreator");
|
|
18
|
-
|
|
19
|
-
const config: AvatarCreatorConfig = {
|
|
20
|
-
clearCache: true,
|
|
21
|
-
bodyType: "fullbody",
|
|
22
|
-
quickStart: true,
|
|
23
|
-
language: "en",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
interface AvatarCreatorProps {
|
|
27
|
-
onSetAvatar?: () => void;
|
|
28
|
-
className?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function AvatarCreator({ onSetAvatar, className }: AvatarCreatorProps) {
|
|
32
|
-
const { token, refetch: refetchRPMToken } = useRPMToken();
|
|
33
|
-
const [loading, setIsLoading] = useState(false);
|
|
34
|
-
const account = useActiveAccount();
|
|
35
|
-
const { data: profile, refetch: refreshProfile } = useProfile({
|
|
36
|
-
address: account?.address,
|
|
37
|
-
fresh: true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const hasAvatar = profile?.avatar;
|
|
41
|
-
|
|
42
|
-
const handleOnAvatarExported = async (event: AvatarExportedEvent) => {
|
|
43
|
-
setIsLoading(true);
|
|
44
|
-
debug("@@AvatarExportedEvent", event);
|
|
45
|
-
try {
|
|
46
|
-
const avatarUpload = await updateAvatar(event.data.url);
|
|
47
|
-
debug("@@avatarUpload", avatarUpload);
|
|
48
|
-
|
|
49
|
-
await refreshProfile();
|
|
50
|
-
toast.success(
|
|
51
|
-
hasAvatar ? "Nice look! Your avatar has been updated!" : "Looks great! Your avatar has been saved!",
|
|
52
|
-
);
|
|
53
|
-
onSetAvatar?.();
|
|
54
|
-
await refetchRPMToken(undefined);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
debug("@@error:AvatarCreator", e);
|
|
57
|
-
toast.error("Failed to update avatar. Please try again.");
|
|
58
|
-
}
|
|
59
|
-
setIsLoading(false);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
if (loading) {
|
|
63
|
-
return (
|
|
64
|
-
<div className="flex h-[80vh] w-full flex-col items-center justify-center gap-4">
|
|
65
|
-
<div className="border-primary h-8 w-8 animate-spin rounded-full border-4 border-t-transparent" />
|
|
66
|
-
<p className="text-muted-foreground text-sm font-medium">Saving your avatar</p>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!token) {
|
|
72
|
-
return (
|
|
73
|
-
<div className="flex h-[80vh] w-full flex-col items-center justify-center gap-4">
|
|
74
|
-
<div className="border-primary h-8 w-8 animate-spin rounded-full border-4 border-t-transparent" />
|
|
75
|
-
<p className="text-muted-foreground text-sm font-medium">Loading avatar creator</p>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div className={cn("h-[calc(90vh-2px)] w-full", className)}>
|
|
82
|
-
<AvatarCreatorRPM
|
|
83
|
-
className="h-full w-full"
|
|
84
|
-
subdomain="b3"
|
|
85
|
-
config={{ ...config, token }}
|
|
86
|
-
onAvatarExported={handleOnAvatarExported}
|
|
87
|
-
/>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
// "use client";
|
|
2
|
-
|
|
3
|
-
// import { AnimatePresence, motion } from "motion/react";
|
|
4
|
-
// import { useEffect, useState } from "react";
|
|
5
|
-
// import ClientOnly from "./custom/ClientOnly";
|
|
6
|
-
|
|
7
|
-
// interface ProfileAvatarProps {
|
|
8
|
-
// avatarId: string;
|
|
9
|
-
// timestamp?: number;
|
|
10
|
-
// }
|
|
11
|
-
|
|
12
|
-
// // this function was taken from b3-shared
|
|
13
|
-
// function createUrlFromAvatarId(avatarId: string, extension: string = "png"): string {
|
|
14
|
-
// if (extension === "png") {
|
|
15
|
-
// return `https://avatars.basement.fun/${avatarId}.png`;
|
|
16
|
-
// }
|
|
17
|
-
// return `https://models.readyplayer.me/${avatarId}.${extension}`;
|
|
18
|
-
// }
|
|
19
|
-
|
|
20
|
-
// // Sub component for the avatar image
|
|
21
|
-
// const ProfileAvatar = ({ avatarId, timestamp }: ProfileAvatarProps) => {
|
|
22
|
-
// const [avatarLoading, setAvatarLoading] = useState(true);
|
|
23
|
-
// const [avatarError, setAvatarError] = useState(false);
|
|
24
|
-
// const [ReadyPlayerMeAvatar, setReadyPlayerMeAvatar] = useState<any>(null);
|
|
25
|
-
// const [Vector3, setVector3] = useState<any>(null);
|
|
26
|
-
// const [dependenciesLoaded, setDependenciesLoaded] = useState(false);
|
|
27
|
-
|
|
28
|
-
// // Dynamically import dependencies only when component is used
|
|
29
|
-
// useEffect(() => {
|
|
30
|
-
// let isMounted = true;
|
|
31
|
-
|
|
32
|
-
// const loadDependencies = async () => {
|
|
33
|
-
// try {
|
|
34
|
-
// const [visageModule, threeModule] = await Promise.all([
|
|
35
|
-
// // @ts-ignore - Optional peer dependency
|
|
36
|
-
// import("@readyplayerme/visage"),
|
|
37
|
-
// // @ts-ignore - Optional peer dependency
|
|
38
|
-
// import("three")
|
|
39
|
-
// ]);
|
|
40
|
-
|
|
41
|
-
// if (isMounted) {
|
|
42
|
-
// setReadyPlayerMeAvatar(() => visageModule.Avatar);
|
|
43
|
-
// setVector3(() => threeModule.Vector3);
|
|
44
|
-
// setDependenciesLoaded(true);
|
|
45
|
-
// }
|
|
46
|
-
// } catch (error) {
|
|
47
|
-
// console.warn("ProfileAvatar: 3D dependencies not available, falling back to 2D avatar:", error);
|
|
48
|
-
// if (isMounted) {
|
|
49
|
-
// setAvatarLoading(false);
|
|
50
|
-
// setDependenciesLoaded(false);
|
|
51
|
-
// }
|
|
52
|
-
// }
|
|
53
|
-
// };
|
|
54
|
-
|
|
55
|
-
// loadDependencies();
|
|
56
|
-
|
|
57
|
-
// return () => {
|
|
58
|
-
// isMounted = false;
|
|
59
|
-
// };
|
|
60
|
-
// }, []);
|
|
61
|
-
|
|
62
|
-
// if (!avatarId) {
|
|
63
|
-
// return (
|
|
64
|
-
// <div className="flex h-full w-full items-center justify-center">
|
|
65
|
-
// <p className="text-white/50">No avatar available</p>
|
|
66
|
-
// </div>
|
|
67
|
-
// );
|
|
68
|
-
// }
|
|
69
|
-
|
|
70
|
-
// return (
|
|
71
|
-
// <AnimatePresence mode="wait">
|
|
72
|
-
// {(avatarLoading || !dependenciesLoaded) && !avatarError && (
|
|
73
|
-
// <motion.img
|
|
74
|
-
// key="avatar-image"
|
|
75
|
-
// src={`https://models.readyplayer.me/${avatarId}.png?camera=fullbody&size=1024&expression=happy&t=${timestamp || ""}`}
|
|
76
|
-
// alt="avatar"
|
|
77
|
-
// className="absolute left-0 top-0 h-full w-full object-cover"
|
|
78
|
-
// initial={{ opacity: 0 }}
|
|
79
|
-
// animate={{ opacity: 1 }}
|
|
80
|
-
// exit={{ opacity: 0 }}
|
|
81
|
-
// transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
82
|
-
// onError={() => setAvatarError(true)}
|
|
83
|
-
// />
|
|
84
|
-
// )}
|
|
85
|
-
// {dependenciesLoaded && (
|
|
86
|
-
// <ClientOnly>
|
|
87
|
-
// <motion.div
|
|
88
|
-
// key={`avatar-3d-${timestamp}`}
|
|
89
|
-
// className="absolute left-0 top-0 h-full w-full"
|
|
90
|
-
// initial={{ opacity: 0 }}
|
|
91
|
-
// animate={{ opacity: avatarLoading ? 0 : 1 }}
|
|
92
|
-
// exit={{ opacity: 0 }}
|
|
93
|
-
// transition={{ duration: 0.3, ease: "easeInOut" }}
|
|
94
|
-
// >
|
|
95
|
-
// {ReadyPlayerMeAvatar && Vector3 && (
|
|
96
|
-
// <ReadyPlayerMeAvatar
|
|
97
|
-
// animationSrc="https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-idle.glb"
|
|
98
|
-
// onLoadedAnimation={{
|
|
99
|
-
// src: "https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-spawn-animation.fbx",
|
|
100
|
-
// loop: 4
|
|
101
|
-
// }}
|
|
102
|
-
// modelSrc={createUrlFromAvatarId(avatarId, "glb")}
|
|
103
|
-
// idleRotation={true}
|
|
104
|
-
// headMovement={true}
|
|
105
|
-
// scale={0.9}
|
|
106
|
-
// keyLightColor="#bca1f4"
|
|
107
|
-
// keyLightIntensity={1}
|
|
108
|
-
// fillLightColor="#8d4cf6"
|
|
109
|
-
// fov={50}
|
|
110
|
-
// emotion={{
|
|
111
|
-
// browInnerUp: 0.3,
|
|
112
|
-
// browOuterUpLeft: 0.37,
|
|
113
|
-
// browOuterUpRight: 0.49,
|
|
114
|
-
// eyeSquintLeft: 0.4,
|
|
115
|
-
// eyeSquintRight: 0.2,
|
|
116
|
-
// mouthShrugUpper: 0.27,
|
|
117
|
-
// mouthSmileLeft: 0.37,
|
|
118
|
-
// mouthSmileRight: 0.36
|
|
119
|
-
// }}
|
|
120
|
-
// cameraZoomTarget={new Vector3(0, 0.1, 3.2)}
|
|
121
|
-
// cameraInitialDistance={3.2}
|
|
122
|
-
// cameraTarget={1.55}
|
|
123
|
-
// className="h-full w-full"
|
|
124
|
-
// onLoaded={() => {
|
|
125
|
-
// setAvatarLoading(false);
|
|
126
|
-
// setAvatarError(false);
|
|
127
|
-
// }}
|
|
128
|
-
// shadows
|
|
129
|
-
// />
|
|
130
|
-
// )}
|
|
131
|
-
// </motion.div>
|
|
132
|
-
// </ClientOnly>
|
|
133
|
-
// )}
|
|
134
|
-
// </AnimatePresence>
|
|
135
|
-
// );
|
|
136
|
-
// };
|
|
137
|
-
|
|
138
|
-
// export default ProfileAvatar;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|