@b3dotfun/sdk 0.0.88-alpha.4 → 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.
Files changed (166) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +1 -1
  2. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +2 -2
  3. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +14 -1
  4. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
  5. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
  6. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
  7. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
  8. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
  9. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
  10. package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -3
  11. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  12. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
  13. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  14. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +23 -57
  15. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  16. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +38 -35
  17. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  18. package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -11
  19. package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
  20. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  21. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +18 -17
  22. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
  23. package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
  24. package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
  25. package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
  26. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
  27. package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +8 -9
  28. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  29. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  30. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  31. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  32. package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
  33. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
  34. package/dist/cjs/global-account/react/components/index.d.ts +1 -2
  35. package/dist/cjs/global-account/react/components/index.js +3 -6
  36. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  37. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  38. package/dist/cjs/global-account/react/hooks/useAuth.js +1 -2
  39. package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
  40. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
  41. package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
  42. package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
  43. package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
  44. package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
  45. package/dist/cjs/global-account/react/hooks/useUserQuery.js +9 -35
  46. package/dist/cjs/global-account/react/index.native.d.ts +0 -2
  47. package/dist/cjs/global-account/react/index.native.js +1 -5
  48. package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
  49. package/dist/cjs/global-account/react/stores/configStore.js +30 -0
  50. package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
  51. package/dist/cjs/global-account/react/stores/index.js +3 -1
  52. package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
  53. package/dist/cjs/global-account/react/stores/userStore.js +30 -0
  54. package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
  55. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +2 -2
  56. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +14 -1
  57. package/dist/esm/anyspend/react/components/common/OrderDetails.js +3 -3
  58. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
  59. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
  60. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
  61. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
  62. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
  63. package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -4
  64. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  65. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
  66. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  67. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +22 -58
  68. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  69. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
  70. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  71. package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -11
  72. package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
  73. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  74. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +18 -17
  75. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
  76. package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
  77. package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
  78. package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
  79. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
  80. package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -3
  81. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  82. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
  83. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  84. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
  85. package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
  86. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
  87. package/dist/esm/global-account/react/components/index.d.ts +1 -2
  88. package/dist/esm/global-account/react/components/index.js +1 -2
  89. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  90. package/dist/esm/global-account/react/hooks/index.js +1 -0
  91. package/dist/esm/global-account/react/hooks/useAuth.js +2 -3
  92. package/dist/esm/global-account/react/hooks/useClient.js +2 -2
  93. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
  94. package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
  95. package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
  96. package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
  97. package/dist/esm/global-account/react/hooks/useUser.js +17 -0
  98. package/dist/esm/global-account/react/hooks/useUserQuery.js +1 -27
  99. package/dist/esm/global-account/react/index.native.d.ts +0 -2
  100. package/dist/esm/global-account/react/index.native.js +0 -2
  101. package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
  102. package/dist/esm/global-account/react/stores/configStore.js +27 -0
  103. package/dist/esm/global-account/react/stores/index.d.ts +1 -0
  104. package/dist/esm/global-account/react/stores/index.js +1 -0
  105. package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
  106. package/dist/esm/global-account/react/stores/userStore.js +27 -0
  107. package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  108. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  109. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  110. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  111. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  112. package/dist/types/global-account/react/components/index.d.ts +1 -2
  113. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  114. package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
  115. package/dist/types/global-account/react/index.native.d.ts +0 -2
  116. package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
  117. package/dist/types/global-account/react/stores/index.d.ts +1 -0
  118. package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
  119. package/package.json +1 -1
  120. package/src/anyspend/react/components/AnySpend.tsx +2 -2
  121. package/src/anyspend/react/components/AnySpendDeposit.tsx +3 -1
  122. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +15 -1
  123. package/src/anyspend/react/components/common/OrderDetails.tsx +8 -2
  124. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -4
  125. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
  126. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
  127. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
  128. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
  129. package/src/global-account/react/components/B3DynamicModal.tsx +3 -4
  130. package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
  131. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +43 -54
  132. package/src/global-account/react/components/B3Provider/B3Provider.tsx +32 -117
  133. package/src/global-account/react/components/B3Provider/useB3.ts +4 -13
  134. package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
  135. package/src/global-account/react/components/B3Provider/useB3Config.ts +18 -31
  136. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
  137. package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
  138. package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
  139. package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
  140. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
  141. package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
  142. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  143. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
  144. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
  145. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  146. package/src/global-account/react/components/StyleRoot.tsx +3 -3
  147. package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
  148. package/src/global-account/react/components/index.ts +1 -2
  149. package/src/global-account/react/hooks/index.ts +1 -0
  150. package/src/global-account/react/hooks/useAuth.ts +2 -3
  151. package/src/global-account/react/hooks/useClient.ts +2 -2
  152. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
  153. package/src/global-account/react/hooks/useNotifications.ts +2 -2
  154. package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
  155. package/src/global-account/react/hooks/useUser.ts +20 -0
  156. package/src/global-account/react/hooks/useUserQuery.ts +1 -40
  157. package/src/global-account/react/index.native.ts +0 -2
  158. package/src/global-account/react/stores/configStore.ts +51 -0
  159. package/src/global-account/react/stores/index.ts +1 -0
  160. package/src/global-account/react/stores/userStore.ts +41 -0
  161. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
  162. package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
  163. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
  164. package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
  165. package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
  166. package/src/global-account/react/components/B3Provider/types.ts +0 -50
@@ -1,4 +1,4 @@
1
- import { useB3, useConnect } from "../../../global-account/react/index.js";
1
+ import { useB3Config, useConnect } from "../../../global-account/react/index.js";
2
2
  import { debugB3React } from "../../../shared/utils/debug.js";
3
3
  import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
4
4
  import { useCallback, useRef, useState } from "react";
@@ -8,7 +8,7 @@ const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
8
8
  * Currently, this is for the basement-privy strategy
9
9
  */
10
10
  export function useHandleConnectWithPrivy(chain, onSuccess) {
11
- const { partnerId } = useB3();
11
+ const { partnerId } = useB3Config();
12
12
  if (!chain) {
13
13
  throw new Error("Chain is required");
14
14
  }
@@ -1,7 +1,7 @@
1
+ import { useB3Config } from "../../../global-account/react/index.js";
1
2
  import { getAuthToken } from "../../../shared/utils/auth-token.js";
2
3
  import { debugB3React } from "../../../shared/utils/debug.js";
3
4
  import { useCallback, useEffect, useState } from "react";
4
- import { useB3 } from "../components/index.js";
5
5
  import { notificationsAPI } from "../utils/notificationsAPI.js";
6
6
  import { useUserQuery } from "./useUserQuery.js";
7
7
  const debug = debugB3React("useNotifications");
@@ -27,7 +27,7 @@ const debug = debugB3React("useNotifications");
27
27
  */
28
28
  export function useNotifications() {
29
29
  const { user } = useUserQuery();
30
- const { partnerId } = useB3();
30
+ const { partnerId } = useB3Config();
31
31
  const [userData, setUserData] = useState(null);
32
32
  const [loading, setLoading] = useState(true);
33
33
  const [error, setError] = useState(null);
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { isNativeToken } from "../../../anyspend/index.js";
3
- import { useB3, useAccountWallet } from "../../../global-account/react/index.js";
3
+ import { useAccountWallet, useAuthStore } from "../../../global-account/react/index.js";
4
4
  import { formatTokenAmount } from "../../../shared/utils/number.js";
5
5
  import { getERC20Balances, getNativeTokenBalance } from "../../../shared/utils/thirdweb-insights.js";
6
6
  import { useQuery } from "@tanstack/react-query";
7
7
  import { useEffect } from "react";
8
8
  export function useTokenBalance({ token, address }) {
9
- const { ready } = useB3();
9
+ const isAuthenticated = useAuthStore(state => state.isAuthenticated);
10
10
  const account = useAccountWallet();
11
11
  const effectiveAddress = address || account?.address;
12
12
  const { data: tokenBalance, isLoading, isFetching, refetch, } = useQuery({
@@ -38,7 +38,7 @@ export function useTokenBalance({ token, address }) {
38
38
  }
39
39
  return { formatted: "0", raw: null };
40
40
  },
41
- enabled: ready && !!effectiveAddress,
41
+ enabled: isAuthenticated && !!effectiveAddress,
42
42
  staleTime: 30000,
43
43
  gcTime: 5 * 60 * 1000,
44
44
  retry: 2,
@@ -46,12 +46,12 @@ export function useTokenBalance({ token, address }) {
46
46
  });
47
47
  // Force a refetch when the wallet or token changes
48
48
  useEffect(() => {
49
- if (ready && effectiveAddress) {
49
+ if (isAuthenticated && effectiveAddress) {
50
50
  refetch();
51
51
  }
52
- }, [ready, effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
52
+ }, [isAuthenticated, effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
53
53
  // Determine if we're actually loading
54
- const isActuallyLoading = !ready || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
54
+ const isActuallyLoading = !isAuthenticated || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
55
55
  return {
56
56
  rawBalance: tokenBalance?.raw || BigInt(0),
57
57
  formattedBalance: tokenBalance?.formatted || "0",
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Preferred Hook to get the user data
3
+ */
4
+ export declare function useUser(): {
5
+ user: {
6
+ email?: string | undefined;
7
+ username?: string | undefined;
8
+ telNumber?: string | undefined;
9
+ ens?: string | undefined;
10
+ avatar?: string | undefined;
11
+ preferences?: {} | undefined;
12
+ referredBy?: string | {} | undefined;
13
+ sourceApp?: string | undefined;
14
+ referralCode?: string | undefined;
15
+ userGroups?: number[] | undefined;
16
+ isMigratedFromBSMNT?: boolean | undefined;
17
+ privyLinkedAccounts?: {
18
+ name?: string | undefined;
19
+ address?: string | undefined;
20
+ email?: string | undefined;
21
+ chain_type?: string | undefined;
22
+ lv?: number | undefined;
23
+ wallet_client_type?: string | undefined;
24
+ smart_wallet_type?: string | undefined;
25
+ subject?: string | undefined;
26
+ type: string;
27
+ }[] | undefined;
28
+ twProfiles?: {
29
+ type: string;
30
+ details: {
31
+ id?: string | undefined;
32
+ name?: string | undefined;
33
+ address?: string | undefined;
34
+ email?: string | undefined;
35
+ username?: string | undefined;
36
+ phone?: string | undefined;
37
+ fid?: string | undefined;
38
+ };
39
+ }[] | undefined;
40
+ turnkeySubOrgs?: {
41
+ hasDelegatedUser?: boolean | undefined;
42
+ subOrgId: string;
43
+ accounts: Record<string, any>[];
44
+ }[] | undefined;
45
+ _id: string | {};
46
+ userId: string;
47
+ smartAccountAddress: string;
48
+ createdAt: number;
49
+ updatedAt: number;
50
+ partnerIds: {
51
+ privyId?: string | undefined;
52
+ thirdwebId?: string | undefined;
53
+ turnkeyId?: string | undefined;
54
+ turnkeyOtpId?: string | undefined;
55
+ };
56
+ } | null;
57
+ isConnecting: boolean;
58
+ isConnected: boolean;
59
+ isAuthenticating: boolean;
60
+ };
@@ -0,0 +1,17 @@
1
+ import { useAuthStore } from "../../../global-account/react/index.js";
2
+ import { useUserStore } from "../stores/userStore.js";
3
+ /**
4
+ * Preferred Hook to get the user data
5
+ */
6
+ export function useUser() {
7
+ const user = useUserStore(state => state.user);
8
+ const isConnecting = useAuthStore(state => state.isConnecting);
9
+ const isConnected = useAuthStore(state => state.isConnected);
10
+ const isAuthenticating = useAuthStore(state => state.isAuthenticating);
11
+ return {
12
+ user,
13
+ isConnecting,
14
+ isConnected,
15
+ isAuthenticating,
16
+ };
17
+ }
@@ -1,32 +1,6 @@
1
- import { debugB3React } from "../../../shared/utils/debug.js";
2
1
  import { useEffect } from "react";
3
- import { create } from "zustand";
4
- import { persist } from "zustand/middleware";
5
- const debug = debugB3React("useUserQuery");
2
+ import { useUserStore } from "../stores/userStore.js";
6
3
  const USER_QUERY_KEY = ["b3-user"];
7
- /**
8
- * Zustand store for managing user state
9
- * Persists user data to localStorage
10
- */
11
- const useUserStore = create()(persist(set => ({
12
- user: null,
13
- setUser: (newUser) => {
14
- const userToSave = newUser ?? null;
15
- set({ user: userToSave });
16
- debug("User updated", userToSave);
17
- },
18
- clearUser: () => {
19
- set({ user: null });
20
- debug("User cleared");
21
- },
22
- }), {
23
- name: "b3-user",
24
- onRehydrateStorage: () => (_, error) => {
25
- if (error) {
26
- console.warn("Failed to rehydrate user store:", error);
27
- }
28
- },
29
- }));
30
4
  /**
31
5
  * NOTE: THIS IS ONLY MEANT FOR INTERNAL USE, from useOnConnect
32
6
  *
@@ -1,6 +1,4 @@
1
1
  export { B3Provider } from "./components/B3Provider/B3Provider.native";
2
- export { B3Context, type B3ContextType } from "./components/B3Provider/types";
3
- export { useB3 } from "./components/B3Provider/useB3";
4
2
  export { useAccountWallet } from "./hooks/useAccountWallet";
5
3
  export { useAuthentication } from "./hooks/useAuthentication";
6
4
  export { useProfile } from "./hooks/useProfile";
@@ -3,8 +3,6 @@
3
3
  // export * from "./stores/index.js";
4
4
  // We only export the components and hooks that are needed for the native app
5
5
  export { B3Provider } from "./components/B3Provider/B3Provider.native.js";
6
- export { B3Context } from "./components/B3Provider/types.js";
7
- export { useB3 } from "./components/B3Provider/useB3.js";
8
6
  export { useAccountWallet } from "./hooks/useAccountWallet.js";
9
7
  export { useAuthentication } from "./hooks/useAuthentication.js";
10
8
  export { useProfile } from "./hooks/useProfile.js";
@@ -0,0 +1,24 @@
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 } from "thirdweb/wallets";
5
+ import { ClientType } from "../../client-manager";
6
+ interface ConfigStore {
7
+ accountOverride?: Account;
8
+ automaticallySetFirstEoa: boolean;
9
+ environment: "development" | "production";
10
+ defaultPermissions: PermissionsConfig;
11
+ theme: "light" | "dark";
12
+ clientType: ClientType;
13
+ partnerId: string;
14
+ stripePublishableKey?: string;
15
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
+ enableTurnkey: boolean;
17
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
+ }
19
+ /**
20
+ * Zustand store for B3 configuration
21
+ * NOT persisted - these are developer-set configuration values
22
+ */
23
+ export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
+ export {};
@@ -0,0 +1,27 @@
1
+ import { create } from "zustand";
2
+ /**
3
+ * Default permissions configuration for B3 provider
4
+ */
5
+ const DEFAULT_PERMISSIONS = {
6
+ approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
7
+ nativeTokenLimitPerTransaction: 0.1,
8
+ startDate: new Date(),
9
+ endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
10
+ };
11
+ /**
12
+ * Zustand store for B3 configuration
13
+ * NOT persisted - these are developer-set configuration values
14
+ */
15
+ export const useB3ConfigStore = create(set => ({
16
+ accountOverride: undefined,
17
+ automaticallySetFirstEoa: false,
18
+ environment: "development",
19
+ defaultPermissions: DEFAULT_PERMISSIONS,
20
+ theme: "light",
21
+ clientType: "rest",
22
+ partnerId: "",
23
+ stripePublishableKey: undefined,
24
+ createClientReferenceId: undefined,
25
+ enableTurnkey: false,
26
+ setConfig: config => set(state => ({ ...state, ...config })),
27
+ }));
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
@@ -1,3 +1,4 @@
1
1
  export { useAuthStore } from "./useAuthStore.js";
2
+ export { useB3ConfigStore } from "./configStore.js";
2
3
  export { useModalStore } from "./useModalStore.js";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore.js";
@@ -0,0 +1,22 @@
1
+ import { Users } from "@b3dotfun/b3-api";
2
+ interface UserStore {
3
+ user: Users | null;
4
+ setUser: (user: Users | undefined) => void;
5
+ clearUser: () => void;
6
+ }
7
+ /**
8
+ * Zustand store for managing user state
9
+ * Persists user data to localStorage
10
+ */
11
+ export declare const useUserStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<UserStore>, "persist"> & {
12
+ persist: {
13
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>) => void;
14
+ clearStorage: () => void;
15
+ rehydrate: () => Promise<void> | void;
16
+ hasHydrated: () => boolean;
17
+ onHydrate: (fn: (state: UserStore) => void) => () => void;
18
+ onFinishHydration: (fn: (state: UserStore) => void) => () => void;
19
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>;
20
+ };
21
+ }>;
22
+ export {};
@@ -0,0 +1,27 @@
1
+ import { debugB3React } from "../../../shared/utils/debug.js";
2
+ import { create } from "zustand";
3
+ import { persist } from "zustand/middleware";
4
+ const debug = debugB3React("useUserQuery");
5
+ /**
6
+ * Zustand store for managing user state
7
+ * Persists user data to localStorage
8
+ */
9
+ export const useUserStore = create()(persist(set => ({
10
+ user: null,
11
+ setUser: (newUser) => {
12
+ const userToSave = newUser ?? null;
13
+ set({ user: userToSave });
14
+ debug("User updated", userToSave);
15
+ },
16
+ clearUser: () => {
17
+ set({ user: null });
18
+ debug("User cleared");
19
+ },
20
+ }), {
21
+ name: "b3-user",
22
+ onRehydrateStorage: () => (_, error) => {
23
+ if (error) {
24
+ console.warn("Failed to rehydrate user store:", error);
25
+ }
26
+ },
27
+ }));
@@ -0,0 +1,5 @@
1
+ declare const AuthenticationProvider: ({ partnerId, automaticallySetFirstEoa, }: {
2
+ partnerId: string;
3
+ automaticallySetFirstEoa: boolean;
4
+ }) => null;
5
+ export default AuthenticationProvider;
@@ -5,15 +5,14 @@ import "@relayprotocol/relay-kit-ui/styles.css";
5
5
  import { Account, Wallet } from "thirdweb/wallets";
6
6
  import { CreateConnectorFn } from "wagmi";
7
7
  import { ClientType } from "../../../client-manager";
8
- import { B3ContextType } from "./types";
9
8
  /**
10
9
  * Main B3Provider component
11
10
  */
12
- export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
11
+ export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
13
12
  theme: "light" | "dark";
14
13
  children: React.ReactNode;
15
14
  accountOverride?: Account;
16
- environment: B3ContextType["environment"];
15
+ environment?: "development" | "production";
17
16
  automaticallySetFirstEoa?: boolean;
18
17
  simDuneApiKey?: string;
19
18
  toaster?: {
@@ -30,20 +29,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
30
29
  overrideDefaultConnectors?: boolean;
31
30
  createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
32
31
  enableTurnkey?: boolean;
33
- }): import("react/jsx-runtime").JSX.Element;
34
- /**
35
- * Inner provider component that provides the actual B3Context
36
- */
37
- export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
38
- children: React.ReactNode;
39
- accountOverride?: Account;
40
- environment: B3ContextType["environment"];
41
32
  defaultPermissions?: PermissionsConfig;
42
- automaticallySetFirstEoa: boolean;
43
- theme: "light" | "dark";
44
- clientType?: ClientType;
45
- partnerId: string;
46
- stripePublishableKey?: string;
47
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
48
- enableTurnkey?: boolean;
49
33
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,27 +1,27 @@
1
1
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
2
2
  import { Account, Wallet } from "thirdweb/wallets";
3
3
  import { ClientType } from "../../../client-manager";
4
- import { B3ContextType } from "./types";
5
4
  /**
6
5
  * Main B3Provider component
7
6
  */
8
- export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }: {
7
+ export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, defaultPermissions, }: {
9
8
  theme: "light" | "dark";
10
9
  children: React.ReactNode;
11
10
  accountOverride?: Account;
12
- environment: B3ContextType["environment"];
11
+ environment?: "development" | "production";
13
12
  clientType?: ClientType;
14
13
  partnerId: string;
15
14
  rpcUrls?: Record<number, string>;
16
15
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
16
+ defaultPermissions?: PermissionsConfig;
17
17
  }): import("react/jsx-runtime").JSX.Element;
18
18
  /**
19
- * Inner provider component that provides the actual B3Context
19
+ * Inner provider component for native
20
20
  */
21
21
  export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
22
22
  children: React.ReactNode;
23
23
  accountOverride?: Account;
24
- environment: B3ContextType["environment"];
24
+ environment?: "development" | "production";
25
25
  defaultPermissions?: PermissionsConfig;
26
26
  theme: "light" | "dark";
27
27
  clientType?: ClientType;
@@ -1,6 +1,16 @@
1
1
  /**
2
- * Hook to access the B3 context
3
- * @throws Error if used outside a B3Provider
4
- * @deprecated Use useB3Config or useB3Account instead
2
+ * Hook to access the B3 configuration
3
+ * @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
5
4
  */
6
- export declare function useB3(): import("./types").B3ContextType;
5
+ export declare function useB3(): {
6
+ automaticallySetFirstEoa: boolean;
7
+ environment: "development" | "production";
8
+ theme: "light" | "dark";
9
+ clientType: import("../../../client-manager").ClientType;
10
+ partnerId: string;
11
+ createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
12
+ enableTurnkey: boolean;
13
+ stripePublishableKey: string | undefined;
14
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
15
+ accountOverride: import("thirdweb/wallets").Account | undefined;
16
+ };
@@ -1,9 +1,17 @@
1
+ /**
2
+ * Hook to access B3 configuration
3
+ * Returns all config values from the Zustand store
4
+ * Since config is static (set once at initialization), destructuring is fine here
5
+ */
1
6
  export declare const useB3Config: () => {
2
7
  automaticallySetFirstEoa: boolean;
3
- environment: "development" | "production" | undefined;
8
+ environment: "development" | "production";
4
9
  theme: "light" | "dark";
5
10
  clientType: import("../../../client-manager").ClientType;
6
11
  partnerId: string;
7
12
  createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
8
- enableTurnkey: boolean | undefined;
13
+ enableTurnkey: boolean;
14
+ stripePublishableKey: string | undefined;
15
+ defaultPermissions: import("../../../types/permissions").PermissionsConfig;
16
+ accountOverride: import("thirdweb/wallets").Account | undefined;
9
17
  };
@@ -1,7 +1,6 @@
1
1
  export { B3DynamicModal } from "./B3DynamicModal";
2
- export { B3Provider, InnerProvider } from "./B3Provider/B3Provider";
2
+ export { B3Provider } from "./B3Provider/B3Provider";
3
3
  export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
4
- export { B3Context, type B3ContextType } from "./B3Provider/types";
5
4
  export { useB3 } from "./B3Provider/useB3";
6
5
  export { useB3Account } from "./B3Provider/useB3Account";
7
6
  export { useB3Config } from "./B3Provider/useB3Config";
@@ -43,3 +43,4 @@ export { useTokensFromAddress } from "./useTokensFromAddress";
43
43
  export { useTurnkeyAuth } from "./useTurnkeyAuth";
44
44
  export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
45
45
  export { useURLParams } from "./useURLParams";
46
+ export { useUser } from "./useUser";
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Preferred Hook to get the user data
3
+ */
4
+ export declare function useUser(): {
5
+ user: {
6
+ email?: string | undefined;
7
+ username?: string | undefined;
8
+ telNumber?: string | undefined;
9
+ ens?: string | undefined;
10
+ avatar?: string | undefined;
11
+ preferences?: {} | undefined;
12
+ referredBy?: string | {} | undefined;
13
+ sourceApp?: string | undefined;
14
+ referralCode?: string | undefined;
15
+ userGroups?: number[] | undefined;
16
+ isMigratedFromBSMNT?: boolean | undefined;
17
+ privyLinkedAccounts?: {
18
+ name?: string | undefined;
19
+ address?: string | undefined;
20
+ email?: string | undefined;
21
+ chain_type?: string | undefined;
22
+ lv?: number | undefined;
23
+ wallet_client_type?: string | undefined;
24
+ smart_wallet_type?: string | undefined;
25
+ subject?: string | undefined;
26
+ type: string;
27
+ }[] | undefined;
28
+ twProfiles?: {
29
+ type: string;
30
+ details: {
31
+ id?: string | undefined;
32
+ name?: string | undefined;
33
+ address?: string | undefined;
34
+ email?: string | undefined;
35
+ username?: string | undefined;
36
+ phone?: string | undefined;
37
+ fid?: string | undefined;
38
+ };
39
+ }[] | undefined;
40
+ turnkeySubOrgs?: {
41
+ hasDelegatedUser?: boolean | undefined;
42
+ subOrgId: string;
43
+ accounts: Record<string, any>[];
44
+ }[] | undefined;
45
+ _id: string | {};
46
+ userId: string;
47
+ smartAccountAddress: string;
48
+ createdAt: number;
49
+ updatedAt: number;
50
+ partnerIds: {
51
+ privyId?: string | undefined;
52
+ thirdwebId?: string | undefined;
53
+ turnkeyId?: string | undefined;
54
+ turnkeyOtpId?: string | undefined;
55
+ };
56
+ } | null;
57
+ isConnecting: boolean;
58
+ isConnected: boolean;
59
+ isAuthenticating: boolean;
60
+ };
@@ -1,6 +1,4 @@
1
1
  export { B3Provider } from "./components/B3Provider/B3Provider.native";
2
- export { B3Context, type B3ContextType } from "./components/B3Provider/types";
3
- export { useB3 } from "./components/B3Provider/useB3";
4
2
  export { useAccountWallet } from "./hooks/useAccountWallet";
5
3
  export { useAuthentication } from "./hooks/useAuthentication";
6
4
  export { useProfile } from "./hooks/useProfile";
@@ -0,0 +1,24 @@
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 { ClientType } from "../../client-manager";
6
+ interface ConfigStore {
7
+ accountOverride?: Account;
8
+ automaticallySetFirstEoa: boolean;
9
+ environment: "development" | "production";
10
+ defaultPermissions: PermissionsConfig;
11
+ theme: "light" | "dark";
12
+ clientType: ClientType;
13
+ partnerId: string;
14
+ stripePublishableKey?: string;
15
+ createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
16
+ enableTurnkey: boolean;
17
+ setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
18
+ }
19
+ /**
20
+ * Zustand store for B3 configuration
21
+ * NOT persisted - these are developer-set configuration values
22
+ */
23
+ export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
24
+ export {};
@@ -1,4 +1,5 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
+ export { useB3ConfigStore } from "./configStore";
2
3
  export { useModalStore } from "./useModalStore";
3
4
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
4
5
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
@@ -0,0 +1,22 @@
1
+ import { Users } from "@b3dotfun/b3-api";
2
+ interface UserStore {
3
+ user: Users | null;
4
+ setUser: (user: Users | undefined) => void;
5
+ clearUser: () => void;
6
+ }
7
+ /**
8
+ * Zustand store for managing user state
9
+ * Persists user data to localStorage
10
+ */
11
+ export declare const useUserStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<UserStore>, "persist"> & {
12
+ persist: {
13
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>) => void;
14
+ clearStorage: () => void;
15
+ rehydrate: () => Promise<void> | void;
16
+ hasHydrated: () => boolean;
17
+ onHydrate: (fn: (state: UserStore) => void) => () => void;
18
+ onFinishHydration: (fn: (state: UserStore) => void) => () => void;
19
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>;
20
+ };
21
+ }>;
22
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.88-alpha.4",
3
+ "version": "0.0.88-alpha.6",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -24,7 +24,7 @@ import {
24
24
  toast,
25
25
  TransitionPanel,
26
26
  useAccountWallet,
27
- useB3,
27
+ useB3Config,
28
28
  useModalStore,
29
29
  useProfile,
30
30
  useRouter,
@@ -151,7 +151,7 @@ function AnySpendInner({
151
151
  const searchParams = useSearchParamsSSR();
152
152
  const router = useRouter();
153
153
 
154
- const { partnerId } = useB3();
154
+ const { partnerId } = useB3Config();
155
155
  const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
156
156
 
157
157
  // Determine if we're in "buy mode" based on whether destination token props are provided
@@ -356,7 +356,7 @@ export function AnySpendDeposit({
356
356
  )}
357
357
  {/* Balance header */}
358
358
  {!isBalanceLoading && totalBalance > 0 && (
359
- <div className="anyspend-deposit-balance border-secondary border-b p-5">
359
+ <div className="anyspend-deposit-balance border-theme-border-secondary border-b p-5">
360
360
  <p className="anyspend-deposit-balance-label text-as-secondary text-sm">Your Balance</p>
361
361
  <p className="anyspend-deposit-balance-value text-as-primary text-3xl font-semibold">
362
362
  {formatDecimal(totalBalance)} <span className="text-sm">USD</span>
@@ -525,6 +525,7 @@ export function AnySpendDeposit({
525
525
  <div className={cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8")}>
526
526
  {isHyperliquidDeposit ? (
527
527
  <AnySpend
528
+ key={selectedChainId}
528
529
  loadOrder={loadOrder}
529
530
  mode={mode}
530
531
  defaultActiveTab={paymentType}
@@ -541,6 +542,7 @@ export function AnySpendDeposit({
541
542
  />
542
543
  ) : (
543
544
  <AnySpendCustomExactIn
545
+ key={selectedChainId}
544
546
  loadOrder={loadOrder}
545
547
  mode={mode}
546
548
  recipientAddress={recipientAddress}