@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,59 +0,0 @@
|
|
|
1
|
-
import { GAS_ORACLE_BASE_URL } from "../constants/index.js";
|
|
2
|
-
/** Supported chain IDs for gas oracle */
|
|
3
|
-
export const GAS_ORACLE_SUPPORTED_CHAINS = [
|
|
4
|
-
1, // Ethereum
|
|
5
|
-
137, // Polygon
|
|
6
|
-
42161, // Arbitrum
|
|
7
|
-
8453, // Base
|
|
8
|
-
56, // BSC
|
|
9
|
-
10, // Optimism
|
|
10
|
-
43114, // Avalanche
|
|
11
|
-
8333, // B3
|
|
12
|
-
2741, // Abstract
|
|
13
|
-
4689, // IoTeX
|
|
14
|
-
3338, // Peaq
|
|
15
|
-
1329, // Sei
|
|
16
|
-
];
|
|
17
|
-
/** Check if a chain is supported by the gas oracle */
|
|
18
|
-
export function isGasOracleSupported(chainId) {
|
|
19
|
-
return GAS_ORACLE_SUPPORTED_CHAINS.includes(chainId);
|
|
20
|
-
}
|
|
21
|
-
/** Fetch gas price data from the gas oracle */
|
|
22
|
-
export async function fetchGasPrice(chainId) {
|
|
23
|
-
const response = await fetch(`${GAS_ORACLE_BASE_URL}/gas/${chainId}`);
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
throw new Error(`Failed to fetch gas price for chain ${chainId}: ${response.status}`);
|
|
26
|
-
}
|
|
27
|
-
return response.json();
|
|
28
|
-
}
|
|
29
|
-
/** Transform raw oracle response to simplified UI data */
|
|
30
|
-
export function toGasPriceData(response) {
|
|
31
|
-
const { analysis } = response;
|
|
32
|
-
const isSpike = analysis.level === "elevated" || analysis.level === "high" || analysis.level === "spike";
|
|
33
|
-
return {
|
|
34
|
-
chainId: response.chainId,
|
|
35
|
-
chainName: response.chainName,
|
|
36
|
-
gasPriceGwei: response.gasPrice.standard,
|
|
37
|
-
baseFeeGwei: response.eip1559?.baseFee,
|
|
38
|
-
level: analysis.level,
|
|
39
|
-
isSpike,
|
|
40
|
-
recommendation: analysis.recommendation,
|
|
41
|
-
vsMedian: analysis.vs1h, // Use 1h as primary comparison
|
|
42
|
-
source: response.source,
|
|
43
|
-
timestamp: response.timestamp,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/** Gas service for fetching and transforming gas data */
|
|
47
|
-
export const gasService = {
|
|
48
|
-
/** Fetch raw gas oracle response */
|
|
49
|
-
fetchRaw: fetchGasPrice,
|
|
50
|
-
/** Fetch and transform to UI-friendly format */
|
|
51
|
-
fetch: async (chainId) => {
|
|
52
|
-
const response = await fetchGasPrice(chainId);
|
|
53
|
-
return toGasPriceData(response);
|
|
54
|
-
},
|
|
55
|
-
/** Check if chain is supported */
|
|
56
|
-
isSupported: isGasOracleSupported,
|
|
57
|
-
/** List of supported chain IDs */
|
|
58
|
-
supportedChains: GAS_ORACLE_SUPPORTED_CHAINS,
|
|
59
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/** Gas level classification based on historical percentiles */
|
|
2
|
-
export type GasLevel = "low" | "normal" | "elevated" | "high" | "spike";
|
|
3
|
-
/** Gas prices in Gwei for different speed tiers */
|
|
4
|
-
export interface GasPrices {
|
|
5
|
-
low: string;
|
|
6
|
-
standard: string;
|
|
7
|
-
fast: string;
|
|
8
|
-
instant?: string;
|
|
9
|
-
}
|
|
10
|
-
/** EIP-1559 specific gas data */
|
|
11
|
-
export interface Eip1559Data {
|
|
12
|
-
baseFee: string;
|
|
13
|
-
maxPriorityFee: GasPrices;
|
|
14
|
-
maxFee: GasPrices;
|
|
15
|
-
}
|
|
16
|
-
/** Spike analysis comparing current gas to historical data */
|
|
17
|
-
export interface GasSpikeAnalysis {
|
|
18
|
-
level: GasLevel;
|
|
19
|
-
percentile: number;
|
|
20
|
-
/** Ratio to 1h median (primary spike detection) */
|
|
21
|
-
vs1h: number;
|
|
22
|
-
/** Ratio to 4h median (short-term context) */
|
|
23
|
-
vs4h: number;
|
|
24
|
-
/** Ratio to 24h median (daily context) */
|
|
25
|
-
vs24h: number;
|
|
26
|
-
recommendation: string;
|
|
27
|
-
}
|
|
28
|
-
/** Full gas response from the gas oracle */
|
|
29
|
-
export interface GasOracleResponse {
|
|
30
|
-
chainId: number;
|
|
31
|
-
chainName: string;
|
|
32
|
-
timestamp: string;
|
|
33
|
-
blockNumber?: number;
|
|
34
|
-
source: "blocknative" | "rpc";
|
|
35
|
-
gasPrice: GasPrices;
|
|
36
|
-
eip1559?: Eip1559Data;
|
|
37
|
-
analysis: GasSpikeAnalysis;
|
|
38
|
-
cached: boolean;
|
|
39
|
-
cacheAge?: number;
|
|
40
|
-
}
|
|
41
|
-
/** Simplified gas data for UI display */
|
|
42
|
-
export interface GasPriceData {
|
|
43
|
-
chainId: number;
|
|
44
|
-
chainName: string;
|
|
45
|
-
/** Standard gas price in Gwei */
|
|
46
|
-
gasPriceGwei: string;
|
|
47
|
-
/** Base fee in Gwei (EIP-1559 chains) */
|
|
48
|
-
baseFeeGwei?: string;
|
|
49
|
-
/** Gas level classification */
|
|
50
|
-
level: GasLevel;
|
|
51
|
-
/** Whether gas is currently spiking (elevated, high, or spike) */
|
|
52
|
-
isSpike: boolean;
|
|
53
|
-
/** Human-readable recommendation */
|
|
54
|
-
recommendation: string;
|
|
55
|
-
/** Ratio to recent median (1 = normal, >1.5 = elevated) */
|
|
56
|
-
vsMedian: number;
|
|
57
|
-
/** Data source */
|
|
58
|
-
source: "blocknative" | "rpc";
|
|
59
|
-
/** Timestamp of the data */
|
|
60
|
-
timestamp: string;
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useAuthentication } from "../../hooks/index.js";
|
|
2
|
-
import { useAutoSelectWallet } from "../../hooks/useAutoSelectWallet.js";
|
|
3
|
-
const AuthenticationProvider = ({ partnerId, automaticallySetFirstEoa, }) => {
|
|
4
|
-
useAuthentication(partnerId);
|
|
5
|
-
useAutoSelectWallet({
|
|
6
|
-
enabled: automaticallySetFirstEoa,
|
|
7
|
-
});
|
|
8
|
-
return null;
|
|
9
|
-
};
|
|
10
|
-
export default AuthenticationProvider;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Wallet } from "thirdweb/wallets";
|
|
2
|
-
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
3
|
-
/**
|
|
4
|
-
* Unified authentication hook that uses Turnkey for authentication
|
|
5
|
-
* This replaces the previous Thirdweb-based authentication
|
|
6
|
-
*
|
|
7
|
-
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
8
|
-
*/
|
|
9
|
-
export declare function useAuth(): {
|
|
10
|
-
authenticate: (turnkeySessionJwt: string, partnerId: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
11
|
-
reAuthenticate: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
12
|
-
logout: (callback?: () => void) => Promise<void>;
|
|
13
|
-
isAuthenticated: boolean;
|
|
14
|
-
isReady: boolean;
|
|
15
|
-
isConnecting: boolean;
|
|
16
|
-
isConnected: boolean;
|
|
17
|
-
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
18
|
-
preAuthenticate: typeof preAuthenticate;
|
|
19
|
-
connect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
20
|
-
isAuthenticating: boolean;
|
|
21
|
-
onConnect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
22
|
-
user: {
|
|
23
|
-
email?: string | undefined;
|
|
24
|
-
username?: string | undefined;
|
|
25
|
-
telNumber?: string | undefined;
|
|
26
|
-
ens?: string | undefined;
|
|
27
|
-
avatar?: string | undefined;
|
|
28
|
-
preferences?: {} | undefined;
|
|
29
|
-
referredBy?: string | {} | undefined;
|
|
30
|
-
sourceApp?: string | undefined;
|
|
31
|
-
referralCode?: string | undefined;
|
|
32
|
-
userGroups?: number[] | undefined;
|
|
33
|
-
isMigratedFromBSMNT?: boolean | undefined;
|
|
34
|
-
privyLinkedAccounts?: {
|
|
35
|
-
name?: string | undefined;
|
|
36
|
-
address?: string | undefined;
|
|
37
|
-
email?: string | undefined;
|
|
38
|
-
chain_type?: string | undefined;
|
|
39
|
-
lv?: number | undefined;
|
|
40
|
-
wallet_client_type?: string | undefined;
|
|
41
|
-
smart_wallet_type?: string | undefined;
|
|
42
|
-
subject?: string | undefined;
|
|
43
|
-
type: string;
|
|
44
|
-
}[] | undefined;
|
|
45
|
-
twProfiles?: {
|
|
46
|
-
type: string;
|
|
47
|
-
details: {
|
|
48
|
-
id?: string | undefined;
|
|
49
|
-
name?: string | undefined;
|
|
50
|
-
address?: string | undefined;
|
|
51
|
-
email?: string | undefined;
|
|
52
|
-
username?: string | undefined;
|
|
53
|
-
phone?: string | undefined;
|
|
54
|
-
fid?: string | undefined;
|
|
55
|
-
};
|
|
56
|
-
}[] | undefined;
|
|
57
|
-
turnkeySubOrgs?: {
|
|
58
|
-
hasDelegatedUser?: boolean | undefined;
|
|
59
|
-
subOrgId: string;
|
|
60
|
-
accounts: Record<string, any>[];
|
|
61
|
-
}[] | undefined;
|
|
62
|
-
_id: string | {};
|
|
63
|
-
userId: string;
|
|
64
|
-
smartAccountAddress: string;
|
|
65
|
-
createdAt: number;
|
|
66
|
-
updatedAt: number;
|
|
67
|
-
partnerIds: {
|
|
68
|
-
privyId?: string | undefined;
|
|
69
|
-
thirdwebId?: string | undefined;
|
|
70
|
-
turnkeyId?: string | undefined;
|
|
71
|
-
turnkeyOtpId?: string | undefined;
|
|
72
|
-
};
|
|
73
|
-
} | undefined;
|
|
74
|
-
refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
75
|
-
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
76
|
-
};
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import app from "../../../global-account/app.js";
|
|
2
|
-
import { authenticateWithB3JWT } from "../../../global-account/bsmnt.js";
|
|
3
|
-
import { useAuthStore, useB3Config } from "../../../global-account/react/index.js";
|
|
4
|
-
import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
5
|
-
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
|
-
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
|
-
import { getConnectors } from "@wagmi/core";
|
|
8
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
9
|
-
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect, useSetActiveWallet, } from "thirdweb/react";
|
|
10
|
-
import { ecosystemWallet } from "thirdweb/wallets";
|
|
11
|
-
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
12
|
-
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
13
|
-
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider.js";
|
|
14
|
-
import { createWagmiConfig } from "../utils/createWagmiConfig.js";
|
|
15
|
-
import { useSearchParam } from "./useSearchParamsSSR.js";
|
|
16
|
-
import { useUserQuery } from "./useUserQuery.js";
|
|
17
|
-
const debug = debugB3React("useAuth");
|
|
18
|
-
/**
|
|
19
|
-
* Unified authentication hook that uses Turnkey for authentication
|
|
20
|
-
* This replaces the previous Thirdweb-based authentication
|
|
21
|
-
*
|
|
22
|
-
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
23
|
-
*/
|
|
24
|
-
export function useAuth() {
|
|
25
|
-
const { onConnectCallback } = useContext(LocalSDKContext);
|
|
26
|
-
const { disconnect } = useDisconnect();
|
|
27
|
-
const wallets = useConnectedWallets();
|
|
28
|
-
const activeWallet = useActiveWallet();
|
|
29
|
-
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
30
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
31
|
-
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
32
|
-
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
33
|
-
const isConnected = useAuthStore(state => state.isConnected);
|
|
34
|
-
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
35
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
36
|
-
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
37
|
-
const setActiveWallet = useSetActiveWallet();
|
|
38
|
-
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
39
|
-
const useAutoConnectLoadingPrevious = useRef(false);
|
|
40
|
-
const referralCode = useSearchParam("referralCode");
|
|
41
|
-
const { partnerId } = useB3Config();
|
|
42
|
-
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
43
|
-
const { connect } = useConnect();
|
|
44
|
-
const activeWagmiAccount = useAccount();
|
|
45
|
-
const { switchAccount } = useSwitchAccount();
|
|
46
|
-
const { user, setUser } = useUserQuery();
|
|
47
|
-
debug("@@activeWagmiAccount", activeWagmiAccount);
|
|
48
|
-
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
49
|
-
partnerId: partnerId,
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* Re-authenticate using existing session
|
|
53
|
-
* Also updates user state and authenticates with BSMNT
|
|
54
|
-
*/
|
|
55
|
-
const reAuthenticate = useCallback(async () => {
|
|
56
|
-
debug("Re-authenticating...");
|
|
57
|
-
try {
|
|
58
|
-
const response = await app.reAuthenticate();
|
|
59
|
-
debug("Re-authentication successful", response);
|
|
60
|
-
// Update user state if user data exists
|
|
61
|
-
if (response.user) {
|
|
62
|
-
setUser(response.user);
|
|
63
|
-
debug("User state updated", response.user);
|
|
64
|
-
}
|
|
65
|
-
// Authenticate with BSMNT
|
|
66
|
-
try {
|
|
67
|
-
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
68
|
-
debug("BSMNT re-authentication successful", b3Jwt);
|
|
69
|
-
}
|
|
70
|
-
catch (bsmntError) {
|
|
71
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
72
|
-
debug("BSMNT re-authentication failed (non-critical)", bsmntError);
|
|
73
|
-
}
|
|
74
|
-
return response;
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
debug("Re-authentication failed", err);
|
|
78
|
-
throw err;
|
|
79
|
-
}
|
|
80
|
-
}, [setUser]);
|
|
81
|
-
const syncWagmi = useCallback(async () => {
|
|
82
|
-
function syncWagmiFunc() {
|
|
83
|
-
const connectors = getConnectors(wagmiConfig);
|
|
84
|
-
debug("@@syncWagmi", {
|
|
85
|
-
connectors,
|
|
86
|
-
wallets,
|
|
87
|
-
});
|
|
88
|
-
// For each that matchs a TW wallet on wallets, connect to the wagmi connector
|
|
89
|
-
// or, since ecosystem wallets is separate, connect those via in-app-wallet from wagmi
|
|
90
|
-
connectors.forEach(async (connector) => {
|
|
91
|
-
const twWallet = wallets.find(wallet => wallet.id === connector.id || connector.id === "in-app-wallet");
|
|
92
|
-
// If no TW wallet, do not prompt the user to connect
|
|
93
|
-
if (!twWallet) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// Metamask will prompt to connect, we can just switch accounts here.
|
|
97
|
-
if (connector.id === "io.metamask") {
|
|
98
|
-
return switchAccount({ connector });
|
|
99
|
-
}
|
|
100
|
-
if (
|
|
101
|
-
// If it's not an in-app wallet or it is the ecosystem wallet, connect
|
|
102
|
-
connector.id !== "in-app-wallet" ||
|
|
103
|
-
(connector.id === "in-app-wallet" && twWallet.id === ecosystemWalletId)) {
|
|
104
|
-
try {
|
|
105
|
-
const options = {
|
|
106
|
-
wallet: twWallet, // the connected wallet
|
|
107
|
-
};
|
|
108
|
-
debug("@@syncWagmi:connecting", { twWallet, connector });
|
|
109
|
-
connect({
|
|
110
|
-
connector,
|
|
111
|
-
...options,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
console.error("@@syncWagmi:error", error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
debug("@@syncWagmi:not-connecting", connector);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
syncWagmiFunc();
|
|
124
|
-
// wagmi config shouldn't change
|
|
125
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
-
}, [partnerId, wallets]);
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
syncWagmi();
|
|
129
|
-
}, [wallets, syncWagmi]);
|
|
130
|
-
/**
|
|
131
|
-
* Authenticate user using Turnkey
|
|
132
|
-
* Note: This no longer requires a wallet for authentication.
|
|
133
|
-
* Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
|
|
134
|
-
*
|
|
135
|
-
* For backward compatibility, this function still accepts a wallet parameter,
|
|
136
|
-
* but it's not used for authentication anymore.
|
|
137
|
-
*/
|
|
138
|
-
const authenticateUser = useCallback(async () => {
|
|
139
|
-
setHasStartedConnecting(true);
|
|
140
|
-
// Try to re-authenticate first
|
|
141
|
-
try {
|
|
142
|
-
const userAuth = await reAuthenticate();
|
|
143
|
-
setUser(userAuth.user);
|
|
144
|
-
setIsAuthenticated(true);
|
|
145
|
-
setIsAuthenticating(false);
|
|
146
|
-
debug("Re-authenticated successfully", { userAuth });
|
|
147
|
-
// Authenticate on BSMNT with B3 JWT
|
|
148
|
-
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
149
|
-
debug("@@b3Jwt", b3Jwt);
|
|
150
|
-
return userAuth;
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
// If re-authentication fails, user needs to authenticate via Turnkey
|
|
154
|
-
// This should be handled by the Turnkey auth modal/flow
|
|
155
|
-
debug("Re-authentication failed. User needs to authenticate via Turnkey.", error);
|
|
156
|
-
setIsAuthenticated(false);
|
|
157
|
-
setIsAuthenticating(false);
|
|
158
|
-
throw new Error("Authentication required. Please authenticate via Turnkey.");
|
|
159
|
-
}
|
|
160
|
-
}, [reAuthenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
161
|
-
/**
|
|
162
|
-
* Authenticate with Turnkey using email OTP
|
|
163
|
-
* This is the primary authentication method, replacing Thirdweb wallet-based auth
|
|
164
|
-
*
|
|
165
|
-
* This function:
|
|
166
|
-
* 1. Authenticates with FeathersJS (persists session via cookies)
|
|
167
|
-
* 2. Sets user state in the user store (persists to localStorage)
|
|
168
|
-
* 3. Authenticates with BSMNT for basement integration
|
|
169
|
-
*/
|
|
170
|
-
const authenticate = useCallback(async (turnkeySessionJwt, partnerId) => {
|
|
171
|
-
if (!turnkeySessionJwt) {
|
|
172
|
-
throw new Error("Turnkey session JWT is required");
|
|
173
|
-
}
|
|
174
|
-
debug("Authenticating with Turnkey JWT", { referralCode, partnerId });
|
|
175
|
-
try {
|
|
176
|
-
// Step 1: Authenticate with FeathersJS (session persisted via cookies)
|
|
177
|
-
const response = await app.authenticate({
|
|
178
|
-
strategy: "turnkey-jwt",
|
|
179
|
-
accessToken: turnkeySessionJwt,
|
|
180
|
-
referralCode,
|
|
181
|
-
partnerId: partnerId,
|
|
182
|
-
});
|
|
183
|
-
debug("Authentication successful", response);
|
|
184
|
-
// Step 2: Set user state (persists to localStorage via Zustand)
|
|
185
|
-
if (response.user) {
|
|
186
|
-
setUser(response.user);
|
|
187
|
-
debug("User state updated", response.user);
|
|
188
|
-
}
|
|
189
|
-
// Step 3: Authenticate with BSMNT for basement integration
|
|
190
|
-
try {
|
|
191
|
-
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
192
|
-
debug("BSMNT authentication successful", b3Jwt);
|
|
193
|
-
}
|
|
194
|
-
catch (bsmntError) {
|
|
195
|
-
// BSMNT authentication failure shouldn't block the main auth flow
|
|
196
|
-
debug("BSMNT authentication failed (non-critical)", bsmntError);
|
|
197
|
-
}
|
|
198
|
-
return response;
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
debug("Authentication failed", err);
|
|
202
|
-
throw err;
|
|
203
|
-
}
|
|
204
|
-
}, [referralCode, setUser]);
|
|
205
|
-
/**
|
|
206
|
-
* Handle wallet connection
|
|
207
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
208
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
209
|
-
*/
|
|
210
|
-
/**
|
|
211
|
-
* Handle wallet connection
|
|
212
|
-
* Note: With Turnkey migration, wallet connection is primarily for signing transactions,
|
|
213
|
-
* not for authentication. Authentication should be done separately via Turnkey email OTP.
|
|
214
|
-
*/
|
|
215
|
-
const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
216
|
-
debug("@@useAuth:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
217
|
-
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
218
|
-
if (!wallet) {
|
|
219
|
-
throw new Error("No smart wallet found during auto-connect");
|
|
220
|
-
}
|
|
221
|
-
debug("@@useAuth:onConnect", { wallet });
|
|
222
|
-
try {
|
|
223
|
-
setHasStartedConnecting(true);
|
|
224
|
-
setIsConnected(true);
|
|
225
|
-
setIsAuthenticating(true);
|
|
226
|
-
await setActiveWallet(wallet);
|
|
227
|
-
// Try to authenticate user (will use re-authenticate if session exists)
|
|
228
|
-
// If no session exists, authentication will need to happen via Turnkey flow
|
|
229
|
-
try {
|
|
230
|
-
const userAuth = await authenticateUser();
|
|
231
|
-
if (userAuth && onConnectCallback) {
|
|
232
|
-
await onConnectCallback(wallet, userAuth.accessToken);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
catch (authError) {
|
|
236
|
-
// Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
|
|
237
|
-
// The Turnkey auth modal should handle this
|
|
238
|
-
debug("@@useAuth:onConnect:authFailed", { authError });
|
|
239
|
-
// Don't set isAuthenticated to false here - let the Turnkey flow handle it
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
debug("@@useAuth:onConnect:failed", { error });
|
|
244
|
-
setIsAuthenticated(false);
|
|
245
|
-
setUser(undefined);
|
|
246
|
-
}
|
|
247
|
-
finally {
|
|
248
|
-
setIsAuthenticating(false);
|
|
249
|
-
}
|
|
250
|
-
debug({
|
|
251
|
-
isAuthenticated,
|
|
252
|
-
isAuthenticating,
|
|
253
|
-
isConnected,
|
|
254
|
-
});
|
|
255
|
-
}, [
|
|
256
|
-
onConnectCallback,
|
|
257
|
-
authenticateUser,
|
|
258
|
-
isAuthenticated,
|
|
259
|
-
isAuthenticating,
|
|
260
|
-
isConnected,
|
|
261
|
-
setActiveWallet,
|
|
262
|
-
setHasStartedConnecting,
|
|
263
|
-
setIsAuthenticated,
|
|
264
|
-
setIsAuthenticating,
|
|
265
|
-
setIsConnected,
|
|
266
|
-
setUser,
|
|
267
|
-
]);
|
|
268
|
-
const logout = useCallback(async (callback) => {
|
|
269
|
-
if (activeWallet) {
|
|
270
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
271
|
-
disconnect(activeWallet);
|
|
272
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
273
|
-
}
|
|
274
|
-
// Log out of each wallet
|
|
275
|
-
wallets.forEach(wallet => {
|
|
276
|
-
console.log("@@logging out", wallet);
|
|
277
|
-
disconnect(wallet);
|
|
278
|
-
});
|
|
279
|
-
// Delete localStorage thirdweb:connected-wallet-ids
|
|
280
|
-
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
281
|
-
if (typeof localStorage !== "undefined") {
|
|
282
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
283
|
-
localStorage.removeItem("wagmi.store");
|
|
284
|
-
localStorage.removeItem("lastAuthProvider");
|
|
285
|
-
localStorage.removeItem("b3-user");
|
|
286
|
-
}
|
|
287
|
-
app.logout();
|
|
288
|
-
debug("@@logout:loggedOut");
|
|
289
|
-
setIsAuthenticated(false);
|
|
290
|
-
setIsConnected(false);
|
|
291
|
-
setUser();
|
|
292
|
-
callback?.();
|
|
293
|
-
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
294
|
-
const { isLoading: useAutoConnectLoading } = useAutoConnect({
|
|
295
|
-
client,
|
|
296
|
-
wallets: [wallet],
|
|
297
|
-
onConnect,
|
|
298
|
-
onTimeout: () => {
|
|
299
|
-
logout().catch(error => {
|
|
300
|
-
debug("@@useAuth:logout on timeout failed", { error });
|
|
301
|
-
});
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
/**
|
|
305
|
-
* useAutoConnectLoading starts as false
|
|
306
|
-
*/
|
|
307
|
-
useEffect(() => {
|
|
308
|
-
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
309
|
-
setIsAuthenticating(false);
|
|
310
|
-
}
|
|
311
|
-
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
312
|
-
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
313
|
-
const isReady = isAuthenticated && !isAuthenticating;
|
|
314
|
-
return {
|
|
315
|
-
authenticate,
|
|
316
|
-
reAuthenticate,
|
|
317
|
-
logout,
|
|
318
|
-
isAuthenticated,
|
|
319
|
-
isReady,
|
|
320
|
-
isConnecting,
|
|
321
|
-
isConnected,
|
|
322
|
-
wallet,
|
|
323
|
-
preAuthenticate,
|
|
324
|
-
connect: onConnect,
|
|
325
|
-
isAuthenticating,
|
|
326
|
-
onConnect,
|
|
327
|
-
user,
|
|
328
|
-
refetchUser: authenticateUser,
|
|
329
|
-
setUser,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
import { useAuthStore } from "../../../global-account/react/index.js";
|
|
2
|
-
import { useUserStore } from "../stores/userStore.js";
|
|
3
|
-
/**
|
|
4
|
-
* Preferred Hook to get the user data
|
|
5
|
-
*/
|
|
6
|
-
export function useUser() {
|
|
7
|
-
const user = useUserStore(state => state.user);
|
|
8
|
-
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
9
|
-
const isConnected = useAuthStore(state => state.isConnected);
|
|
10
|
-
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
11
|
-
return {
|
|
12
|
-
user,
|
|
13
|
-
isConnecting,
|
|
14
|
-
isConnected,
|
|
15
|
-
isAuthenticating,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -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,27 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
/**
|
|
3
|
-
* Default permissions configuration for B3 provider
|
|
4
|
-
*/
|
|
5
|
-
const DEFAULT_PERMISSIONS = {
|
|
6
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
7
|
-
nativeTokenLimitPerTransaction: 0.1,
|
|
8
|
-
startDate: new Date(),
|
|
9
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Zustand store for B3 configuration
|
|
13
|
-
* NOT persisted - these are developer-set configuration values
|
|
14
|
-
*/
|
|
15
|
-
export const useB3ConfigStore = create(set => ({
|
|
16
|
-
accountOverride: undefined,
|
|
17
|
-
automaticallySetFirstEoa: false,
|
|
18
|
-
environment: "development",
|
|
19
|
-
defaultPermissions: DEFAULT_PERMISSIONS,
|
|
20
|
-
theme: "light",
|
|
21
|
-
clientType: "rest",
|
|
22
|
-
partnerId: "",
|
|
23
|
-
stripePublishableKey: undefined,
|
|
24
|
-
createClientReferenceId: undefined,
|
|
25
|
-
enableTurnkey: false,
|
|
26
|
-
setConfig: config => set(state => ({ ...state, ...config })),
|
|
27
|
-
}));
|