@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,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isNativeToken } from "../../../anyspend/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useB3, useAccountWallet } from "../../../global-account/react/index.js";
|
|
4
4
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
5
5
|
import { getERC20Balances, getNativeTokenBalance } from "../../../shared/utils/thirdweb-insights.js";
|
|
6
6
|
import { useQuery } from "@tanstack/react-query";
|
|
7
7
|
import { useEffect } from "react";
|
|
8
8
|
export function useTokenBalance({ token, address }) {
|
|
9
|
-
const
|
|
9
|
+
const { ready } = useB3();
|
|
10
10
|
const account = useAccountWallet();
|
|
11
11
|
const effectiveAddress = address || account?.address;
|
|
12
12
|
const { data: tokenBalance, isLoading, isFetching, refetch, } = useQuery({
|
|
@@ -38,7 +38,7 @@ export function useTokenBalance({ token, address }) {
|
|
|
38
38
|
}
|
|
39
39
|
return { formatted: "0", raw: null };
|
|
40
40
|
},
|
|
41
|
-
enabled:
|
|
41
|
+
enabled: ready && !!effectiveAddress,
|
|
42
42
|
staleTime: 30000,
|
|
43
43
|
gcTime: 5 * 60 * 1000,
|
|
44
44
|
retry: 2,
|
|
@@ -46,12 +46,12 @@ export function useTokenBalance({ token, address }) {
|
|
|
46
46
|
});
|
|
47
47
|
// Force a refetch when the wallet or token changes
|
|
48
48
|
useEffect(() => {
|
|
49
|
-
if (
|
|
49
|
+
if (ready && effectiveAddress) {
|
|
50
50
|
refetch();
|
|
51
51
|
}
|
|
52
|
-
}, [
|
|
52
|
+
}, [ready, effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
|
|
53
53
|
// Determine if we're actually loading
|
|
54
|
-
const isActuallyLoading = !
|
|
54
|
+
const isActuallyLoading = !ready || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
|
|
55
55
|
return {
|
|
56
56
|
rawBalance: tokenBalance?.raw || BigInt(0),
|
|
57
57
|
formattedBalance: tokenBalance?.formatted || "0",
|
|
@@ -4,8 +4,8 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
4
4
|
import { viemToThirdwebChain } from "../../../shared/constants/chains/b3Chain.js";
|
|
5
5
|
import { getChainById } from "../../../shared/utils/chains.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
|
-
import invariant from "invariant";
|
|
8
7
|
import { getWalletBalance } from "thirdweb/wallets";
|
|
8
|
+
import invariant from "invariant";
|
|
9
9
|
export function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
10
10
|
// Normalize chains to array
|
|
11
11
|
const chainIds = Array.isArray(chainsIds) ? chainsIds : [chainsIds];
|
|
@@ -46,9 +46,7 @@ export function useTokenBalancesByChain({ address, chainsIds, enabled = true, })
|
|
|
46
46
|
staleTime: 30000, // Consider data fresh for 30 seconds
|
|
47
47
|
gcTime: 5 * 60 * 1000, // Keep in cache for 5 minutes
|
|
48
48
|
retry: 2, // Limit retries on failure
|
|
49
|
-
|
|
50
|
-
// This ensures we only get new references when data actually changes
|
|
51
|
-
structuralSharing: true,
|
|
49
|
+
structuralSharing: false,
|
|
52
50
|
});
|
|
53
51
|
return {
|
|
54
52
|
nativeTokens: combinedData?.nativeTokens ?? [],
|
|
@@ -3,7 +3,7 @@ import { useCallback, useState } from "react";
|
|
|
3
3
|
import app from "../../app.js";
|
|
4
4
|
import { useB3Config } from "../components/index.js";
|
|
5
5
|
import { useAuthStore } from "../stores/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useAuthentication } from "./useAuthentication.js";
|
|
7
7
|
const debug = debugB3React("useTurnkeyAuth");
|
|
8
8
|
/**
|
|
9
9
|
* Hook for Turnkey email-based OTP authentication
|
|
@@ -19,54 +19,29 @@ export function useTurnkeyAuth() {
|
|
|
19
19
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
20
20
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
21
21
|
const { partnerId } = useB3Config();
|
|
22
|
-
const {
|
|
22
|
+
const { user } = useAuthentication(partnerId);
|
|
23
23
|
/**
|
|
24
24
|
* Step 1: Initiate login with email
|
|
25
|
-
* - Calls backend
|
|
25
|
+
* - Calls backend to create sub-org (if needed) and send OTP
|
|
26
26
|
* - Returns otpId to use in verification step
|
|
27
|
-
*
|
|
28
|
-
* Note: Uses the turnkey-jwt authentication strategy, not the service directly.
|
|
29
|
-
* The turnkey-jwt strategy handles both OTP flow (init/verify) and final authentication.
|
|
30
27
|
*/
|
|
31
28
|
const initiateLogin = useCallback(async (email) => {
|
|
32
29
|
setIsLoading(true);
|
|
33
30
|
setError(null);
|
|
34
31
|
setIsAuthenticating(true);
|
|
35
32
|
try {
|
|
33
|
+
if (!user?.userId) {
|
|
34
|
+
throw new Error("User ID is required to initiate Turnkey login.");
|
|
35
|
+
}
|
|
36
36
|
debug(`Initiating login for: ${email}`);
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
// Backend will get userId from _params.user?.userId if authenticated, or handle unauthenticated case
|
|
40
|
-
// So we only need to send email
|
|
41
|
-
debug(`Calling app.authenticate with turnkey-jwt strategy (init action)`, { email });
|
|
42
|
-
const response = await app.authenticate({
|
|
43
|
-
strategy: "turnkey-jwt",
|
|
44
|
-
action: "init",
|
|
45
|
-
email,
|
|
46
|
-
});
|
|
47
|
-
// The strategy returns the TurnkeyAuthInitResponse directly
|
|
48
|
-
const data = response;
|
|
37
|
+
// Call FeathersJS service to initialize OTP
|
|
38
|
+
const data = await app.service("turnkey-auth").init({ email, userId: user.userId });
|
|
49
39
|
debug(`OTP initialized successfully. OtpId: ${data.otpId}`);
|
|
50
40
|
return data;
|
|
51
41
|
}
|
|
52
42
|
catch (err) {
|
|
53
43
|
debug("Error initiating login:", err);
|
|
54
|
-
|
|
55
|
-
let errorMessage = "Failed to send OTP email. Please try again.";
|
|
56
|
-
if (err.message) {
|
|
57
|
-
errorMessage = err.message;
|
|
58
|
-
}
|
|
59
|
-
else if (err.name === "TypeError" && err.message?.includes("fetch")) {
|
|
60
|
-
errorMessage = "Network error: Unable to reach the server. Please check your connection and try again.";
|
|
61
|
-
}
|
|
62
|
-
else if (err.code === "ECONNREFUSED" || err.code === "ENOTFOUND") {
|
|
63
|
-
errorMessage = "Connection error: Unable to reach the server. Please check your internet connection.";
|
|
64
|
-
}
|
|
65
|
-
else if (err.response) {
|
|
66
|
-
// FeathersJS error response
|
|
67
|
-
errorMessage = err.response.message || err.message || errorMessage;
|
|
68
|
-
debug("FeathersJS error response:", err.response);
|
|
69
|
-
}
|
|
44
|
+
const errorMessage = err.message || "Failed to send OTP email. Please try again.";
|
|
70
45
|
setError(errorMessage);
|
|
71
46
|
throw err;
|
|
72
47
|
}
|
|
@@ -74,11 +49,11 @@ export function useTurnkeyAuth() {
|
|
|
74
49
|
setIsLoading(false);
|
|
75
50
|
setIsAuthenticating(false);
|
|
76
51
|
}
|
|
77
|
-
}, [setIsAuthenticating]);
|
|
52
|
+
}, [user, setIsAuthenticating]);
|
|
78
53
|
/**
|
|
79
54
|
* Step 2: Verify OTP and authenticate
|
|
80
|
-
* - Verifies OTP with backend
|
|
81
|
-
* - Gets Turnkey session JWT
|
|
55
|
+
* - Verifies OTP with backend
|
|
56
|
+
* - Gets Turnkey session JWT
|
|
82
57
|
* - Authenticates with b3-api using "turnkey-jwt" strategy
|
|
83
58
|
* - JWT automatically stored in cookies by SDK
|
|
84
59
|
*/
|
|
@@ -87,22 +62,19 @@ export function useTurnkeyAuth() {
|
|
|
87
62
|
setError(null);
|
|
88
63
|
setIsAuthenticating(true);
|
|
89
64
|
try {
|
|
90
|
-
debug(`Verifying OTP...`, {
|
|
91
|
-
// Step 1: Verify OTP
|
|
92
|
-
|
|
93
|
-
const response = await app.authenticate({
|
|
94
|
-
strategy: "turnkey-jwt",
|
|
95
|
-
action: "verify",
|
|
65
|
+
debug(`Verifying OTP...`, { userId: user?.userId });
|
|
66
|
+
// Step 1: Verify OTP and get Turnkey session JWT
|
|
67
|
+
const { turnkeySessionJwt } = await app.service("turnkey-auth").verify({
|
|
96
68
|
otpId,
|
|
97
69
|
otpCode,
|
|
98
70
|
});
|
|
99
|
-
|
|
100
|
-
const verifyResult = response;
|
|
101
|
-
const { turnkeySessionJwt } = verifyResult;
|
|
102
|
-
debug(`OTP verified! Got Turnkey session JWT. Authenticating with b3-api...`);
|
|
71
|
+
debug(`OTP verified! Authenticating with b3-api...`);
|
|
103
72
|
// Step 2: Authenticate with b3-api using Turnkey JWT
|
|
104
|
-
//
|
|
105
|
-
const authResult = await authenticate(
|
|
73
|
+
// The SDK will automatically store the b3-api JWT in cookies
|
|
74
|
+
const authResult = await app.authenticate({
|
|
75
|
+
strategy: "turnkey-jwt",
|
|
76
|
+
accessToken: turnkeySessionJwt,
|
|
77
|
+
});
|
|
106
78
|
debug(`Successfully authenticated with b3-api!`, authResult);
|
|
107
79
|
// Update auth store to reflect authenticated state
|
|
108
80
|
setIsAuthenticated(true);
|
|
@@ -122,7 +94,7 @@ export function useTurnkeyAuth() {
|
|
|
122
94
|
setIsLoading(false);
|
|
123
95
|
setIsAuthenticating(false);
|
|
124
96
|
}
|
|
125
|
-
}, [
|
|
97
|
+
}, [user, setIsAuthenticating, setIsAuthenticated]);
|
|
126
98
|
const clearError = useCallback(() => {
|
|
127
99
|
setError(null);
|
|
128
100
|
}, []);
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
1
2
|
import { useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
import { persist } from "zustand/middleware";
|
|
5
|
+
const debug = debugB3React("useUserQuery");
|
|
3
6
|
const USER_QUERY_KEY = ["b3-user"];
|
|
7
|
+
/**
|
|
8
|
+
* Zustand store for managing user state
|
|
9
|
+
* Persists user data to localStorage
|
|
10
|
+
*/
|
|
11
|
+
const useUserStore = create()(persist(set => ({
|
|
12
|
+
user: null,
|
|
13
|
+
setUser: (newUser) => {
|
|
14
|
+
const userToSave = newUser ?? null;
|
|
15
|
+
set({ user: userToSave });
|
|
16
|
+
debug("User updated", userToSave);
|
|
17
|
+
},
|
|
18
|
+
clearUser: () => {
|
|
19
|
+
set({ user: null });
|
|
20
|
+
debug("User cleared");
|
|
21
|
+
},
|
|
22
|
+
}), {
|
|
23
|
+
name: "b3-user",
|
|
24
|
+
onRehydrateStorage: () => (_, error) => {
|
|
25
|
+
if (error) {
|
|
26
|
+
console.warn("Failed to rehydrate user store:", error);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
4
30
|
/**
|
|
5
31
|
* NOTE: THIS IS ONLY MEANT FOR INTERNAL USE, from useOnConnect
|
|
6
32
|
*
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { B3Provider } from "./components/B3Provider/B3Provider.native";
|
|
2
|
+
export { B3Context, type B3ContextType } from "./components/B3Provider/types";
|
|
3
|
+
export { useB3 } from "./components/B3Provider/useB3";
|
|
2
4
|
export { useAccountWallet } from "./hooks/useAccountWallet";
|
|
3
5
|
export { useAuthentication } from "./hooks/useAuthentication";
|
|
4
6
|
export { useProfile } from "./hooks/useProfile";
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// export * from "./stores/index.js";
|
|
4
4
|
// We only export the components and hooks that are needed for the native app
|
|
5
5
|
export { B3Provider } from "./components/B3Provider/B3Provider.native.js";
|
|
6
|
+
export { B3Context } from "./components/B3Provider/types.js";
|
|
7
|
+
export { useB3 } from "./components/B3Provider/useB3.js";
|
|
6
8
|
export { useAccountWallet } from "./hooks/useAccountWallet.js";
|
|
7
9
|
export { useAuthentication } from "./hooks/useAuthentication.js";
|
|
8
10
|
export { useProfile } from "./hooks/useProfile.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useAuthStore } from "./useAuthStore";
|
|
2
|
-
export { useB3ConfigStore } from "./configStore";
|
|
3
2
|
export { useModalStore } from "./useModalStore";
|
|
4
3
|
export { useRecentAddressesStore } from "./useRecentAddressesStore";
|
|
5
4
|
export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
|
|
@@ -403,12 +403,6 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
403
403
|
customUsdInputValues?: string[];
|
|
404
404
|
/** prefer eoa wallet */
|
|
405
405
|
preferEoa?: boolean;
|
|
406
|
-
/** Custom URL to redirect to when clicking "Return to Home" on complete order screen */
|
|
407
|
-
returnToHomeUrl?: string;
|
|
408
|
-
/** Custom label for recipient display (e.g., "OBSN Telegram Bot") */
|
|
409
|
-
customRecipientLabel?: string;
|
|
410
|
-
/** Custom label for the return home button (overrides "Return to Home" / "Close") */
|
|
411
|
-
returnHomeLabel?: string;
|
|
412
406
|
}
|
|
413
407
|
export interface AvatarEditorModalProps extends BaseModalProps {
|
|
414
408
|
/** Modal type identifier */
|
|
@@ -477,10 +471,6 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
|
|
|
477
471
|
vendingMachineId: string;
|
|
478
472
|
/** The pack type */
|
|
479
473
|
packType: string;
|
|
480
|
-
/** Active tab */
|
|
481
|
-
activeTab?: "crypto" | "fiat";
|
|
482
|
-
/** Force fiat payment */
|
|
483
|
-
forceFiatPayment?: boolean;
|
|
484
474
|
}
|
|
485
475
|
/**
|
|
486
476
|
* Union type of all possible modal content types
|