@b3dotfun/sdk 0.1.69-alpha.2 → 0.1.69-alpha.20
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 +10 -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/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -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 +10 -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/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- 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/CheckoutSuccess.d.ts +2 -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 +15 -1
- 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/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- 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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWalletState = useWalletState;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const wagmi_1 = require("wagmi");
|
|
6
|
+
/**
|
|
7
|
+
* Unified wallet state from both thirdweb and wagmi layers.
|
|
8
|
+
* Provides available connectors with install status and connect functions.
|
|
9
|
+
*/
|
|
10
|
+
function useWalletState() {
|
|
11
|
+
const { address, isConnected, chain } = (0, wagmi_1.useAccount)();
|
|
12
|
+
const { connectAsync, isPending } = (0, wagmi_1.useConnect)();
|
|
13
|
+
const wagmiConnectors = (0, wagmi_1.useConnectors)();
|
|
14
|
+
// Ref to avoid connectAsync in useMemo deps — wagmi returns a new reference on state
|
|
15
|
+
// changes, which would recreate the connectors array on every render.
|
|
16
|
+
const connectAsyncRef = (0, react_1.useRef)(connectAsync);
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
connectAsyncRef.current = connectAsync;
|
|
19
|
+
});
|
|
20
|
+
const connectors = (0, react_1.useMemo)(() => {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const mapped = wagmiConnectors
|
|
23
|
+
.filter(c => {
|
|
24
|
+
// Hide generic "Injected" — it duplicates the actual wallet (MetaMask, Rabby, etc.)
|
|
25
|
+
if (c.name === "Injected")
|
|
26
|
+
return false;
|
|
27
|
+
if (seen.has(c.name))
|
|
28
|
+
return false;
|
|
29
|
+
seen.add(c.name);
|
|
30
|
+
return true;
|
|
31
|
+
})
|
|
32
|
+
.map(connector => ({
|
|
33
|
+
name: connector.name,
|
|
34
|
+
uid: connector.uid,
|
|
35
|
+
isInstalled: isConnectorInstalled(connector),
|
|
36
|
+
connect: async () => {
|
|
37
|
+
await connectAsyncRef.current({ connector });
|
|
38
|
+
},
|
|
39
|
+
connector,
|
|
40
|
+
}));
|
|
41
|
+
// Sort: installed connectors first
|
|
42
|
+
return mapped.sort((a, b) => (a.isInstalled === b.isInstalled ? 0 : a.isInstalled ? -1 : 1));
|
|
43
|
+
}, [wagmiConnectors]);
|
|
44
|
+
return { address, isConnected, chain, isPending, connectors };
|
|
45
|
+
}
|
|
46
|
+
/** Check if a wallet connector's provider is available in the browser. */
|
|
47
|
+
function isConnectorInstalled(connector) {
|
|
48
|
+
// WalletConnect is always "available" (uses QR code, no extension needed)
|
|
49
|
+
if (connector.id === "walletConnect")
|
|
50
|
+
return true;
|
|
51
|
+
// For injected connectors, check if any provider exists. This may report
|
|
52
|
+
// false positives (e.g., Rabby shows as installed when only MetaMask is)
|
|
53
|
+
// because multiple injected connectors share window.ethereum. This is
|
|
54
|
+
// intentional — we surface all options and let the wallet handle conflicts.
|
|
55
|
+
if (connector.type === "injected") {
|
|
56
|
+
return typeof window !== "undefined" && !!window.ethereum;
|
|
57
|
+
}
|
|
58
|
+
// Coinbase Wallet SDK works without extension (has mobile/QR fallback)
|
|
59
|
+
if (connector.id === "coinbaseWalletSDK")
|
|
60
|
+
return true;
|
|
61
|
+
// Default: assume available (better UX than hiding connectors)
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WalletProvider, type WalletProviderProps } from "./components/WalletProvider";
|
|
2
|
+
export { createWalletConfig, type CreateWalletConfigOptions } from "../utils/createWalletConfig";
|
|
3
|
+
export { useWalletDisconnect } from "./hooks/useWalletDisconnect";
|
|
4
|
+
export { useWalletState, type WalletConnector, type WalletState } from "./hooks/useWalletState";
|
|
5
|
+
export { ConnectWallet, type ConnectWalletProps } from "./components/ConnectWallet";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectWallet = exports.useWalletState = exports.useWalletDisconnect = exports.createWalletConfig = exports.WalletProvider = void 0;
|
|
4
|
+
// Provider
|
|
5
|
+
var WalletProvider_1 = require("./components/WalletProvider");
|
|
6
|
+
Object.defineProperty(exports, "WalletProvider", { enumerable: true, get: function () { return WalletProvider_1.WalletProvider; } });
|
|
7
|
+
var createWalletConfig_1 = require("../utils/createWalletConfig");
|
|
8
|
+
Object.defineProperty(exports, "createWalletConfig", { enumerable: true, get: function () { return createWalletConfig_1.createWalletConfig; } });
|
|
9
|
+
// Hooks
|
|
10
|
+
var useWalletDisconnect_1 = require("./hooks/useWalletDisconnect");
|
|
11
|
+
Object.defineProperty(exports, "useWalletDisconnect", { enumerable: true, get: function () { return useWalletDisconnect_1.useWalletDisconnect; } });
|
|
12
|
+
var useWalletState_1 = require("./hooks/useWalletState");
|
|
13
|
+
Object.defineProperty(exports, "useWalletState", { enumerable: true, get: function () { return useWalletState_1.useWalletState; } });
|
|
14
|
+
// Components
|
|
15
|
+
var ConnectWallet_1 = require("./components/ConnectWallet");
|
|
16
|
+
Object.defineProperty(exports, "ConnectWallet", { enumerable: true, get: function () { return ConnectWallet_1.ConnectWallet; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CreateConnectorFn } from "wagmi";
|
|
2
|
+
import type { Chain } from "viem";
|
|
3
|
+
export interface CreateWalletConfigOptions {
|
|
4
|
+
/** Chains to support. Defaults to SDK's supportedChains. Must be non-empty. */
|
|
5
|
+
chains?: Chain[];
|
|
6
|
+
/**
|
|
7
|
+
* Wagmi connectors. Defaults to injected + Coinbase Wallet.
|
|
8
|
+
* Must be memoized if passed to WalletProvider — inline arrays
|
|
9
|
+
* will cause the config to rebuild on every render, losing wallet connection state.
|
|
10
|
+
*/
|
|
11
|
+
connectors?: CreateConnectorFn[];
|
|
12
|
+
/** Optional RPC URL overrides per chain ID. */
|
|
13
|
+
rpcUrls?: Record<number, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a generic wagmi config with sensible defaults.
|
|
17
|
+
* No ecosystem wallet, no B3-specific concerns.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
|
+
}, CreateConnectorFn[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWalletConfig = createWalletConfig;
|
|
4
|
+
const supported_1 = require("../../shared/constants/chains/supported");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const wagmi_1 = require("wagmi");
|
|
7
|
+
const connectors_1 = require("wagmi/connectors");
|
|
8
|
+
/** Default connectors: injected (MetaMask, Rabby, Brave, etc.) + Coinbase Wallet. */
|
|
9
|
+
const DEFAULT_CONNECTORS = [(0, connectors_1.injected)(), (0, connectors_1.coinbaseWallet)({ appName: "B3" })];
|
|
10
|
+
/**
|
|
11
|
+
* Creates a generic wagmi config with sensible defaults.
|
|
12
|
+
* No ecosystem wallet, no B3-specific concerns.
|
|
13
|
+
*/
|
|
14
|
+
function createWalletConfig(options = {}) {
|
|
15
|
+
const { chains = supported_1.supportedChains, connectors = DEFAULT_CONNECTORS, rpcUrls } = options;
|
|
16
|
+
if (chains.length === 0) {
|
|
17
|
+
throw new Error("createWalletConfig: at least one chain must be provided");
|
|
18
|
+
}
|
|
19
|
+
return (0, wagmi_1.createConfig)({
|
|
20
|
+
chains: [chains[0], ...chains.slice(1)],
|
|
21
|
+
transports: Object.fromEntries(chains.map(chain => [chain.id, (0, viem_1.http)(rpcUrls?.[chain.id])])),
|
|
22
|
+
connectors,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -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
|
/**
|
|
@@ -15,7 +15,7 @@ export const POLYGON_PUBLIC_RPC = "https://polygon-bor-rpc.publicnode.com";
|
|
|
15
15
|
export const AVALANCHE_PUBLIC_RPC = "https://avalanche-c-chain-rpc.publicnode.com";
|
|
16
16
|
export const BSC_PUBLIC_RPC = "https://bsc-rpc.publicnode.com";
|
|
17
17
|
// Chain-specific public endpoints
|
|
18
|
-
export const B3_PUBLIC_RPC = "https://
|
|
18
|
+
export const B3_PUBLIC_RPC = "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2/";
|
|
19
19
|
export const ABSTRACT_PUBLIC_RPC = "https://api.mainnet.abs.xyz";
|
|
20
20
|
export const HYPEREVM_PUBLIC_RPC = "https://rpc.hyperliquid.xyz/evm";
|
|
21
21
|
/**
|
|
@@ -7,7 +7,7 @@ import { formatDisplayNumber, formatTokenAmount } from "../../../shared/utils/nu
|
|
|
7
7
|
import { MoreVertical } from "lucide-react";
|
|
8
8
|
import { AnimatePresence } from "motion/react";
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
|
-
import {
|
|
10
|
+
import { b3Viem } from "../../../shared/constants/chains/b3Viem.js";
|
|
11
11
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
12
12
|
// ABI for contractURI and uri functions
|
|
13
13
|
const CONTRACT_URI_ABI = [
|
|
@@ -89,5 +89,5 @@ function DropdownMenu({ nftContract }) {
|
|
|
89
89
|
const [open, setOpen] = useState(false);
|
|
90
90
|
const chain = ALL_CHAINS[nftContract.chainId];
|
|
91
91
|
const nftUrl = getExplorerAddressUrl(nftContract.chainId, nftContract.contractAddress);
|
|
92
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _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: _jsx(MoreVertical, { className: "h-3 w-3" }) }) }), _jsx(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: _jsxs("div", { className: "pointer-events-auto flex w-full flex-col gap-2 py-2", children: [_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:", _jsxs("span", { className: "font-semibold", children: [formatTokenAmount(BigInt(nftContract.price), nftContract.currency.decimals, 6, false), " ", nftContract.currency.symbol] })] }), _jsxs("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2", children: [_jsx("img", { src: chain?.logoUrl, className: cn("h-5 w-5", nftContract.chainId !==
|
|
92
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _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: _jsx(MoreVertical, { className: "h-3 w-3" }) }) }), _jsx(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: _jsxs("div", { className: "pointer-events-auto flex w-full flex-col gap-2 py-2", children: [_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:", _jsxs("span", { className: "font-semibold", children: [formatTokenAmount(BigInt(nftContract.price), nftContract.currency.decimals, 6, false), " ", nftContract.currency.symbol] })] }), _jsxs("div", { className: "hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2", children: [_jsx("img", { src: chain?.logoUrl, className: cn("h-5 w-5", nftContract.chainId !== b3Viem.id && "rounded-full") }), _jsxs("span", { className: "text-sm", children: ["Minted on ", _jsx("span", { className: "font-semibold", children: chain ? getChainName(nftContract.chainId) : "Unknown" })] })] }), _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" })] }) })] }));
|
|
93
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
4
4
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
5
5
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -262,7 +262,7 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
|
|
|
262
262
|
opacity: hasMounted ? 1 : 0,
|
|
263
263
|
y: hasMounted ? 0 : 20,
|
|
264
264
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
265
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
265
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(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" }) }), _jsx(Button, { onClick: () => {
|
|
266
266
|
setB3ModalOpen(false);
|
|
267
267
|
onSuccess?.();
|
|
268
268
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
4
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
5
5
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
@@ -275,7 +275,7 @@ export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenA
|
|
|
275
275
|
opacity: hasMounted ? 1 : 0,
|
|
276
276
|
y: hasMounted ? 0 : 20,
|
|
277
277
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
278
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
278
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(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" }) }), _jsx(Button, { onClick: () => {
|
|
279
279
|
setB3ModalOpen(false);
|
|
280
280
|
onSuccess?.(formatTokenAmount(BigInt(userStakeAmount), 18) ?? "");
|
|
281
281
|
}, 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;
|
|
@@ -21,7 +21,7 @@ shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp,
|
|
|
21
21
|
// New discount props
|
|
22
22
|
enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
23
23
|
// Variable pricing
|
|
24
|
-
variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
24
|
+
variablePricing, feeOnTop, kycEnabled = false, callbackMetadata: callbackMetadataProp, }) {
|
|
25
25
|
// ===== Variable pricing state =====
|
|
26
26
|
const [variablePricingAmount, setVariablePricingAmount] = useState("0");
|
|
27
27
|
const isVariablePricingActive = variablePricing?.enabled === true;
|
|
@@ -173,8 +173,12 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
173
173
|
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
174
174
|
meta.variablePricingAmount = variablePricingAmount;
|
|
175
175
|
}
|
|
176
|
+
// Namespace caller-supplied metadata to avoid collisions with internal keys
|
|
177
|
+
if (callbackMetadataProp)
|
|
178
|
+
meta.callbackMetadata = callbackMetadataProp;
|
|
176
179
|
return Object.keys(meta).length > 0 ? meta : undefined;
|
|
177
180
|
}, [
|
|
181
|
+
callbackMetadataProp,
|
|
178
182
|
formData,
|
|
179
183
|
selectedShipping,
|
|
180
184
|
shippingAddress,
|
|
@@ -198,5 +202,9 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
198
202
|
(shippingOptions && shippingOptions.length > 0) ||
|
|
199
203
|
collectShippingAddress ||
|
|
200
204
|
enableDiscountCode;
|
|
201
|
-
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content:
|
|
205
|
+
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprint, children: _jsx(AnySpendCustomizationProvider, { slots: slots, content: {
|
|
206
|
+
successTitle: "Payment Successful",
|
|
207
|
+
successDescription: "Your payment has been processed successfully.",
|
|
208
|
+
...content,
|
|
209
|
+
}, theme: theme, children: _jsx(CheckoutLayout, { mode: mode, paymentPanel: _jsxs(_Fragment, { children: [isVariablePricingActive && tokenData && variablePricing && (_jsx(VariablePricingInput, { config: variablePricing, tokenDecimals: tokenDecimals, tokenSymbol: tokenSymbol, themeColor: themeColor, onChange: setVariablePricingAmount })), hasFormContent && (_jsxs("div", { className: "mb-6", children: [_jsx(CheckoutFormPanel, { formSchema: formSchema, formComponent: formComponent, shippingOptions: shippingOptions, collectShippingAddress: collectShippingAddress, enableDiscountCode: enableDiscountCode, validateDiscount: validateDiscount, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, classes: classes, formData: formData, onFormDataChange: handleFormDataChange, selectedShipping: selectedShipping, onShippingChange: handleShippingChange, appliedDiscount: appliedDiscount, onDiscountApplied: handleDiscountApplied, onDiscountRemoved: handleDiscountRemoved, shippingAddress: shippingAddress, onShippingAddressChange: setShippingAddress, checkoutFormSlot: slots?.checkoutForm }), _jsx("div", { className: "mt-6 border-t border-gray-200 dark:border-neutral-700" })] })), _jsx(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: _jsx(CheckoutCartPanel, { items: items, totalAmount: computedTotal, tokenSymbol: tokenSymbol, tokenDecimals: tokenDecimals, 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 }) }) }));
|
|
202
210
|
}
|
|
@@ -53,9 +53,7 @@ export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress
|
|
|
53
53
|
if (activeOrderId) {
|
|
54
54
|
return (_jsx(CheckoutOrderStatus, { orderId: activeOrderId, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, onRetry: handleRetry, showPoints: showPoints, showOrderId: showOrderId, classes: classes }));
|
|
55
55
|
}
|
|
56
|
-
const accordionButtonClass = (active) => cn("anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors", active
|
|
57
|
-
|
|
58
|
-
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
59
|
-
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 bg-white px-4 py-4 dark:border-neutral-800 dark:bg-neutral-900");
|
|
56
|
+
const accordionButtonClass = (active) => 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);
|
|
57
|
+
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 px-4 py-4 dark:border-neutral-800");
|
|
60
58
|
return (_jsxs("div", { className: cn("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [_jsx("h2", { className: cn("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && (_jsx("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), _jsxs("div", { className: 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: [_jsxs("div", { className: "anyspend-method-crypto", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [_jsx(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), _jsx(Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "crypto" && (_jsx(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: _jsx("div", { className: expandedPanelClass, children: _jsx(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")) })] }), _jsxs("div", { className: "anyspend-method-card", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [_jsx(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), _jsx(CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [_jsx(VisaLogo, {}), _jsx(MastercardLogo, {}), _jsx(AmexLogo, {})] })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "card" && (_jsx(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: _jsx("div", { className: expandedPanelClass, children: _jsx(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")) })] }), _jsxs("div", { className: "anyspend-method-coinbase", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [_jsx(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), _jsx(CoinbaseLogo, {}), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && (_jsx(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: _jsx("div", { className: expandedPanelClass, children: _jsx(CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
61
59
|
}
|
|
@@ -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 {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getExplorerTxUrl } from "../../../../anyspend/index.js";
|
|
4
|
+
import { b3Viem } from "../../../../shared/constants/chains/b3Viem.js";
|
|
3
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
6
|
import { ExternalLink } from "lucide-react";
|
|
5
7
|
import { motion } from "motion/react";
|
|
6
8
|
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
7
9
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
8
|
-
export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
10
|
+
export function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }) {
|
|
9
11
|
const { content, slots } = useAnySpendCustomization();
|
|
10
12
|
if (slots.successScreen) {
|
|
11
13
|
return (_jsx(_Fragment, { children: slots.successScreen({
|
|
@@ -15,7 +17,7 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
15
17
|
: "Your payment has been processed successfully.",
|
|
16
18
|
txHash,
|
|
17
19
|
orderId,
|
|
18
|
-
explorerUrl: txHash ?
|
|
20
|
+
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ?? b3Viem.id, txHash) : undefined,
|
|
19
21
|
onDone: () => {
|
|
20
22
|
if (returnUrl)
|
|
21
23
|
window.location.href = returnUrl;
|
|
@@ -24,5 +26,5 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
24
26
|
returnLabel: content.returnButtonLabel || returnLabel,
|
|
25
27
|
}) }));
|
|
26
28
|
}
|
|
27
|
-
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(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" }), _jsx(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 && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href:
|
|
29
|
+
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(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" }), _jsx(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 && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: getExplorerTxUrl(dstChainId ?? 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", _jsx(ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && (_jsxs(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 && (_jsx(motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: 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" }))] }));
|
|
28
30
|
}
|
|
@@ -8,9 +8,8 @@ import { useOnOrderSuccess } from "../../../../anyspend/react/hooks/useOnOrderSu
|
|
|
8
8
|
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "../../../../anyspend/index.js";
|
|
9
9
|
import { getPaymentUrl } from "../../../../anyspend/utils/chain.js";
|
|
10
10
|
import { isNativeToken } from "../../../../anyspend/utils/token.js";
|
|
11
|
-
import { useAccountWallet,
|
|
11
|
+
import { useAccountWallet, useIsMobile, useSimTokenBalance, useTokenData, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
|
|
12
12
|
import { ShinyButton, TextShimmer } from "../../../../global-account/react/index.js";
|
|
13
|
-
import { thirdwebB3Chain } from "../../../../shared/constants/chains/b3Chain.js";
|
|
14
13
|
import { formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
15
14
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
16
15
|
import { Check, ChevronDown, ChevronsUpDown, Copy, Loader2, QrCode } from "lucide-react";
|
|
@@ -18,8 +17,10 @@ import { QRCodeSVG } from "qrcode.react";
|
|
|
18
17
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
19
18
|
import { AnimatePresence, motion } from "motion/react";
|
|
20
19
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { useConnectModal } from "thirdweb/react";
|
|
21
21
|
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
22
22
|
import { ChainTokenIcon } from "../common/ChainTokenIcon.js";
|
|
23
|
+
import { connectModalConfig } from "../common/CryptoPaymentMethod.js";
|
|
23
24
|
export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, buttonText = "Pay", themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, classes, senderAddress, }) {
|
|
24
25
|
// Stable refs for callback props to avoid re-triggering effects
|
|
25
26
|
const onErrorRef = useRef(onError);
|
|
@@ -32,11 +33,10 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
32
33
|
const [selectedSrcChainId, setSelectedSrcChainId] = useState(destinationTokenChainId);
|
|
33
34
|
const [selectedSrcToken, setSelectedSrcToken] = useState(null);
|
|
34
35
|
const [copied, setCopied] = useState(false);
|
|
35
|
-
const { address: walletAddress } = useAccountWallet();
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
36
|
+
const { address: walletAddress, connectedEOAWallet } = useAccountWallet();
|
|
37
|
+
const connectedAddress = walletAddress || connectedEOAWallet?.getAccount()?.address;
|
|
38
|
+
const effectiveAddress = connectedAddress || senderAddress;
|
|
39
|
+
const { connect: openConnectModal } = useConnectModal();
|
|
40
40
|
const { data: dstTokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
41
41
|
// Default to destination token data once available
|
|
42
42
|
useEffect(() => {
|
|
@@ -166,9 +166,8 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
166
166
|
/* ------------------------------------------------------------------ */
|
|
167
167
|
const [walletOrderId, setWalletOrderId] = useState();
|
|
168
168
|
const [isSendingDeposit, setIsSendingDeposit] = useState(false);
|
|
169
|
-
const [depositRejected, setDepositRejected] = useState(false);
|
|
170
169
|
const depositSentRef = useRef(false);
|
|
171
|
-
const {
|
|
170
|
+
const { switchChainAndExecuteWithEOA } = useUnifiedChainSwitchAndExecute();
|
|
172
171
|
const { createOrder: createSwapOrder, isCreatingOrder: isCreatingSwapOrder } = useAnyspendCreateOrder({
|
|
173
172
|
onSuccess: data => {
|
|
174
173
|
const id = data.data?.id;
|
|
@@ -183,7 +182,7 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
183
182
|
const { orderAndTransactions: walletOat } = useAnyspendOrderAndTransactions(walletOrderId);
|
|
184
183
|
// Auto-send deposit tx once swap order is ready
|
|
185
184
|
useEffect(() => {
|
|
186
|
-
if (!walletOat?.data?.order || depositSentRef.current
|
|
185
|
+
if (!walletOat?.data?.order || depositSentRef.current)
|
|
187
186
|
return;
|
|
188
187
|
const order = walletOat.data.order;
|
|
189
188
|
if (order.status !== "scanning_deposit_transaction")
|
|
@@ -195,8 +194,9 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
195
194
|
try {
|
|
196
195
|
setIsSendingDeposit(true);
|
|
197
196
|
const amount = BigInt(order.srcAmount);
|
|
197
|
+
let txHash;
|
|
198
198
|
if (isNativeToken(order.srcTokenAddress)) {
|
|
199
|
-
await
|
|
199
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
200
200
|
to: order.globalAddress,
|
|
201
201
|
value: amount,
|
|
202
202
|
});
|
|
@@ -207,12 +207,18 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
207
207
|
functionName: "transfer",
|
|
208
208
|
args: [order.globalAddress, amount],
|
|
209
209
|
});
|
|
210
|
-
await
|
|
210
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
211
211
|
to: order.srcTokenAddress,
|
|
212
212
|
data,
|
|
213
213
|
value: BigInt(0),
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
+
if (!txHash) {
|
|
217
|
+
// User cancelled or tx failed — reset so they can retry
|
|
218
|
+
depositSentRef.current = false;
|
|
219
|
+
setWalletOrderId(undefined);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
216
222
|
// Deposit sent — notify parent to transition to order lifecycle tracking
|
|
217
223
|
if (walletOrderId) {
|
|
218
224
|
onOrderCreatedRef.current?.(walletOrderId);
|
|
@@ -220,10 +226,8 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
220
226
|
}
|
|
221
227
|
catch (error) {
|
|
222
228
|
depositSentRef.current = false;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
setDepositRejected(true);
|
|
226
|
-
}
|
|
229
|
+
// Reset order so user can retry
|
|
230
|
+
setWalletOrderId(undefined);
|
|
227
231
|
onErrorRef.current?.(error instanceof Error ? error : new Error(error?.message || "Transaction rejected"));
|
|
228
232
|
}
|
|
229
233
|
finally {
|
|
@@ -231,7 +235,7 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
231
235
|
}
|
|
232
236
|
};
|
|
233
237
|
sendDeposit();
|
|
234
|
-
}, [walletOat,
|
|
238
|
+
}, [walletOat, switchChainAndExecuteWithEOA, walletOrderId]);
|
|
235
239
|
useOnOrderSuccess({
|
|
236
240
|
orderData: walletOat,
|
|
237
241
|
orderId: walletOrderId,
|
|
@@ -239,9 +243,10 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
239
243
|
});
|
|
240
244
|
const isWaitingForExecution = !!walletOrderId && walletOat?.data?.order.status !== "executed";
|
|
241
245
|
const handleWalletPay = useCallback(() => {
|
|
242
|
-
if (!selectedSrcToken || !
|
|
246
|
+
if (!selectedSrcToken || !connectedAddress)
|
|
243
247
|
return;
|
|
244
248
|
depositSentRef.current = false;
|
|
249
|
+
setWalletOrderId(undefined);
|
|
245
250
|
createSwapOrder({
|
|
246
251
|
recipientAddress,
|
|
247
252
|
orderType: "swap",
|
|
@@ -256,7 +261,7 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
256
261
|
});
|
|
257
262
|
}, [
|
|
258
263
|
selectedSrcToken,
|
|
259
|
-
|
|
264
|
+
connectedAddress,
|
|
260
265
|
effectiveAddress,
|
|
261
266
|
recipientAddress,
|
|
262
267
|
selectedSrcChainId,
|
|
@@ -288,13 +293,28 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
288
293
|
setTimeout(() => setCopied(false), 2000);
|
|
289
294
|
}
|
|
290
295
|
};
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
const [shouldAutoPay, setShouldAutoPay] = useState(false);
|
|
297
|
+
const handleConnectWallet = async () => {
|
|
298
|
+
try {
|
|
299
|
+
const wallet = await openConnectModal(connectModalConfig);
|
|
300
|
+
if (wallet) {
|
|
301
|
+
setShouldAutoPay(true);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
console.error("Failed to connect wallet:", error);
|
|
306
|
+
}
|
|
294
307
|
};
|
|
308
|
+
// Auto-trigger payment after wallet connect
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if (shouldAutoPay && connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoadingAnyspendQuote) {
|
|
311
|
+
setShouldAutoPay(false);
|
|
312
|
+
handleWalletPay();
|
|
313
|
+
}
|
|
314
|
+
}, [shouldAutoPay, connectedAddress, selectedSrcToken, hasEnoughBalance, isLoadingAnyspendQuote, handleWalletPay]);
|
|
295
315
|
const isLoading = isLoadingAnyspendQuote;
|
|
296
316
|
const isPending = isCreatingSwapOrder || isSendingDeposit || isWaitingForExecution;
|
|
297
|
-
const canPay =
|
|
317
|
+
const canPay = connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoading && !isPending;
|
|
298
318
|
const chainName = ALL_CHAINS[selectedSrcChainId]?.name || "the specified chain";
|
|
299
319
|
const chainLogoUrl = ALL_CHAINS[selectedSrcChainId]?.logoUrl;
|
|
300
320
|
// Collapse QR on mobile when a wallet connector is available
|
|
@@ -313,7 +333,7 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
313
333
|
name: token.name,
|
|
314
334
|
symbol: token.symbol,
|
|
315
335
|
});
|
|
316
|
-
}, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: _jsxs("button", { className: 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 ? (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[selectedSrcToken.chainId]?.logoUrl || "", tokenUrl: selectedSrcToken.metadata?.logoURI, className: "h-8 w-8" }), _jsxs("div", { className: "text-left", children: [_jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: selectedSrcToken.symbol }), _jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: ["Balance: ", balance.formatted] })] })] })) : (_jsx("span", { className: "text-sm text-gray-400", children: "Select token" })), _jsx(ChevronsUpDown, { className: "h-4 w-4 text-gray-400" })] }) })] }), _jsx(motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, ease: "easeOut" }, className: 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: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "You pay" }), _jsx(AnimatePresence, { mode: "wait", children: isLoadingAnyspendQuote ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, children: _jsx(TextShimmer, { duration: 1, className: "text-sm", children: "Fetching quote..." }) }, "quote-loading")) : (_jsxs(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")) })] }) }), _jsx(AnimatePresence, { children:
|
|
336
|
+
}, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: _jsxs("button", { className: 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 ? (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[selectedSrcToken.chainId]?.logoUrl || "", tokenUrl: selectedSrcToken.metadata?.logoURI, className: "h-8 w-8" }), _jsxs("div", { className: "text-left", children: [_jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: selectedSrcToken.symbol }), _jsxs("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: ["Balance: ", balance.formatted] })] })] })) : (_jsx("span", { className: "text-sm text-gray-400", children: "Select token" })), _jsx(ChevronsUpDown, { className: "h-4 w-4 text-gray-400" })] }) })] }), _jsx(motion.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.25, ease: "easeOut" }, className: 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: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "You pay" }), _jsx(AnimatePresence, { mode: "wait", children: isLoadingAnyspendQuote ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.15 }, children: _jsx(TextShimmer, { duration: 1, className: "text-sm", children: "Fetching quote..." }) }, "quote-loading")) : (_jsxs(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")) })] }) }), _jsx(AnimatePresence, { children: connectedAddress && selectedSrcToken && !hasEnoughBalance && !isLoading && (_jsxs(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 ? (_jsx(ShinyButton, { accentColor: themeColor || "hsl(var(--as-brand))", onClick: handleConnectWallet, className: cn("w-full", classes?.payButton), textClassName: "text-white", children: "Connect Wallet to Pay" })) : (_jsx(ShinyButton, { accentColor: themeColor || "hsl(var(--as-brand))", onClick: handleWalletPay, disabled: !canPay, className: cn("w-full", classes?.payButton), textClassName: cn(!canPay ? "text-as-secondary" : "text-white"), children: isPending ? (_jsxs("span", { className: "flex items-center justify-center gap-2", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), isCreatingSwapOrder
|
|
317
337
|
? "Creating order..."
|
|
318
338
|
: isSendingDeposit
|
|
319
339
|
? "Confirm in wallet..."
|
|
@@ -5,19 +5,18 @@ import { USDC_BASE } from "../../../../anyspend/constants/index.js";
|
|
|
5
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
6
6
|
import { formatUnits } from "../../../../shared/utils/number.js";
|
|
7
7
|
import { getStripePromise } from "../../../../shared/utils/payment.utils.js";
|
|
8
|
-
import { ShinyButton, TextShimmer, useB3Config, useModalStore, useTokenData } from "../../../../global-account/react/index.js";
|
|
8
|
+
import { ShinyButton, TextShimmer, useAccountWallet, useB3Config, useModalStore, useTokenData, } from "../../../../global-account/react/index.js";
|
|
9
9
|
import { thirdwebB3Chain } from "../../../../shared/constants/chains/b3Chain.js";
|
|
10
10
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
11
11
|
import { Loader2, Lock, Wallet } from "lucide-react";
|
|
12
12
|
import { AnimatePresence, motion } from "motion/react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
|
-
import { useAccount } from "wagmi";
|
|
15
14
|
import { KycGate } from "./KycGate.js";
|
|
16
15
|
export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, classes, feeOnTop, kycEnabled = false, }) {
|
|
17
16
|
// Stable refs for callback props to avoid re-triggering effects
|
|
18
17
|
const onErrorRef = useRef(onError);
|
|
19
18
|
onErrorRef.current = onError;
|
|
20
|
-
const { address } =
|
|
19
|
+
const { address } = useAccountWallet();
|
|
21
20
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
22
21
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
23
22
|
const { data: tokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
-
import { ShinyButton, TextShimmer, useB3Config, useModalStore } from "../../../../global-account/react/index.js";
|
|
4
|
+
import { ShinyButton, TextShimmer, useAccountWallet, useB3Config, useModalStore, } from "../../../../global-account/react/index.js";
|
|
5
5
|
import { thirdwebB3Chain } from "../../../../shared/constants/chains/b3Chain.js";
|
|
6
6
|
import { Loader2, ShieldCheck, AlertTriangle, Clock, Wallet } from "lucide-react";
|
|
7
7
|
import { AnimatePresence, motion } from "motion/react";
|
|
8
8
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
|
-
import { useAccount } from "wagmi";
|
|
10
9
|
import { useCreateKycInquiry, useKycStatus, useVerifyKyc, useWalletAuthHeaders } from "../../hooks/useKycStatus.js";
|
|
11
10
|
export function KycGate({ themeColor, classes, enabled = false, onStatusResolved }) {
|
|
12
|
-
const { address } =
|
|
11
|
+
const { address } = useAccountWallet();
|
|
13
12
|
const { partnerId } = useB3Config();
|
|
14
13
|
// Gate the status fetch behind explicit user consent so the wallet
|
|
15
14
|
// signature prompt doesn't fire automatically on tab open.
|
|
@@ -5,6 +5,14 @@ export declare enum CryptoPaymentMethodType {
|
|
|
5
5
|
GLOBAL_WALLET = "global_wallet",
|
|
6
6
|
TRANSFER_CRYPTO = "transfer_crypto"
|
|
7
7
|
}
|
|
8
|
+
export declare const recommendWallets: (import("thirdweb/wallets").Wallet<"io.metamask"> | import("thirdweb/wallets").Wallet<"com.coinbase.wallet"> | import("thirdweb/wallets").Wallet<"me.rainbow"> | import("thirdweb/wallets").Wallet<"io.rabby">)[];
|
|
9
|
+
export declare const connectModalConfig: {
|
|
10
|
+
client: import("thirdweb").ThirdwebClient;
|
|
11
|
+
setActive: false;
|
|
12
|
+
size: "compact";
|
|
13
|
+
showThirdwebBranding: boolean;
|
|
14
|
+
wallets: (import("thirdweb/wallets").Wallet<"io.metamask"> | import("thirdweb/wallets").Wallet<"com.coinbase.wallet"> | import("thirdweb/wallets").Wallet<"me.rainbow"> | import("thirdweb/wallets").Wallet<"io.rabby">)[];
|
|
15
|
+
};
|
|
8
16
|
interface CryptoPaymentMethodProps {
|
|
9
17
|
selectedPaymentMethod: CryptoPaymentMethodType;
|
|
10
18
|
setSelectedPaymentMethod: (method: CryptoPaymentMethodType) => void;
|