@b3dotfun/sdk 0.1.66 → 0.1.68
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/react/components/AnySpend.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +40 -11
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- 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 +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +16 -14
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +40 -10
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +5 -4
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/checkout/AddressForm.js +14 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +158 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +61 -0
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.js +20 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.js +27 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormField.js +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.js +75 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutLayout.js +13 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutOrderStatus.js +65 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +64 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +31 -0
- package/dist/cjs/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/checkout/CoinbaseCheckoutPanel.js +170 -0
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +324 -0
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.js +62 -0
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +269 -0
- package/dist/cjs/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/checkout/PoweredByBranding.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.js +20 -0
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +19 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +93 -19
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -4
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +6 -11
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +5 -1
- package/dist/cjs/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/cjs/anyspend/react/components/context/AnySpendCustomizationContext.js +92 -0
- package/dist/cjs/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/cjs/anyspend/react/components/icons/AnimatedCheckmark.js +71 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +8 -1
- package/dist/cjs/anyspend/react/components/index.js +10 -1
- package/dist/cjs/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/cjs/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/cjs/anyspend/react/components/types/customization.js +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +3 -2
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -0
- package/dist/cjs/anyspend/services/anyspend.js +17 -2
- package/dist/cjs/anyspend/types/forms.d.ts +92 -0
- package/dist/cjs/anyspend/types/forms.js +8 -0
- package/dist/cjs/anyspend/utils/format.js +12 -3
- package/dist/cjs/app.shared.js +8 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +9 -3
- package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/cjs/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ui/dialog.js +2 -2
- package/dist/cjs/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/ui/drawer.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +3 -3
- package/dist/cjs/shared/utils/number.d.ts +5 -0
- package/dist/cjs/shared/utils/number.js +13 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +41 -12
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- 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 +9 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +16 -14
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +42 -12
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +5 -4
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/esm/anyspend/react/components/checkout/AddressForm.js +11 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +155 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +58 -0
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/esm/anyspend/react/components/checkout/CartSummary.js +17 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.js +24 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormField.js +28 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.js +72 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutLayout.js +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutOrderStatus.js +62 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +61 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +28 -0
- package/dist/esm/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/esm/anyspend/react/components/checkout/CoinbaseCheckoutPanel.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +321 -0
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.js +59 -0
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +266 -0
- package/dist/esm/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/esm/anyspend/react/components/checkout/PoweredByBranding.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.js +17 -0
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +19 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -4
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +96 -22
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +4 -4
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/esm/anyspend/react/components/common/StepProgress.js +6 -11
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +7 -3
- package/dist/esm/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/esm/anyspend/react/components/context/AnySpendCustomizationContext.js +88 -0
- package/dist/esm/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/esm/anyspend/react/components/icons/AnimatedCheckmark.js +68 -0
- package/dist/esm/anyspend/react/components/index.d.ts +8 -1
- package/dist/esm/anyspend/react/components/index.js +5 -0
- package/dist/esm/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/esm/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/esm/anyspend/react/components/types/customization.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +3 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -0
- package/dist/esm/anyspend/services/anyspend.js +17 -2
- package/dist/esm/anyspend/types/forms.d.ts +92 -0
- package/dist/esm/anyspend/types/forms.js +7 -0
- package/dist/esm/anyspend/utils/format.js +12 -3
- package/dist/esm/app.shared.js +8 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +9 -3
- package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/esm/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/esm/global-account/react/components/ui/dialog.js +2 -2
- package/dist/esm/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/esm/global-account/react/components/ui/drawer.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/esm/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +3 -3
- package/dist/esm/shared/utils/number.d.ts +5 -0
- package/dist/esm/shared/utils/number.js +12 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +6 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +11 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AddressForm.d.ts +9 -0
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +117 -0
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +81 -0
- package/dist/types/anyspend/react/components/checkout/CartItemRow.d.ts +8 -0
- package/dist/types/anyspend/react/components/checkout/CartSummary.d.ts +30 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +32 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutFormField.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +39 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutLayout.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutOrderStatus.d.ts +28 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +31 -0
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +10 -0
- package/dist/types/anyspend/react/components/checkout/CoinbaseCheckoutPanel.d.ts +20 -0
- package/dist/types/anyspend/react/components/checkout/CryptoPayPanel.d.ts +23 -0
- package/dist/types/anyspend/react/components/checkout/DiscountCodeInput.d.ts +12 -0
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +20 -0
- package/dist/types/anyspend/react/components/checkout/PoweredByBranding.d.ts +8 -0
- package/dist/types/anyspend/react/components/checkout/ShippingSelector.d.ts +11 -0
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +5 -1
- package/dist/types/anyspend/react/components/context/AnySpendCustomizationContext.d.ts +16 -0
- package/dist/types/anyspend/react/components/icons/AnimatedCheckmark.d.ts +23 -0
- package/dist/types/anyspend/react/components/index.d.ts +8 -1
- package/dist/types/anyspend/react/components/types/classes.d.ts +50 -0
- package/dist/types/anyspend/react/components/types/customization.d.ts +75 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +8 -2
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +8 -2
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +15 -3
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +9 -2
- package/dist/types/anyspend/services/anyspend.d.ts +1 -0
- package/dist/types/anyspend/types/forms.d.ts +92 -0
- package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/command.d.ts +7 -7
- package/dist/types/global-account/react/components/ui/dialog.d.ts +2 -0
- package/dist/types/global-account/react/components/ui/drawer.d.ts +3 -1
- package/dist/types/global-account/react/hooks/useAuth.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +4 -4
- package/dist/types/global-account/react/hooks/useUser.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +53 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +3 -3
- package/dist/types/shared/utils/number.d.ts +5 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +84 -37
- package/src/anyspend/react/components/AnySpendBondKit.tsx +12 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +14 -0
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +10 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +38 -20
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +82 -35
- package/src/anyspend/react/components/AnySpendDeposit.tsx +24 -2
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +14 -0
- package/src/anyspend/react/components/AnySpendNFT.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +14 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +14 -0
- package/src/anyspend/react/components/AnySpendTournament.tsx +19 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +14 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +10 -0
- package/src/anyspend/react/components/checkout/AddressForm.tsx +98 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +398 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +221 -0
- package/src/anyspend/react/components/checkout/CartItemRow.tsx +58 -0
- package/src/anyspend/react/components/checkout/CartSummary.tsx +158 -0
- package/src/anyspend/react/components/checkout/CheckoutCartPanel.tsx +98 -0
- package/src/anyspend/react/components/checkout/CheckoutFormField.tsx +129 -0
- package/src/anyspend/react/components/checkout/CheckoutFormPanel.tsx +241 -0
- package/src/anyspend/react/components/checkout/CheckoutLayout.tsx +52 -0
- package/src/anyspend/react/components/checkout/CheckoutOrderStatus.tsx +224 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +341 -0
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +110 -0
- package/src/anyspend/react/components/checkout/CoinbaseCheckoutPanel.tsx +279 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +630 -0
- package/src/anyspend/react/components/checkout/DiscountCodeInput.tsx +127 -0
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +612 -0
- package/src/anyspend/react/components/checkout/PoweredByBranding.tsx +42 -0
- package/src/anyspend/react/components/checkout/ShippingSelector.tsx +73 -0
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +29 -7
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +5 -5
- package/src/anyspend/react/components/common/OrderStatus.tsx +140 -34
- package/src/anyspend/react/components/common/PanelOnramp.tsx +9 -9
- package/src/anyspend/react/components/common/PaySection.tsx +1 -1
- package/src/anyspend/react/components/common/StepProgress.tsx +40 -52
- package/src/anyspend/react/components/common/TokenBalance.tsx +0 -12
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +1 -9
- package/src/anyspend/react/components/common/TransferResultScreen.tsx +19 -11
- package/src/anyspend/react/components/context/AnySpendCustomizationContext.tsx +124 -0
- package/src/anyspend/react/components/icons/AnimatedCheckmark.tsx +119 -0
- package/src/anyspend/react/components/index.ts +33 -0
- package/src/anyspend/react/components/types/classes.ts +70 -0
- package/src/anyspend/react/components/types/customization.ts +99 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +3 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +3 -2
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +5 -1
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +5 -2
- package/src/anyspend/services/anyspend.ts +19 -2
- package/src/anyspend/types/forms.ts +97 -0
- package/src/anyspend/utils/format.ts +12 -3
- package/src/app.shared.ts +11 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +13 -4
- package/src/global-account/react/components/ui/dialog.tsx +17 -8
- package/src/global-account/react/components/ui/drawer.tsx +2 -2
- package/src/global-account/react/stores/useModalStore.ts +52 -1
- package/src/shared/utils/number.ts +12 -0
- package/src/styles/index.css +48 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
5
|
+
import type {
|
|
6
|
+
CheckoutFormSchema,
|
|
7
|
+
CheckoutFormComponentProps,
|
|
8
|
+
AddressData,
|
|
9
|
+
ShippingOption,
|
|
10
|
+
DiscountResult,
|
|
11
|
+
} from "../../../types/forms";
|
|
12
|
+
import { CheckoutFormFieldComponent } from "./CheckoutFormField";
|
|
13
|
+
import { AddressForm } from "./AddressForm";
|
|
14
|
+
import { ShippingSelector } from "./ShippingSelector";
|
|
15
|
+
import { DiscountCodeInput } from "./DiscountCodeInput";
|
|
16
|
+
import type { AnySpendCheckoutClasses } from "../types/classes";
|
|
17
|
+
|
|
18
|
+
interface CheckoutFormPanelProps {
|
|
19
|
+
/** JSON form definition */
|
|
20
|
+
formSchema?: CheckoutFormSchema | null;
|
|
21
|
+
/** Custom React component to render instead of schema-based form */
|
|
22
|
+
formComponent?: React.ComponentType<CheckoutFormComponentProps>;
|
|
23
|
+
/** Shipping options */
|
|
24
|
+
shippingOptions?: ShippingOption[] | null;
|
|
25
|
+
/** Whether to collect a shipping address */
|
|
26
|
+
collectShippingAddress?: boolean;
|
|
27
|
+
/** Enable discount code input */
|
|
28
|
+
enableDiscountCode?: boolean;
|
|
29
|
+
/** Validate a discount code */
|
|
30
|
+
validateDiscount?: (code: string) => Promise<DiscountResult>;
|
|
31
|
+
/** Token info for display */
|
|
32
|
+
tokenSymbol?: string;
|
|
33
|
+
tokenDecimals?: number;
|
|
34
|
+
/** CSS class overrides */
|
|
35
|
+
classes?: AnySpendCheckoutClasses;
|
|
36
|
+
/** Current form data (lifted state) */
|
|
37
|
+
formData: Record<string, unknown>;
|
|
38
|
+
/** Update form data */
|
|
39
|
+
onFormDataChange: (data: Record<string, unknown>) => void;
|
|
40
|
+
/** Shipping selection */
|
|
41
|
+
selectedShipping: ShippingOption | null;
|
|
42
|
+
onShippingChange: (option: ShippingOption) => void;
|
|
43
|
+
/** Discount state */
|
|
44
|
+
appliedDiscount: DiscountResult | null;
|
|
45
|
+
onDiscountApplied: (result: DiscountResult) => void;
|
|
46
|
+
onDiscountRemoved: () => void;
|
|
47
|
+
/** Shipping address */
|
|
48
|
+
shippingAddress: AddressData;
|
|
49
|
+
onShippingAddressChange: (address: AddressData) => void;
|
|
50
|
+
/** Slot overrides */
|
|
51
|
+
checkoutFormSlot?: (props: CheckoutFormComponentProps) => React.ReactNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const emptyAddress: AddressData = { street: "", city: "", state: "", zip: "", country: "" };
|
|
55
|
+
|
|
56
|
+
export function CheckoutFormPanel({
|
|
57
|
+
formSchema,
|
|
58
|
+
formComponent: FormComponent,
|
|
59
|
+
shippingOptions,
|
|
60
|
+
collectShippingAddress,
|
|
61
|
+
enableDiscountCode,
|
|
62
|
+
validateDiscount,
|
|
63
|
+
tokenSymbol,
|
|
64
|
+
tokenDecimals,
|
|
65
|
+
classes,
|
|
66
|
+
formData,
|
|
67
|
+
onFormDataChange,
|
|
68
|
+
selectedShipping,
|
|
69
|
+
onShippingChange,
|
|
70
|
+
appliedDiscount,
|
|
71
|
+
onDiscountApplied,
|
|
72
|
+
onDiscountRemoved,
|
|
73
|
+
shippingAddress,
|
|
74
|
+
onShippingAddressChange,
|
|
75
|
+
checkoutFormSlot,
|
|
76
|
+
}: CheckoutFormPanelProps) {
|
|
77
|
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
78
|
+
|
|
79
|
+
const hasFormFields = formSchema && formSchema.fields.length > 0;
|
|
80
|
+
const hasShipping = shippingOptions && shippingOptions.length > 0;
|
|
81
|
+
const hasAnyContent =
|
|
82
|
+
hasFormFields || FormComponent || checkoutFormSlot || hasShipping || collectShippingAddress || enableDiscountCode;
|
|
83
|
+
|
|
84
|
+
// All hooks must be called before any early returns
|
|
85
|
+
const formDataRef = useRef(formData);
|
|
86
|
+
formDataRef.current = formData;
|
|
87
|
+
|
|
88
|
+
const handleFieldChange = useCallback(
|
|
89
|
+
(id: string, value: unknown) => {
|
|
90
|
+
onFormDataChange({ ...formDataRef.current, [id]: value });
|
|
91
|
+
setErrors(prev => {
|
|
92
|
+
if (!prev[id]) return prev;
|
|
93
|
+
const next = { ...prev };
|
|
94
|
+
delete next[id];
|
|
95
|
+
return next;
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
[onFormDataChange],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const handleFormSubmit = useCallback(
|
|
102
|
+
(data: Record<string, unknown>) => {
|
|
103
|
+
onFormDataChange(data);
|
|
104
|
+
},
|
|
105
|
+
[onFormDataChange],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const handleValidationChange = useCallback((_isValid: boolean) => {
|
|
109
|
+
// Validation is handled internally via errors state
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
const handleDiscountApply = useCallback(
|
|
113
|
+
async (code: string): Promise<DiscountResult> => {
|
|
114
|
+
if (!validateDiscount) {
|
|
115
|
+
return { valid: false, error: "Discount validation not available" };
|
|
116
|
+
}
|
|
117
|
+
const result = await validateDiscount(code);
|
|
118
|
+
if (result.valid) {
|
|
119
|
+
onDiscountApplied(result);
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
},
|
|
123
|
+
[validateDiscount, onDiscountApplied],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Separate address fields from regular fields
|
|
127
|
+
const { regularFields, addressFields } = useMemo(() => {
|
|
128
|
+
if (!formSchema) return { regularFields: [], addressFields: [] };
|
|
129
|
+
return {
|
|
130
|
+
regularFields: formSchema.fields.filter(f => f.type !== "address"),
|
|
131
|
+
addressFields: formSchema.fields.filter(f => f.type === "address"),
|
|
132
|
+
};
|
|
133
|
+
}, [formSchema]);
|
|
134
|
+
|
|
135
|
+
if (!hasAnyContent) return null;
|
|
136
|
+
|
|
137
|
+
// Shared shipping + discount section
|
|
138
|
+
const shippingAndDiscount = (
|
|
139
|
+
<>
|
|
140
|
+
{hasShipping && shippingOptions && (
|
|
141
|
+
<ShippingSelector
|
|
142
|
+
options={shippingOptions}
|
|
143
|
+
selectedId={selectedShipping?.id || null}
|
|
144
|
+
onSelect={onShippingChange}
|
|
145
|
+
tokenSymbol={tokenSymbol}
|
|
146
|
+
tokenDecimals={tokenDecimals}
|
|
147
|
+
/>
|
|
148
|
+
)}
|
|
149
|
+
{enableDiscountCode && validateDiscount && (
|
|
150
|
+
<DiscountCodeInput
|
|
151
|
+
onApply={handleDiscountApply}
|
|
152
|
+
appliedDiscount={appliedDiscount}
|
|
153
|
+
onRemove={onDiscountRemoved}
|
|
154
|
+
tokenSymbol={tokenSymbol}
|
|
155
|
+
tokenDecimals={tokenDecimals}
|
|
156
|
+
/>
|
|
157
|
+
)}
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// Render custom form slot if provided
|
|
162
|
+
if (checkoutFormSlot) {
|
|
163
|
+
return (
|
|
164
|
+
<div className={cn("anyspend-form-panel space-y-4", classes?.formPanel)}>
|
|
165
|
+
<div className="anyspend-form-slot">
|
|
166
|
+
{checkoutFormSlot({
|
|
167
|
+
onSubmit: handleFormSubmit,
|
|
168
|
+
onValidationChange: handleValidationChange,
|
|
169
|
+
formData,
|
|
170
|
+
setFormData: onFormDataChange,
|
|
171
|
+
})}
|
|
172
|
+
</div>
|
|
173
|
+
{shippingAndDiscount}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Render custom form component if provided
|
|
179
|
+
if (FormComponent) {
|
|
180
|
+
return (
|
|
181
|
+
<div className={cn("anyspend-form-panel space-y-4", classes?.formPanel)}>
|
|
182
|
+
<div className="anyspend-form-component">
|
|
183
|
+
<FormComponent
|
|
184
|
+
onSubmit={handleFormSubmit}
|
|
185
|
+
onValidationChange={handleValidationChange}
|
|
186
|
+
formData={formData}
|
|
187
|
+
setFormData={onFormDataChange}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
{shippingAndDiscount}
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Schema-based form rendering
|
|
196
|
+
return (
|
|
197
|
+
<div className={cn("anyspend-form-panel space-y-4", classes?.formPanel)}>
|
|
198
|
+
{/* Regular form fields */}
|
|
199
|
+
{regularFields.length > 0 && (
|
|
200
|
+
<div className="anyspend-form-fields space-y-3">
|
|
201
|
+
{regularFields.map(field => (
|
|
202
|
+
<CheckoutFormFieldComponent
|
|
203
|
+
key={field.id}
|
|
204
|
+
field={field}
|
|
205
|
+
value={formData[field.id]}
|
|
206
|
+
onChange={handleFieldChange}
|
|
207
|
+
error={errors[field.id]}
|
|
208
|
+
/>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
212
|
+
|
|
213
|
+
{/* Address fields from schema */}
|
|
214
|
+
{addressFields.map(field => (
|
|
215
|
+
<div key={field.id} className="anyspend-form-address space-y-2">
|
|
216
|
+
<h3 className="anyspend-form-address-title text-sm font-semibold text-gray-900 dark:text-gray-100">
|
|
217
|
+
{field.label}
|
|
218
|
+
</h3>
|
|
219
|
+
<AddressForm
|
|
220
|
+
value={(formData[field.id] as AddressData) || emptyAddress}
|
|
221
|
+
onChange={addr => handleFieldChange(field.id, addr)}
|
|
222
|
+
required={field.required}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
))}
|
|
226
|
+
|
|
227
|
+
{/* Shipping address (from collectShippingAddress prop, not schema) */}
|
|
228
|
+
{collectShippingAddress && addressFields.length === 0 && (
|
|
229
|
+
<div className="anyspend-shipping-address space-y-2">
|
|
230
|
+
<h3 className="anyspend-shipping-address-title text-sm font-semibold text-gray-900 dark:text-gray-100">
|
|
231
|
+
Shipping Address
|
|
232
|
+
</h3>
|
|
233
|
+
<AddressForm value={shippingAddress} onChange={onShippingAddressChange} required />
|
|
234
|
+
</div>
|
|
235
|
+
)}
|
|
236
|
+
|
|
237
|
+
{/* Shipping options + Discount code */}
|
|
238
|
+
{shippingAndDiscount}
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
6
|
+
|
|
7
|
+
interface CheckoutLayoutProps {
|
|
8
|
+
mode: "page" | "embedded";
|
|
9
|
+
paymentPanel: ReactNode;
|
|
10
|
+
cartPanel: ReactNode;
|
|
11
|
+
classes?: AnySpendCheckoutClasses;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function CheckoutLayout({ mode, paymentPanel, cartPanel, classes }: CheckoutLayoutProps) {
|
|
15
|
+
const rightColumnWidth = mode === "page" ? 380 : 340;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={cn("anyspend-checkout mx-auto w-full", classes?.root)}
|
|
20
|
+
style={
|
|
21
|
+
{
|
|
22
|
+
...(mode === "page" ? { maxWidth: 1100, padding: "2rem 1rem" } : undefined),
|
|
23
|
+
"--anyspend-cart-width": `${rightColumnWidth}px`,
|
|
24
|
+
} as React.CSSProperties
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
<div className={cn("anyspend-checkout-grid", classes?.layout)}>
|
|
28
|
+
{/* LEFT: Payment Methods (appears second on mobile, first on desktop) */}
|
|
29
|
+
<div
|
|
30
|
+
className={cn(
|
|
31
|
+
"anyspend-payment-col order-2",
|
|
32
|
+
"rounded-2xl border border-gray-200 bg-white p-6 shadow-sm dark:border-neutral-700 dark:bg-neutral-900",
|
|
33
|
+
classes?.paymentColumn,
|
|
34
|
+
)}
|
|
35
|
+
>
|
|
36
|
+
{paymentPanel}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{/* RIGHT: Cart / Invoice (appears first on mobile, second on desktop) */}
|
|
40
|
+
<div
|
|
41
|
+
className={cn(
|
|
42
|
+
"anyspend-cart-col order-1",
|
|
43
|
+
"rounded-2xl border border-gray-200 bg-gray-50 p-6 dark:border-neutral-700 dark:bg-neutral-800/50",
|
|
44
|
+
classes?.cartColumn,
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
{cartPanel}
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { getErrorDisplay, getExplorerTxUrl, getStatusDisplay } from "@b3dotfun/sdk/anyspend";
|
|
4
|
+
import { useAnyspendOrderAndTransactions } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendOrderAndTransactions";
|
|
5
|
+
import { useOnOrderSuccess } from "@b3dotfun/sdk/anyspend/react/hooks/useOnOrderSuccess";
|
|
6
|
+
import { TextShimmer } from "@b3dotfun/sdk/global-account/react";
|
|
7
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
8
|
+
import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
|
|
9
|
+
import { ExternalLink, Loader2, RefreshCcw } from "lucide-react";
|
|
10
|
+
import { motion } from "motion/react";
|
|
11
|
+
import { useEffect, useRef } from "react";
|
|
12
|
+
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext";
|
|
13
|
+
import { OrderStatus } from "../common/OrderStatus";
|
|
14
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
15
|
+
|
|
16
|
+
interface CheckoutOrderStatusProps {
|
|
17
|
+
/** The order ID to track */
|
|
18
|
+
orderId: string;
|
|
19
|
+
/** Theme color (hex) */
|
|
20
|
+
themeColor?: string;
|
|
21
|
+
/** Return URL for the terminal success state */
|
|
22
|
+
returnUrl?: string;
|
|
23
|
+
/** Label for the return button */
|
|
24
|
+
returnLabel?: string;
|
|
25
|
+
/** Called when the order reaches "executed" */
|
|
26
|
+
onSuccess?: (result: { txHash?: string; orderId?: string }) => void;
|
|
27
|
+
/** Called when the order reaches a failure/expired/refunded terminal state */
|
|
28
|
+
onError?: (error: Error) => void;
|
|
29
|
+
/** Called when the user clicks "Try again" on failure */
|
|
30
|
+
onRetry?: () => void;
|
|
31
|
+
/** Show the points row in the order status summary. Defaults to false. */
|
|
32
|
+
showPoints?: boolean;
|
|
33
|
+
/** Show the order ID row in the order status summary. Defaults to false. */
|
|
34
|
+
showOrderId?: boolean;
|
|
35
|
+
/** Custom class names */
|
|
36
|
+
classes?: AnySpendCheckoutClasses;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function CheckoutOrderStatus({
|
|
40
|
+
orderId,
|
|
41
|
+
themeColor,
|
|
42
|
+
returnUrl,
|
|
43
|
+
returnLabel,
|
|
44
|
+
onSuccess,
|
|
45
|
+
onError,
|
|
46
|
+
onRetry,
|
|
47
|
+
showPoints = false,
|
|
48
|
+
showOrderId = false,
|
|
49
|
+
classes,
|
|
50
|
+
}: CheckoutOrderStatusProps) {
|
|
51
|
+
// Stable refs for callback props to avoid re-triggering effects
|
|
52
|
+
const onErrorRef = useRef(onError);
|
|
53
|
+
onErrorRef.current = onError;
|
|
54
|
+
|
|
55
|
+
const { orderAndTransactions, isLoadingOrderAndTransactions } = useAnyspendOrderAndTransactions(orderId);
|
|
56
|
+
const order = orderAndTransactions?.data?.order;
|
|
57
|
+
const executeTx = orderAndTransactions?.data?.executeTx;
|
|
58
|
+
const points = orderAndTransactions?.data?.points;
|
|
59
|
+
|
|
60
|
+
const { content } = useAnySpendCustomization();
|
|
61
|
+
|
|
62
|
+
// Fire onSuccess when order reaches "executed"
|
|
63
|
+
useOnOrderSuccess({
|
|
64
|
+
orderData: orderAndTransactions,
|
|
65
|
+
orderId,
|
|
66
|
+
onSuccess: (txHash?: string) => onSuccess?.({ orderId, txHash }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Fire onError once for terminal failure states
|
|
70
|
+
const onErrorCalled = useRef(false);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!order || onErrorCalled.current) return;
|
|
73
|
+
if (order.status === "failure" || order.status === "expired" || order.status === "refunded") {
|
|
74
|
+
const { description } = getStatusDisplay(order);
|
|
75
|
+
onErrorRef.current?.(new Error(description || `Order ${order.status}`));
|
|
76
|
+
onErrorCalled.current = true;
|
|
77
|
+
}
|
|
78
|
+
}, [order]);
|
|
79
|
+
|
|
80
|
+
// Reset error flag if orderId changes
|
|
81
|
+
const prevOrderId = useRef(orderId);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (prevOrderId.current !== orderId) {
|
|
84
|
+
onErrorCalled.current = false;
|
|
85
|
+
prevOrderId.current = orderId;
|
|
86
|
+
}
|
|
87
|
+
}, [orderId]);
|
|
88
|
+
|
|
89
|
+
// Clear persisted orderId when order reaches a terminal state
|
|
90
|
+
const orderStatus = order?.status;
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (orderStatus && ["executed", "failure", "expired", "refunded"].includes(orderStatus)) {
|
|
93
|
+
sessionStorage.removeItem("anyspend_checkout_orderId");
|
|
94
|
+
}
|
|
95
|
+
}, [orderStatus]);
|
|
96
|
+
|
|
97
|
+
// Loading state
|
|
98
|
+
if (isLoadingOrderAndTransactions || !order) {
|
|
99
|
+
return (
|
|
100
|
+
<div className={cn("flex flex-col items-center gap-3 py-12", classes?.orderStatusPanel)}>
|
|
101
|
+
<Loader2 className="h-6 w-6 animate-spin text-gray-400" />
|
|
102
|
+
<TextShimmer duration={1.5} className="text-sm">
|
|
103
|
+
Loading order status...
|
|
104
|
+
</TextShimmer>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const isExecuted = order.status === "executed";
|
|
110
|
+
const isRefunding = order.status === "refunding";
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<motion.div
|
|
114
|
+
initial={{ opacity: 0, y: 10 }}
|
|
115
|
+
animate={{ opacity: 1, y: 0 }}
|
|
116
|
+
transition={{ duration: 0.3, ease: "easeOut" }}
|
|
117
|
+
className={cn("anyspend-checkout-order-status flex flex-col items-center gap-5 py-6", classes?.orderStatusPanel)}
|
|
118
|
+
>
|
|
119
|
+
{/* Step progress / terminal state icon */}
|
|
120
|
+
<OrderStatus order={order} />
|
|
121
|
+
|
|
122
|
+
{/* Checkout-relevant order summary: points + order ID (opt-in) */}
|
|
123
|
+
{(showPoints || showOrderId) && (
|
|
124
|
+
<motion.div
|
|
125
|
+
initial={{ opacity: 0, y: 8 }}
|
|
126
|
+
animate={{ opacity: 1, y: 0 }}
|
|
127
|
+
transition={{ duration: 0.25, delay: 0.15 }}
|
|
128
|
+
className="bg-as-surface-secondary border-as-border-secondary w-full rounded-xl border px-4 py-3"
|
|
129
|
+
>
|
|
130
|
+
<div className="flex flex-col gap-2 text-sm">
|
|
131
|
+
{showPoints && points != null && points > 0 && (
|
|
132
|
+
<>
|
|
133
|
+
<div className="flex w-full justify-between">
|
|
134
|
+
<span className="text-as-tertiary">Points</span>
|
|
135
|
+
<span className="text-as-brand font-semibold">+{formatNumber(points)} pts</span>
|
|
136
|
+
</div>
|
|
137
|
+
{showOrderId && <div className="divider w-full" />}
|
|
138
|
+
</>
|
|
139
|
+
)}
|
|
140
|
+
{showOrderId && (
|
|
141
|
+
<div className="flex w-full items-center justify-between gap-3">
|
|
142
|
+
<span className="text-as-tertiary shrink-0">Order ID</span>
|
|
143
|
+
<span className="text-as-primary min-w-0 overflow-hidden text-ellipsis whitespace-nowrap">
|
|
144
|
+
{order.id}
|
|
145
|
+
</span>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
</motion.div>
|
|
150
|
+
)}
|
|
151
|
+
|
|
152
|
+
{/* Transaction link for executed orders */}
|
|
153
|
+
{isExecuted && executeTx && (
|
|
154
|
+
<motion.a
|
|
155
|
+
initial={{ opacity: 0 }}
|
|
156
|
+
animate={{ opacity: 1 }}
|
|
157
|
+
transition={{ duration: 0.3, delay: 0.3, ease: "easeOut" }}
|
|
158
|
+
href={getExplorerTxUrl(order.dstChain, executeTx.txHash)}
|
|
159
|
+
target="_blank"
|
|
160
|
+
rel="noopener noreferrer"
|
|
161
|
+
className={cn(
|
|
162
|
+
"flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400",
|
|
163
|
+
classes?.transactionLink,
|
|
164
|
+
)}
|
|
165
|
+
>
|
|
166
|
+
View Transaction
|
|
167
|
+
<ExternalLink className="h-3.5 w-3.5" />
|
|
168
|
+
</motion.a>
|
|
169
|
+
)}
|
|
170
|
+
|
|
171
|
+
{/* Error details for failure */}
|
|
172
|
+
{order.status === "failure" && order.errorDetails && (
|
|
173
|
+
<motion.p
|
|
174
|
+
initial={{ opacity: 0 }}
|
|
175
|
+
animate={{ opacity: 1 }}
|
|
176
|
+
transition={{ duration: 0.2, delay: 0.2 }}
|
|
177
|
+
className="max-w-[40ch] text-center text-sm text-red-500 dark:text-red-400"
|
|
178
|
+
>
|
|
179
|
+
{getErrorDisplay(order.errorDetails)}
|
|
180
|
+
</motion.p>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
{/* Retry button for failure/expired */}
|
|
184
|
+
{(order.status === "failure" || order.status === "expired") && onRetry && (
|
|
185
|
+
<motion.button
|
|
186
|
+
initial={{ opacity: 0, y: 6 }}
|
|
187
|
+
animate={{ opacity: 1, y: 0 }}
|
|
188
|
+
transition={{ duration: 0.25, delay: 0.3 }}
|
|
189
|
+
onClick={onRetry}
|
|
190
|
+
className={cn(
|
|
191
|
+
"flex items-center gap-2 rounded-xl px-6 py-3 text-sm font-medium transition-colors",
|
|
192
|
+
"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-neutral-800 dark:text-gray-300 dark:hover:bg-neutral-700",
|
|
193
|
+
classes?.retryButton,
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
<RefreshCcw className="h-4 w-4" />
|
|
197
|
+
{content.retryButtonLabel || "Try Again"}
|
|
198
|
+
</motion.button>
|
|
199
|
+
)}
|
|
200
|
+
|
|
201
|
+
{/* Return button for success and refunded */}
|
|
202
|
+
{(isExecuted || order.status === "refunded") && returnUrl && (
|
|
203
|
+
<motion.a
|
|
204
|
+
initial={{ opacity: 0, y: 6 }}
|
|
205
|
+
animate={{ opacity: 1, y: 0 }}
|
|
206
|
+
transition={{ duration: 0.25, delay: 0.4 }}
|
|
207
|
+
href={returnUrl}
|
|
208
|
+
className={cn(
|
|
209
|
+
"inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors",
|
|
210
|
+
classes?.returnButton,
|
|
211
|
+
)}
|
|
212
|
+
style={{ backgroundColor: themeColor || "#111827", color: "#fff" }}
|
|
213
|
+
>
|
|
214
|
+
{content.returnButtonLabel || returnLabel || "Return to Store"}
|
|
215
|
+
</motion.a>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{/* Refunding message (transient state — no action needed) */}
|
|
219
|
+
{isRefunding && (
|
|
220
|
+
<p className="text-sm text-gray-500 dark:text-gray-400">Please wait while your funds are being returned.</p>
|
|
221
|
+
)}
|
|
222
|
+
</motion.div>
|
|
223
|
+
);
|
|
224
|
+
}
|