@b3dotfun/sdk 0.1.69-alpha.2 → 0.1.69-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/rpc.d.ts +1 -1
- package/dist/cjs/anyspend/constants/rpc.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.js +13 -11
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.js +5 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +43 -23
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.js +3 -6
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/cjs/anyspend/react/components/checkout/PriceSkeleton.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.js +3 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +10 -9
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +37 -6
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +7 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -6
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +11 -7
- package/dist/cjs/anyspend/utils/chain.js +8 -7
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/better-auth-client.d.ts +1883 -0
- package/dist/cjs/global-account/better-auth-client.js +17 -0
- package/dist/cjs/global-account/bsmnt.d.ts +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +9 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -8
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +120 -0
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/cjs/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +15 -6
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.js +57 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/cjs/global-account/react/components/Send/Send.js +5 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +67 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +163 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +138 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +96 -15
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +20 -3
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/cjs/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/cjs/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +3 -0
- package/dist/cjs/global-account/react/components/index.js +7 -3
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuth.js +26 -15
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +23 -12
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +157 -0
- package/dist/cjs/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -24
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/cjs/shared/constants/chains/b3Chain.js +4 -4
- package/dist/cjs/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/cjs/shared/constants/chains/b3Viem.js +19 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -1
- package/dist/cjs/shared/generated/chain-networks.json +2 -2
- package/dist/cjs/shared/utils/chains.d.ts +1 -1
- package/dist/cjs/shared/utils/chains.js +2 -2
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +1 -1
- package/dist/esm/anyspend/constants/rpc.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/esm/anyspend/react/components/checkout/CartSummary.js +13 -11
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.js +5 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +44 -24
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.js +3 -6
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/esm/anyspend/react/components/checkout/PriceSkeleton.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.js +3 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -8
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -3
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +34 -3
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/StepProgress.js +4 -2
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -7
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +9 -5
- package/dist/esm/anyspend/utils/chain.js +10 -9
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/better-auth-client.d.ts +1883 -0
- package/dist/esm/global-account/better-auth-client.js +13 -0
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +4 -6
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +115 -0
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +13 -7
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/esm/global-account/react/components/Send/Send.js +5 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +64 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +160 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +135 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +100 -19
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +19 -2
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/esm/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/esm/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +3 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuth.js +28 -17
- package/dist/esm/global-account/react/hooks/useAuthentication.js +24 -13
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +149 -0
- package/dist/esm/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -23
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -4
- package/dist/esm/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/esm/shared/constants/chains/b3Viem.js +16 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -1
- package/dist/esm/shared/generated/chain-networks.json +2 -2
- package/dist/esm/shared/utils/chains.d.ts +1 -1
- package/dist/esm/shared/utils/chains.js +2 -2
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +1 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/types/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/types/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/types/global-account/better-auth-client.d.ts +1883 -0
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/types/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/types/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/types/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +3 -0
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/types/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/types/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/types/shared/constants/chains/supported.d.ts +1 -1
- package/dist/types/shared/utils/chains.d.ts +1 -1
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +15 -6
- package/src/anyspend/constants/rpc.ts +2 -1
- package/src/anyspend/react/components/AnySpendNFT.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +25 -5
- package/src/anyspend/react/components/checkout/CartItemRow.tsx +2 -1
- package/src/anyspend/react/components/checkout/CartSummary.tsx +24 -20
- package/src/anyspend/react/components/checkout/CheckoutCartPanel.tsx +12 -3
- package/src/anyspend/react/components/checkout/CheckoutFormPanel.tsx +5 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +2 -4
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +45 -27
- package/src/anyspend/react/components/checkout/DiscountCodeInput.tsx +15 -5
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- package/src/anyspend/react/components/checkout/PriceSkeleton.tsx +19 -0
- package/src/anyspend/react/components/checkout/ShippingSelector.tsx +5 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +10 -8
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +10 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +4 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +38 -3
- package/src/anyspend/react/components/common/StepProgress.tsx +15 -5
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -7
- package/src/anyspend/react/hooks/useKycStatus.ts +8 -5
- package/src/anyspend/utils/chain.ts +9 -9
- package/src/app.shared.ts +9 -8
- package/src/global-account/better-auth-client.ts +17 -0
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -2
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +6 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +16 -21
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +52 -40
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +127 -0
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +17 -10
- package/src/global-account/react/components/LinkAccount/LinkedAccountItem.tsx +2 -1
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +29 -11
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- package/src/global-account/react/components/Send/Send.tsx +8 -5
- package/src/global-account/react/components/SignInWithB3/BetterAuthResetPassword.tsx +146 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +426 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -4
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +308 -0
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +207 -54
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +24 -4
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +2 -1
- package/src/global-account/react/components/Toast/ToastContext.tsx +39 -7
- package/src/global-account/react/components/index.ts +3 -0
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +28 -17
- package/src/global-account/react/hooks/useAuthentication.ts +24 -13
- package/src/global-account/react/hooks/useBetterAuth.ts +191 -0
- package/src/global-account/react/hooks/useConnect.tsx +2 -2
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -25
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/global-account/react/utils/profileDisplay.ts +21 -19
- package/src/shared/constants/chains/b3Chain.ts +5 -5
- package/src/shared/constants/chains/b3Viem.ts +18 -0
- package/src/shared/generated/chain-networks.json +2 -2
- package/src/shared/utils/chains.ts +3 -2
- package/src/shared/utils/session-duration.ts +64 -0
- package/src/types/torph.d.ts +4 -0
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -13,7 +13,7 @@ export declare const OPTIMISM_PUBLIC_RPC = "https://optimism-rpc.publicnode.com"
|
|
|
13
13
|
export declare const POLYGON_PUBLIC_RPC = "https://polygon-bor-rpc.publicnode.com";
|
|
14
14
|
export declare const AVALANCHE_PUBLIC_RPC = "https://avalanche-c-chain-rpc.publicnode.com";
|
|
15
15
|
export declare const BSC_PUBLIC_RPC = "https://bsc-rpc.publicnode.com";
|
|
16
|
-
export declare const B3_PUBLIC_RPC = "https://
|
|
16
|
+
export declare const B3_PUBLIC_RPC = "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2/";
|
|
17
17
|
export declare const ABSTRACT_PUBLIC_RPC = "https://api.mainnet.abs.xyz";
|
|
18
18
|
export declare const HYPEREVM_PUBLIC_RPC = "https://rpc.hyperliquid.xyz/evm";
|
|
19
19
|
/**
|
|
@@ -18,7 +18,7 @@ exports.POLYGON_PUBLIC_RPC = "https://polygon-bor-rpc.publicnode.com";
|
|
|
18
18
|
exports.AVALANCHE_PUBLIC_RPC = "https://avalanche-c-chain-rpc.publicnode.com";
|
|
19
19
|
exports.BSC_PUBLIC_RPC = "https://bsc-rpc.publicnode.com";
|
|
20
20
|
// Chain-specific public endpoints
|
|
21
|
-
exports.B3_PUBLIC_RPC = "https://
|
|
21
|
+
exports.B3_PUBLIC_RPC = "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2/";
|
|
22
22
|
exports.ABSTRACT_PUBLIC_RPC = "https://api.mainnet.abs.xyz";
|
|
23
23
|
exports.HYPEREVM_PUBLIC_RPC = "https://rpc.hyperliquid.xyz/evm";
|
|
24
24
|
/**
|
|
@@ -10,7 +10,7 @@ const number_1 = require("../../../shared/utils/number");
|
|
|
10
10
|
const lucide_react_1 = require("lucide-react");
|
|
11
11
|
const react_2 = require("motion/react");
|
|
12
12
|
const react_3 = require("react");
|
|
13
|
-
const
|
|
13
|
+
const b3Viem_1 = require("../../../shared/constants/chains/b3Viem");
|
|
14
14
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
15
15
|
// ABI for contractURI and uri functions
|
|
16
16
|
const CONTRACT_URI_ABI = [
|
|
@@ -92,5 +92,5 @@ function DropdownMenu({ nftContract }) {
|
|
|
92
92
|
const [open, setOpen] = (0, react_3.useState)(false);
|
|
93
93
|
const chain = anyspend_1.ALL_CHAINS[nftContract.chainId];
|
|
94
94
|
const nftUrl = (0, anyspend_1.getExplorerAddressUrl)(nftContract.chainId, nftContract.contractAddress);
|
|
95
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Popover, { open: open, onOpenChange: setOpen, children: [(0, jsx_runtime_1.jsx)(react_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { className: "absolute bottom-3 right-3 z-10 flex items-center justify-center rounded-full bg-black/20 p-1 text-white hover:bg-black/30", "aria-label": "Open NFT menu", children: (0, jsx_runtime_1.jsx)(lucide_react_1.MoreVertical, { className: "h-3 w-3" }) }) }), (0, jsx_runtime_1.jsx)(react_1.PopoverContent, { align: "end", className: "bg-b3-react-background border-b3-react-border min-w-48 rounded-lg border p-0 shadow-md backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "pointer-events-auto flex w-full flex-col gap-2 py-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2 text-sm", children: ["Native mint price:", (0, jsx_runtime_1.jsxs)("span", { className: "font-semibold", children: [(0, number_1.formatTokenAmount)(BigInt(nftContract.price), nftContract.currency.decimals, 6, false), " ", nftContract.currency.symbol] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2", children: [(0, jsx_runtime_1.jsx)("img", { src: chain?.logoUrl, className: (0, utils_1.cn)("h-5 w-5", nftContract.chainId !==
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Popover, { open: open, onOpenChange: setOpen, children: [(0, jsx_runtime_1.jsx)(react_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)("button", { className: "absolute bottom-3 right-3 z-10 flex items-center justify-center rounded-full bg-black/20 p-1 text-white hover:bg-black/30", "aria-label": "Open NFT menu", children: (0, jsx_runtime_1.jsx)(lucide_react_1.MoreVertical, { className: "h-3 w-3" }) }) }), (0, jsx_runtime_1.jsx)(react_1.PopoverContent, { align: "end", className: "bg-b3-react-background border-b3-react-border min-w-48 rounded-lg border p-0 shadow-md backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "pointer-events-auto flex w-full flex-col gap-2 py-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2 text-sm", children: ["Native mint price:", (0, jsx_runtime_1.jsxs)("span", { className: "font-semibold", children: [(0, number_1.formatTokenAmount)(BigInt(nftContract.price), nftContract.currency.decimals, 6, false), " ", nftContract.currency.symbol] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2", children: [(0, jsx_runtime_1.jsx)("img", { src: chain?.logoUrl, className: (0, utils_1.cn)("h-5 w-5", nftContract.chainId !== b3Viem_1.b3Viem.id && "rounded-full") }), (0, jsx_runtime_1.jsxs)("span", { className: "text-sm", children: ["Minted on ", (0, jsx_runtime_1.jsx)("span", { className: "font-semibold", children: chain ? (0, anyspend_1.getChainName)(nftContract.chainId) : "Unknown" })] })] }), (0, jsx_runtime_1.jsx)("a", { href: nftUrl, target: "_blank", rel: "noopener noreferrer", className: "hover:bg-as-on-surface-3 text-as-primary flex items-center gap-2 rounded px-2 text-sm", children: "View NFT onchain" })] }) })] }));
|
|
96
96
|
}
|
|
@@ -268,7 +268,7 @@ function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, stakeAmo
|
|
|
268
268
|
opacity: hasMounted ? 1 : 0,
|
|
269
269
|
y: hasMounted ? 0 : 20,
|
|
270
270
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
271
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href:
|
|
271
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chains_1.base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
272
272
|
setB3ModalOpen(false);
|
|
273
273
|
onSuccess?.();
|
|
274
274
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -278,7 +278,7 @@ function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenAddress,
|
|
|
278
278
|
opacity: hasMounted ? 1 : 0,
|
|
279
279
|
y: hasMounted ? 0 : 20,
|
|
280
280
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
281
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href:
|
|
281
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href: (0, anyspend_1.getExplorerTxUrl)(chains_1.base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
282
282
|
setB3ModalOpen(false);
|
|
283
283
|
onSuccess?.((0, number_1.formatTokenAmount)(BigInt(userStakeAmount), 18) ?? "");
|
|
284
284
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -121,5 +121,7 @@ export interface AnySpendCheckoutProps {
|
|
|
121
121
|
feeOnTop?: boolean;
|
|
122
122
|
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
123
123
|
kycEnabled?: boolean;
|
|
124
|
+
/** Extra metadata included under the 'callbackMetadata' key in the order's callbackMetadata (e.g. workflowId, orgId from checkout session) */
|
|
125
|
+
callbackMetadata?: Record<string, unknown>;
|
|
124
126
|
}
|
|
125
|
-
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, variablePricing, feeOnTop, kycEnabled, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
127
|
+
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, variablePricing, feeOnTop, kycEnabled, callbackMetadata: callbackMetadataProp, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,7 +24,7 @@ shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp,
|
|
|
24
24
|
// New discount props
|
|
25
25
|
enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
26
26
|
// Variable pricing
|
|
27
|
-
variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
27
|
+
variablePricing, feeOnTop, kycEnabled = false, callbackMetadata: callbackMetadataProp, }) {
|
|
28
28
|
// ===== Variable pricing state =====
|
|
29
29
|
const [variablePricingAmount, setVariablePricingAmount] = (0, react_2.useState)("0");
|
|
30
30
|
const isVariablePricingActive = variablePricing?.enabled === true;
|
|
@@ -122,10 +122,11 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
122
122
|
isVariablePricingActive,
|
|
123
123
|
variablePricingAmount,
|
|
124
124
|
]);
|
|
125
|
-
// Get destination token metadata
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const
|
|
125
|
+
// Get destination token metadata. While loading, skip price-dependent UI
|
|
126
|
+
// since the 18-decimal fallback is wrong for non-18 tokens (e.g. USDC).
|
|
127
|
+
const { data: tokenData, isLoading: isTokenDataLoading } = (0, react_1.useTokenData)(destinationTokenChainId, destinationTokenAddress);
|
|
128
|
+
const tokenSymbol = tokenData?.symbol ?? "";
|
|
129
|
+
const tokenDecimals = tokenData?.decimals ?? 18;
|
|
129
130
|
// Resolve USD equivalent for non-stablecoin tokens (shown in cart summary)
|
|
130
131
|
const isStablecoin = (0, react_2.useMemo)(() => {
|
|
131
132
|
return [
|
|
@@ -176,8 +177,12 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
176
177
|
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
177
178
|
meta.variablePricingAmount = variablePricingAmount;
|
|
178
179
|
}
|
|
180
|
+
// Namespace caller-supplied metadata to avoid collisions with internal keys
|
|
181
|
+
if (callbackMetadataProp)
|
|
182
|
+
meta.callbackMetadata = callbackMetadataProp;
|
|
179
183
|
return Object.keys(meta).length > 0 ? meta : undefined;
|
|
180
184
|
}, [
|
|
185
|
+
callbackMetadataProp,
|
|
181
186
|
formData,
|
|
182
187
|
selectedShipping,
|
|
183
188
|
shippingAddress,
|
|
@@ -201,5 +206,9 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
201
206
|
(shippingOptions && shippingOptions.length > 0) ||
|
|
202
207
|
collectShippingAddress ||
|
|
203
208
|
enableDiscountCode;
|
|
204
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: (0, jsx_runtime_1.jsx)(AnySpendCustomizationContext_1.AnySpendCustomizationProvider, { slots: slots, content:
|
|
209
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: (0, jsx_runtime_1.jsx)(AnySpendCustomizationContext_1.AnySpendCustomizationProvider, { slots: slots, content: {
|
|
210
|
+
successTitle: "Payment Successful",
|
|
211
|
+
successDescription: "Your payment has been processed successfully.",
|
|
212
|
+
...content,
|
|
213
|
+
}, theme: theme, children: (0, jsx_runtime_1.jsx)(CheckoutLayout_1.CheckoutLayout, { mode: mode, paymentPanel: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isVariablePricingActive && tokenData && variablePricing && ((0, jsx_runtime_1.jsx)(VariablePricingInput_1.VariablePricingInput, { config: variablePricing, tokenDecimals: tokenDecimals, tokenSymbol: tokenSymbol, themeColor: themeColor, onChange: setVariablePricingAmount })), hasFormContent && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-6", children: [(0, jsx_runtime_1.jsx)(CheckoutFormPanel_1.CheckoutFormPanel, { formSchema: formSchema, formComponent: formComponent, shippingOptions: shippingOptions, collectShippingAddress: collectShippingAddress, enableDiscountCode: enableDiscountCode, validateDiscount: validateDiscount, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, pricesLoading: isTokenDataLoading, classes: classes, formData: formData, onFormDataChange: handleFormDataChange, selectedShipping: selectedShipping, onShippingChange: handleShippingChange, appliedDiscount: appliedDiscount, onDiscountApplied: handleDiscountApplied, onDiscountRemoved: handleDiscountRemoved, shippingAddress: shippingAddress, onShippingAddressChange: setShippingAddress, checkoutFormSlot: slots?.checkoutForm }), (0, jsx_runtime_1.jsx)("div", { className: "mt-6 border-t border-gray-200 dark:border-neutral-700" })] })), (0, jsx_runtime_1.jsx)(CheckoutPaymentPanel_1.CheckoutPaymentPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: computedTotal, buttonText: buttonText, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, classes: classes, defaultPaymentMethod: defaultPaymentMethod, senderAddress: senderAddress, showPoints: showPoints, showOrderId: showOrderId, callbackMetadata: checkoutFormMetadata, isFormValid: isFormValid, feeOnTop: feeOnTop, kycEnabled: kycEnabled })] }), cartPanel: (0, jsx_runtime_1.jsx)(CheckoutCartPanel_1.CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, pricesLoading: isTokenDataLoading, organizationName: organizationName, organizationLogo: organizationLogo, classes: classes, footer: footer, shipping: effectiveShipping, tax: typeof tax === "string" ? { amount: tax } : tax, discount: effectiveDiscount, summaryLines: summaryLines, usdEquivalent: usdEquivalent }), classes: classes }) }) }));
|
|
205
214
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import type { CheckoutItem, AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
3
|
interface CartItemRowProps {
|
|
3
4
|
item: CheckoutItem;
|
|
4
|
-
formattedPrice:
|
|
5
|
+
formattedPrice: ReactNode;
|
|
5
6
|
classes?: AnySpendCheckoutClasses;
|
|
6
7
|
}
|
|
7
8
|
export declare function CartItemRow({ item, formattedPrice, classes }: CartItemRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { CheckoutSummaryLine } from "./AnySpendCheckout";
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { AnySpendCheckoutClasses, CheckoutSummaryLine } from "./AnySpendCheckout";
|
|
3
3
|
interface CartSummaryProps {
|
|
4
4
|
/** Formatted total (final amount after all adjustments) */
|
|
5
|
-
total:
|
|
5
|
+
total: ReactNode;
|
|
6
6
|
tokenSymbol?: string;
|
|
7
7
|
classes?: AnySpendCheckoutClasses;
|
|
8
8
|
/** Formatted subtotal (sum of items only — shown when adjustments exist) */
|
|
@@ -25,6 +25,8 @@ interface CartSummaryProps {
|
|
|
25
25
|
summaryLines?: CheckoutSummaryLine[];
|
|
26
26
|
/** Formatted USD equivalent (e.g. "$5.56") — shown for non-stablecoin tokens */
|
|
27
27
|
usdEquivalent?: string | null;
|
|
28
|
+
/** When true, hide adjustment rows and USD equivalent (caller passes a skeleton as `total`). */
|
|
29
|
+
pricesLoading?: boolean;
|
|
28
30
|
}
|
|
29
|
-
export declare function CartSummary({ total, tokenSymbol, classes, subtotal, tokenDecimals, shipping, tax, discount, summaryLines, usdEquivalent, }: CartSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function CartSummary({ total, tokenSymbol, classes, subtotal, tokenDecimals, shipping, tax, discount, summaryLines, usdEquivalent, pricesLoading, }: CartSummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
export {};
|
|
@@ -6,15 +6,17 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
7
|
const number_1 = require("../../../../shared/utils/number");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
function CartSummary({ total, tokenSymbol, classes, subtotal, tokenDecimals = 18, shipping, tax, discount, summaryLines, usdEquivalent, }) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
function CartSummary({ total, tokenSymbol, classes, subtotal, tokenDecimals = 18, shipping, tax, discount, summaryLines, usdEquivalent, pricesLoading = false, }) {
|
|
10
|
+
const formattedShipping = (0, react_1.useMemo)(() => (!pricesLoading && shipping?.amount ? (0, number_1.formatTokenAmount)((0, number_1.safeBigInt)(shipping.amount), tokenDecimals) : null), [pricesLoading, shipping?.amount, tokenDecimals]);
|
|
11
|
+
const formattedTax = (0, react_1.useMemo)(() => (!pricesLoading && tax?.amount ? (0, number_1.formatTokenAmount)((0, number_1.safeBigInt)(tax.amount), tokenDecimals) : null), [pricesLoading, tax?.amount, tokenDecimals]);
|
|
12
|
+
const formattedDiscount = (0, react_1.useMemo)(() => (!pricesLoading && discount?.amount ? (0, number_1.formatTokenAmount)((0, number_1.safeBigInt)(discount.amount), tokenDecimals) : null), [pricesLoading, discount?.amount, tokenDecimals]);
|
|
13
|
+
const formattedSummaryLines = (0, react_1.useMemo)(() => pricesLoading
|
|
14
|
+
? undefined
|
|
15
|
+
: summaryLines?.map(line => ({
|
|
16
|
+
...line,
|
|
17
|
+
formattedAmount: (0, number_1.formatTokenAmount)((0, number_1.safeBigInt)(line.amount), tokenDecimals),
|
|
18
|
+
isNegative: (0, number_1.safeBigInt)(line.amount) < BigInt(0),
|
|
19
|
+
})), [pricesLoading, summaryLines, tokenDecimals]);
|
|
20
|
+
const hasAdjustments = !!formattedShipping || !!formattedTax || !!formattedDiscount || !!formattedSummaryLines?.length;
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("border-t border-gray-200 pt-3 dark:border-neutral-700", classes?.cartSummary), children: [hasAdjustments && subtotal && ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex items-center justify-between py-1", classes?.cartSubtotal), children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Subtotal" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [subtotal, " ", tokenSymbol] })] })), formattedShipping && ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [(0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: shipping?.label || "Shipping" }), (0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [formattedShipping, " ", tokenSymbol] })] })), formattedTax && ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [(0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: [tax?.label || "Tax", tax?.rate && (0, jsx_runtime_1.jsxs)("span", { className: "ml-1 text-xs text-gray-400 dark:text-gray-500", children: ["(", tax.rate, ")"] })] }), (0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [formattedTax, " ", tokenSymbol] })] })), formattedDiscount && ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex items-center justify-between py-1", classes?.cartDiscount), children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [discount?.label || "Discount", discount?.code && ((0, jsx_runtime_1.jsx)("span", { className: "ml-1 rounded bg-green-50 px-1.5 py-0.5 text-xs font-medium text-green-600 dark:bg-green-900/20 dark:text-green-400", children: discount.code }))] }), (0, jsx_runtime_1.jsxs)("span", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: ["-", formattedDiscount, " ", tokenSymbol] })] })), formattedSummaryLines?.map(line => ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex items-center justify-between py-1", classes?.cartSummaryLine), children: [(0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-sm text-gray-500 dark:text-gray-400", classes?.cartSummaryLineLabel), children: [line.label, line.description && ((0, jsx_runtime_1.jsxs)("span", { className: "ml-1 text-xs text-gray-400 dark:text-gray-500", children: ["(", line.description, ")"] }))] }), (0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-sm", line.isNegative ? "font-medium text-green-600 dark:text-green-400" : "text-gray-500 dark:text-gray-400", classes?.cartSummaryLineAmount), children: [line.formattedAmount, " ", tokenSymbol] })] }, line.label))), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex flex-col", hasAdjustments && "mt-1 border-t border-gray-100 pt-2 dark:border-neutral-800"), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: "Total" }), (0, jsx_runtime_1.jsxs)("span", { className: (0, cn_1.cn)("text-base font-semibold text-gray-900 dark:text-gray-100", classes?.cartTotal), children: [total, " ", tokenSymbol] })] }), !pricesLoading && usdEquivalent && ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-end", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: ["~", usdEquivalent, " USD"] }) }))] })] }));
|
|
20
22
|
}
|
|
@@ -5,6 +5,8 @@ interface CheckoutCartPanelProps {
|
|
|
5
5
|
totalAmount: string;
|
|
6
6
|
tokenSymbol?: string;
|
|
7
7
|
tokenDecimals?: number;
|
|
8
|
+
/** True while token decimals/symbol are still loading — prevents rendering mis-decimalized prices. */
|
|
9
|
+
pricesLoading?: boolean;
|
|
8
10
|
organizationName?: string;
|
|
9
11
|
organizationLogo?: string;
|
|
10
12
|
classes?: AnySpendCheckoutClasses;
|
|
@@ -28,5 +30,5 @@ interface CheckoutCartPanelProps {
|
|
|
28
30
|
/** Formatted USD equivalent (e.g. "$5.56") — shown for non-stablecoin tokens */
|
|
29
31
|
usdEquivalent?: string | null;
|
|
30
32
|
}
|
|
31
|
-
export declare function CheckoutCartPanel({ items, totalAmount, tokenSymbol, tokenDecimals, organizationName, organizationLogo, classes, footer, shipping, tax, discount, summaryLines, usdEquivalent, }: CheckoutCartPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function CheckoutCartPanel({ items, totalAmount, tokenSymbol, tokenDecimals, pricesLoading, organizationName, organizationLogo, classes, footer, shipping, tax, discount, summaryLines, usdEquivalent, }: CheckoutCartPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
32
34
|
export {};
|
|
@@ -9,7 +9,8 @@ const react_1 = require("react");
|
|
|
9
9
|
const CartItemRow_1 = require("./CartItemRow");
|
|
10
10
|
const CartSummary_1 = require("./CartSummary");
|
|
11
11
|
const PoweredByBranding_1 = require("./PoweredByBranding");
|
|
12
|
-
|
|
12
|
+
const PriceSkeleton_1 = require("./PriceSkeleton");
|
|
13
|
+
function CheckoutCartPanel({ items, totalAmount, tokenSymbol = "", tokenDecimals = 18, pricesLoading = false, organizationName, organizationLogo, classes, footer, shipping, tax, discount, summaryLines, usdEquivalent, }) {
|
|
13
14
|
const formattedTotal = (0, react_1.useMemo)(() => (0, number_1.formatTokenAmount)((0, number_1.safeBigInt)(totalAmount), tokenDecimals), [totalAmount, tokenDecimals]);
|
|
14
15
|
// Compute subtotal from items only (before adjustments)
|
|
15
16
|
const formattedSubtotal = (0, react_1.useMemo)(() => {
|
|
@@ -19,9 +20,9 @@ function CheckoutCartPanel({ items, totalAmount, tokenSymbol = "", tokenDecimals
|
|
|
19
20
|
}
|
|
20
21
|
return (0, number_1.formatTokenAmount)(subtotal, tokenDecimals);
|
|
21
22
|
}, [items, tokenDecimals]);
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-cart-panel flex flex-col", classes?.cartPanel), children: [(0, jsx_runtime_1.jsx)("h2", { className: (0, cn_1.cn)("anyspend-cart-title mb-4 text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.cartTitle), children: "Order Summary" }), (0, jsx_runtime_1.jsx)("div", { className: "anyspend-cart-items divide-y divide-gray-100 dark:divide-gray-800", children: items.map((item, index) => {
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-cart-panel flex flex-col", classes?.cartPanel), "aria-busy": pricesLoading || undefined, children: [(0, jsx_runtime_1.jsx)("h2", { className: (0, cn_1.cn)("anyspend-cart-title mb-4 text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.cartTitle), children: "Order Summary" }), (0, jsx_runtime_1.jsx)("div", { className: "anyspend-cart-items divide-y divide-gray-100 dark:divide-gray-800", children: items.map((item, index) => {
|
|
23
24
|
const itemTotal = (0, number_1.safeBigInt)(item.amount) * BigInt(item.quantity);
|
|
24
|
-
const formattedPrice = `${(0, number_1.formatTokenAmount)(itemTotal, tokenDecimals)} ${tokenSymbol}
|
|
25
|
+
const formattedPrice = pricesLoading ? ((0, jsx_runtime_1.jsx)(PriceSkeleton_1.PriceSkeleton, {})) : (`${(0, number_1.formatTokenAmount)(itemTotal, tokenDecimals)} ${tokenSymbol}`);
|
|
25
26
|
return (0, jsx_runtime_1.jsx)(CartItemRow_1.CartItemRow, { item: item, formattedPrice: formattedPrice, classes: classes }, item.id || index);
|
|
26
|
-
}) }), (0, jsx_runtime_1.jsx)(CartSummary_1.CartSummary, { total: formattedTotal, tokenSymbol: tokenSymbol, classes: classes, subtotal: formattedSubtotal, tokenDecimals: tokenDecimals, shipping: shipping, tax: tax, discount: discount, summaryLines: summaryLines, usdEquivalent: usdEquivalent }), footer === undefined ? ((0, jsx_runtime_1.jsx)(PoweredByBranding_1.PoweredByBranding, { organizationName: organizationName, organizationLogo: organizationLogo, classes: classes })) : (footer)] }));
|
|
27
|
+
}) }), (0, jsx_runtime_1.jsx)(CartSummary_1.CartSummary, { total: pricesLoading ? (0, jsx_runtime_1.jsx)(PriceSkeleton_1.PriceSkeleton, { className: "w-20" }) : formattedTotal, tokenSymbol: tokenSymbol, classes: classes, subtotal: formattedSubtotal, tokenDecimals: tokenDecimals, shipping: shipping, tax: tax, discount: discount, summaryLines: summaryLines, usdEquivalent: usdEquivalent, pricesLoading: pricesLoading }), footer === undefined ? ((0, jsx_runtime_1.jsx)(PoweredByBranding_1.PoweredByBranding, { organizationName: organizationName, organizationLogo: organizationLogo, classes: classes })) : (footer)] }));
|
|
27
28
|
}
|
|
@@ -16,6 +16,8 @@ interface CheckoutFormPanelProps {
|
|
|
16
16
|
/** Token info for display */
|
|
17
17
|
tokenSymbol?: string;
|
|
18
18
|
tokenDecimals?: number;
|
|
19
|
+
/** True while token decimals/symbol are still loading — prevents rendering mis-decimalized prices. */
|
|
20
|
+
pricesLoading?: boolean;
|
|
19
21
|
/** CSS class overrides */
|
|
20
22
|
classes?: AnySpendCheckoutClasses;
|
|
21
23
|
/** Current form data (lifted state) */
|
|
@@ -35,5 +37,5 @@ interface CheckoutFormPanelProps {
|
|
|
35
37
|
/** Slot overrides */
|
|
36
38
|
checkoutFormSlot?: (props: CheckoutFormComponentProps) => React.ReactNode;
|
|
37
39
|
}
|
|
38
|
-
export declare function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }: CheckoutFormPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
40
|
+
export declare function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, pricesLoading, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }: CheckoutFormPanelProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
41
|
export {};
|
|
@@ -10,7 +10,7 @@ const AddressForm_1 = require("./AddressForm");
|
|
|
10
10
|
const ShippingSelector_1 = require("./ShippingSelector");
|
|
11
11
|
const DiscountCodeInput_1 = require("./DiscountCodeInput");
|
|
12
12
|
const emptyAddress = { street: "", city: "", state: "", zip: "", country: "" };
|
|
13
|
-
function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }) {
|
|
13
|
+
function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingOptions, collectShippingAddress, enableDiscountCode, validateDiscount, tokenSymbol, tokenDecimals, pricesLoading = false, classes, formData, onFormDataChange, selectedShipping, onShippingChange, appliedDiscount, onDiscountApplied, onDiscountRemoved, shippingAddress, onShippingAddressChange, checkoutFormSlot, }) {
|
|
14
14
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
15
15
|
const hasFormFields = formSchema && formSchema.fields.length > 0;
|
|
16
16
|
const hasShipping = shippingOptions && shippingOptions.length > 0;
|
|
@@ -56,7 +56,7 @@ function CheckoutFormPanel({ formSchema, formComponent: FormComponent, shippingO
|
|
|
56
56
|
if (!hasAnyContent)
|
|
57
57
|
return null;
|
|
58
58
|
// Shared shipping + discount section
|
|
59
|
-
const shippingAndDiscount = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasShipping && shippingOptions && ((0, jsx_runtime_1.jsx)(ShippingSelector_1.ShippingSelector, { options: shippingOptions, selectedId: selectedShipping?.id || null, onSelect: onShippingChange, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals })), enableDiscountCode && validateDiscount && ((0, jsx_runtime_1.jsx)(DiscountCodeInput_1.DiscountCodeInput, { onApply: handleDiscountApply, appliedDiscount: appliedDiscount, onRemove: onDiscountRemoved, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals }))] }));
|
|
59
|
+
const shippingAndDiscount = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasShipping && shippingOptions && ((0, jsx_runtime_1.jsx)(ShippingSelector_1.ShippingSelector, { options: shippingOptions, selectedId: selectedShipping?.id || null, onSelect: onShippingChange, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, pricesLoading: pricesLoading })), enableDiscountCode && validateDiscount && ((0, jsx_runtime_1.jsx)(DiscountCodeInput_1.DiscountCodeInput, { onApply: handleDiscountApply, appliedDiscount: appliedDiscount, onRemove: onDiscountRemoved, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, pricesLoading: pricesLoading }))] }));
|
|
60
60
|
// Render custom form slot if provided
|
|
61
61
|
if (checkoutFormSlot) {
|
|
62
62
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("anyspend-form-panel space-y-4", classes?.formPanel), children: [(0, jsx_runtime_1.jsx)("div", { className: "anyspend-form-slot", children: checkoutFormSlot({
|
|
@@ -56,9 +56,7 @@ function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress, desti
|
|
|
56
56
|
if (activeOrderId) {
|
|
57
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
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
|
-
|
|
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");
|
|
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 && "hover:bg-gray-50 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
60
|
+
const expandedPanelClass = (0, cn_1.cn)("anyspend-payment-method-panel border-t border-gray-100 px-4 py-4 dark:border-neutral-800");
|
|
63
61
|
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, feeOnTop: feeOnTop, kycEnabled: kycEnabled }) }) }, "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
62
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
2
|
interface CheckoutSuccessProps {
|
|
3
3
|
txHash?: string;
|
|
4
|
+
dstChainId?: number;
|
|
4
5
|
orderId?: string;
|
|
5
6
|
returnUrl?: string;
|
|
6
7
|
returnLabel?: string;
|
|
7
8
|
classes?: AnySpendCheckoutClasses;
|
|
8
9
|
}
|
|
9
|
-
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.CheckoutSuccess = CheckoutSuccess;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const anyspend_1 = require("../../../../anyspend");
|
|
7
|
+
const b3Viem_1 = require("../../../../shared/constants/chains/b3Viem");
|
|
6
8
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
9
|
const lucide_react_1 = require("lucide-react");
|
|
8
10
|
const react_1 = require("motion/react");
|
|
9
11
|
const AnySpendCustomizationContext_1 = require("../context/AnySpendCustomizationContext");
|
|
10
12
|
const AnimatedCheckmark_1 = require("../icons/AnimatedCheckmark");
|
|
11
|
-
function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
13
|
+
function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }) {
|
|
12
14
|
const { content, slots } = (0, AnySpendCustomizationContext_1.useAnySpendCustomization)();
|
|
13
15
|
if (slots.successScreen) {
|
|
14
16
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: slots.successScreen({
|
|
@@ -18,7 +20,7 @@ function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
|
18
20
|
: "Your payment has been processed successfully.",
|
|
19
21
|
txHash,
|
|
20
22
|
orderId,
|
|
21
|
-
explorerUrl: txHash ?
|
|
23
|
+
explorerUrl: txHash ? (0, anyspend_1.getExplorerTxUrl)(dstChainId ?? b3Viem_1.b3Viem.id, txHash) : undefined,
|
|
22
24
|
onDone: () => {
|
|
23
25
|
if (returnUrl)
|
|
24
26
|
window.location.href = returnUrl;
|
|
@@ -27,5 +29,5 @@ function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
|
27
29
|
returnLabel: content.returnButtonLabel || returnLabel,
|
|
28
30
|
}) }));
|
|
29
31
|
}
|
|
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:
|
|
32
|
+
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: (0, anyspend_1.getExplorerTxUrl)(dstChainId ?? b3Viem_1.b3Viem.id, 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
33
|
}
|
|
@@ -13,7 +13,6 @@ const chain_1 = require("../../../../anyspend/utils/chain");
|
|
|
13
13
|
const token_1 = require("../../../../anyspend/utils/token");
|
|
14
14
|
const react_1 = require("../../../../global-account/react");
|
|
15
15
|
const react_2 = require("../../../../global-account/react");
|
|
16
|
-
const b3Chain_1 = require("../../../../shared/constants/chains/b3Chain");
|
|
17
16
|
const number_1 = require("../../../../shared/utils/number");
|
|
18
17
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
19
18
|
const lucide_react_1 = require("lucide-react");
|
|
@@ -21,8 +20,10 @@ const qrcode_react_1 = require("qrcode.react");
|
|
|
21
20
|
const viem_1 = require("viem");
|
|
22
21
|
const react_3 = require("motion/react");
|
|
23
22
|
const react_4 = require("react");
|
|
23
|
+
const react_5 = require("thirdweb/react");
|
|
24
24
|
const relay_kit_ui_1 = require("@relayprotocol/relay-kit-ui");
|
|
25
25
|
const ChainTokenIcon_1 = require("../common/ChainTokenIcon");
|
|
26
|
+
const CryptoPaymentMethod_1 = require("../common/CryptoPaymentMethod");
|
|
26
27
|
function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText = "Pay", themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, classes, senderAddress, }) {
|
|
27
28
|
// Stable refs for callback props to avoid re-triggering effects
|
|
28
29
|
const onErrorRef = (0, react_4.useRef)(onError);
|
|
@@ -35,11 +36,10 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
35
36
|
const [selectedSrcChainId, setSelectedSrcChainId] = (0, react_4.useState)(destinationTokenChainId);
|
|
36
37
|
const [selectedSrcToken, setSelectedSrcToken] = (0, react_4.useState)(null);
|
|
37
38
|
const [copied, setCopied] = (0, react_4.useState)(false);
|
|
38
|
-
const { address: walletAddress } = (0, react_1.useAccountWallet)();
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
|
|
39
|
+
const { address: walletAddress, connectedEOAWallet } = (0, react_1.useAccountWallet)();
|
|
40
|
+
const connectedAddress = walletAddress || connectedEOAWallet?.getAccount()?.address;
|
|
41
|
+
const effectiveAddress = connectedAddress || senderAddress;
|
|
42
|
+
const { connect: openConnectModal } = (0, react_5.useConnectModal)();
|
|
43
43
|
const { data: dstTokenData } = (0, react_1.useTokenData)(destinationTokenChainId, destinationTokenAddress);
|
|
44
44
|
// Default to destination token data once available
|
|
45
45
|
(0, react_4.useEffect)(() => {
|
|
@@ -169,9 +169,8 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
169
169
|
/* ------------------------------------------------------------------ */
|
|
170
170
|
const [walletOrderId, setWalletOrderId] = (0, react_4.useState)();
|
|
171
171
|
const [isSendingDeposit, setIsSendingDeposit] = (0, react_4.useState)(false);
|
|
172
|
-
const [depositRejected, setDepositRejected] = (0, react_4.useState)(false);
|
|
173
172
|
const depositSentRef = (0, react_4.useRef)(false);
|
|
174
|
-
const {
|
|
173
|
+
const { switchChainAndExecuteWithEOA } = (0, react_1.useUnifiedChainSwitchAndExecute)();
|
|
175
174
|
const { createOrder: createSwapOrder, isCreatingOrder: isCreatingSwapOrder } = (0, useAnyspendCreateOrder_1.useAnyspendCreateOrder)({
|
|
176
175
|
onSuccess: data => {
|
|
177
176
|
const id = data.data?.id;
|
|
@@ -186,7 +185,7 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
186
185
|
const { orderAndTransactions: walletOat } = (0, useAnyspendOrderAndTransactions_1.useAnyspendOrderAndTransactions)(walletOrderId);
|
|
187
186
|
// Auto-send deposit tx once swap order is ready
|
|
188
187
|
(0, react_4.useEffect)(() => {
|
|
189
|
-
if (!walletOat?.data?.order || depositSentRef.current
|
|
188
|
+
if (!walletOat?.data?.order || depositSentRef.current)
|
|
190
189
|
return;
|
|
191
190
|
const order = walletOat.data.order;
|
|
192
191
|
if (order.status !== "scanning_deposit_transaction")
|
|
@@ -198,8 +197,9 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
198
197
|
try {
|
|
199
198
|
setIsSendingDeposit(true);
|
|
200
199
|
const amount = BigInt(order.srcAmount);
|
|
200
|
+
let txHash;
|
|
201
201
|
if ((0, token_1.isNativeToken)(order.srcTokenAddress)) {
|
|
202
|
-
await
|
|
202
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
203
203
|
to: order.globalAddress,
|
|
204
204
|
value: amount,
|
|
205
205
|
});
|
|
@@ -210,12 +210,18 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
210
210
|
functionName: "transfer",
|
|
211
211
|
args: [order.globalAddress, amount],
|
|
212
212
|
});
|
|
213
|
-
await
|
|
213
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
214
214
|
to: order.srcTokenAddress,
|
|
215
215
|
data,
|
|
216
216
|
value: BigInt(0),
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
+
if (!txHash) {
|
|
220
|
+
// User cancelled or tx failed — reset so they can retry
|
|
221
|
+
depositSentRef.current = false;
|
|
222
|
+
setWalletOrderId(undefined);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
219
225
|
// Deposit sent — notify parent to transition to order lifecycle tracking
|
|
220
226
|
if (walletOrderId) {
|
|
221
227
|
onOrderCreatedRef.current?.(walletOrderId);
|
|
@@ -223,10 +229,8 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
223
229
|
}
|
|
224
230
|
catch (error) {
|
|
225
231
|
depositSentRef.current = false;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
setDepositRejected(true);
|
|
229
|
-
}
|
|
232
|
+
// Reset order so user can retry
|
|
233
|
+
setWalletOrderId(undefined);
|
|
230
234
|
onErrorRef.current?.(error instanceof Error ? error : new Error(error?.message || "Transaction rejected"));
|
|
231
235
|
}
|
|
232
236
|
finally {
|
|
@@ -234,7 +238,7 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
234
238
|
}
|
|
235
239
|
};
|
|
236
240
|
sendDeposit();
|
|
237
|
-
}, [walletOat,
|
|
241
|
+
}, [walletOat, switchChainAndExecuteWithEOA, walletOrderId]);
|
|
238
242
|
(0, useOnOrderSuccess_1.useOnOrderSuccess)({
|
|
239
243
|
orderData: walletOat,
|
|
240
244
|
orderId: walletOrderId,
|
|
@@ -242,9 +246,10 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
242
246
|
});
|
|
243
247
|
const isWaitingForExecution = !!walletOrderId && walletOat?.data?.order.status !== "executed";
|
|
244
248
|
const handleWalletPay = (0, react_4.useCallback)(() => {
|
|
245
|
-
if (!selectedSrcToken || !
|
|
249
|
+
if (!selectedSrcToken || !connectedAddress)
|
|
246
250
|
return;
|
|
247
251
|
depositSentRef.current = false;
|
|
252
|
+
setWalletOrderId(undefined);
|
|
248
253
|
createSwapOrder({
|
|
249
254
|
recipientAddress,
|
|
250
255
|
orderType: "swap",
|
|
@@ -259,7 +264,7 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
259
264
|
});
|
|
260
265
|
}, [
|
|
261
266
|
selectedSrcToken,
|
|
262
|
-
|
|
267
|
+
connectedAddress,
|
|
263
268
|
effectiveAddress,
|
|
264
269
|
recipientAddress,
|
|
265
270
|
selectedSrcChainId,
|
|
@@ -291,13 +296,28 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
291
296
|
setTimeout(() => setCopied(false), 2000);
|
|
292
297
|
}
|
|
293
298
|
};
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
299
|
+
const [shouldAutoPay, setShouldAutoPay] = (0, react_4.useState)(false);
|
|
300
|
+
const handleConnectWallet = async () => {
|
|
301
|
+
try {
|
|
302
|
+
const wallet = await openConnectModal(CryptoPaymentMethod_1.connectModalConfig);
|
|
303
|
+
if (wallet) {
|
|
304
|
+
setShouldAutoPay(true);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
console.error("Failed to connect wallet:", error);
|
|
309
|
+
}
|
|
297
310
|
};
|
|
311
|
+
// Auto-trigger payment after wallet connect
|
|
312
|
+
(0, react_4.useEffect)(() => {
|
|
313
|
+
if (shouldAutoPay && connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoadingAnyspendQuote) {
|
|
314
|
+
setShouldAutoPay(false);
|
|
315
|
+
handleWalletPay();
|
|
316
|
+
}
|
|
317
|
+
}, [shouldAutoPay, connectedAddress, selectedSrcToken, hasEnoughBalance, isLoadingAnyspendQuote, handleWalletPay]);
|
|
298
318
|
const isLoading = isLoadingAnyspendQuote;
|
|
299
319
|
const isPending = isCreatingSwapOrder || isSendingDeposit || isWaitingForExecution;
|
|
300
|
-
const canPay =
|
|
320
|
+
const canPay = connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoading && !isPending;
|
|
301
321
|
const chainName = anyspend_1.ALL_CHAINS[selectedSrcChainId]?.name || "the specified chain";
|
|
302
322
|
const chainLogoUrl = anyspend_1.ALL_CHAINS[selectedSrcChainId]?.logoUrl;
|
|
303
323
|
// Collapse QR on mobile when a wallet connector is available
|
|
@@ -316,7 +336,7 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
316
336
|
name: token.name,
|
|
317
337
|
symbol: token.symbol,
|
|
318
338
|
});
|
|
319
|
-
}, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: (0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("flex w-full items-center justify-between rounded-xl border border-gray-200 bg-white px-4 py-3 transition-colors hover:border-gray-300 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-neutral-600", classes?.tokenSelector), children: [selectedSrcToken ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(ChainTokenIcon_1.ChainTokenIcon, { chainUrl: anyspend_1.ALL_CHAINS[selectedSrcToken.chainId]?.logoUrl || "", tokenUrl: selectedSrcToken.metadata?.logoURI, className: "h-8 w-8" }), (0, jsx_runtime_1.jsxs)("div", { className: "text-left", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: selectedSrcToken.symbol }), (0, jsx_runtime_1.jsxs)("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: ["Balance: ", balance.formatted] })] })] })) : ((0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-400", children: "Select token" })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-4 w-4 text-gray-400" })] }) })] }), (0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, ease: "easeOut" }, className: (0, cn_1.cn)("rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 dark:border-neutral-700 dark:bg-neutral-800/50", classes?.quoteDisplay), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "You pay" }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { mode: "wait", children: isLoadingAnyspendQuote ? ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, children: (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1, className: "text-sm", children: "Fetching quote..." }) }, "quote-loading")) : ((0, jsx_runtime_1.jsxs)(react_3.motion.span, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: [srcAmountFormatted, " ", selectedSrcToken?.symbol || ""] }, "quote-amount")) })] }) }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { children:
|
|
339
|
+
}, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: (0, jsx_runtime_1.jsxs)("button", { className: (0, cn_1.cn)("flex w-full items-center justify-between rounded-xl border border-gray-200 bg-white px-4 py-3 transition-colors hover:border-gray-300 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-neutral-600", classes?.tokenSelector), children: [selectedSrcToken ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(ChainTokenIcon_1.ChainTokenIcon, { chainUrl: anyspend_1.ALL_CHAINS[selectedSrcToken.chainId]?.logoUrl || "", tokenUrl: selectedSrcToken.metadata?.logoURI, className: "h-8 w-8" }), (0, jsx_runtime_1.jsxs)("div", { className: "text-left", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: selectedSrcToken.symbol }), (0, jsx_runtime_1.jsxs)("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: ["Balance: ", balance.formatted] })] })] })) : ((0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-400", children: "Select token" })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "h-4 w-4 text-gray-400" })] }) })] }), (0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, ease: "easeOut" }, className: (0, cn_1.cn)("rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 dark:border-neutral-700 dark:bg-neutral-800/50", classes?.quoteDisplay), children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "You pay" }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { mode: "wait", children: isLoadingAnyspendQuote ? ((0, jsx_runtime_1.jsx)(react_3.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, children: (0, jsx_runtime_1.jsx)(react_2.TextShimmer, { duration: 1, className: "text-sm", children: "Fetching quote..." }) }, "quote-loading")) : ((0, jsx_runtime_1.jsxs)(react_3.motion.span, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: [srcAmountFormatted, " ", selectedSrcToken?.symbol || ""] }, "quote-amount")) })] }) }), (0, jsx_runtime_1.jsx)(react_3.AnimatePresence, { children: connectedAddress && selectedSrcToken && !hasEnoughBalance && !isLoading && ((0, jsx_runtime_1.jsxs)(react_3.motion.p, { initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.2, ease: "easeOut" }, className: "text-center text-sm text-red-500", children: ["Insufficient ", selectedSrcToken.symbol, " balance"] }, "balance-warning")) }), !connectedAddress ? ((0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: themeColor || "hsl(var(--as-brand))", onClick: handleConnectWallet, className: (0, cn_1.cn)("w-full", classes?.payButton), textClassName: "text-white", children: "Connect Wallet to Pay" })) : ((0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: themeColor || "hsl(var(--as-brand))", onClick: handleWalletPay, disabled: !canPay, className: (0, cn_1.cn)("w-full", classes?.payButton), textClassName: (0, cn_1.cn)(!canPay ? "text-as-secondary" : "text-white"), children: isPending ? ((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" }), isCreatingSwapOrder
|
|
320
340
|
? "Creating order..."
|
|
321
341
|
: isSendingDeposit
|
|
322
342
|
? "Confirm in wallet..."
|
|
@@ -6,7 +6,9 @@ interface DiscountCodeInputProps {
|
|
|
6
6
|
loading?: boolean;
|
|
7
7
|
tokenSymbol?: string;
|
|
8
8
|
tokenDecimals?: number;
|
|
9
|
+
/** True while token decimals/symbol are still loading — renders applied amount as skeleton. */
|
|
10
|
+
pricesLoading?: boolean;
|
|
9
11
|
className?: string;
|
|
10
12
|
}
|
|
11
|
-
export declare function DiscountCodeInput({ onApply, appliedDiscount, onRemove, loading, tokenSymbol, tokenDecimals, className, }: DiscountCodeInputProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function DiscountCodeInput({ onApply, appliedDiscount, onRemove, loading, tokenSymbol, tokenDecimals, pricesLoading, className, }: DiscountCodeInputProps): import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
export {};
|