@b3dotfun/sdk 0.0.88 → 0.0.89-alpha.1
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 +2 -0
- package/dist/cjs/anyspend/constants/index.js +3 -1
- package/dist/cjs/anyspend/index.d.ts +2 -0
- package/dist/cjs/anyspend/index.js +3 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +9 -6
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +24 -20
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +14 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
- package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +34 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +34 -6
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +3 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- 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/useGasPrice.d.ts +37 -0
- package/dist/cjs/anyspend/react/hooks/useGasPrice.js +43 -0
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
- package/dist/cjs/anyspend/services/gas.d.ts +21 -0
- package/dist/cjs/anyspend/services/gas.js +65 -0
- package/dist/cjs/anyspend/types/gas.d.ts +61 -0
- package/dist/cjs/anyspend/types/gas.js +2 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -3
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -52
- 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 +38 -35
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
- 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 +8 -9
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +76 -20
- 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 +3 -1
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
- package/dist/cjs/global-account/react/components/index.d.ts +1 -2
- package/dist/cjs/global-account/react/components/index.js +3 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -0
- package/dist/cjs/global-account/react/hooks/index.js +5 -1
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +76 -0
- package/dist/cjs/global-account/react/hooks/useAuth.js +337 -0
- 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 +3 -0
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +8 -0
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +4 -2
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +50 -22
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +9 -35
- package/dist/cjs/global-account/react/index.native.d.ts +0 -2
- package/dist/cjs/global-account/react/index.native.js +1 -5
- package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/cjs/global-account/react/stores/configStore.js +30 -0
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
- package/dist/cjs/global-account/react/stores/index.js +3 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -0
- package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/cjs/global-account/react/stores/userStore.js +30 -0
- package/dist/esm/anyspend/constants/index.d.ts +2 -0
- package/dist/esm/anyspend/constants/index.js +2 -0
- package/dist/esm/anyspend/index.d.ts +2 -0
- package/dist/esm/anyspend/index.js +3 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +11 -8
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +8 -4
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +14 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +31 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +36 -8
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +3 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- 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/useGasPrice.d.ts +37 -0
- package/dist/esm/anyspend/react/hooks/useGasPrice.js +40 -0
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
- package/dist/esm/anyspend/services/gas.d.ts +21 -0
- package/dist/esm/anyspend/services/gas.js +59 -0
- package/dist/esm/anyspend/types/gas.d.ts +61 -0
- package/dist/esm/anyspend/types/gas.js +1 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -4
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +34 -53
- 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 +3 -1
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
- 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 +2 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +76 -20
- 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 +5 -3
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
- package/dist/esm/global-account/react/components/index.d.ts +1 -2
- package/dist/esm/global-account/react/components/index.js +1 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -0
- package/dist/esm/global-account/react/hooks/index.js +2 -0
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +76 -0
- package/dist/esm/global-account/react/hooks/useAuth.js +331 -0
- 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 +3 -0
- package/dist/esm/global-account/react/hooks/useTWAuth.js +8 -0
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -2
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +50 -22
- package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/esm/global-account/react/hooks/useUser.js +17 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +1 -27
- package/dist/esm/global-account/react/index.native.d.ts +0 -2
- package/dist/esm/global-account/react/index.native.js +0 -2
- package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/esm/global-account/react/stores/configStore.js +27 -0
- package/dist/esm/global-account/react/stores/index.d.ts +1 -0
- package/dist/esm/global-account/react/stores/index.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -0
- package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/esm/global-account/react/stores/userStore.js +27 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +2 -0
- package/dist/types/anyspend/index.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useGasPrice.d.ts +37 -0
- package/dist/types/anyspend/services/gas.d.ts +21 -0
- package/dist/types/anyspend/types/gas.d.ts +61 -0
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/types/global-account/react/components/index.d.ts +1 -2
- package/dist/types/global-account/react/hooks/index.d.ts +2 -0
- package/dist/types/global-account/react/hooks/useAuth.d.ts +76 -0
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +3 -0
- package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/types/global-account/react/index.native.d.ts +0 -2
- package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/types/global-account/react/stores/index.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -0
- package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +3 -0
- package/src/anyspend/index.ts +4 -0
- package/src/anyspend/react/components/AnySpend.tsx +28 -2
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +6 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +53 -48
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +23 -0
- package/src/anyspend/react/components/AnySpendDeposit.tsx +27 -18
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +4 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +15 -1
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +5 -1
- package/src/anyspend/react/components/common/GasIndicator.tsx +59 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -42
- package/src/anyspend/react/components/common/PanelOnramp.tsx +5 -1
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -4
- package/src/anyspend/react/hooks/index.ts +1 -0
- 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/useGasPrice.ts +70 -0
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
- package/src/anyspend/services/gas.test.ts +31 -0
- package/src/anyspend/services/gas.ts +73 -0
- package/src/anyspend/types/gas.ts +66 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -4
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +43 -54
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +44 -106
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +4 -1
- package/src/global-account/react/components/B3Provider/useB3.ts +4 -13
- package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
- package/src/global-account/react/components/B3Provider/useB3Config.ts +18 -31
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
- 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 +168 -100
- 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 +7 -4
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
- package/src/global-account/react/components/index.ts +1 -2
- package/src/global-account/react/hooks/index.ts +2 -0
- package/src/global-account/react/hooks/useAuth.ts +379 -0
- 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 +10 -0
- package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -2
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +54 -23
- package/src/global-account/react/hooks/useUser.ts +20 -0
- package/src/global-account/react/hooks/useUserQuery.ts +1 -40
- package/src/global-account/react/index.native.ts +0 -2
- package/src/global-account/react/stores/configStore.ts +51 -0
- package/src/global-account/react/stores/index.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +10 -0
- package/src/global-account/react/stores/userStore.ts +41 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/src/global-account/react/components/B3Provider/types.ts +0 -50
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
TextLoop,
|
|
22
22
|
TextShimmer,
|
|
23
23
|
useAccountWallet,
|
|
24
|
-
|
|
24
|
+
useB3Config,
|
|
25
25
|
useModalStore,
|
|
26
26
|
useProfile,
|
|
27
27
|
useUnifiedChainSwitchAndExecute,
|
|
@@ -65,6 +65,10 @@ interface OrderDetailsProps {
|
|
|
65
65
|
onBack?: () => void;
|
|
66
66
|
disableUrlParamManagement?: boolean; // When true, will not modify URL parameters
|
|
67
67
|
points?: number | undefined; // Points earned from the transaction
|
|
68
|
+
/** Custom URL to redirect to when clicking "Return to Home" on complete order screen */
|
|
69
|
+
returnToHomeUrl?: string;
|
|
70
|
+
/** Custom label for the return home button (overrides "Return to Home" / "Close") */
|
|
71
|
+
returnHomeLabel?: string;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
// Add this helper function near the top or just above the component
|
|
@@ -217,12 +221,14 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
217
221
|
onBack,
|
|
218
222
|
disableUrlParamManagement = false,
|
|
219
223
|
points,
|
|
224
|
+
returnToHomeUrl,
|
|
225
|
+
returnHomeLabel,
|
|
220
226
|
}: OrderDetailsProps) {
|
|
221
227
|
const router = useRouter();
|
|
222
228
|
const searchParams = useSearchParams();
|
|
223
229
|
|
|
224
230
|
// Get theme from B3Provider context
|
|
225
|
-
const { theme } =
|
|
231
|
+
const { theme } = useB3Config();
|
|
226
232
|
const colorMode = theme || "light";
|
|
227
233
|
|
|
228
234
|
// Read crypto payment method from URL parameters
|
|
@@ -377,6 +383,49 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
377
383
|
onBack?.();
|
|
378
384
|
}, [cleanupUrlParams, onBack]);
|
|
379
385
|
|
|
386
|
+
// Handle "Return to Home" click - redirects to custom URL if provided
|
|
387
|
+
const handleReturnToHome = useCallback(() => {
|
|
388
|
+
if (returnToHomeUrl) {
|
|
389
|
+
// Validate URL to prevent Open Redirect / XSS attacks
|
|
390
|
+
try {
|
|
391
|
+
const url = new URL(returnToHomeUrl, window.location.origin);
|
|
392
|
+
// Only allow http/https protocols
|
|
393
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
394
|
+
window.location.href = url.href;
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
} catch {
|
|
398
|
+
// If URL parsing fails, check if it's a safe relative URL
|
|
399
|
+
if (returnToHomeUrl.startsWith("/") && !returnToHomeUrl.startsWith("//")) {
|
|
400
|
+
window.location.href = returnToHomeUrl;
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Fallback to handleBack if URL is not safe
|
|
405
|
+
handleBack();
|
|
406
|
+
} else {
|
|
407
|
+
handleBack();
|
|
408
|
+
}
|
|
409
|
+
}, [returnToHomeUrl, handleBack]);
|
|
410
|
+
|
|
411
|
+
// Reusable "Return to Home" / "Close" button
|
|
412
|
+
const returnHomeOrCloseButton = (
|
|
413
|
+
<button
|
|
414
|
+
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
415
|
+
onClick={returnToHomeUrl ? handleReturnToHome : mode === "page" ? handleBack : handleCloseModal}
|
|
416
|
+
>
|
|
417
|
+
{returnHomeLabel ? (
|
|
418
|
+
returnHomeLabel
|
|
419
|
+
) : mode === "page" ? (
|
|
420
|
+
<>
|
|
421
|
+
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
422
|
+
</>
|
|
423
|
+
) : (
|
|
424
|
+
"Close"
|
|
425
|
+
)}
|
|
426
|
+
</button>
|
|
427
|
+
);
|
|
428
|
+
|
|
380
429
|
useEffect(() => {
|
|
381
430
|
if (txSuccess) {
|
|
382
431
|
toast.success("Transaction successful! We are processing your order.", { duration: 10000 });
|
|
@@ -521,18 +570,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
521
570
|
</span>
|
|
522
571
|
</div>
|
|
523
572
|
)}
|
|
524
|
-
|
|
525
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
526
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
527
|
-
>
|
|
528
|
-
{mode === "page" ? (
|
|
529
|
-
<>
|
|
530
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
531
|
-
</>
|
|
532
|
-
) : (
|
|
533
|
-
"Close"
|
|
534
|
-
)}
|
|
535
|
-
</button>
|
|
573
|
+
{returnHomeOrCloseButton}
|
|
536
574
|
</>
|
|
537
575
|
);
|
|
538
576
|
}
|
|
@@ -649,20 +687,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
649
687
|
</ShinyButton>
|
|
650
688
|
)}
|
|
651
689
|
|
|
652
|
-
{order.status === "executed" &&
|
|
653
|
-
<button
|
|
654
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
655
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
656
|
-
>
|
|
657
|
-
{mode === "page" ? (
|
|
658
|
-
<>
|
|
659
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
660
|
-
</>
|
|
661
|
-
) : (
|
|
662
|
-
"Close"
|
|
663
|
-
)}
|
|
664
|
-
</button>
|
|
665
|
-
)}
|
|
690
|
+
{order.status === "executed" && returnHomeOrCloseButton}
|
|
666
691
|
</>
|
|
667
692
|
);
|
|
668
693
|
}
|
|
@@ -786,20 +811,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
786
811
|
</ShinyButton>
|
|
787
812
|
)}
|
|
788
813
|
|
|
789
|
-
{order.status === "executed" &&
|
|
790
|
-
<button
|
|
791
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
792
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
793
|
-
>
|
|
794
|
-
{mode === "page" ? (
|
|
795
|
-
<>
|
|
796
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
797
|
-
</>
|
|
798
|
-
) : (
|
|
799
|
-
"Close"
|
|
800
|
-
)}
|
|
801
|
-
</button>
|
|
802
|
-
)}
|
|
814
|
+
{order.status === "executed" && returnHomeOrCloseButton}
|
|
803
815
|
</>
|
|
804
816
|
);
|
|
805
817
|
}
|
|
@@ -905,6 +917,12 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
905
917
|
)}
|
|
906
918
|
|
|
907
919
|
{/* <DelayedSupportMessage /> */}
|
|
920
|
+
<button
|
|
921
|
+
className="text-b3-primary-blue hover:text-b3-primary-blue/50 order-details-cancel-btn flex w-full items-center justify-center gap-2 underline"
|
|
922
|
+
onClick={handleBack}
|
|
923
|
+
>
|
|
924
|
+
<RefreshCcw className="ml-2 h-4 w-4" /> Cancel and start over
|
|
925
|
+
</button>
|
|
908
926
|
</>
|
|
909
927
|
);
|
|
910
928
|
}
|
|
@@ -33,6 +33,7 @@ export function PanelOnramp({
|
|
|
33
33
|
onShowPointsDetail,
|
|
34
34
|
onShowFeeDetail,
|
|
35
35
|
customUsdInputValues = ["5", "10", "20", "25"],
|
|
36
|
+
customRecipientLabel,
|
|
36
37
|
}: {
|
|
37
38
|
srcAmountOnRamp: string;
|
|
38
39
|
setSrcAmountOnRamp: (amount: string) => void;
|
|
@@ -52,6 +53,8 @@ export function PanelOnramp({
|
|
|
52
53
|
onShowPointsDetail?: () => void;
|
|
53
54
|
onShowFeeDetail?: () => void;
|
|
54
55
|
customUsdInputValues?: string[];
|
|
56
|
+
/** Custom label for recipient display (overrides recipientName) */
|
|
57
|
+
customRecipientLabel?: string;
|
|
55
58
|
}) {
|
|
56
59
|
// Helper function to get fees from anyspend quote
|
|
57
60
|
const getFeeFromApi = (paymentMethod: FiatPaymentMethod): number | null => {
|
|
@@ -228,7 +231,8 @@ export function PanelOnramp({
|
|
|
228
231
|
onClick={() => setActivePanel(recipientSelectionPanelIndex)} // Recipient selection panel
|
|
229
232
|
>
|
|
230
233
|
<span className="text-sm">
|
|
231
|
-
{
|
|
234
|
+
{customRecipientLabel ||
|
|
235
|
+
(recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress))}
|
|
232
236
|
</span>
|
|
233
237
|
<ChevronRight size={16} />
|
|
234
238
|
</button>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
2
1
|
import { OrderDetailsCollapsible, useStripeClientSecret } from "@b3dotfun/sdk/anyspend/react";
|
|
3
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
4
|
-
import { ShinyButton,
|
|
3
|
+
import { ShinyButton, useB3Config, useModalStore, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
5
4
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
6
|
-
import { formatStripeAmount } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
5
|
+
import { formatStripeAmount, getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
7
6
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
8
7
|
import { PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
|
|
9
8
|
import { X } from "lucide-react";
|
|
@@ -19,7 +18,7 @@ interface PaymentStripeWeb2Props {
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }: PaymentStripeWeb2Props) {
|
|
22
|
-
const { theme, stripePublishableKey } =
|
|
21
|
+
const { theme, stripePublishableKey } = useB3Config();
|
|
23
22
|
const fingerprintConfig = getFingerprintConfig();
|
|
24
23
|
|
|
25
24
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } =
|
|
@@ -7,6 +7,7 @@ export * from "./useAnyspendQuote";
|
|
|
7
7
|
export * from "./useAnyspendTokens";
|
|
8
8
|
export * from "./useCoinbaseOnrampOptions";
|
|
9
9
|
export * from "./useConnectedUserProfile";
|
|
10
|
+
export * from "./useGasPrice";
|
|
10
11
|
export * from "./useGeoOnrampOptions";
|
|
11
12
|
export * from "./useGetGeo";
|
|
12
13
|
export * from "./useHyperliquidTransfer";
|
|
@@ -3,7 +3,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
3
3
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
4
4
|
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
5
5
|
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
6
|
-
import {
|
|
6
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
7
7
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
8
8
|
import { useMutation } from "@tanstack/react-query";
|
|
9
9
|
import { useMemo } from "react";
|
|
@@ -36,7 +36,7 @@ export type UseAnyspendCreateOnrampOrderProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
|
|
38
38
|
// Get B3 context values
|
|
39
|
-
const { partnerId } =
|
|
39
|
+
const { partnerId } = useB3Config();
|
|
40
40
|
|
|
41
41
|
// Get validated client reference ID from B3 context
|
|
42
42
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
@@ -2,7 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
3
|
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
4
4
|
import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
5
|
-
import {
|
|
5
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
7
7
|
import { useMutation } from "@tanstack/react-query";
|
|
8
8
|
import { useMemo } from "react";
|
|
@@ -36,7 +36,7 @@ export type UseAnyspendCreateOrderProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
|
|
38
38
|
// Get B3 context values
|
|
39
|
-
const { partnerId } =
|
|
39
|
+
const { partnerId } = useB3Config();
|
|
40
40
|
|
|
41
41
|
// Get validated client reference ID from B3 context
|
|
42
42
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
@@ -2,7 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
3
|
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
4
4
|
import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
5
|
-
import {
|
|
5
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
7
7
|
import { useMutation } from "@tanstack/react-query";
|
|
8
8
|
import { useMemo } from "react";
|
|
@@ -29,7 +29,7 @@ export type UseCreateDepositFirstOrderProps = {
|
|
|
29
29
|
* This order type doesn't require srcAmount - the user deposits tokens after the order is created.
|
|
30
30
|
*/
|
|
31
31
|
export function useCreateDepositFirstOrder({ onSuccess, onError }: UseCreateDepositFirstOrderProps = {}) {
|
|
32
|
-
const { partnerId } =
|
|
32
|
+
const { partnerId } = useB3Config();
|
|
33
33
|
|
|
34
34
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
35
35
|
const visitorData: VisitorData | undefined = fpData && {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { gasService, isGasOracleSupported } from "../../services/gas";
|
|
4
|
+
import type { GasPriceData } from "../../types/gas";
|
|
5
|
+
|
|
6
|
+
export interface UseGasPriceOptions {
|
|
7
|
+
/** Refetch interval in ms (default: 10000 = 10s) */
|
|
8
|
+
refetchInterval?: number;
|
|
9
|
+
/** Whether to enable the query (default: true if chainId is supported) */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface UseGasPriceResult {
|
|
14
|
+
/** Gas price data */
|
|
15
|
+
gasPrice: GasPriceData | undefined;
|
|
16
|
+
/** Whether the query is loading */
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
/** Whether there's an error */
|
|
19
|
+
isError: boolean;
|
|
20
|
+
/** Error object if any */
|
|
21
|
+
error: Error | null;
|
|
22
|
+
/** Whether gas is currently spiking */
|
|
23
|
+
isSpike: boolean;
|
|
24
|
+
/** Refetch function */
|
|
25
|
+
refetch: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* React hook to fetch current gas price for a chain.
|
|
30
|
+
*
|
|
31
|
+
* @param chainId - The chain ID to fetch gas price for
|
|
32
|
+
* @param options - Optional configuration
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* const { gasPrice, isSpike, isLoading } = useGasPrice(8453); // Base
|
|
37
|
+
*
|
|
38
|
+
* if (isSpike) {
|
|
39
|
+
* return <Warning>Gas prices are high: {gasPrice?.recommendation}</Warning>;
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function useGasPrice(chainId: number | undefined, options: UseGasPriceOptions = {}): UseGasPriceResult {
|
|
44
|
+
const { refetchInterval = 10000, enabled } = options;
|
|
45
|
+
|
|
46
|
+
const isSupported = chainId !== undefined && isGasOracleSupported(chainId);
|
|
47
|
+
const queryEnabled = enabled ?? isSupported;
|
|
48
|
+
|
|
49
|
+
const { data, isLoading, isError, error, refetch } = useQuery({
|
|
50
|
+
queryKey: ["gasPrice", chainId],
|
|
51
|
+
queryFn: () => gasService.fetch(chainId as number),
|
|
52
|
+
enabled: queryEnabled && chainId !== undefined,
|
|
53
|
+
refetchInterval,
|
|
54
|
+
staleTime: 5000, // Consider data fresh for 5s
|
|
55
|
+
retry: 2,
|
|
56
|
+
refetchOnWindowFocus: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return useMemo(
|
|
60
|
+
() => ({
|
|
61
|
+
gasPrice: data,
|
|
62
|
+
isLoading,
|
|
63
|
+
isError,
|
|
64
|
+
error: error as Error | null,
|
|
65
|
+
isSpike: data?.isSpike ?? false,
|
|
66
|
+
refetch,
|
|
67
|
+
}),
|
|
68
|
+
[data, isLoading, isError, error, refetch],
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Validators } from "@b3dotfun/sdk/anyspend/utils/validation";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
import { CreateOnrampOrderParams } from "./useAnyspendCreateOnrampOrder";
|
|
5
5
|
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
@@ -9,7 +9,7 @@ import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
|
9
9
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
10
10
|
*/
|
|
11
11
|
export function useValidatedClientReferenceId() {
|
|
12
|
-
const { createClientReferenceId } =
|
|
12
|
+
const { createClientReferenceId } = useB3Config();
|
|
13
13
|
|
|
14
14
|
const createValidatedClientReferenceId = useCallback(
|
|
15
15
|
async (params: CreateOrderParams | CreateOnrampOrderParams) => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { gasService, isGasOracleSupported } from "./gas";
|
|
3
|
+
|
|
4
|
+
describe("gasService", () => {
|
|
5
|
+
it("should check supported chains", () => {
|
|
6
|
+
expect(isGasOracleSupported(8453)).toBe(true); // Base
|
|
7
|
+
expect(isGasOracleSupported(1)).toBe(true); // Ethereum
|
|
8
|
+
expect(isGasOracleSupported(999999)).toBe(false); // Unknown
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should fetch gas price for Base", async () => {
|
|
12
|
+
const gas = await gasService.fetch(8453);
|
|
13
|
+
|
|
14
|
+
console.log("Gas data:", gas);
|
|
15
|
+
|
|
16
|
+
expect(gas.chainId).toBe(8453);
|
|
17
|
+
expect(gas.chainName).toBe("Base");
|
|
18
|
+
expect(gas.level).toMatch(/low|normal|elevated|high|spike/);
|
|
19
|
+
expect(typeof gas.gasPriceGwei).toBe("string");
|
|
20
|
+
expect(typeof gas.isSpike).toBe("boolean");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should fetch gas price for Ethereum", async () => {
|
|
24
|
+
const gas = await gasService.fetch(1);
|
|
25
|
+
|
|
26
|
+
console.log("ETH Gas:", gas);
|
|
27
|
+
|
|
28
|
+
expect(gas.chainId).toBe(1);
|
|
29
|
+
expect(gas.source).toBe("blocknative"); // ETH uses Blocknative
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GAS_ORACLE_BASE_URL } from "../constants";
|
|
2
|
+
import type { GasOracleResponse, GasPriceData } from "../types/gas";
|
|
3
|
+
|
|
4
|
+
/** Supported chain IDs for gas oracle */
|
|
5
|
+
export const GAS_ORACLE_SUPPORTED_CHAINS = [
|
|
6
|
+
1, // Ethereum
|
|
7
|
+
137, // Polygon
|
|
8
|
+
42161, // Arbitrum
|
|
9
|
+
8453, // Base
|
|
10
|
+
56, // BSC
|
|
11
|
+
10, // Optimism
|
|
12
|
+
43114, // Avalanche
|
|
13
|
+
8333, // B3
|
|
14
|
+
2741, // Abstract
|
|
15
|
+
4689, // IoTeX
|
|
16
|
+
3338, // Peaq
|
|
17
|
+
1329, // Sei
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export type GasOracleSupportedChainId = (typeof GAS_ORACLE_SUPPORTED_CHAINS)[number];
|
|
21
|
+
|
|
22
|
+
/** Check if a chain is supported by the gas oracle */
|
|
23
|
+
export function isGasOracleSupported(chainId: number): chainId is GasOracleSupportedChainId {
|
|
24
|
+
return GAS_ORACLE_SUPPORTED_CHAINS.includes(chainId as GasOracleSupportedChainId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Fetch gas price data from the gas oracle */
|
|
28
|
+
export async function fetchGasPrice(chainId: number): Promise<GasOracleResponse> {
|
|
29
|
+
const response = await fetch(`${GAS_ORACLE_BASE_URL}/gas/${chainId}`);
|
|
30
|
+
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`Failed to fetch gas price for chain ${chainId}: ${response.status}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return response.json();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Transform raw oracle response to simplified UI data */
|
|
39
|
+
export function toGasPriceData(response: GasOracleResponse): GasPriceData {
|
|
40
|
+
const { analysis } = response;
|
|
41
|
+
const isSpike = analysis.level === "elevated" || analysis.level === "high" || analysis.level === "spike";
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
chainId: response.chainId,
|
|
45
|
+
chainName: response.chainName,
|
|
46
|
+
gasPriceGwei: response.gasPrice.standard,
|
|
47
|
+
baseFeeGwei: response.eip1559?.baseFee,
|
|
48
|
+
level: analysis.level,
|
|
49
|
+
isSpike,
|
|
50
|
+
recommendation: analysis.recommendation,
|
|
51
|
+
vsMedian: analysis.vs1h, // Use 1h as primary comparison
|
|
52
|
+
source: response.source,
|
|
53
|
+
timestamp: response.timestamp,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Gas service for fetching and transforming gas data */
|
|
58
|
+
export const gasService = {
|
|
59
|
+
/** Fetch raw gas oracle response */
|
|
60
|
+
fetchRaw: fetchGasPrice,
|
|
61
|
+
|
|
62
|
+
/** Fetch and transform to UI-friendly format */
|
|
63
|
+
fetch: async (chainId: number): Promise<GasPriceData> => {
|
|
64
|
+
const response = await fetchGasPrice(chainId);
|
|
65
|
+
return toGasPriceData(response);
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/** Check if chain is supported */
|
|
69
|
+
isSupported: isGasOracleSupported,
|
|
70
|
+
|
|
71
|
+
/** List of supported chain IDs */
|
|
72
|
+
supportedChains: GAS_ORACLE_SUPPORTED_CHAINS,
|
|
73
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Gas level classification based on historical percentiles */
|
|
2
|
+
export type GasLevel = "low" | "normal" | "elevated" | "high" | "spike";
|
|
3
|
+
|
|
4
|
+
/** Gas prices in Gwei for different speed tiers */
|
|
5
|
+
export interface GasPrices {
|
|
6
|
+
low: string;
|
|
7
|
+
standard: string;
|
|
8
|
+
fast: string;
|
|
9
|
+
instant?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** EIP-1559 specific gas data */
|
|
13
|
+
export interface Eip1559Data {
|
|
14
|
+
baseFee: string;
|
|
15
|
+
maxPriorityFee: GasPrices;
|
|
16
|
+
maxFee: GasPrices;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Spike analysis comparing current gas to historical data */
|
|
20
|
+
export interface GasSpikeAnalysis {
|
|
21
|
+
level: GasLevel;
|
|
22
|
+
percentile: number;
|
|
23
|
+
/** Ratio to 1h median (primary spike detection) */
|
|
24
|
+
vs1h: number;
|
|
25
|
+
/** Ratio to 4h median (short-term context) */
|
|
26
|
+
vs4h: number;
|
|
27
|
+
/** Ratio to 24h median (daily context) */
|
|
28
|
+
vs24h: number;
|
|
29
|
+
recommendation: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Full gas response from the gas oracle */
|
|
33
|
+
export interface GasOracleResponse {
|
|
34
|
+
chainId: number;
|
|
35
|
+
chainName: string;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
blockNumber?: number;
|
|
38
|
+
source: "blocknative" | "rpc";
|
|
39
|
+
gasPrice: GasPrices;
|
|
40
|
+
eip1559?: Eip1559Data;
|
|
41
|
+
analysis: GasSpikeAnalysis;
|
|
42
|
+
cached: boolean;
|
|
43
|
+
cacheAge?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Simplified gas data for UI display */
|
|
47
|
+
export interface GasPriceData {
|
|
48
|
+
chainId: number;
|
|
49
|
+
chainName: string;
|
|
50
|
+
/** Standard gas price in Gwei */
|
|
51
|
+
gasPriceGwei: string;
|
|
52
|
+
/** Base fee in Gwei (EIP-1559 chains) */
|
|
53
|
+
baseFeeGwei?: string;
|
|
54
|
+
/** Gas level classification */
|
|
55
|
+
level: GasLevel;
|
|
56
|
+
/** Whether gas is currently spiking (elevated, high, or spike) */
|
|
57
|
+
isSpike: boolean;
|
|
58
|
+
/** Human-readable recommendation */
|
|
59
|
+
recommendation: string;
|
|
60
|
+
/** Ratio to recent median (1 = normal, >1.5 = elevated) */
|
|
61
|
+
vsMedian: number;
|
|
62
|
+
/** Data source */
|
|
63
|
+
source: "blocknative" | "rpc";
|
|
64
|
+
/** Timestamp of the data */
|
|
65
|
+
timestamp: string;
|
|
66
|
+
}
|
|
@@ -14,14 +14,13 @@ import { AnySpendDepositHype } from "@b3dotfun/sdk/anyspend/react/components/Any
|
|
|
14
14
|
import { AnySpendDepositUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendDepositUpside";
|
|
15
15
|
import { AnySpendStakeUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpside";
|
|
16
16
|
import { AnySpendStakeUpsideExactIn } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpsideExactIn";
|
|
17
|
-
import { useGlobalAccount, useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
17
|
+
import { useB3Config, useGlobalAccount, useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
18
18
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
19
19
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
20
20
|
import { AnimatePresence, motion } from "framer-motion";
|
|
21
21
|
import { useEffect, useRef } from "react";
|
|
22
22
|
import { useSetActiveWallet } from "thirdweb/react";
|
|
23
23
|
import { AvatarEditor } from "./AvatarEditor/AvatarEditor";
|
|
24
|
-
import { useB3 } from "./B3Provider/useB3";
|
|
25
24
|
import { Deposit } from "./Deposit/Deposit";
|
|
26
25
|
import { LinkAccount } from "./LinkAccount/LinkAccount";
|
|
27
26
|
import { LinkNewAccount } from "./LinkAccount/LinkNewAccount";
|
|
@@ -30,8 +29,8 @@ import NotificationsContent from "./ManageAccount/NotificationsContent";
|
|
|
30
29
|
import { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
31
30
|
import { Send } from "./Send/Send";
|
|
32
31
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
33
|
-
import { TurnkeyAuthModal } from "./TurnkeyAuthModal";
|
|
34
32
|
import { ToastContainer, useToastContext } from "./Toast/index";
|
|
33
|
+
import { TurnkeyAuthModal } from "./TurnkeyAuthModal";
|
|
35
34
|
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./ui/dialog";
|
|
36
35
|
import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from "./ui/drawer";
|
|
37
36
|
|
|
@@ -42,7 +41,7 @@ export function B3DynamicModal() {
|
|
|
42
41
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
43
42
|
const contentType = useModalStore(state => state.contentType);
|
|
44
43
|
const navigateBack = useModalStore(state => state.navigateBack);
|
|
45
|
-
const { theme } =
|
|
44
|
+
const { theme } = useB3Config();
|
|
46
45
|
const isMobile = useIsMobile();
|
|
47
46
|
const prevIsOpenRef = useRef(isOpen);
|
|
48
47
|
const { wallet } = useGlobalAccount();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useAuthentication } from "../../hooks";
|
|
2
|
+
import { useAutoSelectWallet } from "../../hooks/useAutoSelectWallet";
|
|
3
|
+
|
|
4
|
+
const AuthenticationProvider = ({
|
|
5
|
+
partnerId,
|
|
6
|
+
automaticallySetFirstEoa,
|
|
7
|
+
}: {
|
|
8
|
+
partnerId: string;
|
|
9
|
+
automaticallySetFirstEoa: boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
useAuthentication(partnerId);
|
|
12
|
+
useAutoSelectWallet({
|
|
13
|
+
enabled: automaticallySetFirstEoa,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default AuthenticationProvider;
|