@b3dotfun/sdk 0.0.88-alpha.5 → 0.0.88-alpha.6
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 +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -3
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +23 -57
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +38 -35
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
- package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
- package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +8 -9
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
- package/dist/cjs/global-account/react/components/index.d.ts +1 -2
- package/dist/cjs/global-account/react/components/index.js +3 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -2
- package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
- package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +9 -35
- package/dist/cjs/global-account/react/index.native.d.ts +0 -2
- package/dist/cjs/global-account/react/index.native.js +1 -5
- package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/cjs/global-account/react/stores/configStore.js +30 -0
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
- package/dist/cjs/global-account/react/stores/index.js +3 -1
- package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/cjs/global-account/react/stores/userStore.js +30 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -4
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +22 -58
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
- package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
- package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
- package/dist/esm/global-account/react/components/index.d.ts +1 -2
- package/dist/esm/global-account/react/components/index.js +1 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -3
- package/dist/esm/global-account/react/hooks/useClient.js +2 -2
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
- package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/esm/global-account/react/hooks/useUser.js +17 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +1 -27
- package/dist/esm/global-account/react/index.native.d.ts +0 -2
- package/dist/esm/global-account/react/index.native.js +0 -2
- package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/esm/global-account/react/stores/configStore.js +27 -0
- package/dist/esm/global-account/react/stores/index.d.ts +1 -0
- package/dist/esm/global-account/react/stores/index.js +1 -0
- package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/esm/global-account/react/stores/userStore.js +27 -0
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/types/global-account/react/components/index.d.ts +1 -2
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/types/global-account/react/index.native.d.ts +0 -2
- package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/types/global-account/react/stores/index.d.ts +1 -0
- package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -4
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -4
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +43 -54
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +32 -117
- package/src/global-account/react/components/B3Provider/useB3.ts +4 -13
- package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
- package/src/global-account/react/components/B3Provider/useB3Config.ts +18 -31
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
- package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
- package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/StyleRoot.tsx +3 -3
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
- package/src/global-account/react/components/index.ts +1 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +2 -3
- package/src/global-account/react/hooks/useClient.ts +2 -2
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
- package/src/global-account/react/hooks/useNotifications.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
- package/src/global-account/react/hooks/useUser.ts +20 -0
- package/src/global-account/react/hooks/useUserQuery.ts +1 -40
- package/src/global-account/react/index.native.ts +0 -2
- package/src/global-account/react/stores/configStore.ts +51 -0
- package/src/global-account/react/stores/index.ts +1 -0
- package/src/global-account/react/stores/userStore.ts +41 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/src/global-account/react/components/B3Provider/types.ts +0 -50
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Button, StyleRoot,
|
|
1
|
+
import { Button, StyleRoot, useModalStore, useUser } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
3
3
|
import { SignInWithB3Props } from "../SignInWithB3/SignInWithB3";
|
|
4
4
|
|
|
5
5
|
export function ManageAccountButton(props: SignInWithB3Props & { className?: string }) {
|
|
6
|
-
const { partnerId } = useB3();
|
|
7
6
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
8
|
-
const { isConnected } =
|
|
7
|
+
const { isConnected } = useUser();
|
|
9
8
|
|
|
10
9
|
const handleClickManageAccount = () => {
|
|
11
10
|
setB3ModalContentType({
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// TODO woj: Barrel file for all components, this might be reason of bundle size issues
|
|
2
2
|
// Core Components
|
|
3
3
|
export { B3DynamicModal } from "./B3DynamicModal";
|
|
4
|
-
export { B3Provider
|
|
4
|
+
export { B3Provider } from "./B3Provider/B3Provider";
|
|
5
5
|
export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
6
|
-
export { B3Context, type B3ContextType } from "./B3Provider/types";
|
|
7
6
|
export { useB3 } from "./B3Provider/useB3";
|
|
8
7
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
9
8
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
@@ -52,3 +52,4 @@ export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
|
52
52
|
export { useTurnkeyAuth } from "./useTurnkeyAuth";
|
|
53
53
|
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
54
54
|
export { useURLParams } from "./useURLParams";
|
|
55
|
+
export { useUser } from "./useUser";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
2
|
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
3
|
-
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
5
5
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
@@ -18,7 +18,6 @@ import { Wallet, ecosystemWallet } from "thirdweb/wallets";
|
|
|
18
18
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
19
19
|
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
20
20
|
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider";
|
|
21
|
-
import { useB3 } from "../components/B3Provider/useB3";
|
|
22
21
|
import { createWagmiConfig } from "../utils/createWagmiConfig";
|
|
23
22
|
import { useSearchParam } from "./useSearchParamsSSR";
|
|
24
23
|
import { useUserQuery } from "./useUserQuery";
|
|
@@ -48,7 +47,7 @@ export function useAuth() {
|
|
|
48
47
|
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
49
48
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
50
49
|
const referralCode = useSearchParam("referralCode");
|
|
51
|
-
const { partnerId } =
|
|
50
|
+
const { partnerId } = useB3Config();
|
|
52
51
|
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
53
52
|
const { connect } = useConnect();
|
|
54
53
|
const activeWagmiAccount = useAccount();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import {
|
|
4
4
|
ClientType,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
* Hook to access the current FeathersJS client and client management utilities
|
|
14
14
|
*/
|
|
15
15
|
export function useClient() {
|
|
16
|
-
const { clientType } =
|
|
16
|
+
const { clientType } = useB3Config();
|
|
17
17
|
|
|
18
18
|
const getCurrentClient = useCallback(() => {
|
|
19
19
|
return getClient();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3Config, useConnect } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
3
|
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
@@ -11,7 +11,7 @@ const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
|
11
11
|
* Currently, this is for the basement-privy strategy
|
|
12
12
|
*/
|
|
13
13
|
export function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void) {
|
|
14
|
-
const { partnerId } =
|
|
14
|
+
const { partnerId } = useB3Config();
|
|
15
15
|
if (!chain) {
|
|
16
16
|
throw new Error("Chain is required");
|
|
17
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
1
2
|
import { getAuthToken } from "@b3dotfun/sdk/shared/utils/auth-token";
|
|
2
3
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
4
|
import { useCallback, useEffect, useState } from "react";
|
|
4
|
-
import { useB3 } from "../components";
|
|
5
5
|
import { notificationsAPI, UserData } from "../utils/notificationsAPI";
|
|
6
6
|
import { useUserQuery } from "./useUserQuery";
|
|
7
7
|
|
|
@@ -56,7 +56,7 @@ export interface UseNotificationsReturn {
|
|
|
56
56
|
*/
|
|
57
57
|
export function useNotifications(): UseNotificationsReturn {
|
|
58
58
|
const { user } = useUserQuery();
|
|
59
|
-
const { partnerId } =
|
|
59
|
+
const { partnerId } = useB3Config();
|
|
60
60
|
const [userData, setUserData] = useState<UserData | null>(null);
|
|
61
61
|
const [loading, setLoading] = useState(true);
|
|
62
62
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { isNativeToken } from "@b3dotfun/sdk/anyspend";
|
|
4
|
-
import {
|
|
4
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
5
|
+
import { useAccountWallet, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
5
6
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
6
7
|
import { getERC20Balances, getNativeTokenBalance } from "@b3dotfun/sdk/shared/utils/thirdweb-insights";
|
|
7
8
|
import { useQuery } from "@tanstack/react-query";
|
|
8
9
|
import { useEffect } from "react";
|
|
9
|
-
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
10
10
|
|
|
11
11
|
interface UseTokenBalanceProps {
|
|
12
12
|
token: components["schemas"]["Token"];
|
|
@@ -20,7 +20,8 @@ export interface TokenBalanceResult {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function useTokenBalance({ token, address }: UseTokenBalanceProps): TokenBalanceResult {
|
|
23
|
-
const
|
|
23
|
+
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
24
|
+
|
|
24
25
|
const account = useAccountWallet();
|
|
25
26
|
|
|
26
27
|
const effectiveAddress = address || account?.address;
|
|
@@ -60,7 +61,7 @@ export function useTokenBalance({ token, address }: UseTokenBalanceProps): Token
|
|
|
60
61
|
}
|
|
61
62
|
return { formatted: "0", raw: null };
|
|
62
63
|
},
|
|
63
|
-
enabled:
|
|
64
|
+
enabled: isAuthenticated && !!effectiveAddress,
|
|
64
65
|
staleTime: 30000,
|
|
65
66
|
gcTime: 5 * 60 * 1000,
|
|
66
67
|
retry: 2,
|
|
@@ -69,13 +70,13 @@ export function useTokenBalance({ token, address }: UseTokenBalanceProps): Token
|
|
|
69
70
|
|
|
70
71
|
// Force a refetch when the wallet or token changes
|
|
71
72
|
useEffect(() => {
|
|
72
|
-
if (
|
|
73
|
+
if (isAuthenticated && effectiveAddress) {
|
|
73
74
|
refetch();
|
|
74
75
|
}
|
|
75
|
-
}, [
|
|
76
|
+
}, [isAuthenticated, effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
|
|
76
77
|
|
|
77
78
|
// Determine if we're actually loading
|
|
78
|
-
const isActuallyLoading = !
|
|
79
|
+
const isActuallyLoading = !isAuthenticated || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
|
|
79
80
|
|
|
80
81
|
return {
|
|
81
82
|
rawBalance: tokenBalance?.raw || BigInt(0),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { useUserStore } from "../stores/userStore";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Preferred Hook to get the user data
|
|
6
|
+
*/
|
|
7
|
+
export function useUser() {
|
|
8
|
+
const user = useUserStore(state => state.user);
|
|
9
|
+
|
|
10
|
+
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
11
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
12
|
+
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
user,
|
|
16
|
+
isConnecting,
|
|
17
|
+
isConnected,
|
|
18
|
+
isAuthenticating,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,48 +1,9 @@
|
|
|
1
1
|
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
2
|
import { useEffect } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { persist } from "zustand/middleware";
|
|
6
|
-
|
|
7
|
-
const debug = debugB3React("useUserQuery");
|
|
3
|
+
import { useUserStore } from "../stores/userStore";
|
|
8
4
|
|
|
9
5
|
const USER_QUERY_KEY = ["b3-user"];
|
|
10
6
|
|
|
11
|
-
interface UserStore {
|
|
12
|
-
user: Users | null;
|
|
13
|
-
setUser: (user: Users | undefined) => void;
|
|
14
|
-
clearUser: () => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Zustand store for managing user state
|
|
19
|
-
* Persists user data to localStorage
|
|
20
|
-
*/
|
|
21
|
-
const useUserStore = create<UserStore>()(
|
|
22
|
-
persist(
|
|
23
|
-
set => ({
|
|
24
|
-
user: null,
|
|
25
|
-
setUser: (newUser: Users | undefined) => {
|
|
26
|
-
const userToSave = newUser ?? null;
|
|
27
|
-
set({ user: userToSave });
|
|
28
|
-
debug("User updated", userToSave);
|
|
29
|
-
},
|
|
30
|
-
clearUser: () => {
|
|
31
|
-
set({ user: null });
|
|
32
|
-
debug("User cleared");
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
{
|
|
36
|
-
name: "b3-user",
|
|
37
|
-
onRehydrateStorage: () => (_, error) => {
|
|
38
|
-
if (error) {
|
|
39
|
-
console.warn("Failed to rehydrate user store:", error);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
),
|
|
44
|
-
);
|
|
45
|
-
|
|
46
7
|
/**
|
|
47
8
|
* NOTE: THIS IS ONLY MEANT FOR INTERNAL USE, from useOnConnect
|
|
48
9
|
*
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
export { B3Provider } from "./components/B3Provider/B3Provider.native";
|
|
8
8
|
|
|
9
|
-
export { B3Context, type B3ContextType } from "./components/B3Provider/types";
|
|
10
|
-
export { useB3 } from "./components/B3Provider/useB3";
|
|
11
9
|
export { useAccountWallet } from "./hooks/useAccountWallet";
|
|
12
10
|
export { useAuthentication } from "./hooks/useAuthentication";
|
|
13
11
|
export { useProfile } from "./hooks/useProfile";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
+
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
|
+
import { Account } from "thirdweb/wallets";
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import { ClientType } from "../../client-manager";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default permissions configuration for B3 provider
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_PERMISSIONS: PermissionsConfig = {
|
|
12
|
+
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
13
|
+
nativeTokenLimitPerTransaction: 0.1,
|
|
14
|
+
startDate: new Date(),
|
|
15
|
+
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface ConfigStore {
|
|
19
|
+
accountOverride?: Account;
|
|
20
|
+
automaticallySetFirstEoa: boolean;
|
|
21
|
+
environment: "development" | "production";
|
|
22
|
+
defaultPermissions: PermissionsConfig;
|
|
23
|
+
theme: "light" | "dark";
|
|
24
|
+
clientType: ClientType;
|
|
25
|
+
partnerId: string;
|
|
26
|
+
stripePublishableKey?: string;
|
|
27
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
|
+
enableTurnkey: boolean;
|
|
29
|
+
|
|
30
|
+
// Actions
|
|
31
|
+
setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Zustand store for B3 configuration
|
|
36
|
+
* NOT persisted - these are developer-set configuration values
|
|
37
|
+
*/
|
|
38
|
+
export const useB3ConfigStore = create<ConfigStore>(set => ({
|
|
39
|
+
accountOverride: undefined,
|
|
40
|
+
automaticallySetFirstEoa: false,
|
|
41
|
+
environment: "development",
|
|
42
|
+
defaultPermissions: DEFAULT_PERMISSIONS,
|
|
43
|
+
theme: "light",
|
|
44
|
+
clientType: "rest",
|
|
45
|
+
partnerId: "",
|
|
46
|
+
stripePublishableKey: undefined,
|
|
47
|
+
createClientReferenceId: undefined,
|
|
48
|
+
enableTurnkey: false,
|
|
49
|
+
|
|
50
|
+
setConfig: config => set(state => ({ ...state, ...config })),
|
|
51
|
+
}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
import { persist } from "zustand/middleware";
|
|
5
|
+
|
|
6
|
+
const debug = debugB3React("useUserQuery");
|
|
7
|
+
|
|
8
|
+
interface UserStore {
|
|
9
|
+
user: Users | null;
|
|
10
|
+
setUser: (user: Users | undefined) => void;
|
|
11
|
+
clearUser: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Zustand store for managing user state
|
|
16
|
+
* Persists user data to localStorage
|
|
17
|
+
*/
|
|
18
|
+
export const useUserStore = create<UserStore>()(
|
|
19
|
+
persist(
|
|
20
|
+
set => ({
|
|
21
|
+
user: null,
|
|
22
|
+
setUser: (newUser: Users | undefined) => {
|
|
23
|
+
const userToSave = newUser ?? null;
|
|
24
|
+
set({ user: userToSave });
|
|
25
|
+
debug("User updated", userToSave);
|
|
26
|
+
},
|
|
27
|
+
clearUser: () => {
|
|
28
|
+
set({ user: null });
|
|
29
|
+
debug("User cleared");
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
{
|
|
33
|
+
name: "b3-user",
|
|
34
|
+
onRehydrateStorage: () => (_, error) => {
|
|
35
|
+
if (error) {
|
|
36
|
+
console.warn("Failed to rehydrate user store:", error);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
),
|
|
41
|
+
);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
|
-
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
|
-
import { ClientType } from "../../../client-manager";
|
|
6
|
-
/**
|
|
7
|
-
* Context type for B3Provider
|
|
8
|
-
*/
|
|
9
|
-
export interface B3ContextType {
|
|
10
|
-
account?: Account;
|
|
11
|
-
automaticallySetFirstEoa: boolean;
|
|
12
|
-
wallet?: Wallet;
|
|
13
|
-
initialized: boolean;
|
|
14
|
-
ready: boolean;
|
|
15
|
-
environment?: "development" | "production";
|
|
16
|
-
defaultPermissions?: PermissionsConfig;
|
|
17
|
-
theme: "light" | "dark";
|
|
18
|
-
clientType: ClientType;
|
|
19
|
-
partnerId: string;
|
|
20
|
-
stripePublishableKey?: string;
|
|
21
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
22
|
-
enableTurnkey?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Context for B3 provider
|
|
26
|
-
*/
|
|
27
|
-
export declare const B3Context: import("react").Context<B3ContextType>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.B3Context = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
/**
|
|
6
|
-
* Context for B3 provider
|
|
7
|
-
*/
|
|
8
|
-
exports.B3Context = (0, react_1.createContext)({
|
|
9
|
-
account: undefined,
|
|
10
|
-
automaticallySetFirstEoa: false,
|
|
11
|
-
//user: undefined,
|
|
12
|
-
//setWallet: () => {},
|
|
13
|
-
wallet: undefined,
|
|
14
|
-
//setUser: () => {},
|
|
15
|
-
//refetchUser: async () => {},
|
|
16
|
-
initialized: false,
|
|
17
|
-
ready: false,
|
|
18
|
-
environment: "development",
|
|
19
|
-
theme: "light",
|
|
20
|
-
clientType: "rest",
|
|
21
|
-
partnerId: "",
|
|
22
|
-
createClientReferenceId: undefined,
|
|
23
|
-
enableTurnkey: false,
|
|
24
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
|
-
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
|
-
import { ClientType } from "../../../client-manager";
|
|
6
|
-
/**
|
|
7
|
-
* Context type for B3Provider
|
|
8
|
-
*/
|
|
9
|
-
export interface B3ContextType {
|
|
10
|
-
account?: Account;
|
|
11
|
-
automaticallySetFirstEoa: boolean;
|
|
12
|
-
wallet?: Wallet;
|
|
13
|
-
initialized: boolean;
|
|
14
|
-
ready: boolean;
|
|
15
|
-
environment?: "development" | "production";
|
|
16
|
-
defaultPermissions?: PermissionsConfig;
|
|
17
|
-
theme: "light" | "dark";
|
|
18
|
-
clientType: ClientType;
|
|
19
|
-
partnerId: string;
|
|
20
|
-
stripePublishableKey?: string;
|
|
21
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
22
|
-
enableTurnkey?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Context for B3 provider
|
|
26
|
-
*/
|
|
27
|
-
export declare const B3Context: import("react").Context<B3ContextType>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Context for B3 provider
|
|
4
|
-
*/
|
|
5
|
-
export const B3Context = createContext({
|
|
6
|
-
account: undefined,
|
|
7
|
-
automaticallySetFirstEoa: false,
|
|
8
|
-
//user: undefined,
|
|
9
|
-
//setWallet: () => {},
|
|
10
|
-
wallet: undefined,
|
|
11
|
-
//setUser: () => {},
|
|
12
|
-
//refetchUser: async () => {},
|
|
13
|
-
initialized: false,
|
|
14
|
-
ready: false,
|
|
15
|
-
environment: "development",
|
|
16
|
-
theme: "light",
|
|
17
|
-
clientType: "rest",
|
|
18
|
-
partnerId: "",
|
|
19
|
-
createClientReferenceId: undefined,
|
|
20
|
-
enableTurnkey: false,
|
|
21
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
|
-
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
|
-
import { ClientType } from "../../../client-manager";
|
|
6
|
-
/**
|
|
7
|
-
* Context type for B3Provider
|
|
8
|
-
*/
|
|
9
|
-
export interface B3ContextType {
|
|
10
|
-
account?: Account;
|
|
11
|
-
automaticallySetFirstEoa: boolean;
|
|
12
|
-
wallet?: Wallet;
|
|
13
|
-
initialized: boolean;
|
|
14
|
-
ready: boolean;
|
|
15
|
-
environment?: "development" | "production";
|
|
16
|
-
defaultPermissions?: PermissionsConfig;
|
|
17
|
-
theme: "light" | "dark";
|
|
18
|
-
clientType: ClientType;
|
|
19
|
-
partnerId: string;
|
|
20
|
-
stripePublishableKey?: string;
|
|
21
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
22
|
-
enableTurnkey?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Context for B3 provider
|
|
26
|
-
*/
|
|
27
|
-
export declare const B3Context: import("react").Context<B3ContextType>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
|
-
import { createContext } from "react";
|
|
5
|
-
import { Account, Wallet } from "thirdweb/wallets";
|
|
6
|
-
import { ClientType } from "../../../client-manager";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Context type for B3Provider
|
|
10
|
-
*/
|
|
11
|
-
export interface B3ContextType {
|
|
12
|
-
account?: Account;
|
|
13
|
-
automaticallySetFirstEoa: boolean;
|
|
14
|
-
//user?: Users;
|
|
15
|
-
//setWallet: (wallet: Wallet) => void;
|
|
16
|
-
wallet?: Wallet;
|
|
17
|
-
//setUser: (user?: Users) => void;
|
|
18
|
-
//refetchUser: () => Promise<any>;
|
|
19
|
-
initialized: boolean;
|
|
20
|
-
ready: boolean;
|
|
21
|
-
environment?: "development" | "production";
|
|
22
|
-
defaultPermissions?: PermissionsConfig;
|
|
23
|
-
theme: "light" | "dark";
|
|
24
|
-
clientType: ClientType;
|
|
25
|
-
partnerId: string;
|
|
26
|
-
stripePublishableKey?: string;
|
|
27
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
|
-
enableTurnkey?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Context for B3 provider
|
|
33
|
-
*/
|
|
34
|
-
export const B3Context = createContext<B3ContextType>({
|
|
35
|
-
account: undefined,
|
|
36
|
-
automaticallySetFirstEoa: false,
|
|
37
|
-
//user: undefined,
|
|
38
|
-
//setWallet: () => {},
|
|
39
|
-
wallet: undefined,
|
|
40
|
-
//setUser: () => {},
|
|
41
|
-
//refetchUser: async () => {},
|
|
42
|
-
initialized: false,
|
|
43
|
-
ready: false,
|
|
44
|
-
environment: "development",
|
|
45
|
-
theme: "light",
|
|
46
|
-
clientType: "rest",
|
|
47
|
-
partnerId: "",
|
|
48
|
-
createClientReferenceId: undefined,
|
|
49
|
-
enableTurnkey: false,
|
|
50
|
-
});
|