@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
@@ -6,6 +6,7 @@ import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
6
6
  import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
7
7
  import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-react";
8
8
  import { useConnectModal, useDisconnect, useWalletInfo } from "thirdweb/react";
9
+ import { createWallet } from "thirdweb/wallets";
9
10
  import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay";
10
11
 
11
12
  export enum CryptoPaymentMethodType {
@@ -15,6 +16,13 @@ export enum CryptoPaymentMethodType {
15
16
  TRANSFER_CRYPTO = "transfer_crypto",
16
17
  }
17
18
 
19
+ const recommendWallets = [
20
+ createWallet("io.metamask"),
21
+ createWallet("com.coinbase.wallet"),
22
+ createWallet("me.rainbow"),
23
+ createWallet("io.rabby"),
24
+ ];
25
+
18
26
  interface CryptoPaymentMethodProps {
19
27
  selectedPaymentMethod: CryptoPaymentMethodType;
20
28
  setSelectedPaymentMethod: (method: CryptoPaymentMethodType) => void;
@@ -47,7 +55,13 @@ export function CryptoPaymentMethod({
47
55
  if (connectedEOAWallet) {
48
56
  await disconnect(connectedEOAWallet);
49
57
  }
50
- const wallet = await openConnectModal({ client, setActive: false });
58
+ const wallet = await openConnectModal({
59
+ client,
60
+ setActive: false,
61
+ size: "compact",
62
+ showThirdwebBranding: false,
63
+ wallets: recommendWallets,
64
+ });
51
65
  if (wallet) {
52
66
  // setActiveWallet(wallet);
53
67
  setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
@@ -21,7 +21,7 @@ import {
21
21
  TextLoop,
22
22
  TextShimmer,
23
23
  useAccountWallet,
24
- useB3,
24
+ useB3Config,
25
25
  useModalStore,
26
26
  useProfile,
27
27
  useUnifiedChainSwitchAndExecute,
@@ -222,7 +222,7 @@ export const OrderDetails = memo(function OrderDetails({
222
222
  const searchParams = useSearchParams();
223
223
 
224
224
  // Get theme from B3Provider context
225
- const { theme } = useB3();
225
+ const { theme } = useB3Config();
226
226
  const colorMode = theme || "light";
227
227
 
228
228
  // Read crypto payment method from URL parameters
@@ -905,6 +905,12 @@ export const OrderDetails = memo(function OrderDetails({
905
905
  )}
906
906
 
907
907
  {/* <DelayedSupportMessage /> */}
908
+ <button
909
+ className="text-b3-primary-blue hover:text-b3-primary-blue/50 order-details-cancel-btn flex w-full items-center justify-center gap-2 underline"
910
+ onClick={handleBack}
911
+ >
912
+ <RefreshCcw className="ml-2 h-4 w-4" /> Cancel and start over
913
+ </button>
908
914
  </>
909
915
  );
910
916
  }
@@ -1,9 +1,8 @@
1
- import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
2
1
  import { OrderDetailsCollapsible, useStripeClientSecret } from "@b3dotfun/sdk/anyspend/react";
3
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
- import { ShinyButton, useB3, useModalStore, useProfile } from "@b3dotfun/sdk/global-account/react";
3
+ import { ShinyButton, useB3Config, useModalStore, useProfile } from "@b3dotfun/sdk/global-account/react";
5
4
  import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
6
- import { formatStripeAmount } from "@b3dotfun/sdk/shared/utils/payment.utils";
5
+ import { formatStripeAmount, getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
7
6
  import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
8
7
  import { PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
9
8
  import { X } from "lucide-react";
@@ -19,7 +18,7 @@ interface PaymentStripeWeb2Props {
19
18
  }
20
19
 
21
20
  export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }: PaymentStripeWeb2Props) {
22
- const { theme, stripePublishableKey } = useB3();
21
+ const { theme, stripePublishableKey } = useB3Config();
23
22
  const fingerprintConfig = getFingerprintConfig();
24
23
 
25
24
  const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } =
@@ -3,7 +3,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
3
3
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
4
  import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
5
5
  import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
6
- import { useB3 } from "@b3dotfun/sdk/global-account/react";
6
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
7
7
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
8
8
  import { useMutation } from "@tanstack/react-query";
9
9
  import { useMemo } from "react";
@@ -36,7 +36,7 @@ export type UseAnyspendCreateOnrampOrderProps = {
36
36
  */
37
37
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
38
38
  // Get B3 context values
39
- const { partnerId } = useB3();
39
+ const { partnerId } = useB3Config();
40
40
 
41
41
  // Get validated client reference ID from B3 context
42
42
  const createValidatedClientReferenceId = useValidatedClientReferenceId();
@@ -2,7 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
3
3
  import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
4
4
  import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
5
- import { useB3 } from "@b3dotfun/sdk/global-account/react";
5
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
6
6
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
7
7
  import { useMutation } from "@tanstack/react-query";
8
8
  import { useMemo } from "react";
@@ -36,7 +36,7 @@ export type UseAnyspendCreateOrderProps = {
36
36
  */
37
37
  export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
38
38
  // Get B3 context values
39
- const { partnerId } = useB3();
39
+ const { partnerId } = useB3Config();
40
40
 
41
41
  // Get validated client reference ID from B3 context
42
42
  const createValidatedClientReferenceId = useValidatedClientReferenceId();
@@ -2,7 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
3
3
  import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
4
4
  import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
5
- import { useB3 } from "@b3dotfun/sdk/global-account/react";
5
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
6
6
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
7
7
  import { useMutation } from "@tanstack/react-query";
8
8
  import { useMemo } from "react";
@@ -29,7 +29,7 @@ export type UseCreateDepositFirstOrderProps = {
29
29
  * This order type doesn't require srcAmount - the user deposits tokens after the order is created.
30
30
  */
31
31
  export function useCreateDepositFirstOrder({ onSuccess, onError }: UseCreateDepositFirstOrderProps = {}) {
32
- const { partnerId } = useB3();
32
+ const { partnerId } = useB3Config();
33
33
 
34
34
  const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
35
35
  const visitorData: VisitorData | undefined = fpData && {
@@ -1,5 +1,5 @@
1
1
  import { Validators } from "@b3dotfun/sdk/anyspend/utils/validation";
2
- import { useB3 } from "@b3dotfun/sdk/global-account/react";
2
+ import { useB3Config } from "@b3dotfun/sdk/global-account/react";
3
3
  import { useCallback } from "react";
4
4
  import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
5
5
  import { CreateOrderParams } from "./useAnyspendCreateOrder";
@@ -9,7 +9,7 @@ import { CreateOrderParams } from "./useAnyspendCreateOrder";
9
9
  * Gets the createClientReferenceId function from B3 context and validates the result
10
10
  */
11
11
  export function useValidatedClientReferenceId() {
12
- const { createClientReferenceId } = useB3();
12
+ const { createClientReferenceId } = useB3Config();
13
13
 
14
14
  const createValidatedClientReferenceId = useCallback(
15
15
  async (params: CreateOrderParams | CreateOnrampOrderParams) => {
@@ -14,14 +14,13 @@ import { AnySpendDepositHype } from "@b3dotfun/sdk/anyspend/react/components/Any
14
14
  import { AnySpendDepositUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendDepositUpside";
15
15
  import { AnySpendStakeUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpside";
16
16
  import { AnySpendStakeUpsideExactIn } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpsideExactIn";
17
- import { useGlobalAccount, useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
17
+ import { useB3Config, useGlobalAccount, useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
18
18
  import { cn } from "@b3dotfun/sdk/shared/utils/cn";
19
19
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
20
20
  import { AnimatePresence, motion } from "framer-motion";
21
21
  import { useEffect, useRef } from "react";
22
22
  import { useSetActiveWallet } from "thirdweb/react";
23
23
  import { AvatarEditor } from "./AvatarEditor/AvatarEditor";
24
- import { useB3 } from "./B3Provider/useB3";
25
24
  import { Deposit } from "./Deposit/Deposit";
26
25
  import { LinkAccount } from "./LinkAccount/LinkAccount";
27
26
  import { LinkNewAccount } from "./LinkAccount/LinkNewAccount";
@@ -30,8 +29,8 @@ import NotificationsContent from "./ManageAccount/NotificationsContent";
30
29
  import { RequestPermissions } from "./RequestPermissions/RequestPermissions";
31
30
  import { Send } from "./Send/Send";
32
31
  import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
33
- import { TurnkeyAuthModal } from "./TurnkeyAuthModal";
34
32
  import { ToastContainer, useToastContext } from "./Toast/index";
33
+ import { TurnkeyAuthModal } from "./TurnkeyAuthModal";
35
34
  import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./ui/dialog";
36
35
  import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from "./ui/drawer";
37
36
 
@@ -42,7 +41,7 @@ export function B3DynamicModal() {
42
41
  const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
43
42
  const contentType = useModalStore(state => state.contentType);
44
43
  const navigateBack = useModalStore(state => state.navigateBack);
45
- const { theme } = useB3();
44
+ const { theme } = useB3Config();
46
45
  const isMobile = useIsMobile();
47
46
  const prevIsOpenRef = useRef(isOpen);
48
47
  const { wallet } = useGlobalAccount();
@@ -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
  };