@b3dotfun/sdk 0.0.88-alpha.5 → 0.0.88-alpha.7

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 (198) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +6 -0
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +5 -5
  3. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
  4. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +3 -3
  5. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
  6. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +2 -2
  7. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
  8. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
  9. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
  10. package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +4 -0
  11. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +33 -5
  12. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
  13. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +3 -2
  14. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
  15. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
  16. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
  17. package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
  18. package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
  19. package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -3
  20. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  21. package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
  22. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  23. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +23 -57
  24. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  25. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +38 -35
  26. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  27. package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -11
  28. package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
  29. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  30. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +18 -17
  31. package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
  32. package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
  33. package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
  34. package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
  35. package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
  36. package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +8 -9
  37. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
  38. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  39. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  40. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
  41. package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
  42. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
  43. package/dist/cjs/global-account/react/components/index.d.ts +1 -2
  44. package/dist/cjs/global-account/react/components/index.js +3 -6
  45. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
  46. package/dist/cjs/global-account/react/hooks/index.js +3 -1
  47. package/dist/cjs/global-account/react/hooks/useAuth.js +1 -2
  48. package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
  49. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
  50. package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
  51. package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
  52. package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
  53. package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
  54. package/dist/cjs/global-account/react/hooks/useUserQuery.js +9 -35
  55. package/dist/cjs/global-account/react/index.native.d.ts +0 -2
  56. package/dist/cjs/global-account/react/index.native.js +1 -5
  57. package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
  58. package/dist/cjs/global-account/react/stores/configStore.js +30 -0
  59. package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
  60. package/dist/cjs/global-account/react/stores/index.js +3 -1
  61. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +6 -0
  62. package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
  63. package/dist/cjs/global-account/react/stores/userStore.js +30 -0
  64. package/dist/esm/anyspend/react/components/AnySpend.d.ts +6 -0
  65. package/dist/esm/anyspend/react/components/AnySpend.js +6 -6
  66. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
  67. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +3 -3
  68. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
  69. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +2 -2
  70. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
  71. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
  72. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
  73. package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +4 -0
  74. package/dist/esm/anyspend/react/components/common/OrderDetails.js +35 -7
  75. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
  76. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +3 -2
  77. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
  78. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
  79. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
  80. package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
  81. package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
  82. package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -4
  83. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  84. package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
  85. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  86. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +22 -58
  87. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  88. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
  89. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  90. package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -11
  91. package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
  92. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  93. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +18 -17
  94. package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
  95. package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
  96. package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
  97. package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
  98. package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
  99. package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -3
  100. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  101. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
  102. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
  103. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
  104. package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
  105. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
  106. package/dist/esm/global-account/react/components/index.d.ts +1 -2
  107. package/dist/esm/global-account/react/components/index.js +1 -2
  108. package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
  109. package/dist/esm/global-account/react/hooks/index.js +1 -0
  110. package/dist/esm/global-account/react/hooks/useAuth.js +2 -3
  111. package/dist/esm/global-account/react/hooks/useClient.js +2 -2
  112. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
  113. package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
  114. package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
  115. package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
  116. package/dist/esm/global-account/react/hooks/useUser.js +17 -0
  117. package/dist/esm/global-account/react/hooks/useUserQuery.js +1 -27
  118. package/dist/esm/global-account/react/index.native.d.ts +0 -2
  119. package/dist/esm/global-account/react/index.native.js +0 -2
  120. package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
  121. package/dist/esm/global-account/react/stores/configStore.js +27 -0
  122. package/dist/esm/global-account/react/stores/index.d.ts +1 -0
  123. package/dist/esm/global-account/react/stores/index.js +1 -0
  124. package/dist/esm/global-account/react/stores/useModalStore.d.ts +6 -0
  125. package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
  126. package/dist/esm/global-account/react/stores/userStore.js +27 -0
  127. package/dist/types/anyspend/react/components/AnySpend.d.ts +6 -0
  128. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
  129. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
  130. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
  131. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
  132. package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +4 -0
  133. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
  134. package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
  135. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
  136. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
  137. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +14 -4
  138. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
  139. package/dist/types/global-account/react/components/index.d.ts +1 -2
  140. package/dist/types/global-account/react/hooks/index.d.ts +1 -0
  141. package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
  142. package/dist/types/global-account/react/index.native.d.ts +0 -2
  143. package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
  144. package/dist/types/global-account/react/stores/index.d.ts +1 -0
  145. package/dist/types/global-account/react/stores/useModalStore.d.ts +6 -0
  146. package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
  147. package/package.json +1 -1
  148. package/src/anyspend/react/components/AnySpend.tsx +18 -2
  149. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +13 -0
  150. package/src/anyspend/react/components/AnySpendDeposit.tsx +15 -0
  151. package/src/anyspend/react/components/AnyspendDepositHype.tsx +4 -0
  152. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +5 -1
  153. package/src/anyspend/react/components/common/OrderDetails.tsx +54 -42
  154. package/src/anyspend/react/components/common/PanelOnramp.tsx +5 -1
  155. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -4
  156. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
  157. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
  158. package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
  159. package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
  160. package/src/global-account/react/components/B3DynamicModal.tsx +3 -4
  161. package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
  162. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +43 -54
  163. package/src/global-account/react/components/B3Provider/B3Provider.tsx +32 -117
  164. package/src/global-account/react/components/B3Provider/useB3.ts +4 -13
  165. package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
  166. package/src/global-account/react/components/B3Provider/useB3Config.ts +18 -31
  167. package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
  168. package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
  169. package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
  170. package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
  171. package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
  172. package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
  173. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  174. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
  175. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
  176. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  177. package/src/global-account/react/components/StyleRoot.tsx +3 -3
  178. package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
  179. package/src/global-account/react/components/index.ts +1 -2
  180. package/src/global-account/react/hooks/index.ts +1 -0
  181. package/src/global-account/react/hooks/useAuth.ts +2 -3
  182. package/src/global-account/react/hooks/useClient.ts +2 -2
  183. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
  184. package/src/global-account/react/hooks/useNotifications.ts +2 -2
  185. package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
  186. package/src/global-account/react/hooks/useUser.ts +20 -0
  187. package/src/global-account/react/hooks/useUserQuery.ts +1 -40
  188. package/src/global-account/react/index.native.ts +0 -2
  189. package/src/global-account/react/stores/configStore.ts +51 -0
  190. package/src/global-account/react/stores/index.ts +1 -0
  191. package/src/global-account/react/stores/useModalStore.ts +6 -0
  192. package/src/global-account/react/stores/userStore.ts +41 -0
  193. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
  194. package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
  195. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
  196. package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
  197. package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
  198. package/src/global-account/react/components/B3Provider/types.ts +0 -50
@@ -0,0 +1,19 @@
1
+ import { useAuthentication } from "../../hooks";
2
+ import { useAutoSelectWallet } from "../../hooks/useAutoSelectWallet";
3
+
4
+ const AuthenticationProvider = ({
5
+ partnerId,
6
+ automaticallySetFirstEoa,
7
+ }: {
8
+ partnerId: string;
9
+ automaticallySetFirstEoa: boolean;
10
+ }) => {
11
+ useAuthentication(partnerId);
12
+ useAutoSelectWallet({
13
+ enabled: automaticallySetFirstEoa,
14
+ });
15
+
16
+ return null;
17
+ };
18
+
19
+ export default AuthenticationProvider;
@@ -1,24 +1,16 @@
1
1
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
2
2
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
- import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
3
+ import { useEffect } from "react";
4
+ import { ThirdwebProvider } from "thirdweb/react";
4
5
  import { Account, Wallet } from "thirdweb/wallets";
5
6
 
6
7
  import { ClientType } from "../../../client-manager";
7
8
 
8
9
  import { WagmiProvider } from "wagmi";
10
+ import { useB3ConfigStore } from "../../stores/configStore";
9
11
  import { createWagmiConfig } from "../../utils/createWagmiConfig";
12
+ import AuthenticationProvider from "./AuthenticationProvider";
10
13
  import { LocalSDKProvider } from "./LocalSDKProvider";
11
- import { B3Context, B3ContextType } from "./types";
12
-
13
- /**
14
- * Default permissions configuration for B3 provider
15
- */
16
- const DEFAULT_PERMISSIONS = {
17
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
18
- nativeTokenLimitPerTransaction: 0.1, // in ETH
19
- startDate: new Date(),
20
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
21
- };
22
14
 
23
15
  // Create queryClient instance
24
16
  const queryClient = new QueryClient();
@@ -35,44 +27,53 @@ export function B3Provider({
35
27
  partnerId,
36
28
  rpcUrls,
37
29
  onConnect,
30
+ defaultPermissions,
38
31
  }: {
39
32
  theme: "light" | "dark";
40
33
  children: React.ReactNode;
41
34
  accountOverride?: Account;
42
- environment: B3ContextType["environment"];
35
+ environment?: "development" | "production";
43
36
  clientType?: ClientType;
44
37
  partnerId: string;
45
38
  rpcUrls?: Record<number, string>;
46
39
  onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
40
+ defaultPermissions?: PermissionsConfig;
47
41
  }) {
42
+ const setConfig = useB3ConfigStore(state => state.setConfig);
43
+
44
+ // Initialize config store on mount - props are static and never change
45
+ useEffect(() => {
46
+ setConfig({
47
+ accountOverride,
48
+ environment: environment ?? "development",
49
+ automaticallySetFirstEoa: false,
50
+ theme,
51
+ clientType,
52
+ partnerId,
53
+ defaultPermissions,
54
+ });
55
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
56
+
48
57
  return (
49
58
  <ThirdwebProvider>
50
59
  <LocalSDKProvider onConnectCallback={onConnect}>
51
- <InnerProvider
52
- accountOverride={accountOverride}
53
- environment={environment}
54
- theme={theme}
55
- clientType={clientType}
56
- partnerId={partnerId}
57
- rpcUrls={rpcUrls}
58
- >
59
- {/* <RelayKitProviderWrapper> */}
60
- {children}
61
- {/* </RelayKitProviderWrapper> */}
62
- </InnerProvider>
60
+ {/* <RelayKitProviderWrapper> */}
61
+ {children}
62
+ <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={false} />
63
+ {/* </RelayKitProviderWrapper> */}
63
64
  </LocalSDKProvider>
64
65
  </ThirdwebProvider>
65
66
  );
66
67
  }
67
68
 
68
69
  /**
69
- * Inner provider component that provides the actual B3Context
70
+ * Inner provider component for native
70
71
  */
71
72
  export function InnerProvider({
72
73
  children,
73
74
  accountOverride,
74
75
  environment,
75
- defaultPermissions = DEFAULT_PERMISSIONS,
76
+ defaultPermissions,
76
77
  theme = "light",
77
78
  clientType = "socket",
78
79
  partnerId,
@@ -80,44 +81,32 @@ export function InnerProvider({
80
81
  }: {
81
82
  children: React.ReactNode;
82
83
  accountOverride?: Account;
83
- environment: B3ContextType["environment"];
84
+ environment?: "development" | "production";
84
85
  defaultPermissions?: PermissionsConfig;
85
86
  theme: "light" | "dark";
86
87
  clientType?: ClientType;
87
88
  partnerId: string;
88
89
  rpcUrls?: Record<number, string>;
89
90
  }) {
90
- const activeAccount = useActiveAccount();
91
- //const { user, setUser, refetchUser } = useAuthentication(partnerId);
91
+ const setConfig = useB3ConfigStore(state => state.setConfig);
92
92
  const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
93
93
 
94
- // Use given accountOverride or activeAccount from thirdweb
95
- const effectiveAccount = accountOverride || activeAccount;
94
+ // Initialize config store on mount - props are static and never change
95
+ useEffect(() => {
96
+ setConfig({
97
+ accountOverride,
98
+ environment: environment ?? "development",
99
+ automaticallySetFirstEoa: false,
100
+ theme,
101
+ clientType,
102
+ partnerId,
103
+ defaultPermissions,
104
+ });
105
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
96
106
 
97
107
  return (
98
108
  <WagmiProvider config={wagmiConfig}>
99
- <QueryClientProvider client={queryClient}>
100
- <B3Context.Provider
101
- value={{
102
- //account: effectiveAccount,
103
- automaticallySetFirstEoa: false,
104
- //setWallet: () => {},
105
- wallet: undefined,
106
- //user,
107
- //setUser,
108
- initialized: true,
109
- ready: !!effectiveAccount,
110
- environment,
111
- defaultPermissions,
112
- theme,
113
- clientType,
114
- partnerId,
115
- //refetchUser,
116
- }}
117
- >
118
- {children}
119
- </B3Context.Provider>
120
- </QueryClientProvider>
109
+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
121
110
  </WagmiProvider>
122
111
  );
123
112
  }
@@ -1,36 +1,21 @@
1
1
  import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
2
2
  import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
3
- import {
4
- RelayKitProviderWrapper,
5
- TooltipProvider,
6
- useAuthentication,
7
- useAuthStore,
8
- } from "@b3dotfun/sdk/global-account/react";
9
- import { useAutoSelectWallet } from "@b3dotfun/sdk/global-account/react/hooks/useAutoSelectWallet";
3
+ import { RelayKitProviderWrapper, TooltipProvider } from "@b3dotfun/sdk/global-account/react";
10
4
  import { createWagmiConfig } from "@b3dotfun/sdk/global-account/react/utils/createWagmiConfig";
11
5
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
12
6
  import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
13
7
  import "@relayprotocol/relay-kit-ui/styles.css";
14
8
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
15
9
  import { useEffect, useMemo } from "react";
16
- import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
10
+ import { ThirdwebProvider } from "thirdweb/react";
17
11
  import { Account, Wallet } from "thirdweb/wallets";
18
12
  import { CreateConnectorFn, WagmiProvider } from "wagmi";
19
13
  import { ClientType, setClientType } from "../../../client-manager";
14
+ import { useB3ConfigStore } from "../../stores/configStore";
20
15
  import { StyleRoot } from "../StyleRoot";
21
16
  import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
17
+ import AuthenticationProvider from "./AuthenticationProvider";
22
18
  import { LocalSDKProvider } from "./LocalSDKProvider";
23
- import { B3Context, B3ContextType } from "./types";
24
-
25
- /**
26
- * Default permissions configuration for B3 provider
27
- */
28
- const DEFAULT_PERMISSIONS = {
29
- approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
30
- nativeTokenLimitPerTransaction: 0.1, // in ETH
31
- startDate: new Date(),
32
- endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
33
- };
34
19
 
35
20
  // Create queryClient instance
36
21
  const queryClient = new QueryClient();
@@ -56,11 +41,12 @@ export function B3Provider({
56
41
  overrideDefaultConnectors = false,
57
42
  createClientReferenceId,
58
43
  enableTurnkey = false,
44
+ defaultPermissions,
59
45
  }: {
60
46
  theme: "light" | "dark";
61
47
  children: React.ReactNode;
62
48
  accountOverride?: Account;
63
- environment: B3ContextType["environment"];
49
+ environment?: "development" | "production";
64
50
  automaticallySetFirstEoa?: boolean;
65
51
  simDuneApiKey?: string;
66
52
  toaster?: {
@@ -77,7 +63,26 @@ export function B3Provider({
77
63
  overrideDefaultConnectors?: boolean;
78
64
  createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
79
65
  enableTurnkey?: boolean;
66
+ defaultPermissions?: PermissionsConfig;
80
67
  }) {
68
+ const setConfig = useB3ConfigStore(state => state.setConfig);
69
+
70
+ // Initialize config store on mount - props are static and never change
71
+ useEffect(() => {
72
+ setConfig({
73
+ accountOverride,
74
+ environment: environment ?? "development",
75
+ automaticallySetFirstEoa: !!automaticallySetFirstEoa,
76
+ theme,
77
+ clientType,
78
+ partnerId,
79
+ stripePublishableKey,
80
+ createClientReferenceId,
81
+ enableTurnkey,
82
+ defaultPermissions,
83
+ });
84
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
85
+
81
86
  // Initialize Google Analytics on mount
82
87
  useEffect(() => {
83
88
  loadGA4Script();
@@ -100,24 +105,13 @@ export function B3Provider({
100
105
  <TooltipProvider>
101
106
  <ToastProvider>
102
107
  <LocalSDKProvider onConnectCallback={onConnect}>
103
- <InnerProvider
104
- accountOverride={accountOverride}
105
- environment={environment}
106
- theme={theme}
107
- automaticallySetFirstEoa={!!automaticallySetFirstEoa}
108
- clientType={clientType}
109
- partnerId={partnerId}
110
- stripePublishableKey={stripePublishableKey}
111
- createClientReferenceId={createClientReferenceId}
112
- enableTurnkey={enableTurnkey}
113
- >
114
- <ToastContextConnector />
115
- <RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
116
- {children}
117
- {/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
118
- <StyleRoot id="b3-root" />
119
- </RelayKitProviderWrapper>
120
- </InnerProvider>
108
+ <ToastContextConnector />
109
+ <RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
110
+ {children}
111
+ {/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
112
+ <StyleRoot id="b3-root" />
113
+ </RelayKitProviderWrapper>
114
+ <AuthenticationProvider partnerId={partnerId} automaticallySetFirstEoa={!!automaticallySetFirstEoa} />
121
115
  </LocalSDKProvider>
122
116
  </ToastProvider>
123
117
  </TooltipProvider>
@@ -127,85 +121,6 @@ export function B3Provider({
127
121
  );
128
122
  }
129
123
 
130
- /**
131
- * Inner provider component that provides the actual B3Context
132
- */
133
- export function InnerProvider({
134
- children,
135
- accountOverride,
136
- environment,
137
- defaultPermissions = DEFAULT_PERMISSIONS,
138
- automaticallySetFirstEoa,
139
- theme = "light",
140
- clientType = "socket",
141
- partnerId,
142
- stripePublishableKey,
143
- createClientReferenceId,
144
- enableTurnkey,
145
- }: {
146
- children: React.ReactNode;
147
- accountOverride?: Account;
148
- environment: B3ContextType["environment"];
149
- defaultPermissions?: PermissionsConfig;
150
- automaticallySetFirstEoa: boolean;
151
- theme: "light" | "dark";
152
- clientType?: ClientType;
153
- partnerId: string;
154
- stripePublishableKey?: string;
155
- createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
156
- enableTurnkey?: boolean;
157
- }) {
158
- const activeAccount = useActiveAccount();
159
- const isAuthenticated = useAuthStore(state => state.isAuthenticated);
160
- //const isConnected = useAuthStore(state => state.isConnected);
161
- //const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
162
-
163
- // Note: This fixes a bug where useAuthentication is no longer rendered on every page, as of this PR https://github.com/b3-fun/b3/pull/385/files#diff-3ef996931b8fc8e49021ba1b42ddaa97535214681610dc5fdacf63542e261af7
164
- // The above PR removes useAuthentication from the overall B3Provider. useAuthentication should be everywhere the provider is, since it sets the overall auth state
165
- // By just calling it manually, we fix that issue
166
- // As a follow up, we should fix the SDK directly
167
- useAuthentication(partnerId);
168
-
169
- // Use given accountOverride or activeAccount from thirdweb
170
- // WOJ: why if isAuthenticated is false, we don't use activeAccount, which should be undefined?
171
- // skip isAuthenticated check ?
172
- const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
173
-
174
- // Wrapper to set active wallet via thirdweb
175
- // Note: `wallet` in context is deprecated - use useActiveWallet() from thirdweb/react instead
176
-
177
- // Auto-select first EOA wallet when enabled
178
- useAutoSelectWallet({
179
- enabled: automaticallySetFirstEoa,
180
- });
181
-
182
- return (
183
- <B3Context.Provider
184
- value={{
185
- account: effectiveAccount,
186
- // setWallet,
187
- //wallet: undefined, // Deprecated: use useActiveWallet() from thirdweb/react instead
188
- //user,
189
- //setUser,
190
- //refetchUser,
191
- initialized: true,
192
- ready: !!effectiveAccount,
193
- automaticallySetFirstEoa,
194
- environment,
195
- defaultPermissions,
196
- theme,
197
- clientType,
198
- partnerId: partnerId,
199
- stripePublishableKey,
200
- createClientReferenceId,
201
- enableTurnkey,
202
- }}
203
- >
204
- {children}
205
- </B3Context.Provider>
206
- );
207
- }
208
-
209
124
  /**
210
125
  * Component to connect the toast context to the global toast API
211
126
  */
@@ -1,18 +1,9 @@
1
- import { useContext, useMemo } from "react";
2
- import { B3Context } from "./types";
1
+ import { useB3Config } from "./useB3Config";
3
2
 
4
3
  /**
5
- * Hook to access the B3 context
6
- * @throws Error if used outside a B3Provider
7
- * @deprecated Use useB3Config or useB3Account instead
4
+ * Hook to access the B3 configuration
5
+ * @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
8
6
  */
9
7
  export function useB3() {
10
- const context = useContext(B3Context);
11
-
12
- if (!context.initialized) {
13
- throw new Error("useB3 must be used within a B3Provider");
14
- }
15
-
16
- // Return a stable reference
17
- return useMemo(() => context, [context]);
8
+ return useB3Config();
18
9
  }
@@ -1,7 +1,11 @@
1
1
  import { useActiveAccount } from "thirdweb/react";
2
+ import { useAuthStore } from "../../stores/useAuthStore";
2
3
 
3
4
  // Wrapper around useActiveAccount
4
5
  export const useB3Account = () => {
5
- const account = useActiveAccount();
6
- return account;
6
+ const isAuthenticated = useAuthStore(state => state.isAuthenticated);
7
+ const activeAccount = useActiveAccount();
8
+ const effectiveAccount = isAuthenticated ? activeAccount : undefined;
9
+
10
+ return effectiveAccount;
7
11
  };
@@ -1,34 +1,21 @@
1
- import { useContext, useMemo } from "react";
2
- import { B3Context } from "./types";
1
+ import { useB3ConfigStore } from "../../stores/configStore";
3
2
 
3
+ /**
4
+ * Hook to access B3 configuration
5
+ * Returns all config values from the Zustand store
6
+ * Since config is static (set once at initialization), destructuring is fine here
7
+ */
4
8
  export const useB3Config = () => {
5
- const context = useContext(B3Context);
6
-
7
- if (!context) {
8
- throw new Error("useB3 must be used within a B3Provider");
9
- }
10
-
11
- const {
12
- automaticallySetFirstEoa,
13
- environment,
14
- theme,
15
- clientType,
16
- partnerId,
17
- createClientReferenceId,
18
- enableTurnkey,
19
- } = context;
20
-
21
- // Return a stable reference
22
- return useMemo(
23
- () => ({
24
- automaticallySetFirstEoa,
25
- environment,
26
- theme,
27
- clientType,
28
- partnerId,
29
- createClientReferenceId,
30
- enableTurnkey,
31
- }),
32
- [automaticallySetFirstEoa, environment, theme, clientType, partnerId, createClientReferenceId, enableTurnkey],
33
- );
9
+ return useB3ConfigStore(state => ({
10
+ automaticallySetFirstEoa: state.automaticallySetFirstEoa,
11
+ environment: state.environment,
12
+ theme: state.theme,
13
+ clientType: state.clientType,
14
+ partnerId: state.partnerId,
15
+ createClientReferenceId: state.createClientReferenceId,
16
+ enableTurnkey: state.enableTurnkey,
17
+ stripePublishableKey: state.stripePublishableKey,
18
+ defaultPermissions: state.defaultPermissions,
19
+ accountOverride: state.accountOverride,
20
+ }));
34
21
  };
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  useAccountWallet,
3
- useAuthentication,
4
- useB3Config,
5
3
  useModalStore,
6
4
  useProfile,
7
5
  useSimBalance,
6
+ useUser,
8
7
  } from "@b3dotfun/sdk/global-account/react";
9
8
  import { formatUsername } from "@b3dotfun/sdk/shared/utils";
10
9
  import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
@@ -22,8 +21,7 @@ const ProfileSection = () => {
22
21
  address: eoaAddress || account?.address,
23
22
  fresh: true,
24
23
  });
25
- const { partnerId } = useB3Config();
26
- const { user } = useAuthentication(partnerId);
24
+ const { user } = useUser();
27
25
  const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
28
26
  const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
29
27
  const navigateBack = useModalStore(state => state.navigateBack);
@@ -1,7 +1,7 @@
1
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
1
2
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
2
3
  import { useState } from "react";
3
4
  import { notificationsAPI } from "../../../utils/notificationsAPI";
4
- import { useB3 } from "../../B3Provider/useB3";
5
5
  import { toast } from "../../Toast/toastApi";
6
6
  import { NotificationChannel } from "../NotificationChannel";
7
7
 
@@ -26,7 +26,7 @@ export const DiscordChannel = ({
26
26
  onConnectionChange,
27
27
  onToggle,
28
28
  }: DiscordChannelProps) => {
29
- const { partnerId } = useB3();
29
+ const { partnerId } = useB3Config();
30
30
 
31
31
  const [discordId, setDiscordId] = useState("");
32
32
  const [isConnecting, setIsConnecting] = useState(false);
@@ -1,7 +1,7 @@
1
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
1
2
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
2
3
  import { useState } from "react";
3
4
  import { notificationsAPI } from "../../../utils/notificationsAPI";
4
- import { useB3 } from "../../B3Provider/useB3";
5
5
  import { toast } from "../../Toast/toastApi";
6
6
  import { NotificationChannel } from "../NotificationChannel";
7
7
 
@@ -31,7 +31,7 @@ export const EmailChannel = ({
31
31
  onConnectionChange,
32
32
  onToggle,
33
33
  }: EmailChannelProps) => {
34
- const { partnerId } = useB3();
34
+ const { partnerId } = useB3Config();
35
35
 
36
36
  const [email, setEmail] = useState("");
37
37
  const [emailError, setEmailError] = useState<string | null>(null);
@@ -1,7 +1,7 @@
1
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
1
2
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
2
3
  import { useState } from "react";
3
4
  import { notificationsAPI } from "../../../utils/notificationsAPI";
4
- import { useB3 } from "../../B3Provider/useB3";
5
5
  import { toast } from "../../Toast/toastApi";
6
6
  import { NotificationChannel } from "../NotificationChannel";
7
7
 
@@ -32,7 +32,7 @@ export const PhoneChannel = ({
32
32
  onConnectionChange,
33
33
  onToggle,
34
34
  }: PhoneChannelProps) => {
35
- const { partnerId } = useB3();
35
+ const { partnerId } = useB3Config();
36
36
 
37
37
  const [phoneNumber, setPhoneNumber] = useState("");
38
38
  const [isConnectingSMS, setIsConnectingSMS] = useState(false);
@@ -1,7 +1,7 @@
1
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
1
2
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
2
3
  import { useState } from "react";
3
4
  import { notificationsAPI } from "../../../utils/notificationsAPI";
4
- import { useB3 } from "../../B3Provider/useB3";
5
5
  import { toast } from "../../Toast/toastApi";
6
6
  import { NotificationChannel } from "../NotificationChannel";
7
7
 
@@ -26,7 +26,7 @@ export const TelegramChannel = ({
26
26
  onConnectionChange,
27
27
  onToggle,
28
28
  }: TelegramChannelProps) => {
29
- const { partnerId } = useB3();
29
+ const { partnerId } = useB3Config();
30
30
 
31
31
  const [isConnecting, setIsConnecting] = useState(false);
32
32
  const [status, setStatus] = useState<"idle" | "pending" | "connected">("idle");
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  Button,
3
- useB3,
3
+ PermissionItem,
4
+ RequestPermissionsModalProps,
4
5
  useAddTWSessionKey,
6
+ useB3Config,
5
7
  useGetAllTWSigners,
6
- RequestPermissionsModalProps,
7
8
  } from "@b3dotfun/sdk/global-account/react";
8
- import { PermissionItem } from "@b3dotfun/sdk/global-account/react";
9
9
  import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
10
10
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
11
11
  import { formatAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
@@ -30,7 +30,7 @@ export function RequestPermissions({
30
30
  }: RequestPermissionsModalProps) {
31
31
  const [isApproving, setIsApproving] = useState(false);
32
32
  const account = useActiveAccount();
33
- const { defaultPermissions } = useB3();
33
+ const { defaultPermissions } = useB3Config();
34
34
  const DEFAULT_PERMISSIONS = useMemo(
35
35
  () => permissions ?? (defaultPermissions as PermissionsConfig),
36
36
  [defaultPermissions, permissions],
@@ -5,7 +5,7 @@ import {
5
5
  StyleRoot,
6
6
  useAccountWallet,
7
7
  useAuthentication,
8
- useB3,
8
+ useB3Config,
9
9
  useIsMobile,
10
10
  } from "@b3dotfun/sdk/global-account/react";
11
11
  import Icon from "@b3dotfun/sdk/global-account/react/components/custom/Icon";
@@ -30,7 +30,7 @@ type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackButton">
30
30
 
31
31
  export function SignIn(props: SignInWithB3Props) {
32
32
  const { className } = props;
33
- const { automaticallySetFirstEoa, partnerId } = useB3();
33
+ const { automaticallySetFirstEoa, partnerId } = useB3Config();
34
34
  const {
35
35
  address: globalAddress,
36
36
  ensName,
@@ -2,7 +2,7 @@ import {
2
2
  Loading,
3
3
  useAuthentication,
4
4
  useAuthStore,
5
- useB3,
5
+ useB3Config,
6
6
  useHandleConnectWithPrivy,
7
7
  } from "@b3dotfun/sdk/global-account/react";
8
8
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
@@ -19,7 +19,7 @@ interface SignInWithB3PrivyProps {
19
19
  }
20
20
 
21
21
  export function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps) {
22
- const { partnerId } = useB3();
22
+ const { partnerId } = useB3Config();
23
23
  const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
24
24
  const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
25
25
  const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
@@ -1,4 +1,4 @@
1
- import { useAuthentication, useB3, useQueryB3 } from "@b3dotfun/sdk/global-account/react";
1
+ import { useAuthentication, useB3Config, useQueryB3 } from "@b3dotfun/sdk/global-account/react";
2
2
  import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
3
3
  import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
4
4
  import { Chain } from "thirdweb";
@@ -50,7 +50,7 @@ export function LoginStepContainer({ children, partnerId }: LoginStepContainerPr
50
50
  }
51
51
 
52
52
  export function LoginStep({ onSuccess, chain }: LoginStepProps) {
53
- const { partnerId, theme } = useB3();
53
+ const { partnerId, theme } = useB3Config();
54
54
  const wallet = ecosystemWallet(ecosystemWalletId, {
55
55
  partnerId: partnerId,
56
56
  });
@@ -7,7 +7,7 @@ import {
7
7
  LoginStepContainer,
8
8
  useAuthentication,
9
9
  useAuthStore,
10
- useB3,
10
+ useB3Config,
11
11
  useConnect,
12
12
  WalletRow,
13
13
  } from "@b3dotfun/sdk/global-account/react";
@@ -37,7 +37,7 @@ export function LoginStepCustom({
37
37
  maxInitialWallets = 2,
38
38
  automaticallySetFirstEoa,
39
39
  }: LoginStepCustomProps) {
40
- const { partnerId } = useB3();
40
+ const { partnerId } = useB3Config();
41
41
  const [isLoading, setIsLoading] = useState(false);
42
42
  const [showAllWallets, setShowAllWallets] = useState(false);
43
43
  const { connect } = useConnect(partnerId, chain);