@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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CheckoutLayout = CheckoutLayout;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
|
+
function CheckoutLayout({ mode, paymentPanel, cartPanel, classes }) {
|
|
8
|
+
const rightColumnWidth = mode === "page" ? 380 : 340;
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-checkout mx-auto w-full", classes?.root), style: {
|
|
10
|
+
...(mode === "page" ? { maxWidth: 1100, padding: "2rem 1rem" } : undefined),
|
|
11
|
+
"--anyspend-cart-width": `${rightColumnWidth}px`,
|
|
12
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-checkout-grid", classes?.layout), children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-payment-col order-2", "rounded-2xl border border-gray-200 bg-white p-6 shadow-sm dark:border-neutral-700 dark:bg-neutral-900", classes?.paymentColumn), children: paymentPanel }), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("anyspend-cart-col order-1", "rounded-2xl border border-gray-200 bg-gray-50 p-6 dark:border-neutral-700 dark:bg-neutral-800/50", classes?.cartColumn), children: cartPanel })] }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CheckoutOrderStatusProps {
|
|
3
|
+
/** The order ID to track */
|
|
4
|
+
orderId: string;
|
|
5
|
+
/** Theme color (hex) */
|
|
6
|
+
themeColor?: string;
|
|
7
|
+
/** Return URL for the terminal success state */
|
|
8
|
+
returnUrl?: string;
|
|
9
|
+
/** Label for the return button */
|
|
10
|
+
returnLabel?: string;
|
|
11
|
+
/** Called when the order reaches "executed" */
|
|
12
|
+
onSuccess?: (result: {
|
|
13
|
+
txHash?: string;
|
|
14
|
+
orderId?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
/** Called when the order reaches a failure/expired/refunded terminal state */
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
/** Called when the user clicks "Try again" on failure */
|
|
19
|
+
onRetry?: () => void;
|
|
20
|
+
/** Show the points row in the order status summary. Defaults to false. */
|
|
21
|
+
showPoints?: boolean;
|
|
22
|
+
/** Show the order ID row in the order status summary. Defaults to false. */
|
|
23
|
+
showOrderId?: boolean;
|
|
24
|
+
/** Custom class names */
|
|
25
|
+
classes?: AnySpendCheckoutClasses;
|
|
26
|
+
}
|
|
27
|
+
export declare function CheckoutOrderStatus({ orderId, themeColor, returnUrl, returnLabel, onSuccess, onError, onRetry, showPoints, showOrderId, classes, }: CheckoutOrderStatusProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CheckoutOrderStatus = CheckoutOrderStatus;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const anyspend_1 = require("../../../../anyspend");
|
|
7
|
+
const useAnyspendOrderAndTransactions_1 = require("../../../../anyspend/react/hooks/useAnyspendOrderAndTransactions");
|
|
8
|
+
const useOnOrderSuccess_1 = require("../../../../anyspend/react/hooks/useOnOrderSuccess");
|
|
9
|
+
const react_1 = require("../../../../global-account/react");
|
|
10
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
11
|
+
const formatNumber_1 = require("../../../../shared/utils/formatNumber");
|
|
12
|
+
const lucide_react_1 = require("lucide-react");
|
|
13
|
+
const react_2 = require("motion/react");
|
|
14
|
+
const react_3 = require("react");
|
|
15
|
+
const AnySpendCustomizationContext_1 = require("../context/AnySpendCustomizationContext");
|
|
16
|
+
const OrderStatus_1 = require("../common/OrderStatus");
|
|
17
|
+
function CheckoutOrderStatus({ orderId, themeColor, returnUrl, returnLabel, onSuccess, onError, onRetry, showPoints = false, showOrderId = false, classes, }) {
|
|
18
|
+
// Stable refs for callback props to avoid re-triggering effects
|
|
19
|
+
const onErrorRef = (0, react_3.useRef)(onError);
|
|
20
|
+
onErrorRef.current = onError;
|
|
21
|
+
const { orderAndTransactions, isLoadingOrderAndTransactions } = (0, useAnyspendOrderAndTransactions_1.useAnyspendOrderAndTransactions)(orderId);
|
|
22
|
+
const order = orderAndTransactions?.data?.order;
|
|
23
|
+
const executeTx = orderAndTransactions?.data?.executeTx;
|
|
24
|
+
const points = orderAndTransactions?.data?.points;
|
|
25
|
+
const { content } = (0, AnySpendCustomizationContext_1.useAnySpendCustomization)();
|
|
26
|
+
// Fire onSuccess when order reaches "executed"
|
|
27
|
+
(0, useOnOrderSuccess_1.useOnOrderSuccess)({
|
|
28
|
+
orderData: orderAndTransactions,
|
|
29
|
+
orderId,
|
|
30
|
+
onSuccess: (txHash) => onSuccess?.({ orderId, txHash }),
|
|
31
|
+
});
|
|
32
|
+
// Fire onError once for terminal failure states
|
|
33
|
+
const onErrorCalled = (0, react_3.useRef)(false);
|
|
34
|
+
(0, react_3.useEffect)(() => {
|
|
35
|
+
if (!order || onErrorCalled.current)
|
|
36
|
+
return;
|
|
37
|
+
if (order.status === "failure" || order.status === "expired" || order.status === "refunded") {
|
|
38
|
+
const { description } = (0, anyspend_1.getStatusDisplay)(order);
|
|
39
|
+
onErrorRef.current?.(new Error(description || `Order ${order.status}`));
|
|
40
|
+
onErrorCalled.current = true;
|
|
41
|
+
}
|
|
42
|
+
}, [order]);
|
|
43
|
+
// Reset error flag if orderId changes
|
|
44
|
+
const prevOrderId = (0, react_3.useRef)(orderId);
|
|
45
|
+
(0, react_3.useEffect)(() => {
|
|
46
|
+
if (prevOrderId.current !== orderId) {
|
|
47
|
+
onErrorCalled.current = false;
|
|
48
|
+
prevOrderId.current = orderId;
|
|
49
|
+
}
|
|
50
|
+
}, [orderId]);
|
|
51
|
+
// Clear persisted orderId when order reaches a terminal state
|
|
52
|
+
const orderStatus = order?.status;
|
|
53
|
+
(0, react_3.useEffect)(() => {
|
|
54
|
+
if (orderStatus && ["executed", "failure", "expired", "refunded"].includes(orderStatus)) {
|
|
55
|
+
sessionStorage.removeItem("anyspend_checkout_orderId");
|
|
56
|
+
}
|
|
57
|
+
}, [orderStatus]);
|
|
58
|
+
// Loading state
|
|
59
|
+
if (isLoadingOrderAndTransactions || !order) {
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex flex-col items-center gap-3 py-12", classes?.orderStatusPanel), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-6 w-6 animate-spin text-gray-400" }), (0, jsx_runtime_1.jsx)(react_1.TextShimmer, { duration: 1.5, className: "text-sm", children: "Loading order status..." })] }));
|
|
61
|
+
}
|
|
62
|
+
const isExecuted = order.status === "executed";
|
|
63
|
+
const isRefunding = order.status === "refunding";
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, ease: "easeOut" }, className: (0, cn_1.cn)("anyspend-checkout-order-status flex flex-col items-center gap-5 py-6", classes?.orderStatusPanel), children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order }), (showPoints || showOrderId) && ((0, jsx_runtime_1.jsx)(react_2.motion.div, { initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.15 }, className: "bg-as-surface-secondary border-as-border-secondary w-full rounded-xl border px-4 py-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2 text-sm", children: [showPoints && points != null && points > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiary", children: "Points" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-brand font-semibold", children: ["+", (0, formatNumber_1.formatNumber)(points), " pts"] })] }), showOrderId && (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" })] })), showOrderId && ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiary shrink-0", children: "Order ID" }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary min-w-0 overflow-hidden text-ellipsis whitespace-nowrap", children: order.id })] }))] }) })), isExecuted && executeTx && ((0, jsx_runtime_1.jsxs)(react_2.motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.3, ease: "easeOut" }, href: (0, anyspend_1.getExplorerTxUrl)(order.dstChain, executeTx.txHash), target: "_blank", rel: "noopener noreferrer", className: (0, cn_1.cn)("flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", classes?.transactionLink), children: ["View Transaction", (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { className: "h-3.5 w-3.5" })] })), order.status === "failure" && order.errorDetails && ((0, jsx_runtime_1.jsx)(react_2.motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.2, delay: 0.2 }, className: "max-w-[40ch] text-center text-sm text-red-500 dark:text-red-400", children: (0, anyspend_1.getErrorDisplay)(order.errorDetails) })), (order.status === "failure" || order.status === "expired") && onRetry && ((0, jsx_runtime_1.jsxs)(react_2.motion.button, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.3 }, onClick: onRetry, className: (0, cn_1.cn)("flex items-center gap-2 rounded-xl px-6 py-3 text-sm font-medium transition-colors", "bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-neutral-800 dark:text-gray-300 dark:hover:bg-neutral-700", classes?.retryButton), children: [(0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "h-4 w-4" }), content.retryButtonLabel || "Try Again"] })), (isExecuted || order.status === "refunded") && returnUrl && ((0, jsx_runtime_1.jsx)(react_2.motion.a, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, delay: 0.4 }, href: returnUrl, className: (0, cn_1.cn)("inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: themeColor || "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" })), isRefunding && ((0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Please wait while your funds are being returned." }))] }));
|
|
65
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
export type PaymentMethod = "crypto" | "card" | "coinbase";
|
|
3
|
+
interface CheckoutPaymentPanelProps {
|
|
4
|
+
recipientAddress: string;
|
|
5
|
+
destinationTokenAddress: string;
|
|
6
|
+
destinationTokenChainId: number;
|
|
7
|
+
totalAmount: string;
|
|
8
|
+
buttonText?: string;
|
|
9
|
+
themeColor?: string;
|
|
10
|
+
returnUrl?: string;
|
|
11
|
+
returnLabel?: string;
|
|
12
|
+
onSuccess?: (result: {
|
|
13
|
+
txHash?: string;
|
|
14
|
+
orderId?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
callbackMetadata?: Record<string, unknown>;
|
|
18
|
+
classes?: AnySpendCheckoutClasses;
|
|
19
|
+
/** Which payment method to expand initially. Defaults to none (all collapsed). */
|
|
20
|
+
defaultPaymentMethod?: PaymentMethod;
|
|
21
|
+
/** Optional sender (payer) address — pre-fills token balances in the crypto panel */
|
|
22
|
+
senderAddress?: string;
|
|
23
|
+
/** Show the points row in the order status summary. Defaults to false. */
|
|
24
|
+
showPoints?: boolean;
|
|
25
|
+
/** Show the order ID row in the order status summary. Defaults to false. */
|
|
26
|
+
showOrderId?: boolean;
|
|
27
|
+
/** Whether the checkout form is valid. When false, payment methods are disabled. */
|
|
28
|
+
isFormValid?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid, }: CheckoutPaymentPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CheckoutPaymentPanel = CheckoutPaymentPanel;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
|
+
const lucide_react_1 = require("lucide-react");
|
|
8
|
+
const react_1 = require("motion/react");
|
|
9
|
+
const react_2 = require("react");
|
|
10
|
+
const CheckoutOrderStatus_1 = require("./CheckoutOrderStatus");
|
|
11
|
+
const CoinbaseCheckoutPanel_1 = require("./CoinbaseCheckoutPanel");
|
|
12
|
+
const CryptoPayPanel_1 = require("./CryptoPayPanel");
|
|
13
|
+
const FiatCheckoutPanel_1 = require("./FiatCheckoutPanel");
|
|
14
|
+
const SESSION_STORAGE_KEY = "anyspend_checkout_orderId";
|
|
15
|
+
function RadioCircle({ selected, themeColor }) {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2 transition-colors", selected ? "border-blue-600" : "border-gray-300 dark:border-neutral-600"), style: selected && themeColor ? { borderColor: themeColor } : undefined, children: selected && ((0, jsx_runtime_1.jsx)("div", { className: "h-2 w-2 rounded-full bg-blue-600", style: themeColor ? { backgroundColor: themeColor } : undefined })) }));
|
|
17
|
+
}
|
|
18
|
+
/** Card brand logos - all use consistent 32x20 viewBox */
|
|
19
|
+
function VisaLogo() {
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Visa", children: [(0, jsx_runtime_1.jsx)("rect", { width: "32", height: "20", rx: "3", fill: "#1A1F71" }), (0, jsx_runtime_1.jsx)("text", { x: "16", y: "13.5", textAnchor: "middle", fill: "white", fontSize: "9", fontWeight: "bold", fontFamily: "sans-serif", fontStyle: "italic", children: "VISA" })] }));
|
|
21
|
+
}
|
|
22
|
+
function MastercardLogo() {
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Mastercard", children: [(0, jsx_runtime_1.jsx)("rect", { width: "32", height: "20", rx: "3", fill: "#252525" }), (0, jsx_runtime_1.jsx)("circle", { cx: "12.5", cy: "10", r: "6", fill: "#EB001B" }), (0, jsx_runtime_1.jsx)("circle", { cx: "19.5", cy: "10", r: "6", fill: "#F79E1B" }), (0, jsx_runtime_1.jsx)("path", { d: "M16 5.6a6 6 0 0 1 0 8.8 6 6 0 0 1 0-8.8z", fill: "#FF5F00" })] }));
|
|
24
|
+
}
|
|
25
|
+
function AmexLogo() {
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 32 20", style: { width: 32, height: 20 }, "aria-label": "Amex", children: [(0, jsx_runtime_1.jsx)("rect", { width: "32", height: "20", rx: "3", fill: "#006FCF" }), (0, jsx_runtime_1.jsx)("text", { x: "16", y: "13", textAnchor: "middle", fill: "white", fontSize: "7", fontWeight: "bold", fontFamily: "sans-serif", children: "AMEX" })] }));
|
|
27
|
+
}
|
|
28
|
+
/** Coinbase mark */
|
|
29
|
+
function CoinbaseLogo() {
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", style: { width: 20, height: 20 }, "aria-label": "Coinbase", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "12", fill: "#0052FF" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 4.5a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15zm-1.8 4.8h3.6c.33 0 .6.27.6.6v4.2c0 .33-.27.6-.6.6h-3.6a.6.6 0 0 1-.6-.6V9.9c0-.33.27-.6.6-.6z", fill: "white" })] }));
|
|
31
|
+
}
|
|
32
|
+
function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, returnUrl, returnLabel, onSuccess, onError, callbackMetadata, classes, defaultPaymentMethod, senderAddress, showPoints, showOrderId, isFormValid = true, }) {
|
|
33
|
+
const [paymentMethod, setPaymentMethod] = (0, react_2.useState)(defaultPaymentMethod ?? null);
|
|
34
|
+
// Restore activeOrderId from sessionStorage (handles page refresh / Coinbase return)
|
|
35
|
+
const [activeOrderId, setActiveOrderId] = (0, react_2.useState)(() => {
|
|
36
|
+
if (typeof window !== "undefined") {
|
|
37
|
+
return sessionStorage.getItem(SESSION_STORAGE_KEY) || null;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
});
|
|
41
|
+
// Persist activeOrderId to sessionStorage
|
|
42
|
+
(0, react_2.useEffect)(() => {
|
|
43
|
+
if (activeOrderId) {
|
|
44
|
+
sessionStorage.setItem(SESSION_STORAGE_KEY, activeOrderId);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
sessionStorage.removeItem(SESSION_STORAGE_KEY);
|
|
48
|
+
}
|
|
49
|
+
}, [activeOrderId]);
|
|
50
|
+
const handleOrderCreated = (0, react_2.useCallback)((orderId) => {
|
|
51
|
+
setActiveOrderId(orderId);
|
|
52
|
+
}, []);
|
|
53
|
+
const handleRetry = (0, react_2.useCallback)(() => {
|
|
54
|
+
setActiveOrderId(null);
|
|
55
|
+
}, []);
|
|
56
|
+
if (activeOrderId) {
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(CheckoutOrderStatus_1.CheckoutOrderStatus, { orderId: activeOrderId, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, onRetry: handleRetry, showPoints: showPoints, showOrderId: showOrderId, classes: classes }));
|
|
58
|
+
}
|
|
59
|
+
const accordionButtonClass = (active) => (0, cn_1.cn)("anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors", active
|
|
60
|
+
? "bg-white dark:bg-neutral-900"
|
|
61
|
+
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
62
|
+
const expandedPanelClass = (0, cn_1.cn)("anyspend-payment-method-panel border-t border-gray-100 bg-white px-4 py-4 dark:border-neutral-800 dark:bg-neutral-900");
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [(0, jsx_runtime_1.jsx)("h2", { className: (0, cn_1.cn)("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && ((0, jsx_runtime_1.jsx)("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-payment-methods divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 dark:divide-neutral-700 dark:border-neutral-700", !isFormValid && "pointer-events-none opacity-50", classes?.paymentMethodSelector), children: [(0, jsx_runtime_1.jsxs)("div", { className: "anyspend-method-crypto", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [(0, jsx_runtime_1.jsx)(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), (0, jsx_runtime_1.jsx)(lucide_react_1.Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { initial: false, children: paymentMethod === "crypto" && ((0, jsx_runtime_1.jsx)(react_1.motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: (0, jsx_runtime_1.jsx)("div", { className: expandedPanelClass, children: (0, jsx_runtime_1.jsx)(CryptoPayPanel_1.CryptoPayPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, buttonText: buttonText, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, senderAddress: senderAddress }) }) }, "crypto-panel")) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-method-card", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [(0, jsx_runtime_1.jsx)(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), (0, jsx_runtime_1.jsx)(lucide_react_1.CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), (0, jsx_runtime_1.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)(VisaLogo, {}), (0, jsx_runtime_1.jsx)(MastercardLogo, {}), (0, jsx_runtime_1.jsx)(AmexLogo, {})] })] }), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { initial: false, children: paymentMethod === "card" && ((0, jsx_runtime_1.jsx)(react_1.motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: (0, jsx_runtime_1.jsx)("div", { className: expandedPanelClass, children: (0, jsx_runtime_1.jsx)(FiatCheckoutPanel_1.FiatCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "card-panel")) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "anyspend-method-coinbase", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [(0, jsx_runtime_1.jsx)(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), (0, jsx_runtime_1.jsx)(CoinbaseLogo, {}), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && ((0, jsx_runtime_1.jsx)(react_1.motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: (0, jsx_runtime_1.jsx)("div", { className: expandedPanelClass, children: (0, jsx_runtime_1.jsx)(CoinbaseCheckoutPanel_1.CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
64
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CheckoutSuccessProps {
|
|
3
|
+
txHash?: string;
|
|
4
|
+
orderId?: string;
|
|
5
|
+
returnUrl?: string;
|
|
6
|
+
returnLabel?: string;
|
|
7
|
+
classes?: AnySpendCheckoutClasses;
|
|
8
|
+
}
|
|
9
|
+
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CheckoutSuccess = CheckoutSuccess;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
|
+
const lucide_react_1 = require("lucide-react");
|
|
8
|
+
const react_1 = require("motion/react");
|
|
9
|
+
const AnySpendCustomizationContext_1 = require("../context/AnySpendCustomizationContext");
|
|
10
|
+
const AnimatedCheckmark_1 = require("../icons/AnimatedCheckmark");
|
|
11
|
+
function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
12
|
+
const { content, slots } = (0, AnySpendCustomizationContext_1.useAnySpendCustomization)();
|
|
13
|
+
if (slots.successScreen) {
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: slots.successScreen({
|
|
15
|
+
title: typeof content.successTitle === "string" ? content.successTitle : "Payment Successful",
|
|
16
|
+
description: typeof content.successDescription === "string"
|
|
17
|
+
? content.successDescription
|
|
18
|
+
: "Your payment has been processed successfully.",
|
|
19
|
+
txHash,
|
|
20
|
+
orderId,
|
|
21
|
+
explorerUrl: txHash ? `https://explorer.b3.fun/tx/${txHash}` : undefined,
|
|
22
|
+
onDone: () => {
|
|
23
|
+
if (returnUrl)
|
|
24
|
+
window.location.href = returnUrl;
|
|
25
|
+
},
|
|
26
|
+
returnUrl,
|
|
27
|
+
returnLabel: content.returnButtonLabel || returnLabel,
|
|
28
|
+
}) }));
|
|
29
|
+
}
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-success-icon mb-4", children: (0, jsx_runtime_1.jsx)(AnimatedCheckmark_1.AnimatedCheckmark, { className: "h-16 w-16" }) }), (0, jsx_runtime_1.jsx)(react_1.motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), (0, jsx_runtime_1.jsx)(react_1.motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && ((0, jsx_runtime_1.jsxs)(react_1.motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: `https://explorer.b3.fun/tx/${txHash}`, target: "_blank", rel: "noopener noreferrer", className: "anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", children: ["View Transaction", (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && ((0, jsx_runtime_1.jsxs)(react_1.motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, className: "anyspend-success-order-id mt-4 text-xs text-gray-400 dark:text-gray-500", children: ["Order ID: ", orderId] })), returnUrl && ((0, jsx_runtime_1.jsx)(react_1.motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: (0, cn_1.cn)("anyspend-success-return-btn mt-6 inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" }))] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CoinbaseCheckoutPanelProps {
|
|
3
|
+
recipientAddress: string;
|
|
4
|
+
destinationTokenAddress: string;
|
|
5
|
+
destinationTokenChainId: number;
|
|
6
|
+
totalAmount: string;
|
|
7
|
+
themeColor?: string;
|
|
8
|
+
/** @deprecated Use onOrderCreated instead. Kept for backward compatibility. */
|
|
9
|
+
onSuccess?: (result: {
|
|
10
|
+
txHash?: string;
|
|
11
|
+
orderId?: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
/** Called when order is created — triggers lifecycle tracking in parent */
|
|
14
|
+
onOrderCreated?: (orderId: string) => void;
|
|
15
|
+
onError?: (error: Error) => void;
|
|
16
|
+
callbackMetadata?: Record<string, unknown>;
|
|
17
|
+
classes?: AnySpendCheckoutClasses;
|
|
18
|
+
}
|
|
19
|
+
export declare function CoinbaseCheckoutPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, }: CoinbaseCheckoutPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CoinbaseCheckoutPanel = CoinbaseCheckoutPanel;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("../../../../anyspend/react");
|
|
7
|
+
const anyspend_1 = require("../../../../anyspend/services/anyspend");
|
|
8
|
+
const number_1 = require("../../../../shared/utils/number");
|
|
9
|
+
const react_2 = require("../../../../global-account/react");
|
|
10
|
+
const lucide_react_1 = require("lucide-react");
|
|
11
|
+
const react_3 = require("motion/react");
|
|
12
|
+
const react_4 = require("react");
|
|
13
|
+
/** Map chain IDs to Coinbase blockchain identifiers */
|
|
14
|
+
const CHAIN_ID_TO_COINBASE_BLOCKCHAIN = {
|
|
15
|
+
1: "ethereum",
|
|
16
|
+
8453: "base",
|
|
17
|
+
42161: "arbitrum",
|
|
18
|
+
10: "optimism",
|
|
19
|
+
137: "polygon",
|
|
20
|
+
43114: "avalanche",
|
|
21
|
+
56: "bsc",
|
|
22
|
+
};
|
|
23
|
+
function CoinbaseCheckoutPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, }) {
|
|
24
|
+
// Stable refs for callback props to avoid re-triggering effects
|
|
25
|
+
const onSuccessRef = (0, react_4.useRef)(onSuccess);
|
|
26
|
+
onSuccessRef.current = onSuccess;
|
|
27
|
+
const onOrderCreatedRef = (0, react_4.useRef)(onOrderCreated);
|
|
28
|
+
onOrderCreatedRef.current = onOrderCreated;
|
|
29
|
+
const onErrorRef = (0, react_4.useRef)(onError);
|
|
30
|
+
onErrorRef.current = onError;
|
|
31
|
+
const { data: tokenData } = (0, react_2.useTokenData)(destinationTokenChainId, destinationTokenAddress);
|
|
32
|
+
const formattedAmount = (0, react_4.useMemo)(() => {
|
|
33
|
+
const decimals = tokenData?.decimals || 18;
|
|
34
|
+
return (0, number_1.formatTokenAmount)(BigInt(totalAmount), decimals);
|
|
35
|
+
}, [totalAmount, tokenData]);
|
|
36
|
+
const { geoData, coinbaseAvailablePaymentMethods, isLoading } = (0, react_1.useGeoOnrampOptions)(formattedAmount);
|
|
37
|
+
// Order + redirect state
|
|
38
|
+
const [orderId, setOrderId] = (0, react_4.useState)(null);
|
|
39
|
+
const [isRedirecting, setIsRedirecting] = (0, react_4.useState)(false);
|
|
40
|
+
const [error, setError] = (0, react_4.useState)(null);
|
|
41
|
+
const orderCreatedRef = (0, react_4.useRef)(false);
|
|
42
|
+
const { createOrder, isCreatingOrder } = (0, react_1.useAnyspendCreateOnrampOrder)({
|
|
43
|
+
onSuccess: data => {
|
|
44
|
+
const id = data.data?.id;
|
|
45
|
+
if (id) {
|
|
46
|
+
setOrderId(id);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setError("Failed to create Coinbase order. Please try again.");
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
onError: (err) => {
|
|
53
|
+
setError(err.message || "Failed to create payment order.");
|
|
54
|
+
onErrorRef.current?.(err);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Once we have orderId, generate Coinbase onramp URL and redirect
|
|
58
|
+
(0, react_4.useEffect)(() => {
|
|
59
|
+
if (!orderId || isRedirecting)
|
|
60
|
+
return;
|
|
61
|
+
const blockchain = CHAIN_ID_TO_COINBASE_BLOCKCHAIN[destinationTokenChainId];
|
|
62
|
+
if (!blockchain) {
|
|
63
|
+
setError(`Coinbase Pay is not supported for this chain.`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const paymentMethodId = coinbaseAvailablePaymentMethods[0]?.id || "CARD";
|
|
67
|
+
setIsRedirecting(true);
|
|
68
|
+
anyspend_1.anyspendService
|
|
69
|
+
.getCoinbaseOnrampUrl({
|
|
70
|
+
presetFiatAmount: formattedAmount,
|
|
71
|
+
fiatCurrency: "USD",
|
|
72
|
+
defaultAsset: tokenData?.symbol || "USDC",
|
|
73
|
+
defaultPaymentMethod: paymentMethodId,
|
|
74
|
+
destinationAddress: recipientAddress,
|
|
75
|
+
blockchains: [blockchain],
|
|
76
|
+
country: geoData?.country || "US",
|
|
77
|
+
orderId,
|
|
78
|
+
redirectUrl: window.location.href,
|
|
79
|
+
useSessionToken: false,
|
|
80
|
+
})
|
|
81
|
+
.then(response => {
|
|
82
|
+
if (response.data?.url) {
|
|
83
|
+
// Persist orderId directly before redirect — useEffect won't run in time
|
|
84
|
+
if (orderId) {
|
|
85
|
+
sessionStorage.setItem("anyspend_checkout_orderId", orderId);
|
|
86
|
+
onOrderCreatedRef.current?.(orderId);
|
|
87
|
+
}
|
|
88
|
+
onSuccessRef.current?.({ orderId });
|
|
89
|
+
window.location.href = response.data.url;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
setError("Failed to generate Coinbase Pay URL.");
|
|
93
|
+
setIsRedirecting(false);
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.catch(err => {
|
|
97
|
+
setError(err.message || "Failed to generate Coinbase Pay URL.");
|
|
98
|
+
setIsRedirecting(false);
|
|
99
|
+
onErrorRef.current?.(err instanceof Error ? err : new Error(err.message));
|
|
100
|
+
});
|
|
101
|
+
}, [
|
|
102
|
+
orderId,
|
|
103
|
+
isRedirecting,
|
|
104
|
+
destinationTokenChainId,
|
|
105
|
+
coinbaseAvailablePaymentMethods,
|
|
106
|
+
formattedAmount,
|
|
107
|
+
tokenData,
|
|
108
|
+
recipientAddress,
|
|
109
|
+
geoData,
|
|
110
|
+
]);
|
|
111
|
+
const handleContinue = (0, react_4.useCallback)(() => {
|
|
112
|
+
if (isCreatingOrder || orderCreatedRef.current)
|
|
113
|
+
return;
|
|
114
|
+
setError(null);
|
|
115
|
+
orderCreatedRef.current = true;
|
|
116
|
+
const dstToken = {
|
|
117
|
+
address: destinationTokenAddress,
|
|
118
|
+
chainId: destinationTokenChainId,
|
|
119
|
+
decimals: tokenData?.decimals || 18,
|
|
120
|
+
symbol: tokenData?.symbol || "",
|
|
121
|
+
name: tokenData?.name || "",
|
|
122
|
+
metadata: { logoURI: tokenData?.logoURI || "" },
|
|
123
|
+
};
|
|
124
|
+
const paymentMethodId = coinbaseAvailablePaymentMethods[0]?.id || "CARD";
|
|
125
|
+
createOrder({
|
|
126
|
+
recipientAddress,
|
|
127
|
+
orderType: "swap",
|
|
128
|
+
dstChain: destinationTokenChainId,
|
|
129
|
+
dstToken,
|
|
130
|
+
srcFiatAmount: formattedAmount,
|
|
131
|
+
onramp: {
|
|
132
|
+
vendor: "coinbase",
|
|
133
|
+
paymentMethod: paymentMethodId,
|
|
134
|
+
country: geoData?.country || "US",
|
|
135
|
+
redirectUrl: window.location.href,
|
|
136
|
+
},
|
|
137
|
+
expectedDstAmount: totalAmount,
|
|
138
|
+
callbackMetadata,
|
|
139
|
+
});
|
|
140
|
+
}, [
|
|
141
|
+
isCreatingOrder,
|
|
142
|
+
destinationTokenAddress,
|
|
143
|
+
destinationTokenChainId,
|
|
144
|
+
tokenData,
|
|
145
|
+
coinbaseAvailablePaymentMethods,
|
|
146
|
+
recipientAddress,
|
|
147
|
+
formattedAmount,
|
|
148
|
+
geoData,
|
|
149
|
+
totalAmount,
|
|
150
|
+
callbackMetadata,
|
|
151
|
+
createOrder,
|
|
152
|
+
]);
|
|
153
|
+
if (isLoading) {
|
|
154
|
+
return ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.2, ease: "easeOut" }, className: "anyspend-coinbase-loading flex items-center justify-center py-6", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin text-gray-400" }), (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1.5, className: "ml-2 text-sm", children: "Checking availability..." })] }));
|
|
155
|
+
}
|
|
156
|
+
if (coinbaseAvailablePaymentMethods.length === 0) {
|
|
157
|
+
return ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, ease: "easeOut" }, className: "anyspend-coinbase-unavailable py-4 text-center", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Coinbase Pay is not available in your region for this amount." }) }));
|
|
158
|
+
}
|
|
159
|
+
const isProcessing = isCreatingOrder || isRedirecting;
|
|
160
|
+
return ((0, jsx_runtime_1.jsxs)(react_3.motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, ease: "easeOut" }, className: "anyspend-coinbase-panel flex flex-col gap-3", children: [(0, jsx_runtime_1.jsx)("p", { className: "anyspend-coinbase-description text-sm text-gray-600 dark:text-gray-400", children: "Pay with your Coinbase account using debit card, bank account, or crypto balance." }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { initial: false, children: error && ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, className: "rounded-lg border border-red-200 bg-red-50 px-3 py-2 dark:border-red-800 dark:bg-red-900/20", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: error }) }, "coinbase-error")) }), (0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: themeColor || "#0052FF", onClick: () => {
|
|
161
|
+
if (error) {
|
|
162
|
+
// Reset state for retry
|
|
163
|
+
setError(null);
|
|
164
|
+
setOrderId(null);
|
|
165
|
+
setIsRedirecting(false);
|
|
166
|
+
orderCreatedRef.current = false;
|
|
167
|
+
}
|
|
168
|
+
handleContinue();
|
|
169
|
+
}, disabled: isProcessing, className: "anyspend-coinbase-btn w-full", textClassName: "text-white", children: isProcessing ? ((0, jsx_runtime_1.jsxs)("span", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-4 w-4 animate-spin" }), isRedirecting ? "Redirecting to Coinbase..." : "Creating order..."] })) : error ? ("Try again") : ("Continue with Coinbase") })] }));
|
|
170
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
|
+
interface CryptoPayPanelProps {
|
|
3
|
+
recipientAddress: string;
|
|
4
|
+
destinationTokenAddress: string;
|
|
5
|
+
destinationTokenChainId: number;
|
|
6
|
+
totalAmount: string;
|
|
7
|
+
buttonText?: string;
|
|
8
|
+
themeColor?: string;
|
|
9
|
+
/** @deprecated Use onOrderCreated instead. Kept for backward compatibility. */
|
|
10
|
+
onSuccess?: (result: {
|
|
11
|
+
txHash?: string;
|
|
12
|
+
orderId?: string;
|
|
13
|
+
}) => void;
|
|
14
|
+
/** Called when an order is created and payment committed — triggers lifecycle tracking in parent */
|
|
15
|
+
onOrderCreated?: (orderId: string) => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
callbackMetadata?: Record<string, unknown>;
|
|
18
|
+
classes?: AnySpendCheckoutClasses;
|
|
19
|
+
/** Optional sender address for pre-fetching balances. Falls back to connected wallet. */
|
|
20
|
+
senderAddress?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, classes, senderAddress, }: CryptoPayPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|