@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,337 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useAuth = useAuth;
|
|
7
|
-
const app_1 = __importDefault(require("../../../global-account/app"));
|
|
8
|
-
const bsmnt_1 = require("../../../global-account/bsmnt");
|
|
9
|
-
const react_1 = require("../../../global-account/react");
|
|
10
|
-
const constants_1 = require("../../../shared/constants");
|
|
11
|
-
const debug_1 = require("../../../shared/utils/debug");
|
|
12
|
-
const thirdweb_1 = require("../../../shared/utils/thirdweb");
|
|
13
|
-
const core_1 = require("@wagmi/core");
|
|
14
|
-
const react_2 = require("react");
|
|
15
|
-
const react_3 = require("thirdweb/react");
|
|
16
|
-
const wallets_1 = require("thirdweb/wallets");
|
|
17
|
-
const in_app_1 = require("thirdweb/wallets/in-app");
|
|
18
|
-
const wagmi_1 = require("wagmi");
|
|
19
|
-
const LocalSDKProvider_1 = require("../components/B3Provider/LocalSDKProvider");
|
|
20
|
-
const createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
21
|
-
const useSearchParamsSSR_1 = require("./useSearchParamsSSR");
|
|
22
|
-
const useUserQuery_1 = require("./useUserQuery");
|
|
23
|
-
const debug = (0, debug_1.debugB3React)("useAuth");
|
|
24
|
-
/**
|
|
25
|
-
* Unified authentication hook that uses Turnkey for authentication
|
|
26
|
-
* This replaces the previous Thirdweb-based authentication
|
|
27
|
-
*
|
|
28
|
-
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
29
|
-
*/
|
|
30
|
-
function useAuth() {
|
|
31
|
-
const { onConnectCallback } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
|
|
32
|
-
const { disconnect } = (0, react_3.useDisconnect)();
|
|
33
|
-
const wallets = (0, react_3.useConnectedWallets)();
|
|
34
|
-
const activeWallet = (0, react_3.useActiveWallet)();
|
|
35
|
-
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
36
|
-
const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
37
|
-
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
38
|
-
const isConnecting = (0, react_1.useAuthStore)(state => state.isConnecting);
|
|
39
|
-
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
40
|
-
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
41
|
-
const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
42
|
-
const setHasStartedConnecting = (0, react_1.useAuthStore)(state => state.setHasStartedConnecting);
|
|
43
|
-
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
44
|
-
const hasStartedConnecting = (0, react_1.useAuthStore)(state => state.hasStartedConnecting);
|
|
45
|
-
const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
|
|
46
|
-
const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
|
|
47
|
-
const { partnerId } = (0, react_1.useB3Config)();
|
|
48
|
-
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
|
|
49
|
-
const { connect } = (0, wagmi_1.useConnect)();
|
|
50
|
-
const activeWagmiAccount = (0, wagmi_1.useAccount)();
|
|
51
|
-
const { switchAccount } = (0, wagmi_1.useSwitchAccount)();
|
|
52
|
-
const { user, setUser } = (0, useUserQuery_1.useUserQuery)();
|
|
53
|
-
debug("@@activeWagmiAccount", activeWagmiAccount);
|
|
54
|
-
const wallet = (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, {
|
|
55
|
-
partnerId: partnerId,
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* Re-authenticate using existing session
|
|
59
|
-
* Also updates user state and authenticates with BSMNT
|
|
60
|
-
*/
|
|
61
|
-
const reAuthenticate = (0, react_2.useCallback)(async () => {
|
|
62
|
-
debug("Re-authenticating...");
|
|
63
|
-
try {
|
|
64
|
-
const response = await app_1.default.reAuthenticate();
|
|
65
|
-
debug("Re-authentication successful", response);
|
|
66
|
-
// Update user state if user data exists
|
|
67
|
-
if (response.user) {
|
|
68
|
-
setUser(response.user);
|
|
69
|
-
debug("User state updated", response.user);
|
|
70
|
-
}
|
|
71
|
-
// Authenticate with BSMNT
|
|
72
|
-
try {
|
|
73
|
-
const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(response.accessToken);
|
|
74
|
-
debug("BSMNT re-authentication successful", b3Jwt);
|
|
75
|
-
}
|
|
76
|
-
catch (bsmntError) {
|
|
77
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
78
|
-
debug("BSMNT re-authentication failed (non-critical)", bsmntError);
|
|
79
|
-
}
|
|
80
|
-
return response;
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
debug("Re-authentication failed", err);
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
}, [setUser]);
|
|
87
|
-
const syncWagmi = (0, react_2.useCallback)(async () => {
|
|
88
|
-
function syncWagmiFunc() {
|
|
89
|
-
const connectors = (0, core_1.getConnectors)(wagmiConfig);
|
|
90
|
-
debug("@@syncWagmi", {
|
|
91
|
-
connectors,
|
|
92
|
-
wallets,
|
|
93
|
-
});
|
|
94
|
-
// For each that matchs a TW wallet on wallets, connect to the wagmi connector
|
|
95
|
-
// or, since ecosystem wallets is separate, connect those via in-app-wallet from wagmi
|
|
96
|
-
connectors.forEach(async (connector) => {
|
|
97
|
-
const twWallet = wallets.find(wallet => wallet.id === connector.id || connector.id === "in-app-wallet");
|
|
98
|
-
// If no TW wallet, do not prompt the user to connect
|
|
99
|
-
if (!twWallet) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
// Metamask will prompt to connect, we can just switch accounts here.
|
|
103
|
-
if (connector.id === "io.metamask") {
|
|
104
|
-
return switchAccount({ connector });
|
|
105
|
-
}
|
|
106
|
-
if (
|
|
107
|
-
// If it's not an in-app wallet or it is the ecosystem wallet, connect
|
|
108
|
-
connector.id !== "in-app-wallet" ||
|
|
109
|
-
(connector.id === "in-app-wallet" && twWallet.id === constants_1.ecosystemWalletId)) {
|
|
110
|
-
try {
|
|
111
|
-
const options = {
|
|
112
|
-
wallet: twWallet, // the connected wallet
|
|
113
|
-
};
|
|
114
|
-
debug("@@syncWagmi:connecting", { twWallet, connector });
|
|
115
|
-
connect({
|
|
116
|
-
connector,
|
|
117
|
-
...options,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error("@@syncWagmi:error", error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
debug("@@syncWagmi:not-connecting", connector);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
syncWagmiFunc();
|
|
130
|
-
// wagmi config shouldn't change
|
|
131
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
|
-
}, [partnerId, wallets]);
|
|
133
|
-
(0, react_2.useEffect)(() => {
|
|
134
|
-
syncWagmi();
|
|
135
|
-
}, [wallets, syncWagmi]);
|
|
136
|
-
/**
|
|
137
|
-
* Authenticate user using Turnkey
|
|
138
|
-
* Note: This no longer requires a wallet for authentication.
|
|
139
|
-
* Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
|
|
140
|
-
*
|
|
141
|
-
* For backward compatibility, this function still accepts a wallet parameter,
|
|
142
|
-
* but it's not used for authentication anymore.
|
|
143
|
-
*/
|
|
144
|
-
const authenticateUser = (0, react_2.useCallback)(async () => {
|
|
145
|
-
setHasStartedConnecting(true);
|
|
146
|
-
// Try to re-authenticate first
|
|
147
|
-
try {
|
|
148
|
-
const userAuth = await reAuthenticate();
|
|
149
|
-
setUser(userAuth.user);
|
|
150
|
-
setIsAuthenticated(true);
|
|
151
|
-
setIsAuthenticating(false);
|
|
152
|
-
debug("Re-authenticated successfully", { userAuth });
|
|
153
|
-
// Authenticate on BSMNT with B3 JWT
|
|
154
|
-
const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(userAuth.accessToken);
|
|
155
|
-
debug("@@b3Jwt", b3Jwt);
|
|
156
|
-
return userAuth;
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
// If re-authentication fails, user needs to authenticate via Turnkey
|
|
160
|
-
// This should be handled by the Turnkey auth modal/flow
|
|
161
|
-
debug("Re-authentication failed. User needs to authenticate via Turnkey.", error);
|
|
162
|
-
setIsAuthenticated(false);
|
|
163
|
-
setIsAuthenticating(false);
|
|
164
|
-
throw new Error("Authentication required. Please authenticate via Turnkey.");
|
|
165
|
-
}
|
|
166
|
-
}, [reAuthenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
167
|
-
/**
|
|
168
|
-
* Authenticate with Turnkey using email OTP
|
|
169
|
-
* This is the primary authentication method, replacing Thirdweb wallet-based auth
|
|
170
|
-
*
|
|
171
|
-
* This function:
|
|
172
|
-
* 1. Authenticates with FeathersJS (persists session via cookies)
|
|
173
|
-
* 2. Sets user state in the user store (persists to localStorage)
|
|
174
|
-
* 3. Authenticates with BSMNT for basement integration
|
|
175
|
-
*/
|
|
176
|
-
const authenticate = (0, react_2.useCallback)(async (turnkeySessionJwt, partnerId) => {
|
|
177
|
-
if (!turnkeySessionJwt) {
|
|
178
|
-
throw new Error("Turnkey session JWT is required");
|
|
179
|
-
}
|
|
180
|
-
debug("Authenticating with Turnkey JWT", { referralCode, partnerId });
|
|
181
|
-
try {
|
|
182
|
-
// Step 1: Authenticate with FeathersJS (session persisted via cookies)
|
|
183
|
-
const response = await app_1.default.authenticate({
|
|
184
|
-
strategy: "turnkey-jwt",
|
|
185
|
-
accessToken: turnkeySessionJwt,
|
|
186
|
-
referralCode,
|
|
187
|
-
partnerId: partnerId,
|
|
188
|
-
});
|
|
189
|
-
debug("Authentication successful", response);
|
|
190
|
-
// Step 2: Set user state (persists to localStorage via Zustand)
|
|
191
|
-
if (response.user) {
|
|
192
|
-
setUser(response.user);
|
|
193
|
-
debug("User state updated", response.user);
|
|
194
|
-
}
|
|
195
|
-
// Step 3: Authenticate with BSMNT for basement integration
|
|
196
|
-
try {
|
|
197
|
-
const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(response.accessToken);
|
|
198
|
-
debug("BSMNT authentication successful", b3Jwt);
|
|
199
|
-
}
|
|
200
|
-
catch (bsmntError) {
|
|
201
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
202
|
-
debug("BSMNT authentication failed (non-critical)", bsmntError);
|
|
203
|
-
}
|
|
204
|
-
return response;
|
|
205
|
-
}
|
|
206
|
-
catch (err) {
|
|
207
|
-
debug("Authentication failed", err);
|
|
208
|
-
throw err;
|
|
209
|
-
}
|
|
210
|
-
}, [referralCode, setUser]);
|
|
211
|
-
/**
|
|
212
|
-
* Handle wallet connection
|
|
213
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
214
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
215
|
-
*/
|
|
216
|
-
/**
|
|
217
|
-
* Handle wallet connection
|
|
218
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
219
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
220
|
-
*/
|
|
221
|
-
const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
222
|
-
debug("@@useAuth:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
223
|
-
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
224
|
-
if (!wallet) {
|
|
225
|
-
throw new Error("No smart wallet found during auto-connect");
|
|
226
|
-
}
|
|
227
|
-
debug("@@useAuth:onConnect", { wallet });
|
|
228
|
-
try {
|
|
229
|
-
setHasStartedConnecting(true);
|
|
230
|
-
setIsConnected(true);
|
|
231
|
-
setIsAuthenticating(true);
|
|
232
|
-
await setActiveWallet(wallet);
|
|
233
|
-
// Try to authenticate user (will use re-authenticate if session exists)
|
|
234
|
-
// If no session exists, authentication will need to happen via Turnkey flow
|
|
235
|
-
try {
|
|
236
|
-
const userAuth = await authenticateUser();
|
|
237
|
-
if (userAuth && onConnectCallback) {
|
|
238
|
-
await onConnectCallback(wallet, userAuth.accessToken);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (authError) {
|
|
242
|
-
// Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
|
|
243
|
-
// The Turnkey auth modal should handle this
|
|
244
|
-
debug("@@useAuth:onConnect:authFailed", { authError });
|
|
245
|
-
// Don't set isAuthenticated to false here - let the Turnkey flow handle it
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
debug("@@useAuth:onConnect:failed", { error });
|
|
250
|
-
setIsAuthenticated(false);
|
|
251
|
-
setUser(undefined);
|
|
252
|
-
}
|
|
253
|
-
finally {
|
|
254
|
-
setIsAuthenticating(false);
|
|
255
|
-
}
|
|
256
|
-
debug({
|
|
257
|
-
isAuthenticated,
|
|
258
|
-
isAuthenticating,
|
|
259
|
-
isConnected,
|
|
260
|
-
});
|
|
261
|
-
}, [
|
|
262
|
-
onConnectCallback,
|
|
263
|
-
authenticateUser,
|
|
264
|
-
isAuthenticated,
|
|
265
|
-
isAuthenticating,
|
|
266
|
-
isConnected,
|
|
267
|
-
setActiveWallet,
|
|
268
|
-
setHasStartedConnecting,
|
|
269
|
-
setIsAuthenticated,
|
|
270
|
-
setIsAuthenticating,
|
|
271
|
-
setIsConnected,
|
|
272
|
-
setUser,
|
|
273
|
-
]);
|
|
274
|
-
const logout = (0, react_2.useCallback)(async (callback) => {
|
|
275
|
-
if (activeWallet) {
|
|
276
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
277
|
-
disconnect(activeWallet);
|
|
278
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
279
|
-
}
|
|
280
|
-
// Log out of each wallet
|
|
281
|
-
wallets.forEach(wallet => {
|
|
282
|
-
console.log("@@logging out", wallet);
|
|
283
|
-
disconnect(wallet);
|
|
284
|
-
});
|
|
285
|
-
// Delete localStorage thirdweb:connected-wallet-ids
|
|
286
|
-
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
287
|
-
if (typeof localStorage !== "undefined") {
|
|
288
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
289
|
-
localStorage.removeItem("wagmi.store");
|
|
290
|
-
localStorage.removeItem("lastAuthProvider");
|
|
291
|
-
localStorage.removeItem("b3-user");
|
|
292
|
-
}
|
|
293
|
-
app_1.default.logout();
|
|
294
|
-
debug("@@logout:loggedOut");
|
|
295
|
-
setIsAuthenticated(false);
|
|
296
|
-
setIsConnected(false);
|
|
297
|
-
setUser();
|
|
298
|
-
callback?.();
|
|
299
|
-
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
300
|
-
const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
|
|
301
|
-
client: thirdweb_1.client,
|
|
302
|
-
wallets: [wallet],
|
|
303
|
-
onConnect,
|
|
304
|
-
onTimeout: () => {
|
|
305
|
-
logout().catch(error => {
|
|
306
|
-
debug("@@useAuth:logout on timeout failed", { error });
|
|
307
|
-
});
|
|
308
|
-
},
|
|
309
|
-
});
|
|
310
|
-
/**
|
|
311
|
-
* useAutoConnectLoading starts as false
|
|
312
|
-
*/
|
|
313
|
-
(0, react_2.useEffect)(() => {
|
|
314
|
-
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
315
|
-
setIsAuthenticating(false);
|
|
316
|
-
}
|
|
317
|
-
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
318
|
-
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
319
|
-
const isReady = isAuthenticated && !isAuthenticating;
|
|
320
|
-
return {
|
|
321
|
-
authenticate,
|
|
322
|
-
reAuthenticate,
|
|
323
|
-
logout,
|
|
324
|
-
isAuthenticated,
|
|
325
|
-
isReady,
|
|
326
|
-
isConnecting,
|
|
327
|
-
isConnected,
|
|
328
|
-
wallet,
|
|
329
|
-
preAuthenticate: in_app_1.preAuthenticate,
|
|
330
|
-
connect: onConnect,
|
|
331
|
-
isAuthenticating,
|
|
332
|
-
onConnect,
|
|
333
|
-
user,
|
|
334
|
-
refetchUser: authenticateUser,
|
|
335
|
-
setUser,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Preferred Hook to get the user data
|
|
3
|
-
*/
|
|
4
|
-
export declare function useUser(): {
|
|
5
|
-
user: {
|
|
6
|
-
email?: string | undefined;
|
|
7
|
-
username?: string | undefined;
|
|
8
|
-
telNumber?: string | undefined;
|
|
9
|
-
ens?: string | undefined;
|
|
10
|
-
avatar?: string | undefined;
|
|
11
|
-
preferences?: {} | undefined;
|
|
12
|
-
referredBy?: string | {} | undefined;
|
|
13
|
-
sourceApp?: string | undefined;
|
|
14
|
-
referralCode?: string | undefined;
|
|
15
|
-
userGroups?: number[] | undefined;
|
|
16
|
-
isMigratedFromBSMNT?: boolean | undefined;
|
|
17
|
-
privyLinkedAccounts?: {
|
|
18
|
-
name?: string | undefined;
|
|
19
|
-
address?: string | undefined;
|
|
20
|
-
email?: string | undefined;
|
|
21
|
-
chain_type?: string | undefined;
|
|
22
|
-
lv?: number | undefined;
|
|
23
|
-
wallet_client_type?: string | undefined;
|
|
24
|
-
smart_wallet_type?: string | undefined;
|
|
25
|
-
subject?: string | undefined;
|
|
26
|
-
type: string;
|
|
27
|
-
}[] | undefined;
|
|
28
|
-
twProfiles?: {
|
|
29
|
-
type: string;
|
|
30
|
-
details: {
|
|
31
|
-
id?: string | undefined;
|
|
32
|
-
name?: string | undefined;
|
|
33
|
-
address?: string | undefined;
|
|
34
|
-
email?: string | undefined;
|
|
35
|
-
username?: string | undefined;
|
|
36
|
-
phone?: string | undefined;
|
|
37
|
-
fid?: string | undefined;
|
|
38
|
-
};
|
|
39
|
-
}[] | undefined;
|
|
40
|
-
turnkeySubOrgs?: {
|
|
41
|
-
hasDelegatedUser?: boolean | undefined;
|
|
42
|
-
subOrgId: string;
|
|
43
|
-
accounts: Record<string, any>[];
|
|
44
|
-
}[] | undefined;
|
|
45
|
-
_id: string | {};
|
|
46
|
-
userId: string;
|
|
47
|
-
smartAccountAddress: string;
|
|
48
|
-
createdAt: number;
|
|
49
|
-
updatedAt: number;
|
|
50
|
-
partnerIds: {
|
|
51
|
-
privyId?: string | undefined;
|
|
52
|
-
thirdwebId?: string | undefined;
|
|
53
|
-
turnkeyId?: string | undefined;
|
|
54
|
-
turnkeyOtpId?: string | undefined;
|
|
55
|
-
};
|
|
56
|
-
} | null;
|
|
57
|
-
isConnecting: boolean;
|
|
58
|
-
isConnected: boolean;
|
|
59
|
-
isAuthenticating: boolean;
|
|
60
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useUser = useUser;
|
|
4
|
-
const react_1 = require("../../../global-account/react");
|
|
5
|
-
const userStore_1 = require("../stores/userStore");
|
|
6
|
-
/**
|
|
7
|
-
* Preferred Hook to get the user data
|
|
8
|
-
*/
|
|
9
|
-
function useUser() {
|
|
10
|
-
const user = (0, userStore_1.useUserStore)(state => state.user);
|
|
11
|
-
const isConnecting = (0, react_1.useAuthStore)(state => state.isConnecting);
|
|
12
|
-
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
13
|
-
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
14
|
-
return {
|
|
15
|
-
user,
|
|
16
|
-
isConnecting,
|
|
17
|
-
isConnected,
|
|
18
|
-
isAuthenticating,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CreateOnrampOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
-
import { CreateOrderParams } from "../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import { PermissionsConfig } from "../../../global-account/types/permissions";
|
|
4
|
-
import { Account } from "thirdweb/wallets";
|
|
5
|
-
import { ClientType } from "../../client-manager";
|
|
6
|
-
interface ConfigStore {
|
|
7
|
-
accountOverride?: Account;
|
|
8
|
-
automaticallySetFirstEoa: boolean;
|
|
9
|
-
environment: "development" | "production";
|
|
10
|
-
defaultPermissions: PermissionsConfig;
|
|
11
|
-
theme: "light" | "dark";
|
|
12
|
-
clientType: ClientType;
|
|
13
|
-
partnerId: string;
|
|
14
|
-
stripePublishableKey?: string;
|
|
15
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
16
|
-
enableTurnkey: boolean;
|
|
17
|
-
setConfig: (config: Partial<Omit<ConfigStore, "setConfig">>) => void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Zustand store for B3 configuration
|
|
21
|
-
* NOT persisted - these are developer-set configuration values
|
|
22
|
-
*/
|
|
23
|
-
export declare const useB3ConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigStore>>;
|
|
24
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useB3ConfigStore = void 0;
|
|
4
|
-
const zustand_1 = require("zustand");
|
|
5
|
-
/**
|
|
6
|
-
* Default permissions configuration for B3 provider
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_PERMISSIONS = {
|
|
9
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
10
|
-
nativeTokenLimitPerTransaction: 0.1,
|
|
11
|
-
startDate: new Date(),
|
|
12
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Zustand store for B3 configuration
|
|
16
|
-
* NOT persisted - these are developer-set configuration values
|
|
17
|
-
*/
|
|
18
|
-
exports.useB3ConfigStore = (0, zustand_1.create)(set => ({
|
|
19
|
-
accountOverride: undefined,
|
|
20
|
-
automaticallySetFirstEoa: false,
|
|
21
|
-
environment: "development",
|
|
22
|
-
defaultPermissions: DEFAULT_PERMISSIONS,
|
|
23
|
-
theme: "light",
|
|
24
|
-
clientType: "rest",
|
|
25
|
-
partnerId: "",
|
|
26
|
-
stripePublishableKey: undefined,
|
|
27
|
-
createClientReferenceId: undefined,
|
|
28
|
-
enableTurnkey: false,
|
|
29
|
-
setConfig: config => set(state => ({ ...state, ...config })),
|
|
30
|
-
}));
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
-
interface UserStore {
|
|
3
|
-
user: Users | null;
|
|
4
|
-
setUser: (user: Users | undefined) => void;
|
|
5
|
-
clearUser: () => void;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Zustand store for managing user state
|
|
9
|
-
* Persists user data to localStorage
|
|
10
|
-
*/
|
|
11
|
-
export declare const useUserStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<UserStore>, "persist"> & {
|
|
12
|
-
persist: {
|
|
13
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>) => void;
|
|
14
|
-
clearStorage: () => void;
|
|
15
|
-
rehydrate: () => Promise<void> | void;
|
|
16
|
-
hasHydrated: () => boolean;
|
|
17
|
-
onHydrate: (fn: (state: UserStore) => void) => () => void;
|
|
18
|
-
onFinishHydration: (fn: (state: UserStore) => void) => () => void;
|
|
19
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>;
|
|
20
|
-
};
|
|
21
|
-
}>;
|
|
22
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useUserStore = void 0;
|
|
4
|
-
const debug_1 = require("../../../shared/utils/debug");
|
|
5
|
-
const zustand_1 = require("zustand");
|
|
6
|
-
const middleware_1 = require("zustand/middleware");
|
|
7
|
-
const debug = (0, debug_1.debugB3React)("useUserQuery");
|
|
8
|
-
/**
|
|
9
|
-
* Zustand store for managing user state
|
|
10
|
-
* Persists user data to localStorage
|
|
11
|
-
*/
|
|
12
|
-
exports.useUserStore = (0, zustand_1.create)()((0, middleware_1.persist)(set => ({
|
|
13
|
-
user: null,
|
|
14
|
-
setUser: (newUser) => {
|
|
15
|
-
const userToSave = newUser ?? null;
|
|
16
|
-
set({ user: userToSave });
|
|
17
|
-
debug("User updated", userToSave);
|
|
18
|
-
},
|
|
19
|
-
clearUser: () => {
|
|
20
|
-
set({ user: null });
|
|
21
|
-
debug("User cleared");
|
|
22
|
-
},
|
|
23
|
-
}), {
|
|
24
|
-
name: "b3-user",
|
|
25
|
-
onRehydrateStorage: () => (_, error) => {
|
|
26
|
-
if (error) {
|
|
27
|
-
console.warn("Failed to rehydrate user store:", error);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GasPriceData } from "../../../types/gas";
|
|
2
|
-
export interface GasIndicatorProps {
|
|
3
|
-
gasPrice: GasPriceData;
|
|
4
|
-
className?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function GasIndicator({ gasPrice, className }: GasIndicatorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
-
import { motion } from "motion/react";
|
|
5
|
-
const LEVEL_LABELS = {
|
|
6
|
-
low: "Low",
|
|
7
|
-
normal: "Normal",
|
|
8
|
-
elevated: "Elevated",
|
|
9
|
-
high: "High",
|
|
10
|
-
spike: "Spike",
|
|
11
|
-
};
|
|
12
|
-
const LEVEL_STYLES = {
|
|
13
|
-
low: "bg-green-500/20 text-green-500",
|
|
14
|
-
normal: "bg-as-surface-tertiary text-as-secondary",
|
|
15
|
-
elevated: "bg-yellow-500/20 text-yellow-600",
|
|
16
|
-
high: "bg-orange-500/20 text-orange-500",
|
|
17
|
-
spike: "bg-red-500/20 text-red-500",
|
|
18
|
-
};
|
|
19
|
-
function formatGasPrice(gweiString) {
|
|
20
|
-
const gwei = parseFloat(gweiString);
|
|
21
|
-
if (gwei < 0.001)
|
|
22
|
-
return "<0.001";
|
|
23
|
-
if (gwei < 1)
|
|
24
|
-
return gwei.toFixed(3);
|
|
25
|
-
if (gwei < 10)
|
|
26
|
-
return gwei.toFixed(2);
|
|
27
|
-
return gwei.toFixed(1);
|
|
28
|
-
}
|
|
29
|
-
export function GasIndicator({ gasPrice, className }) {
|
|
30
|
-
return (_jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.2 }, className: cn("flex items-center justify-between rounded-lg px-3 py-2", gasPrice.isSpike ? "bg-yellow-500/10" : "bg-as-surface-secondary", className), children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("span", { className: "text-as-secondary text-xs", children: ["Gas on ", gasPrice.chainName] }) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: cn("rounded px-1.5 py-0.5 text-xs font-medium", LEVEL_STYLES[gasPrice.level]), children: LEVEL_LABELS[gasPrice.level] }), _jsxs("span", { className: "text-as-primary text-xs font-medium", children: [formatGasPrice(gasPrice.gasPriceGwei), " Gwei"] })] })] }));
|
|
31
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { GasPriceData } from "../../types/gas";
|
|
2
|
-
export interface UseGasPriceOptions {
|
|
3
|
-
/** Refetch interval in ms (default: 10000 = 10s) */
|
|
4
|
-
refetchInterval?: number;
|
|
5
|
-
/** Whether to enable the query (default: true if chainId is supported) */
|
|
6
|
-
enabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface UseGasPriceResult {
|
|
9
|
-
/** Gas price data */
|
|
10
|
-
gasPrice: GasPriceData | undefined;
|
|
11
|
-
/** Whether the query is loading */
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
/** Whether there's an error */
|
|
14
|
-
isError: boolean;
|
|
15
|
-
/** Error object if any */
|
|
16
|
-
error: Error | null;
|
|
17
|
-
/** Whether gas is currently spiking */
|
|
18
|
-
isSpike: boolean;
|
|
19
|
-
/** Refetch function */
|
|
20
|
-
refetch: () => void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* React hook to fetch current gas price for a chain.
|
|
24
|
-
*
|
|
25
|
-
* @param chainId - The chain ID to fetch gas price for
|
|
26
|
-
* @param options - Optional configuration
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```tsx
|
|
30
|
-
* const { gasPrice, isSpike, isLoading } = useGasPrice(8453); // Base
|
|
31
|
-
*
|
|
32
|
-
* if (isSpike) {
|
|
33
|
-
* return <Warning>Gas prices are high: {gasPrice?.recommendation}</Warning>;
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function useGasPrice(chainId: number | undefined, options?: UseGasPriceOptions): UseGasPriceResult;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { gasService, isGasOracleSupported } from "../../services/gas.js";
|
|
4
|
-
/**
|
|
5
|
-
* React hook to fetch current gas price for a chain.
|
|
6
|
-
*
|
|
7
|
-
* @param chainId - The chain ID to fetch gas price for
|
|
8
|
-
* @param options - Optional configuration
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const { gasPrice, isSpike, isLoading } = useGasPrice(8453); // Base
|
|
13
|
-
*
|
|
14
|
-
* if (isSpike) {
|
|
15
|
-
* return <Warning>Gas prices are high: {gasPrice?.recommendation}</Warning>;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function useGasPrice(chainId, options = {}) {
|
|
20
|
-
const { refetchInterval = 10000, enabled } = options;
|
|
21
|
-
const isSupported = chainId !== undefined && isGasOracleSupported(chainId);
|
|
22
|
-
const queryEnabled = enabled ?? isSupported;
|
|
23
|
-
const { data, isLoading, isError, error, refetch } = useQuery({
|
|
24
|
-
queryKey: ["gasPrice", chainId],
|
|
25
|
-
queryFn: () => gasService.fetch(chainId),
|
|
26
|
-
enabled: queryEnabled && chainId !== undefined,
|
|
27
|
-
refetchInterval,
|
|
28
|
-
staleTime: 5000, // Consider data fresh for 5s
|
|
29
|
-
retry: 2,
|
|
30
|
-
refetchOnWindowFocus: true,
|
|
31
|
-
});
|
|
32
|
-
return useMemo(() => ({
|
|
33
|
-
gasPrice: data,
|
|
34
|
-
isLoading,
|
|
35
|
-
isError,
|
|
36
|
-
error: error,
|
|
37
|
-
isSpike: data?.isSpike ?? false,
|
|
38
|
-
refetch,
|
|
39
|
-
}), [data, isLoading, isError, error, refetch]);
|
|
40
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { GasOracleResponse, GasPriceData } from "../types/gas";
|
|
2
|
-
/** Supported chain IDs for gas oracle */
|
|
3
|
-
export declare const GAS_ORACLE_SUPPORTED_CHAINS: readonly [1, 137, 42161, 8453, 56, 10, 43114, 8333, 2741, 4689, 3338, 1329];
|
|
4
|
-
export type GasOracleSupportedChainId = (typeof GAS_ORACLE_SUPPORTED_CHAINS)[number];
|
|
5
|
-
/** Check if a chain is supported by the gas oracle */
|
|
6
|
-
export declare function isGasOracleSupported(chainId: number): chainId is GasOracleSupportedChainId;
|
|
7
|
-
/** Fetch gas price data from the gas oracle */
|
|
8
|
-
export declare function fetchGasPrice(chainId: number): Promise<GasOracleResponse>;
|
|
9
|
-
/** Transform raw oracle response to simplified UI data */
|
|
10
|
-
export declare function toGasPriceData(response: GasOracleResponse): GasPriceData;
|
|
11
|
-
/** Gas service for fetching and transforming gas data */
|
|
12
|
-
export declare const gasService: {
|
|
13
|
-
/** Fetch raw gas oracle response */
|
|
14
|
-
fetchRaw: typeof fetchGasPrice;
|
|
15
|
-
/** Fetch and transform to UI-friendly format */
|
|
16
|
-
fetch: (chainId: number) => Promise<GasPriceData>;
|
|
17
|
-
/** Check if chain is supported */
|
|
18
|
-
isSupported: typeof isGasOracleSupported;
|
|
19
|
-
/** List of supported chain IDs */
|
|
20
|
-
supportedChains: readonly [1, 137, 42161, 8453, 56, 10, 43114, 8333, 2741, 4689, 3338, 1329];
|
|
21
|
-
};
|