@b3dotfun/sdk 0.0.35 → 0.0.36
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/anyspend/react/components/AnySpend.js +5 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +58 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/cjs/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/cjs/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/index.js +5 -5
- 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.d.ts +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +19 -5
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.d.ts +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +6 -6
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -13
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +0 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +0 -3
- 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.d.ts +1 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +16 -15
- 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/useAuthStore.d.ts +2 -4
- package/dist/cjs/global-account/react/stores/useAuthStore.js +2 -4
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +11 -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/anyspend/react/components/AnySpend.js +5 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +5 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +55 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +22 -15
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -4
- package/dist/esm/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/esm/anyspend/react/components/common/PaySection.js +10 -15
- package/dist/esm/anyspend/react/components/index.d.ts +2 -2
- package/dist/esm/anyspend/react/components/index.js +2 -2
- 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.d.ts +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +20 -6
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.d.ts +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +6 -6
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -13
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -3
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +0 -3
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +0 -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.d.ts +1 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +16 -15
- 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/useAuthStore.d.ts +2 -4
- package/dist/esm/global-account/react/stores/useAuthStore.js +2 -4
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +11 -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/anyspend/react/components/common/ConnectWalletPayment.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +16 -0
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/PaySection.d.ts +2 -6
- package/dist/types/anyspend/react/components/index.d.ts +2 -2
- 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/ManageAccount/BalanceContent.d.ts +3 -1
- package/dist/types/global-account/react/components/ManageAccount/ManageAccount.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/useAuthentication.d.ts +1 -2
- 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/useAuthStore.d.ts +2 -4
- package/dist/types/global-account/react/stores/useModalStore.d.ts +11 -1
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +4 -0
- package/package.json +8 -7
- package/src/anyspend/react/components/AnySpend.tsx +7 -6
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +2 -5
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +6 -1
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +153 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +80 -43
- package/src/anyspend/react/components/common/OrderDetails.tsx +13 -4
- package/src/anyspend/react/components/common/PaySection.tsx +64 -140
- package/src/anyspend/react/components/index.ts +2 -2
- 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 +63 -35
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +106 -78
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -13
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +0 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +0 -3
- 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 +18 -15
- 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/useAuthStore.ts +4 -8
- package/src/global-account/react/stores/useModalStore.ts +13 -1
- package/src/global-account/react/utils/updateAvatar.ts +21 -0
|
@@ -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";
|
|
@@ -19,17 +20,15 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
19
20
|
const activeWallet = useActiveWallet();
|
|
20
21
|
const { authenticate } = useSiwe();
|
|
21
22
|
const { setUser } = useB3();
|
|
22
|
-
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
23
23
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
24
24
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
26
25
|
const setIsConnecting = useAuthStore(state => state.setIsConnecting);
|
|
27
26
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
28
27
|
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
29
28
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
30
29
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
30
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
31
|
+
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
33
32
|
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
34
33
|
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
35
34
|
const { connect } = useConnect(partnerId, b3MainnetThirdWeb);
|
|
@@ -50,11 +49,10 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
50
49
|
debug("Skipping SIWE login", { loginWithSiwe });
|
|
51
50
|
setIsAuthenticated(true);
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
setIsAuthenticating(false);
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
debug("setIsAuthenticating:true:4");
|
|
57
|
-
setIsAuthenticating(true);
|
|
58
56
|
const account = await wallet.getAccount();
|
|
59
57
|
if (!account) {
|
|
60
58
|
throw new Error("No account found during auto-connect");
|
|
@@ -65,16 +63,24 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
65
63
|
const userAuth = await app.reAuthenticate();
|
|
66
64
|
setUser(userAuth.user);
|
|
67
65
|
setIsAuthenticated(true);
|
|
68
|
-
|
|
66
|
+
setIsAuthenticating(false);
|
|
69
67
|
debug("Re-authenticated successfully", { userAuth });
|
|
68
|
+
|
|
69
|
+
// Authenticate on BSMNT with B3 JWT
|
|
70
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
71
|
+
console.log("@@b3Jwt", b3Jwt);
|
|
70
72
|
} catch (error) {
|
|
71
73
|
// If re-authentication fails, try fresh authentication
|
|
72
74
|
debug("Re-authentication failed, attempting fresh authentication");
|
|
73
75
|
const userAuth = await authenticate(account, partnerId);
|
|
74
76
|
setUser(userAuth.user);
|
|
75
77
|
setIsAuthenticated(true);
|
|
76
|
-
|
|
78
|
+
setIsAuthenticating(false);
|
|
77
79
|
debug("Fresh authentication successful", { userAuth });
|
|
80
|
+
|
|
81
|
+
// Authenticate on BSMNT with B3 JWT
|
|
82
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
83
|
+
console.log("@@b3Jwt", b3Jwt);
|
|
78
84
|
}
|
|
79
85
|
} catch (error) {
|
|
80
86
|
debug("Auto-connect authentication failed", { error });
|
|
@@ -82,7 +88,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
82
88
|
debug("setIsAuthenticating:false:4");
|
|
83
89
|
setUser();
|
|
84
90
|
}
|
|
85
|
-
|
|
91
|
+
setIsAuthenticating(false);
|
|
86
92
|
},
|
|
87
93
|
});
|
|
88
94
|
|
|
@@ -91,7 +97,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
91
97
|
*/
|
|
92
98
|
useEffect(() => {
|
|
93
99
|
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
94
|
-
|
|
100
|
+
setIsAuthenticating(false);
|
|
95
101
|
}
|
|
96
102
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
97
103
|
}, [useAutoConnectLoading]);
|
|
@@ -105,16 +111,14 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
105
111
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
106
112
|
const timeout = setTimeout(() => {
|
|
107
113
|
debug("setIsAuthenticating:false:5a");
|
|
108
|
-
setIsAuthenticating(false);
|
|
109
114
|
setIsConnecting(false);
|
|
110
115
|
}, 100); // Add a small delay to prevent quick flickers
|
|
111
116
|
return () => clearTimeout(timeout);
|
|
112
117
|
} else {
|
|
113
118
|
debug("setIsAuthenticating:false:5b");
|
|
114
|
-
setIsAuthenticating(false);
|
|
115
119
|
setIsConnecting(false);
|
|
116
120
|
}
|
|
117
|
-
}, [useAutoConnectLoading, isAuthenticated,
|
|
121
|
+
}, [useAutoConnectLoading, isAuthenticated, setIsConnecting, setIsConnected]);
|
|
118
122
|
|
|
119
123
|
const logout = async (callback?: () => void) => {
|
|
120
124
|
if (activeWallet) {
|
|
@@ -151,7 +155,6 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
151
155
|
|
|
152
156
|
return {
|
|
153
157
|
logout,
|
|
154
|
-
isAuthenticating: useAutoConnectLoading || isAuthenticating,
|
|
155
158
|
isAuthenticated,
|
|
156
159
|
isReady,
|
|
157
160
|
isConnecting,
|
|
@@ -159,6 +162,6 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
159
162
|
wallet,
|
|
160
163
|
preAuthenticate,
|
|
161
164
|
connect,
|
|
162
|
-
|
|
165
|
+
isAuthenticating,
|
|
163
166
|
};
|
|
164
167
|
}
|
|
@@ -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
|
+
}
|
|
@@ -7,7 +7,6 @@ interface AuthState {
|
|
|
7
7
|
provider?: string;
|
|
8
8
|
accessToken?: string;
|
|
9
9
|
chain?: Chain;
|
|
10
|
-
isAuthenticating: boolean;
|
|
11
10
|
isAuthenticated: boolean;
|
|
12
11
|
isConnecting: boolean;
|
|
13
12
|
isConnected: boolean;
|
|
@@ -17,7 +16,6 @@ interface AuthState {
|
|
|
17
16
|
setStep: (step: "login" | "permissions") => void;
|
|
18
17
|
setIsConnecting: (isConnecting: boolean) => void;
|
|
19
18
|
setIsConnected: (isConnected: boolean) => void;
|
|
20
|
-
setIsAuthenticating: (isAuthenticating: boolean) => void;
|
|
21
19
|
setIsAuthenticated: (isAuthenticated: boolean) => void;
|
|
22
20
|
startAuth: (params: {
|
|
23
21
|
provider: string;
|
|
@@ -27,8 +25,8 @@ interface AuthState {
|
|
|
27
25
|
onError?: (error: Error) => void;
|
|
28
26
|
}) => void;
|
|
29
27
|
reset: () => void;
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
isAuthenticating: boolean;
|
|
29
|
+
setIsAuthenticating: (isAuthenticating: boolean) => void;
|
|
32
30
|
hasStartedConnecting: boolean;
|
|
33
31
|
setHasStartedConnecting: (hasStartedConnecting: boolean) => void;
|
|
34
32
|
}
|
|
@@ -39,7 +37,6 @@ export const useAuthStore = create<AuthState>(set => ({
|
|
|
39
37
|
provider: undefined,
|
|
40
38
|
accessToken: undefined,
|
|
41
39
|
chain: undefined,
|
|
42
|
-
isAuthenticating: false,
|
|
43
40
|
isAuthenticated: false,
|
|
44
41
|
isConnecting: false,
|
|
45
42
|
isConnected: false,
|
|
@@ -49,7 +46,6 @@ export const useAuthStore = create<AuthState>(set => ({
|
|
|
49
46
|
setStep: step => set({ step }),
|
|
50
47
|
setIsConnecting: isConnecting => set({ isConnecting }),
|
|
51
48
|
setIsConnected: isConnected => set({ isConnected }),
|
|
52
|
-
setIsAuthenticating: isAuthenticating => set({ isAuthenticating }),
|
|
53
49
|
setIsAuthenticated: isAuthenticated => set({ isAuthenticated }),
|
|
54
50
|
startAuth: params =>
|
|
55
51
|
set({
|
|
@@ -73,8 +69,8 @@ export const useAuthStore = create<AuthState>(set => ({
|
|
|
73
69
|
onSuccess: undefined,
|
|
74
70
|
onError: undefined,
|
|
75
71
|
}),
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
isAuthenticating: true,
|
|
73
|
+
setIsAuthenticating: isAuthenticating => set({ isAuthenticating: isAuthenticating }),
|
|
78
74
|
hasStartedConnecting: false,
|
|
79
75
|
setHasStartedConnecting: hasStartedConnecting => set({ hasStartedConnecting }),
|
|
80
76
|
}));
|
|
@@ -89,6 +89,10 @@ export interface ManageAccountModalProps extends BaseModalProps {
|
|
|
89
89
|
setActiveTab?: (tab: "overview" | "tokens" | "nfts" | "apps" | "settings") => void;
|
|
90
90
|
/** Whether to show the referral information */
|
|
91
91
|
showReferralInfo?: boolean;
|
|
92
|
+
/** Whether to show the swap button */
|
|
93
|
+
showSwap?: boolean;
|
|
94
|
+
/** Whether to show the deposit button */
|
|
95
|
+
showDeposit?: boolean;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
@@ -305,6 +309,13 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
305
309
|
onSuccess?: (amount?: string) => void;
|
|
306
310
|
}
|
|
307
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
|
+
|
|
308
319
|
/**
|
|
309
320
|
* Union type of all possible modal content types
|
|
310
321
|
*/
|
|
@@ -323,7 +334,8 @@ export type ModalContentType =
|
|
|
323
334
|
| AnySpendSignatureMintProps
|
|
324
335
|
| AnySpendBondKitProps
|
|
325
336
|
| LinkAccountModalProps
|
|
326
|
-
| AnySpendDepositHypeProps
|
|
337
|
+
| AnySpendDepositHypeProps
|
|
338
|
+
| AvatarEditorModalProps;
|
|
327
339
|
// Add other modal types here like: | OtherModalProps | AnotherModalProps
|
|
328
340
|
|
|
329
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
|
+
}
|