@b3dotfun/sdk 0.0.88-alpha.10 → 0.0.88-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/index.d.ts +0 -2
- package/dist/cjs/anyspend/constants/index.js +1 -3
- package/dist/cjs/anyspend/index.d.ts +0 -2
- package/dist/cjs/anyspend/index.js +0 -3
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/AnySpend.js +6 -9
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -3
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +20 -24
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -14
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +2 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +0 -4
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -34
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -3
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -3
- package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/index.js +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +57 -35
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +35 -38
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +24 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +4 -14
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +11 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
- package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
- package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +9 -8
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -76
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
- package/dist/cjs/global-account/react/components/TurnkeyAuthModal.js +1 -3
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -1
- package/dist/cjs/global-account/react/components/index.js +6 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
- package/dist/cjs/global-account/react/hooks/index.js +1 -5
- package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
- package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +2 -4
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +22 -50
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +35 -9
- package/dist/cjs/global-account/react/index.native.d.ts +2 -0
- package/dist/cjs/global-account/react/index.native.js +5 -1
- package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
- package/dist/cjs/global-account/react/stores/index.js +1 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -10
- package/dist/esm/anyspend/constants/index.d.ts +0 -2
- package/dist/esm/anyspend/constants/index.js +0 -2
- package/dist/esm/anyspend/index.d.ts +0 -2
- package/dist/esm/anyspend/index.js +0 -3
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/esm/anyspend/react/components/AnySpend.js +8 -11
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +4 -8
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -14
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +0 -4
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -36
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -3
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +4 -3
- package/dist/esm/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/index.js +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +58 -34
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +21 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +4 -14
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +11 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
- package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -76
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
- package/dist/esm/global-account/react/components/TurnkeyAuthModal.js +3 -5
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -1
- package/dist/esm/global-account/react/components/index.js +2 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
- package/dist/esm/global-account/react/hooks/index.js +0 -2
- package/dist/esm/global-account/react/hooks/useClient.js +2 -2
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
- package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +2 -4
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +22 -50
- package/dist/esm/global-account/react/hooks/useUserQuery.js +27 -1
- package/dist/esm/global-account/react/index.native.d.ts +2 -0
- package/dist/esm/global-account/react/index.native.js +2 -0
- package/dist/esm/global-account/react/stores/index.d.ts +0 -1
- package/dist/esm/global-account/react/stores/index.js +0 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -10
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -2
- package/dist/types/anyspend/index.d.ts +0 -2
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -6
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +1 -5
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -6
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +1 -7
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +0 -4
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +1 -3
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +0 -4
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +1 -3
- package/dist/types/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +4 -14
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/types/global-account/react/components/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/index.d.ts +0 -2
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/types/global-account/react/index.native.d.ts +2 -0
- package/dist/types/global-account/react/stores/index.d.ts +0 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -10
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +0 -3
- package/src/anyspend/index.ts +0 -4
- package/src/anyspend/react/components/AnySpend.tsx +2 -28
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +0 -6
- package/src/anyspend/react/components/AnySpendCustom.tsx +47 -52
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +0 -23
- package/src/anyspend/react/components/AnySpendDeposit.tsx +1 -18
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +0 -4
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -15
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +1 -5
- package/src/anyspend/react/components/common/OrderDetails.tsx +42 -60
- package/src/anyspend/react/components/common/PanelOnramp.tsx +1 -5
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +4 -3
- package/src/anyspend/react/hooks/index.ts +0 -1
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +4 -3
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +54 -43
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +117 -44
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +1 -4
- package/src/global-account/react/components/B3Provider/types.ts +50 -0
- package/src/global-account/react/components/B3Provider/useB3.ts +13 -4
- package/src/global-account/react/components/B3Provider/useB3Account.ts +2 -6
- package/src/global-account/react/components/B3Provider/useB3Config.ts +31 -18
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +4 -2
- package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
- package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +100 -168
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/StyleRoot.tsx +3 -3
- package/src/global-account/react/components/TurnkeyAuthModal.tsx +4 -7
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/components/index.ts +2 -1
- package/src/global-account/react/hooks/index.ts +0 -2
- package/src/global-account/react/hooks/useClient.ts +2 -2
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
- package/src/global-account/react/hooks/useNotifications.ts +2 -2
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
- package/src/global-account/react/hooks/useTokenBalance.tsx +7 -8
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +2 -4
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +23 -54
- package/src/global-account/react/hooks/useUserQuery.ts +40 -1
- package/src/global-account/react/index.native.ts +2 -0
- package/src/global-account/react/stores/index.ts +0 -1
- package/src/global-account/react/stores/useModalStore.ts +0 -10
- package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +0 -34
- package/dist/cjs/anyspend/react/hooks/useGasPrice.d.ts +0 -37
- package/dist/cjs/anyspend/react/hooks/useGasPrice.js +0 -43
- package/dist/cjs/anyspend/services/gas.d.ts +0 -21
- package/dist/cjs/anyspend/services/gas.js +0 -65
- package/dist/cjs/anyspend/types/gas.d.ts +0 -61
- package/dist/cjs/anyspend/types/gas.js +0 -2
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -12
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/cjs/global-account/react/hooks/useAuth.js +0 -337
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/cjs/global-account/react/hooks/useUser.js +0 -20
- package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/cjs/global-account/react/stores/configStore.js +0 -30
- package/dist/cjs/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/cjs/global-account/react/stores/userStore.js +0 -30
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +0 -6
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +0 -31
- package/dist/esm/anyspend/react/hooks/useGasPrice.d.ts +0 -37
- package/dist/esm/anyspend/react/hooks/useGasPrice.js +0 -40
- package/dist/esm/anyspend/services/gas.d.ts +0 -21
- package/dist/esm/anyspend/services/gas.js +0 -59
- package/dist/esm/anyspend/types/gas.d.ts +0 -61
- package/dist/esm/anyspend/types/gas.js +0 -1
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -10
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/esm/global-account/react/hooks/useAuth.js +0 -331
- package/dist/esm/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/esm/global-account/react/hooks/useUser.js +0 -17
- package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/esm/global-account/react/stores/configStore.js +0 -27
- package/dist/esm/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/esm/global-account/react/stores/userStore.js +0 -27
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +0 -6
- package/dist/types/anyspend/react/hooks/useGasPrice.d.ts +0 -37
- package/dist/types/anyspend/services/gas.d.ts +0 -21
- package/dist/types/anyspend/types/gas.d.ts +0 -61
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/types/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/types/global-account/react/stores/userStore.d.ts +0 -22
- package/src/anyspend/react/components/common/GasIndicator.tsx +0 -59
- package/src/anyspend/react/hooks/useGasPrice.ts +0 -70
- package/src/anyspend/services/gas.test.ts +0 -31
- package/src/anyspend/services/gas.ts +0 -73
- package/src/anyspend/types/gas.ts +0 -66
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +0 -19
- package/src/global-account/react/hooks/useAuth.ts +0 -379
- package/src/global-account/react/hooks/useUser.ts +0 -20
- package/src/global-account/react/stores/configStore.ts +0 -51
- package/src/global-account/react/stores/userStore.ts +0 -41
|
@@ -1,19 +0,0 @@
|
|
|
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,379 +0,0 @@
|
|
|
1
|
-
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
-
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
3
|
-
import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
5
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
|
-
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
|
-
import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
8
|
-
import { getConnectors } from "@wagmi/core";
|
|
9
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
10
|
-
import {
|
|
11
|
-
useActiveWallet,
|
|
12
|
-
useAutoConnect,
|
|
13
|
-
useConnectedWallets,
|
|
14
|
-
useDisconnect,
|
|
15
|
-
useSetActiveWallet,
|
|
16
|
-
} from "thirdweb/react";
|
|
17
|
-
import { Wallet, ecosystemWallet } from "thirdweb/wallets";
|
|
18
|
-
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
19
|
-
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
20
|
-
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider";
|
|
21
|
-
import { createWagmiConfig } from "../utils/createWagmiConfig";
|
|
22
|
-
import { useSearchParam } from "./useSearchParamsSSR";
|
|
23
|
-
import { useUserQuery } from "./useUserQuery";
|
|
24
|
-
|
|
25
|
-
const debug = debugB3React("useAuth");
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Unified authentication hook that uses Turnkey for authentication
|
|
29
|
-
* This replaces the previous Thirdweb-based authentication
|
|
30
|
-
*
|
|
31
|
-
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
32
|
-
*/
|
|
33
|
-
export function useAuth() {
|
|
34
|
-
const { onConnectCallback } = useContext(LocalSDKContext);
|
|
35
|
-
const { disconnect } = useDisconnect();
|
|
36
|
-
const wallets = useConnectedWallets();
|
|
37
|
-
const activeWallet = useActiveWallet();
|
|
38
|
-
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
39
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
40
|
-
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
41
|
-
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
42
|
-
const isConnected = useAuthStore(state => state.isConnected);
|
|
43
|
-
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
44
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
45
|
-
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
46
|
-
const setActiveWallet = useSetActiveWallet();
|
|
47
|
-
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
48
|
-
const useAutoConnectLoadingPrevious = useRef(false);
|
|
49
|
-
const referralCode = useSearchParam("referralCode");
|
|
50
|
-
const { partnerId } = useB3Config();
|
|
51
|
-
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
52
|
-
const { connect } = useConnect();
|
|
53
|
-
const activeWagmiAccount = useAccount();
|
|
54
|
-
const { switchAccount } = useSwitchAccount();
|
|
55
|
-
const { user, setUser } = useUserQuery();
|
|
56
|
-
debug("@@activeWagmiAccount", activeWagmiAccount);
|
|
57
|
-
|
|
58
|
-
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
59
|
-
partnerId: partnerId,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Re-authenticate using existing session
|
|
64
|
-
* Also updates user state and authenticates with BSMNT
|
|
65
|
-
*/
|
|
66
|
-
const reAuthenticate = useCallback(async () => {
|
|
67
|
-
debug("Re-authenticating...");
|
|
68
|
-
try {
|
|
69
|
-
const response = await app.reAuthenticate();
|
|
70
|
-
debug("Re-authentication successful", response);
|
|
71
|
-
|
|
72
|
-
// Update user state if user data exists
|
|
73
|
-
if (response.user) {
|
|
74
|
-
setUser(response.user);
|
|
75
|
-
debug("User state updated", response.user);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Authenticate with BSMNT
|
|
79
|
-
try {
|
|
80
|
-
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
81
|
-
debug("BSMNT re-authentication successful", b3Jwt);
|
|
82
|
-
} catch (bsmntError) {
|
|
83
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
84
|
-
debug("BSMNT re-authentication failed (non-critical)", bsmntError);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return response;
|
|
88
|
-
} catch (err: any) {
|
|
89
|
-
debug("Re-authentication failed", err);
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
}, [setUser]);
|
|
93
|
-
|
|
94
|
-
const syncWagmi = useCallback(async () => {
|
|
95
|
-
function syncWagmiFunc() {
|
|
96
|
-
const connectors = getConnectors(wagmiConfig);
|
|
97
|
-
debug("@@syncWagmi", {
|
|
98
|
-
connectors,
|
|
99
|
-
wallets,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// For each that matchs a TW wallet on wallets, connect to the wagmi connector
|
|
103
|
-
// or, since ecosystem wallets is separate, connect those via in-app-wallet from wagmi
|
|
104
|
-
connectors.forEach(async connector => {
|
|
105
|
-
const twWallet = wallets.find(wallet => wallet.id === connector.id || connector.id === "in-app-wallet");
|
|
106
|
-
|
|
107
|
-
// If no TW wallet, do not prompt the user to connect
|
|
108
|
-
if (!twWallet) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Metamask will prompt to connect, we can just switch accounts here.
|
|
113
|
-
if (connector.id === "io.metamask") {
|
|
114
|
-
return switchAccount({ connector });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
// If it's not an in-app wallet or it is the ecosystem wallet, connect
|
|
119
|
-
connector.id !== "in-app-wallet" ||
|
|
120
|
-
(connector.id === "in-app-wallet" && twWallet.id === ecosystemWalletId)
|
|
121
|
-
) {
|
|
122
|
-
try {
|
|
123
|
-
const options = {
|
|
124
|
-
wallet: twWallet, // the connected wallet
|
|
125
|
-
} satisfies ConnectionOptions;
|
|
126
|
-
debug("@@syncWagmi:connecting", { twWallet, connector });
|
|
127
|
-
connect({
|
|
128
|
-
connector,
|
|
129
|
-
...options,
|
|
130
|
-
});
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("@@syncWagmi:error", error);
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
debug("@@syncWagmi:not-connecting", connector);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
syncWagmiFunc();
|
|
140
|
-
// wagmi config shouldn't change
|
|
141
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
-
}, [partnerId, wallets]);
|
|
143
|
-
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
syncWagmi();
|
|
146
|
-
}, [wallets, syncWagmi]);
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Authenticate user using Turnkey
|
|
150
|
-
* Note: This no longer requires a wallet for authentication.
|
|
151
|
-
* Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
|
|
152
|
-
*
|
|
153
|
-
* For backward compatibility, this function still accepts a wallet parameter,
|
|
154
|
-
* but it's not used for authentication anymore.
|
|
155
|
-
*/
|
|
156
|
-
const authenticateUser = useCallback(async () => {
|
|
157
|
-
setHasStartedConnecting(true);
|
|
158
|
-
|
|
159
|
-
// Try to re-authenticate first
|
|
160
|
-
try {
|
|
161
|
-
const userAuth = await reAuthenticate();
|
|
162
|
-
setUser(userAuth.user);
|
|
163
|
-
setIsAuthenticated(true);
|
|
164
|
-
setIsAuthenticating(false);
|
|
165
|
-
debug("Re-authenticated successfully", { userAuth });
|
|
166
|
-
|
|
167
|
-
// Authenticate on BSMNT with B3 JWT
|
|
168
|
-
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
169
|
-
debug("@@b3Jwt", b3Jwt);
|
|
170
|
-
|
|
171
|
-
return userAuth;
|
|
172
|
-
} catch (error) {
|
|
173
|
-
// If re-authentication fails, user needs to authenticate via Turnkey
|
|
174
|
-
// This should be handled by the Turnkey auth modal/flow
|
|
175
|
-
debug("Re-authentication failed. User needs to authenticate via Turnkey.", error);
|
|
176
|
-
setIsAuthenticated(false);
|
|
177
|
-
setIsAuthenticating(false);
|
|
178
|
-
throw new Error("Authentication required. Please authenticate via Turnkey.");
|
|
179
|
-
}
|
|
180
|
-
}, [reAuthenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Authenticate with Turnkey using email OTP
|
|
184
|
-
* This is the primary authentication method, replacing Thirdweb wallet-based auth
|
|
185
|
-
*
|
|
186
|
-
* This function:
|
|
187
|
-
* 1. Authenticates with FeathersJS (persists session via cookies)
|
|
188
|
-
* 2. Sets user state in the user store (persists to localStorage)
|
|
189
|
-
* 3. Authenticates with BSMNT for basement integration
|
|
190
|
-
*/
|
|
191
|
-
const authenticate = useCallback(
|
|
192
|
-
async (turnkeySessionJwt: string, partnerId: string) => {
|
|
193
|
-
if (!turnkeySessionJwt) {
|
|
194
|
-
throw new Error("Turnkey session JWT is required");
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
debug("Authenticating with Turnkey JWT", { referralCode, partnerId });
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
// Step 1: Authenticate with FeathersJS (session persisted via cookies)
|
|
201
|
-
const response = await app.authenticate({
|
|
202
|
-
strategy: "turnkey-jwt",
|
|
203
|
-
accessToken: turnkeySessionJwt,
|
|
204
|
-
referralCode,
|
|
205
|
-
partnerId: partnerId,
|
|
206
|
-
} as any);
|
|
207
|
-
|
|
208
|
-
debug("Authentication successful", response);
|
|
209
|
-
|
|
210
|
-
// Step 2: Set user state (persists to localStorage via Zustand)
|
|
211
|
-
if (response.user) {
|
|
212
|
-
setUser(response.user);
|
|
213
|
-
debug("User state updated", response.user);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Step 3: Authenticate with BSMNT for basement integration
|
|
217
|
-
try {
|
|
218
|
-
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
219
|
-
debug("BSMNT authentication successful", b3Jwt);
|
|
220
|
-
} catch (bsmntError) {
|
|
221
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
222
|
-
debug("BSMNT authentication failed (non-critical)", bsmntError);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return response;
|
|
226
|
-
} catch (err: any) {
|
|
227
|
-
debug("Authentication failed", err);
|
|
228
|
-
throw err;
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
[referralCode, setUser],
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Handle wallet connection
|
|
236
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
237
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
238
|
-
*/
|
|
239
|
-
/**
|
|
240
|
-
* Handle wallet connection
|
|
241
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
242
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
243
|
-
*/
|
|
244
|
-
const onConnect = useCallback(
|
|
245
|
-
async (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => {
|
|
246
|
-
debug("@@useAuth:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
247
|
-
|
|
248
|
-
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
249
|
-
|
|
250
|
-
if (!wallet) {
|
|
251
|
-
throw new Error("No smart wallet found during auto-connect");
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
debug("@@useAuth:onConnect", { wallet });
|
|
255
|
-
|
|
256
|
-
try {
|
|
257
|
-
setHasStartedConnecting(true);
|
|
258
|
-
setIsConnected(true);
|
|
259
|
-
setIsAuthenticating(true);
|
|
260
|
-
await setActiveWallet(wallet);
|
|
261
|
-
|
|
262
|
-
// Try to authenticate user (will use re-authenticate if session exists)
|
|
263
|
-
// If no session exists, authentication will need to happen via Turnkey flow
|
|
264
|
-
try {
|
|
265
|
-
const userAuth = await authenticateUser();
|
|
266
|
-
|
|
267
|
-
if (userAuth && onConnectCallback) {
|
|
268
|
-
await onConnectCallback(wallet, userAuth.accessToken);
|
|
269
|
-
}
|
|
270
|
-
} catch (authError) {
|
|
271
|
-
// Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
|
|
272
|
-
// The Turnkey auth modal should handle this
|
|
273
|
-
debug("@@useAuth:onConnect:authFailed", { authError });
|
|
274
|
-
// Don't set isAuthenticated to false here - let the Turnkey flow handle it
|
|
275
|
-
}
|
|
276
|
-
} catch (error) {
|
|
277
|
-
debug("@@useAuth:onConnect:failed", { error });
|
|
278
|
-
setIsAuthenticated(false);
|
|
279
|
-
setUser(undefined);
|
|
280
|
-
} finally {
|
|
281
|
-
setIsAuthenticating(false);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
debug({
|
|
285
|
-
isAuthenticated,
|
|
286
|
-
isAuthenticating,
|
|
287
|
-
isConnected,
|
|
288
|
-
});
|
|
289
|
-
},
|
|
290
|
-
[
|
|
291
|
-
onConnectCallback,
|
|
292
|
-
authenticateUser,
|
|
293
|
-
isAuthenticated,
|
|
294
|
-
isAuthenticating,
|
|
295
|
-
isConnected,
|
|
296
|
-
setActiveWallet,
|
|
297
|
-
setHasStartedConnecting,
|
|
298
|
-
setIsAuthenticated,
|
|
299
|
-
setIsAuthenticating,
|
|
300
|
-
setIsConnected,
|
|
301
|
-
setUser,
|
|
302
|
-
],
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
const logout = useCallback(
|
|
306
|
-
async (callback?: () => void) => {
|
|
307
|
-
if (activeWallet) {
|
|
308
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
309
|
-
disconnect(activeWallet);
|
|
310
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Log out of each wallet
|
|
314
|
-
wallets.forEach(wallet => {
|
|
315
|
-
console.log("@@logging out", wallet);
|
|
316
|
-
disconnect(wallet);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// Delete localStorage thirdweb:connected-wallet-ids
|
|
320
|
-
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
321
|
-
if (typeof localStorage !== "undefined") {
|
|
322
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
323
|
-
localStorage.removeItem("wagmi.store");
|
|
324
|
-
localStorage.removeItem("lastAuthProvider");
|
|
325
|
-
localStorage.removeItem("b3-user");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
app.logout();
|
|
329
|
-
debug("@@logout:loggedOut");
|
|
330
|
-
|
|
331
|
-
setIsAuthenticated(false);
|
|
332
|
-
setIsConnected(false);
|
|
333
|
-
setUser();
|
|
334
|
-
callback?.();
|
|
335
|
-
},
|
|
336
|
-
[activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected],
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
const { isLoading: useAutoConnectLoading } = useAutoConnect({
|
|
340
|
-
client,
|
|
341
|
-
wallets: [wallet],
|
|
342
|
-
onConnect,
|
|
343
|
-
onTimeout: () => {
|
|
344
|
-
logout().catch(error => {
|
|
345
|
-
debug("@@useAuth:logout on timeout failed", { error });
|
|
346
|
-
});
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* useAutoConnectLoading starts as false
|
|
352
|
-
*/
|
|
353
|
-
useEffect(() => {
|
|
354
|
-
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
355
|
-
setIsAuthenticating(false);
|
|
356
|
-
}
|
|
357
|
-
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
358
|
-
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
359
|
-
|
|
360
|
-
const isReady = isAuthenticated && !isAuthenticating;
|
|
361
|
-
|
|
362
|
-
return {
|
|
363
|
-
authenticate,
|
|
364
|
-
reAuthenticate,
|
|
365
|
-
logout,
|
|
366
|
-
isAuthenticated,
|
|
367
|
-
isReady,
|
|
368
|
-
isConnecting,
|
|
369
|
-
isConnected,
|
|
370
|
-
wallet,
|
|
371
|
-
preAuthenticate,
|
|
372
|
-
connect: onConnect,
|
|
373
|
-
isAuthenticating,
|
|
374
|
-
onConnect,
|
|
375
|
-
user,
|
|
376
|
-
refetchUser: authenticateUser,
|
|
377
|
-
setUser,
|
|
378
|
-
};
|
|
379
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
-
import { useUserStore } from "../stores/userStore";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Preferred Hook to get the user data
|
|
6
|
-
*/
|
|
7
|
-
export function useUser() {
|
|
8
|
-
const user = useUserStore(state => state.user);
|
|
9
|
-
|
|
10
|
-
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
11
|
-
const isConnected = useAuthStore(state => state.isConnected);
|
|
12
|
-
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
user,
|
|
16
|
-
isConnecting,
|
|
17
|
-
isConnected,
|
|
18
|
-
isAuthenticating,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
4
|
-
import { Account } from "thirdweb/wallets";
|
|
5
|
-
import { create } from "zustand";
|
|
6
|
-
import { ClientType } from "../../client-manager";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Default permissions configuration for B3 provider
|
|
10
|
-
*/
|
|
11
|
-
const DEFAULT_PERMISSIONS: PermissionsConfig = {
|
|
12
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
13
|
-
nativeTokenLimitPerTransaction: 0.1,
|
|
14
|
-
startDate: new Date(),
|
|
15
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
interface ConfigStore {
|
|
19
|
-
accountOverride?: Account;
|
|
20
|
-
automaticallySetFirstEoa: boolean;
|
|
21
|
-
environment: "development" | "production";
|
|
22
|
-
defaultPermissions: PermissionsConfig;
|
|
23
|
-
theme: "light" | "dark";
|
|
24
|
-
clientType: ClientType;
|
|
25
|
-
partnerId: string;
|
|
26
|
-
stripePublishableKey?: string;
|
|
27
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
28
|
-
enableTurnkey: boolean;
|
|
29
|
-
|
|
30
|
-
// Actions
|
|
31
|
-
setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Zustand store for B3 configuration
|
|
36
|
-
* NOT persisted - these are developer-set configuration values
|
|
37
|
-
*/
|
|
38
|
-
export const useB3ConfigStore = create<ConfigStore>(set => ({
|
|
39
|
-
accountOverride: undefined,
|
|
40
|
-
automaticallySetFirstEoa: false,
|
|
41
|
-
environment: "development",
|
|
42
|
-
defaultPermissions: DEFAULT_PERMISSIONS,
|
|
43
|
-
theme: "light",
|
|
44
|
-
clientType: "rest",
|
|
45
|
-
partnerId: "",
|
|
46
|
-
stripePublishableKey: undefined,
|
|
47
|
-
createClientReferenceId: undefined,
|
|
48
|
-
enableTurnkey: false,
|
|
49
|
-
|
|
50
|
-
setConfig: config => set(state => ({ ...state, ...config })),
|
|
51
|
-
}));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
-
import { create } from "zustand";
|
|
4
|
-
import { persist } from "zustand/middleware";
|
|
5
|
-
|
|
6
|
-
const debug = debugB3React("useUserQuery");
|
|
7
|
-
|
|
8
|
-
interface UserStore {
|
|
9
|
-
user: Users | null;
|
|
10
|
-
setUser: (user: Users | undefined) => void;
|
|
11
|
-
clearUser: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Zustand store for managing user state
|
|
16
|
-
* Persists user data to localStorage
|
|
17
|
-
*/
|
|
18
|
-
export const useUserStore = create<UserStore>()(
|
|
19
|
-
persist(
|
|
20
|
-
set => ({
|
|
21
|
-
user: null,
|
|
22
|
-
setUser: (newUser: Users | undefined) => {
|
|
23
|
-
const userToSave = newUser ?? null;
|
|
24
|
-
set({ user: userToSave });
|
|
25
|
-
debug("User updated", userToSave);
|
|
26
|
-
},
|
|
27
|
-
clearUser: () => {
|
|
28
|
-
set({ user: null });
|
|
29
|
-
debug("User cleared");
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
{
|
|
33
|
-
name: "b3-user",
|
|
34
|
-
onRehydrateStorage: () => (_, error) => {
|
|
35
|
-
if (error) {
|
|
36
|
-
console.warn("Failed to rehydrate user store:", error);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
),
|
|
41
|
-
);
|