thirdweb 5.39.0 → 5.40.0
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/exports/react.js +7 -2
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/react/core/design-system/index.js +2 -0
- package/dist/cjs/react/core/design-system/index.js.map +1 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +13 -94
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js +16 -3
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/core/utils/defaultTokens.js +32 -25
- package/dist/cjs/react/core/utils/defaultTokens.js.map +1 -1
- package/dist/cjs/react/core/utils/wallet.js +91 -13
- package/dist/cjs/react/core/utils/wallet.js.map +1 -1
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +18 -127
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +184 -118
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +104 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +69 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +23 -5
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +132 -45
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +9 -5
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +8 -3
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +84 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +13 -7
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +16 -9
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +53 -0
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +33 -0
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +16 -5
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js +18 -2
- package/dist/cjs/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
- package/dist/cjs/react/web/wallets/shared/oauthSignIn.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/index.js +15 -0
- package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/in-app.js +10 -0
- package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js +2 -0
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js +9 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js +26 -0
- package/dist/cjs/wallets/in-app/web/lib/get-url-token.js.map +1 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js +13 -3
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/exports/react.js +3 -1
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/react/core/design-system/index.js +2 -0
- package/dist/esm/react/core/design-system/index.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +13 -93
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +16 -3
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/core/utils/defaultTokens.js +31 -25
- package/dist/esm/react/core/utils/defaultTokens.js.map +1 -1
- package/dist/esm/react/core/utils/wallet.js +88 -13
- package/dist/esm/react/core/utils/wallet.js.map +1 -1
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +20 -129
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +188 -122
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +101 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +66 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +22 -5
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +130 -44
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +7 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +9 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +81 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +14 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +16 -9
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +50 -0
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +29 -0
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +15 -4
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js +17 -1
- package/dist/esm/react/web/wallets/shared/SocialLogin.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
- package/dist/esm/react/web/wallets/shared/oauthSignIn.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/in-app/core/wallet/index.js +15 -0
- package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/in-app.js +10 -0
- package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/index.js +2 -0
- package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/oauth.js +7 -0
- package/dist/esm/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js +23 -0
- package/dist/esm/wallets/in-app/web/lib/get-url-token.js.map +1 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js +14 -4
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/types/exports/react.d.ts +3 -2
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/utils.d.ts +1 -0
- package/dist/types/exports/utils.d.ts.map +1 -1
- package/dist/types/react/core/design-system/index.d.ts +2 -0
- package/dist/types/react/core/design-system/index.d.ts.map +1 -1
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +80 -34
- package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +3 -15
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAutoConnect.d.ts.map +1 -1
- package/dist/types/react/core/utils/defaultTokens.d.ts +222 -0
- package/dist/types/react/core/utils/defaultTokens.d.ts.map +1 -1
- package/dist/types/react/core/utils/wallet.d.ts +43 -1
- package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
- package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts +2 -4
- package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +3 -1
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts +0 -3
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts +18 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +18 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +5 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +14 -8
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +19 -9
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +6 -5
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts +0 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts +4 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts +1 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +19 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/nativeToken.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +0 -6
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts +9 -0
- package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -0
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +24 -0
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -0
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/SocialLogin.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/{openOauthSignInWindow.d.ts → oauthSignIn.d.ts} +1 -2
- package/dist/types/react/web/wallets/shared/oauthSignIn.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/ecosystem/types.d.ts +3 -0
- package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/interfaces/connector.d.ts +4 -1
- package/dist/types/wallets/in-app/core/interfaces/connector.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/types.d.ts +4 -1
- package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/in-app.d.ts +10 -0
- package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts +11 -2
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts +5 -0
- package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts +12 -0
- package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts.map +1 -0
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +4 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/react.ts +14 -2
- package/src/exports/utils.ts +2 -0
- package/src/react/core/design-system/index.ts +2 -0
- package/src/react/core/hooks/connection/ConnectButtonProps.ts +103 -51
- package/src/react/core/hooks/transaction/useSendTransaction.ts +17 -127
- package/src/react/core/hooks/wallets/useAutoConnect.ts +17 -3
- package/src/react/core/utils/defaultTokens.ts +38 -26
- package/src/react/core/utils/wallet.ts +102 -18
- package/src/react/web/hooks/transaction/useSendTransaction.tsx +34 -278
- package/src/react/web/ui/ConnectWallet/Details.tsx +6 -4
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +9 -3
- package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +347 -383
- package/src/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.tsx +266 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +253 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +52 -21
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx +3 -6
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.tsx +5 -6
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +2 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +2 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +16 -12
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +155 -60
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +8 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +17 -12
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +2 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +2 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +2 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +27 -19
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.tsx +8 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +12 -5
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.tsx +2 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.tsx +3 -4
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +243 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.tsx +30 -17
- package/src/react/web/ui/ConnectWallet/screens/nativeToken.ts +5 -1
- package/src/react/web/ui/PayEmbed.tsx +31 -32
- package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +127 -0
- package/src/react/web/ui/TransactionButton/TransactionModal.tsx +83 -0
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +18 -4
- package/src/react/web/wallets/shared/SocialLogin.tsx +20 -1
- package/src/react/web/wallets/shared/{openOauthSignInWindow.ts → oauthSignIn.ts} +1 -2
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/types.ts +3 -0
- package/src/wallets/in-app/core/interfaces/connector.ts +6 -0
- package/src/wallets/in-app/core/wallet/index.ts +22 -0
- package/src/wallets/in-app/core/wallet/types.ts +4 -0
- package/src/wallets/in-app/web/in-app.ts +10 -0
- package/src/wallets/in-app/web/lib/auth/index.ts +14 -3
- package/src/wallets/in-app/web/lib/auth/oauth.ts +12 -0
- package/src/wallets/in-app/web/lib/get-url-token.ts +36 -0
- package/src/wallets/in-app/web/lib/web-connector.ts +18 -4
- package/dist/cjs/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
- package/dist/esm/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
- package/dist/types/react/web/wallets/shared/openOauthSignInWindow.d.ts.map +0 -1
@@ -1,21 +1,21 @@
|
|
1
1
|
import { IdCardIcon } from "@radix-ui/react-icons";
|
2
|
-
import { useMemo, useState } from "react";
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
3
3
|
import type { Chain } from "../../../../../../chains/types.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../../../client/client.js";
|
5
5
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
|
6
6
|
import type { GetBuyWithCryptoQuoteParams } from "../../../../../../pay/buyWithCrypto/getQuote.js";
|
7
7
|
import { isSwapRequiredPostOnramp } from "../../../../../../pay/buyWithFiat/isSwapRequiredPostOnramp.js";
|
8
8
|
import { formatNumber } from "../../../../../../utils/formatNumber.js";
|
9
|
-
import { toEther, toTokens } from "../../../../../../utils/units.js";
|
10
9
|
import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
|
11
10
|
import {
|
12
11
|
type Theme,
|
13
|
-
fontSize,
|
14
12
|
iconSize,
|
15
13
|
spacing,
|
16
14
|
} from "../../../../../core/design-system/index.js";
|
17
|
-
import type {
|
18
|
-
|
15
|
+
import type {
|
16
|
+
FundWalletOptions,
|
17
|
+
PayUIOptions,
|
18
|
+
} from "../../../../../core/hooks/connection/ConnectButtonProps.js";
|
19
19
|
import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
|
20
20
|
import { useBuyWithCryptoQuote } from "../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
|
21
21
|
import { useBuyWithFiatQuote } from "../../../../../core/hooks/pay/useBuyWithFiatQuote.js";
|
@@ -29,11 +29,9 @@ import {
|
|
29
29
|
DrawerOverlay,
|
30
30
|
useDrawer,
|
31
31
|
} from "../../../components/Drawer.js";
|
32
|
-
import { Skeleton } from "../../../components/Skeleton.js";
|
33
32
|
import { Spacer } from "../../../components/Spacer.js";
|
34
33
|
import { Spinner } from "../../../components/Spinner.js";
|
35
34
|
import { SwitchNetworkButton } from "../../../components/SwitchNetwork.js";
|
36
|
-
import { TokenIcon } from "../../../components/TokenIcon.js";
|
37
35
|
import { Container, Line, ModalHeader } from "../../../components/basic.js";
|
38
36
|
import { Button } from "../../../components/buttons.js";
|
39
37
|
import { Text } from "../../../components/text.js";
|
@@ -44,28 +42,28 @@ import { CoinsIcon } from "../../icons/CoinsIcon.js";
|
|
44
42
|
import type { ConnectLocale } from "../../locale/types.js";
|
45
43
|
import { TokenSelector } from "../TokenSelector.js";
|
46
44
|
import { WalletSwitcherConnectionScreen } from "../WalletSwitcherConnectionScreen.js";
|
47
|
-
import {
|
48
|
-
|
49
|
-
NATIVE_TOKEN,
|
50
|
-
isNativeToken,
|
51
|
-
} from "../nativeToken.js";
|
45
|
+
import { type ERC20OrNativeToken, isNativeToken } from "../nativeToken.js";
|
46
|
+
import { DirectPaymentModeScreen } from "./DirectPaymentModeScreen.js";
|
52
47
|
import { EstimatedTimeAndFees } from "./EstimatedTimeAndFees.js";
|
53
48
|
import { PayTokenIcon } from "./PayTokenIcon.js";
|
54
49
|
import { PayWithCreditCard } from "./PayWIthCreditCard.js";
|
55
|
-
import {
|
50
|
+
import { TransactionModeScreen } from "./TransactionModeScreen.js";
|
56
51
|
import { WalletSelectorButton } from "./WalletSelectorButton.js";
|
57
52
|
import { CurrencySelection } from "./fiat/CurrencySelection.js";
|
58
53
|
import { FiatFlow } from "./fiat/FiatFlow.js";
|
59
54
|
import type { CurrencyMeta } from "./fiat/currencies.js";
|
60
|
-
import type {
|
61
|
-
import {
|
62
|
-
|
55
|
+
import type { SelectedScreen } from "./main/types.js";
|
56
|
+
import {
|
57
|
+
type PaymentMethods,
|
58
|
+
useEnabledPaymentMethods,
|
59
|
+
} from "./main/useEnabledPaymentMethods.js";
|
63
60
|
import { useUISelectionStates } from "./main/useUISelectionStates.js";
|
64
61
|
import { openOnrampPopup } from "./openOnRamppopup.js";
|
65
62
|
import { BuyTokenInput } from "./swap/BuyTokenInput.js";
|
66
63
|
import { FiatFees, SwapFees } from "./swap/Fees.js";
|
67
64
|
import { PayWithCrypto } from "./swap/PayWithCrypto.js";
|
68
65
|
import { SwapFlow } from "./swap/SwapFlow.js";
|
66
|
+
import { TransferFlow } from "./swap/TransferFlow.js";
|
69
67
|
import { WalletSwitcherDrawerContent } from "./swap/WalletSwitcherDrawerContent.js";
|
70
68
|
import { addPendingTx } from "./swap/pendingSwapTx.js";
|
71
69
|
import {
|
@@ -80,10 +78,8 @@ export type BuyScreenProps = {
|
|
80
78
|
title: string;
|
81
79
|
onBack: (() => void) | undefined;
|
82
80
|
supportedTokens: SupportedTokens | undefined;
|
83
|
-
onViewPendingTx: () => void;
|
84
81
|
client: ThirdwebClient;
|
85
82
|
connectLocale: ConnectLocale;
|
86
|
-
buyForTx: BuyForTx | undefined;
|
87
83
|
payOptions: PayUIOptions;
|
88
84
|
theme: "light" | "dark" | Theme;
|
89
85
|
onDone: () => void;
|
@@ -104,9 +100,7 @@ export default function BuyScreen(props: BuyScreenProps) {
|
|
104
100
|
return (
|
105
101
|
<BuyScreenContent
|
106
102
|
{...props}
|
107
|
-
onViewPendingTx={props.onViewPendingTx}
|
108
103
|
supportedDestinations={supportedDestinationsQuery.data}
|
109
|
-
buyForTx={props.buyForTx}
|
110
104
|
/>
|
111
105
|
);
|
112
106
|
}
|
@@ -116,10 +110,8 @@ type BuyScreenContentProps = {
|
|
116
110
|
client: ThirdwebClient;
|
117
111
|
onBack?: () => void;
|
118
112
|
supportedTokens?: SupportedTokens;
|
119
|
-
onViewPendingTx: () => void;
|
120
113
|
supportedDestinations: SupportedChainAndTokens;
|
121
114
|
connectLocale: ConnectLocale;
|
122
|
-
buyForTx?: BuyForTx;
|
123
115
|
theme: "light" | "dark" | Theme;
|
124
116
|
payOptions: PayUIOptions;
|
125
117
|
onDone: () => void;
|
@@ -131,8 +123,7 @@ type BuyScreenContentProps = {
|
|
131
123
|
* @internal
|
132
124
|
*/
|
133
125
|
function BuyScreenContent(props: BuyScreenContentProps) {
|
134
|
-
const { client, supportedDestinations, connectLocale, payOptions
|
135
|
-
props;
|
126
|
+
const { client, supportedDestinations, connectLocale, payOptions } = props;
|
136
127
|
|
137
128
|
const activeAccount = useActiveAccount();
|
138
129
|
const { payer, setPayer } = usePayerSetup();
|
@@ -143,6 +134,11 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
143
134
|
|
144
135
|
const [hasEditedAmount, setHasEditedAmount] = useState(false);
|
145
136
|
|
137
|
+
const onDone = useCallback(() => {
|
138
|
+
setScreen({ id: "main" });
|
139
|
+
props.onDone();
|
140
|
+
}, [props.onDone]);
|
141
|
+
|
146
142
|
// UI selection
|
147
143
|
const {
|
148
144
|
tokenAmount,
|
@@ -160,7 +156,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
160
156
|
setSelectedCurrency,
|
161
157
|
} = useUISelectionStates({
|
162
158
|
payOptions,
|
163
|
-
buyForTx,
|
164
159
|
supportedDestinations,
|
165
160
|
});
|
166
161
|
|
@@ -195,6 +190,18 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
195
190
|
);
|
196
191
|
}, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
|
197
192
|
|
193
|
+
const enabledPaymentMethods = useEnabledPaymentMethods({
|
194
|
+
payOptions: props.payOptions,
|
195
|
+
supportedDestinations: props.supportedDestinations,
|
196
|
+
toChain: toChain,
|
197
|
+
toToken: toToken,
|
198
|
+
});
|
199
|
+
|
200
|
+
const payDisabled =
|
201
|
+
enabledPaymentMethods.showPaymentSelection === false &&
|
202
|
+
enabledPaymentMethods.buyWithCryptoEnabled === false &&
|
203
|
+
enabledPaymentMethods.buyWithFiatEnabled === false;
|
204
|
+
|
198
205
|
// screens ----------------------------
|
199
206
|
|
200
207
|
if (screen.id === "connect-payer-wallet") {
|
@@ -231,7 +238,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
231
238
|
return (
|
232
239
|
<SwapFlow
|
233
240
|
title={props.title}
|
234
|
-
|
241
|
+
transactionMode={payOptions.mode === "transaction"}
|
235
242
|
isEmbed={props.isEmbed}
|
236
243
|
client={client}
|
237
244
|
onBack={() => {
|
@@ -241,9 +248,8 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
241
248
|
}}
|
242
249
|
buyWithCryptoQuote={screen.quote}
|
243
250
|
payer={payer}
|
244
|
-
onViewPendingTx={props.onViewPendingTx}
|
245
251
|
isFiatFlow={false}
|
246
|
-
onDone={
|
252
|
+
onDone={onDone}
|
247
253
|
onTryAgain={() => {
|
248
254
|
setScreen({
|
249
255
|
id: "buy-with-crypto",
|
@@ -257,7 +263,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
257
263
|
return (
|
258
264
|
<FiatFlow
|
259
265
|
title={props.title}
|
260
|
-
|
266
|
+
transactionMode={payOptions.mode === "transaction"}
|
261
267
|
quote={screen.quote}
|
262
268
|
onBack={() => {
|
263
269
|
setScreen({
|
@@ -270,15 +276,37 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
270
276
|
props.payOptions.buyWithFiat?.testMode === true
|
271
277
|
}
|
272
278
|
theme={typeof props.theme === "string" ? props.theme : props.theme.type}
|
273
|
-
onViewPendingTx={props.onViewPendingTx}
|
274
279
|
openedWindow={screen.openedWindow}
|
275
|
-
onDone={
|
280
|
+
onDone={onDone}
|
276
281
|
isEmbed={props.isEmbed}
|
277
282
|
payer={payer}
|
278
283
|
/>
|
279
284
|
);
|
280
285
|
}
|
281
286
|
|
287
|
+
if (screen.id === "transfer-flow" && payer && activeAccount) {
|
288
|
+
const goBack = () => setScreen({ id: "buy-with-crypto" });
|
289
|
+
// TODO (pay) pass it via screen props
|
290
|
+
const defaultRecipientAddress = (
|
291
|
+
props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
|
292
|
+
)?.paymentInfo?.sellerAddress;
|
293
|
+
const receiverAddress = defaultRecipientAddress || activeAccount.address;
|
294
|
+
return (
|
295
|
+
<TransferFlow
|
296
|
+
title={props.title}
|
297
|
+
onBack={goBack}
|
298
|
+
payer={payer}
|
299
|
+
client={props.client}
|
300
|
+
onDone={onDone}
|
301
|
+
chain={toChain}
|
302
|
+
token={toToken}
|
303
|
+
tokenAmount={tokenAmount}
|
304
|
+
receiverAddress={receiverAddress}
|
305
|
+
transactionMode={props.payOptions.mode === "transaction"}
|
306
|
+
/>
|
307
|
+
);
|
308
|
+
}
|
309
|
+
|
282
310
|
if (screen.id === "select-currency") {
|
283
311
|
const goBack = () => setScreen(screen.backScreen);
|
284
312
|
return (
|
@@ -295,8 +323,10 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
295
323
|
if (screen.id === "select-to-token") {
|
296
324
|
const chains = supportedDestinations.map((x) => x.chain);
|
297
325
|
const goBack = () => setScreen(screen.backScreen);
|
326
|
+
const allowEdits = (payOptions as FundWalletOptions)?.prefillBuy
|
327
|
+
?.allowEdits;
|
298
328
|
// if token selection is disabled - only show network selector screen
|
299
|
-
if (
|
329
|
+
if (allowEdits?.token === false) {
|
300
330
|
return (
|
301
331
|
<ChainSelectionScreen
|
302
332
|
chains={chains}
|
@@ -322,7 +352,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
322
352
|
chain={toChain}
|
323
353
|
chainSelection={
|
324
354
|
// hide chain selection if it's disabled
|
325
|
-
|
355
|
+
allowEdits?.chain !== false
|
326
356
|
? {
|
327
357
|
chains: chains,
|
328
358
|
select: (c) => {
|
@@ -397,28 +427,32 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
397
427
|
<MainScreen
|
398
428
|
title={props.title}
|
399
429
|
payerAccount={payer?.account}
|
400
|
-
buyForTx={buyForTx}
|
401
430
|
client={client}
|
402
431
|
onSelectBuyToken={() =>
|
403
432
|
setScreen({ id: "select-to-token", backScreen: screen })
|
404
433
|
}
|
405
434
|
payOptions={payOptions}
|
406
435
|
setTokenAmount={setTokenAmount}
|
436
|
+
setToChain={setToChain}
|
437
|
+
setToToken={setToToken}
|
438
|
+
setFromChain={setFromChain}
|
439
|
+
setFromToken={setFromToken}
|
407
440
|
toChain={toChain}
|
408
441
|
toToken={toToken}
|
409
442
|
tokenAmount={tokenAmount}
|
410
443
|
connectOptions={props.connectOptions}
|
411
|
-
onViewPendingTx={props.onViewPendingTx}
|
412
444
|
setScreen={setScreen}
|
413
445
|
supportedDestinations={supportedDestinations}
|
414
446
|
onBack={props.onBack}
|
415
447
|
theme={props.theme}
|
416
448
|
hasEditedAmount={hasEditedAmount}
|
417
449
|
setHasEditedAmount={setHasEditedAmount}
|
450
|
+
enabledPaymentMethods={enabledPaymentMethods}
|
418
451
|
/>
|
419
452
|
)}
|
420
453
|
|
421
454
|
{(screen.id === "select-payment-method" ||
|
455
|
+
screen.id === "select-wallet" ||
|
422
456
|
screen.id === "buy-with-crypto" ||
|
423
457
|
screen.id === "buy-with-fiat") &&
|
424
458
|
payer && (
|
@@ -430,11 +464,14 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
430
464
|
client={client}
|
431
465
|
onBack={() => {
|
432
466
|
if (
|
433
|
-
|
434
|
-
screen.id === "
|
467
|
+
enabledPaymentMethods.showPaymentSelection &&
|
468
|
+
(screen.id === "select-wallet" ||
|
469
|
+
screen.id === "buy-with-fiat")
|
435
470
|
) {
|
436
471
|
setScreen({ id: "select-payment-method" });
|
437
|
-
} else if (screen.id === "
|
472
|
+
} else if (screen.id === "buy-with-crypto") {
|
473
|
+
setScreen({ id: "select-wallet" });
|
474
|
+
} else {
|
438
475
|
setScreen({ id: "main" });
|
439
476
|
}
|
440
477
|
}}
|
@@ -443,6 +480,38 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
443
480
|
<PaymentMethodSelection setScreen={(id) => setScreen({ id })} />
|
444
481
|
)}
|
445
482
|
|
483
|
+
{screen.id === "select-wallet" && (
|
484
|
+
<WalletSwitcherDrawerContent
|
485
|
+
client={client}
|
486
|
+
onSelect={(w) => {
|
487
|
+
const chain = w.getChain();
|
488
|
+
const account = w.getAccount();
|
489
|
+
if (chain && account) {
|
490
|
+
setPayer({
|
491
|
+
account,
|
492
|
+
chain,
|
493
|
+
wallet: w,
|
494
|
+
});
|
495
|
+
setScreen({ id: "buy-with-crypto" });
|
496
|
+
}
|
497
|
+
}}
|
498
|
+
showAllWallets={!!props.connectOptions?.showAllWallets}
|
499
|
+
wallets={props.connectOptions?.wallets}
|
500
|
+
onBack={() => {
|
501
|
+
// no-op
|
502
|
+
}}
|
503
|
+
onConnect={() => {
|
504
|
+
setScreen({
|
505
|
+
id: "connect-payer-wallet",
|
506
|
+
backScreen: {
|
507
|
+
id: "select-wallet",
|
508
|
+
},
|
509
|
+
});
|
510
|
+
}}
|
511
|
+
selectedAddress={payer.account.address}
|
512
|
+
/>
|
513
|
+
)}
|
514
|
+
|
446
515
|
{screen.id === "buy-with-crypto" && activeAccount && (
|
447
516
|
<SwapScreenContent
|
448
517
|
setScreen={setScreen}
|
@@ -458,11 +527,9 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
458
527
|
});
|
459
528
|
}}
|
460
529
|
payer={payer}
|
461
|
-
buyForTx={buyForTx || null}
|
462
530
|
client={client}
|
463
531
|
isEmbed={props.isEmbed}
|
464
|
-
onDone={
|
465
|
-
onViewPendingTx={props.onViewPendingTx}
|
532
|
+
onDone={onDone}
|
466
533
|
payOptions={payOptions}
|
467
534
|
connectLocale={connectLocale}
|
468
535
|
connectOptions={props.connectOptions}
|
@@ -471,6 +538,14 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
471
538
|
activeAccount={activeAccount}
|
472
539
|
setTokenAmount={setTokenAmount}
|
473
540
|
setHasEditedAmount={setHasEditedAmount}
|
541
|
+
disableTokenSelection={
|
542
|
+
payDisabled === true ||
|
543
|
+
(payOptions.buyWithCrypto !== false &&
|
544
|
+
payOptions.buyWithCrypto?.prefillSource?.allowEdits
|
545
|
+
?.chain === false &&
|
546
|
+
payOptions.buyWithCrypto?.prefillSource?.allowEdits
|
547
|
+
?.token === false)
|
548
|
+
}
|
474
549
|
/>
|
475
550
|
)}
|
476
551
|
|
@@ -481,11 +556,9 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
481
556
|
toChain={toChain}
|
482
557
|
toToken={toToken}
|
483
558
|
selectedCurrency={selectedCurrency}
|
484
|
-
buyForTx={buyForTx || null}
|
485
559
|
client={client}
|
486
560
|
isEmbed={props.isEmbed}
|
487
|
-
onDone={
|
488
|
-
onViewPendingTx={props.onViewPendingTx}
|
561
|
+
onDone={onDone}
|
489
562
|
payOptions={payOptions}
|
490
563
|
theme={props.theme}
|
491
564
|
showCurrencySelector={() => {
|
@@ -556,9 +629,12 @@ function SelectedTokenInfo(props: {
|
|
556
629
|
|
557
630
|
function MainScreen(props: {
|
558
631
|
title: string;
|
559
|
-
buyForTx: BuyForTx | undefined;
|
560
632
|
client: ThirdwebClient;
|
561
633
|
setTokenAmount: (amount: string) => void;
|
634
|
+
setFromChain: (chain: Chain) => void;
|
635
|
+
setFromToken: (token: ERC20OrNativeToken) => void;
|
636
|
+
setToChain: (chain: Chain) => void;
|
637
|
+
setToToken: (token: ERC20OrNativeToken) => void;
|
562
638
|
payerAccount: Account | undefined;
|
563
639
|
tokenAmount: string;
|
564
640
|
payOptions: PayUIOptions;
|
@@ -566,148 +642,159 @@ function MainScreen(props: {
|
|
566
642
|
toChain: Chain;
|
567
643
|
onSelectBuyToken: () => void;
|
568
644
|
connectOptions: PayEmbedConnectOptions | undefined;
|
569
|
-
onViewPendingTx: () => void;
|
570
645
|
setScreen: (screen: SelectedScreen) => void;
|
571
646
|
supportedDestinations: SupportedChainAndTokens;
|
572
647
|
onBack: (() => void) | undefined;
|
573
648
|
theme: "light" | "dark" | Theme;
|
574
649
|
hasEditedAmount: boolean;
|
575
650
|
setHasEditedAmount: (hasEdited: boolean) => void;
|
651
|
+
enabledPaymentMethods: PaymentMethods;
|
576
652
|
}) {
|
577
|
-
const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } =
|
578
|
-
useEnabledPaymentMethods({
|
579
|
-
payOptions: props.payOptions,
|
580
|
-
supportedDestinations: props.supportedDestinations,
|
581
|
-
toChain: props.toChain,
|
582
|
-
toToken: props.toToken,
|
583
|
-
});
|
584
|
-
|
585
653
|
const {
|
586
|
-
buyForTx,
|
587
654
|
setTokenAmount,
|
655
|
+
setToChain,
|
656
|
+
setToToken,
|
657
|
+
setFromChain,
|
658
|
+
setFromToken,
|
588
659
|
payerAccount,
|
589
660
|
client,
|
590
661
|
tokenAmount,
|
591
662
|
payOptions,
|
592
663
|
toToken,
|
593
664
|
toChain,
|
665
|
+
supportedDestinations,
|
666
|
+
enabledPaymentMethods,
|
594
667
|
} = props;
|
595
668
|
|
596
|
-
|
597
|
-
|
598
|
-
setTokenAmount,
|
599
|
-
buyForTx: buyForTx || null,
|
600
|
-
hasEditedAmount: props.hasEditedAmount,
|
601
|
-
account: payerAccount || null,
|
602
|
-
});
|
603
|
-
|
669
|
+
const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } =
|
670
|
+
enabledPaymentMethods;
|
604
671
|
const disableContinue = !tokenAmount;
|
605
672
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
)
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
673
|
+
switch (payOptions.mode) {
|
674
|
+
case "transaction": {
|
675
|
+
return (
|
676
|
+
<TransactionModeScreen
|
677
|
+
supportedDestinations={supportedDestinations}
|
678
|
+
payUiOptions={payOptions}
|
679
|
+
payerAccount={payerAccount}
|
680
|
+
connectOptions={props.connectOptions}
|
681
|
+
client={client}
|
682
|
+
onContinue={(tokenAmount, toChain, toToken) => {
|
683
|
+
setTokenAmount(tokenAmount);
|
684
|
+
setToChain(toChain);
|
685
|
+
setFromChain(toChain);
|
686
|
+
setFromToken(toToken);
|
687
|
+
setToToken(toToken);
|
688
|
+
if (showPaymentSelection) {
|
689
|
+
props.setScreen({ id: "select-payment-method" });
|
690
|
+
} else if (buyWithCryptoEnabled) {
|
691
|
+
props.setScreen({ id: "select-wallet" });
|
692
|
+
} else if (buyWithFiatEnabled) {
|
693
|
+
props.setScreen({ id: "buy-with-fiat" });
|
694
|
+
} else {
|
695
|
+
// default to buy with crypto with connected wallet if chain not supported by pay
|
696
|
+
props.setScreen({ id: "select-wallet" });
|
697
|
+
}
|
698
|
+
}}
|
699
|
+
/>
|
700
|
+
);
|
701
|
+
}
|
702
|
+
case "direct_payment": {
|
703
|
+
return (
|
704
|
+
<DirectPaymentModeScreen
|
705
|
+
client={client}
|
706
|
+
payUiOptions={payOptions}
|
707
|
+
payerAccount={payerAccount}
|
708
|
+
connectOptions={props.connectOptions}
|
709
|
+
supportedDestinations={supportedDestinations}
|
710
|
+
onContinue={(tokenAmount, toChain, toToken) => {
|
711
|
+
setTokenAmount(tokenAmount);
|
712
|
+
setToChain(toChain);
|
713
|
+
setFromChain(toChain);
|
714
|
+
setFromToken(toToken);
|
715
|
+
setToToken(toToken);
|
716
|
+
if (showPaymentSelection) {
|
717
|
+
props.setScreen({ id: "select-payment-method" });
|
718
|
+
} else if (buyWithCryptoEnabled) {
|
719
|
+
props.setScreen({ id: "buy-with-crypto" });
|
720
|
+
} else if (buyWithFiatEnabled) {
|
721
|
+
props.setScreen({ id: "buy-with-fiat" });
|
722
|
+
} else {
|
723
|
+
// default to buy with crypto with connected wallet if chain not supported by pay
|
724
|
+
props.setScreen({ id: "select-wallet" });
|
725
|
+
}
|
726
|
+
}}
|
727
|
+
/>
|
728
|
+
);
|
729
|
+
}
|
730
|
+
default: {
|
731
|
+
return (
|
732
|
+
<Container p="lg">
|
733
|
+
<ModalHeader title={props.title} onBack={props.onBack} />
|
654
734
|
|
655
|
-
|
735
|
+
<Spacer y="xl" />
|
656
736
|
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
client={props.client}
|
664
|
-
theme={props.theme}
|
665
|
-
connectButton={{
|
666
|
-
style: {
|
667
|
-
width: "100%",
|
668
|
-
},
|
669
|
-
}}
|
670
|
-
/>
|
671
|
-
</div>
|
672
|
-
) : (
|
673
|
-
<Button
|
674
|
-
variant="accent"
|
675
|
-
fullWidth
|
676
|
-
disabled={disableContinue}
|
677
|
-
data-disabled={disableContinue}
|
678
|
-
onClick={() => {
|
679
|
-
if (showPaymentSelection) {
|
680
|
-
props.setScreen({ id: "select-payment-method" });
|
681
|
-
} else if (buyWithCryptoEnabled) {
|
682
|
-
props.setScreen({ id: "buy-with-crypto" });
|
683
|
-
} else if (buyWithFiatEnabled) {
|
684
|
-
props.setScreen({ id: "buy-with-fiat" });
|
685
|
-
} else {
|
686
|
-
console.error("No payment method enabled");
|
687
|
-
}
|
737
|
+
{/* To */}
|
738
|
+
<BuyTokenInput
|
739
|
+
value={tokenAmount}
|
740
|
+
onChange={async (value) => {
|
741
|
+
props.setHasEditedAmount(true);
|
742
|
+
setTokenAmount(value);
|
688
743
|
}}
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
744
|
+
freezeAmount={payOptions.prefillBuy?.allowEdits?.amount === false}
|
745
|
+
freezeChainAndToken={
|
746
|
+
payOptions.prefillBuy?.allowEdits?.chain === false &&
|
747
|
+
payOptions.prefillBuy?.allowEdits?.token === false
|
748
|
+
}
|
749
|
+
token={toToken}
|
750
|
+
chain={toChain}
|
751
|
+
onSelectToken={props.onSelectBuyToken}
|
752
|
+
client={props.client}
|
753
|
+
/>
|
693
754
|
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
755
|
+
<Spacer y="xl" />
|
756
|
+
|
757
|
+
{/* Continue */}
|
758
|
+
<Container flex="column" gap="sm">
|
759
|
+
{!payerAccount ? (
|
760
|
+
<div>
|
761
|
+
<ConnectButton
|
762
|
+
{...props.connectOptions}
|
763
|
+
client={props.client}
|
764
|
+
theme={props.theme}
|
765
|
+
connectButton={{
|
766
|
+
style: {
|
767
|
+
width: "100%",
|
768
|
+
},
|
769
|
+
}}
|
770
|
+
/>
|
771
|
+
</div>
|
772
|
+
) : (
|
773
|
+
<Button
|
774
|
+
variant="accent"
|
775
|
+
fullWidth
|
776
|
+
disabled={disableContinue}
|
777
|
+
data-disabled={disableContinue}
|
778
|
+
onClick={() => {
|
779
|
+
if (showPaymentSelection) {
|
780
|
+
props.setScreen({ id: "select-payment-method" });
|
781
|
+
} else if (buyWithCryptoEnabled) {
|
782
|
+
props.setScreen({ id: "buy-with-crypto" });
|
783
|
+
} else if (buyWithFiatEnabled) {
|
784
|
+
props.setScreen({ id: "buy-with-fiat" });
|
785
|
+
} else {
|
786
|
+
console.error("No payment method enabled");
|
787
|
+
}
|
788
|
+
}}
|
789
|
+
>
|
790
|
+
Continue
|
791
|
+
</Button>
|
792
|
+
)}
|
793
|
+
</Container>
|
794
|
+
</Container>
|
795
|
+
);
|
796
|
+
}
|
797
|
+
}
|
711
798
|
}
|
712
799
|
|
713
800
|
function TokenSelectedLayout(props: {
|
@@ -753,7 +840,7 @@ function TokenSelectedLayout(props: {
|
|
753
840
|
}
|
754
841
|
|
755
842
|
function PaymentMethodSelection(props: {
|
756
|
-
setScreen: (screenId: "
|
843
|
+
setScreen: (screenId: "select-wallet" | "buy-with-fiat") => void;
|
757
844
|
}) {
|
758
845
|
return (
|
759
846
|
<Container animate="fadein">
|
@@ -782,7 +869,7 @@ function PaymentMethodSelection(props: {
|
|
782
869
|
<Text size="md" color="primaryText">
|
783
870
|
Credit Card
|
784
871
|
</Text>
|
785
|
-
<Text size="xs">
|
872
|
+
<Text size="xs">Securely pay with credit card</Text>
|
786
873
|
</Container>
|
787
874
|
</Button>
|
788
875
|
|
@@ -790,7 +877,7 @@ function PaymentMethodSelection(props: {
|
|
790
877
|
<Button
|
791
878
|
variant="outline"
|
792
879
|
bg="tertiaryBg"
|
793
|
-
onClick={() => props.setScreen("
|
880
|
+
onClick={() => props.setScreen("select-wallet")}
|
794
881
|
style={{
|
795
882
|
justifyContent: "flex-start",
|
796
883
|
}}
|
@@ -804,7 +891,7 @@ function PaymentMethodSelection(props: {
|
|
804
891
|
<Text size="md" color="primaryText">
|
805
892
|
Crypto
|
806
893
|
</Text>
|
807
|
-
<Text size="xs">Pay with
|
894
|
+
<Text size="xs">Pay with your connected wallet</Text>
|
808
895
|
</Container>
|
809
896
|
</Button>
|
810
897
|
</Container>
|
@@ -823,9 +910,7 @@ function SwapScreenContent(props: {
|
|
823
910
|
payer: PayerInfo;
|
824
911
|
client: ThirdwebClient;
|
825
912
|
payOptions: PayUIOptions;
|
826
|
-
buyForTx: BuyForTx | null;
|
827
913
|
isEmbed: boolean;
|
828
|
-
onViewPendingTx: () => void;
|
829
914
|
onDone: () => void;
|
830
915
|
connectOptions: PayEmbedConnectOptions | undefined;
|
831
916
|
connectLocale: ConnectLocale;
|
@@ -833,6 +918,7 @@ function SwapScreenContent(props: {
|
|
833
918
|
activeAccount: Account;
|
834
919
|
setTokenAmount: (amount: string) => void;
|
835
920
|
setHasEditedAmount: (hasEdited: boolean) => void;
|
921
|
+
disableTokenSelection: boolean;
|
836
922
|
}) {
|
837
923
|
const {
|
838
924
|
setScreen,
|
@@ -845,11 +931,14 @@ function SwapScreenContent(props: {
|
|
845
931
|
fromToken,
|
846
932
|
showFromTokenSelector,
|
847
933
|
payOptions,
|
934
|
+
disableTokenSelection,
|
848
935
|
} = props;
|
849
936
|
|
850
|
-
const
|
851
|
-
props.payOptions
|
852
|
-
);
|
937
|
+
const defaultRecipientAddress = (
|
938
|
+
props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
|
939
|
+
)?.paymentInfo?.sellerAddress;
|
940
|
+
const receiverAddress =
|
941
|
+
defaultRecipientAddress || props.activeAccount.address;
|
853
942
|
const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
|
854
943
|
const [drawerScreen, setDrawerScreen] = useState<
|
855
944
|
"fees" | "receiver" | "payer"
|
@@ -862,27 +951,35 @@ function SwapScreenContent(props: {
|
|
862
951
|
client,
|
863
952
|
});
|
864
953
|
|
865
|
-
const
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
954
|
+
const fromTokenId = isNativeToken(fromToken)
|
955
|
+
? NATIVE_TOKEN_ADDRESS
|
956
|
+
: fromToken.address.toLowerCase();
|
957
|
+
const toTokenId = isNativeToken(toToken)
|
958
|
+
? NATIVE_TOKEN_ADDRESS
|
959
|
+
: toToken.address.toLowerCase();
|
960
|
+
const swapRequired =
|
961
|
+
!!tokenAmount &&
|
962
|
+
!(fromChain.id === toChain.id && fromTokenId === toTokenId);
|
963
|
+
const quoteParams: GetBuyWithCryptoQuoteParams | undefined = swapRequired
|
964
|
+
? {
|
965
|
+
// wallets
|
966
|
+
fromAddress: payer.account.address,
|
967
|
+
toAddress: receiverAddress,
|
968
|
+
// from
|
969
|
+
fromChainId: fromChain.id,
|
970
|
+
fromTokenAddress: isNativeToken(fromToken)
|
971
|
+
? NATIVE_TOKEN_ADDRESS
|
972
|
+
: fromToken.address,
|
973
|
+
// to
|
974
|
+
toChainId: toChain.id,
|
975
|
+
toTokenAddress: isNativeToken(toToken)
|
976
|
+
? NATIVE_TOKEN_ADDRESS
|
977
|
+
: toToken.address,
|
978
|
+
toAmount: tokenAmount,
|
979
|
+
client,
|
980
|
+
purchaseData: payOptions.purchaseData,
|
981
|
+
}
|
982
|
+
: undefined;
|
886
983
|
|
887
984
|
const quoteQuery = useBuyWithCryptoQuote(quoteParams, {
|
888
985
|
// refetch every 30 seconds
|
@@ -891,14 +988,17 @@ function SwapScreenContent(props: {
|
|
891
988
|
gcTime: 30 * 1000,
|
892
989
|
});
|
893
990
|
|
894
|
-
const sourceTokenAmount =
|
991
|
+
const sourceTokenAmount = swapRequired
|
992
|
+
? quoteQuery.data?.swapDetails.fromAmount
|
993
|
+
: tokenAmount;
|
895
994
|
|
896
995
|
const isNotEnoughBalance =
|
897
996
|
!!sourceTokenAmount &&
|
898
997
|
!!fromTokenBalanceQuery.data &&
|
899
998
|
Number(fromTokenBalanceQuery.data.displayValue) < Number(sourceTokenAmount);
|
900
999
|
|
901
|
-
const disableContinue =
|
1000
|
+
const disableContinue =
|
1001
|
+
(swapRequired && !quoteQuery.data) || isNotEnoughBalance;
|
902
1002
|
const switchChainRequired = props.payer.chain.id !== fromChain.id;
|
903
1003
|
|
904
1004
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
@@ -935,6 +1035,25 @@ function SwapScreenContent(props: {
|
|
935
1035
|
: undefined;
|
936
1036
|
|
937
1037
|
function showSwapFlow() {
|
1038
|
+
if (
|
1039
|
+
(props.payOptions.mode === "transaction" ||
|
1040
|
+
props.payOptions.mode === "direct_payment") &&
|
1041
|
+
!isNotEnoughBalance &&
|
1042
|
+
!swapRequired
|
1043
|
+
) {
|
1044
|
+
if (payer.account.address !== receiverAddress) {
|
1045
|
+
// same currency, just transfer, but from another wallet
|
1046
|
+
setScreen({
|
1047
|
+
id: "transfer-flow",
|
1048
|
+
});
|
1049
|
+
} else {
|
1050
|
+
// has enough balance to just do the transaction directly
|
1051
|
+
props.onDone();
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
return;
|
1055
|
+
}
|
1056
|
+
|
938
1057
|
if (!quoteQuery.data) {
|
939
1058
|
return;
|
940
1059
|
}
|
@@ -954,13 +1073,6 @@ function SwapScreenContent(props: {
|
|
954
1073
|
setDrawerScreen("fees");
|
955
1074
|
}
|
956
1075
|
|
957
|
-
const prefillSource =
|
958
|
-
payOptions.buyWithCrypto !== false
|
959
|
-
? payOptions.buyWithCrypto?.prefillSource
|
960
|
-
: undefined;
|
961
|
-
|
962
|
-
const disableReceiverSelection = !!props.payOptions.recipientAddress;
|
963
|
-
|
964
1076
|
return (
|
965
1077
|
<Container flex="column" gap="md" animate="fadein">
|
966
1078
|
{isOpen && (
|
@@ -976,46 +1088,6 @@ function SwapScreenContent(props: {
|
|
976
1088
|
<SwapFees quote={quoteQuery.data} align="left" />
|
977
1089
|
</div>
|
978
1090
|
)}
|
979
|
-
|
980
|
-
{drawerScreen === "receiver" && (
|
981
|
-
<ReceiverWalletDrawerScreen
|
982
|
-
client={props.client}
|
983
|
-
onSelect={(x) => setReceiverAddress(x)}
|
984
|
-
receiverAddress={receiverAddress}
|
985
|
-
onBack={() => setIsOpen(false)}
|
986
|
-
/>
|
987
|
-
)}
|
988
|
-
|
989
|
-
{drawerScreen === "payer" && (
|
990
|
-
<WalletSwitcherDrawerContent
|
991
|
-
client={client}
|
992
|
-
onSelect={(w) => {
|
993
|
-
const chain = w.getChain();
|
994
|
-
const account = w.getAccount();
|
995
|
-
if (chain && account) {
|
996
|
-
props.setPayer({
|
997
|
-
account,
|
998
|
-
chain,
|
999
|
-
wallet: w,
|
1000
|
-
});
|
1001
|
-
}
|
1002
|
-
}}
|
1003
|
-
showAllWallets={!!props.connectOptions?.showAllWallets}
|
1004
|
-
wallets={props.connectOptions?.wallets}
|
1005
|
-
onBack={() => {
|
1006
|
-
setIsOpen(false);
|
1007
|
-
}}
|
1008
|
-
onConnect={() => {
|
1009
|
-
setScreen({
|
1010
|
-
id: "connect-payer-wallet",
|
1011
|
-
backScreen: {
|
1012
|
-
id: "buy-with-crypto",
|
1013
|
-
},
|
1014
|
-
});
|
1015
|
-
}}
|
1016
|
-
selectedAddress={payer.account.address}
|
1017
|
-
/>
|
1018
|
-
)}
|
1019
1091
|
</Drawer>
|
1020
1092
|
</>
|
1021
1093
|
)}
|
@@ -1025,8 +1097,7 @@ function SwapScreenContent(props: {
|
|
1025
1097
|
<WalletSelectorButton
|
1026
1098
|
client={props.client}
|
1027
1099
|
onClick={() => {
|
1028
|
-
|
1029
|
-
setDrawerScreen("payer");
|
1100
|
+
setScreen({ id: "select-wallet" });
|
1030
1101
|
}}
|
1031
1102
|
address={props.payer.account.address}
|
1032
1103
|
walletId={props.payer.wallet.id}
|
@@ -1043,34 +1114,20 @@ function SwapScreenContent(props: {
|
|
1043
1114
|
token={fromToken}
|
1044
1115
|
isLoading={quoteQuery.isLoading && !sourceTokenAmount}
|
1045
1116
|
client={client}
|
1046
|
-
freezeChainAndTokenSelection={
|
1047
|
-
prefillSource?.allowEdits?.chain === false &&
|
1048
|
-
prefillSource?.allowEdits?.token === false
|
1049
|
-
}
|
1117
|
+
freezeChainAndTokenSelection={disableTokenSelection}
|
1050
1118
|
payerAccount={props.payer.account}
|
1119
|
+
swapRequired={swapRequired}
|
1051
1120
|
/>
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1121
|
+
{swapRequired && (
|
1122
|
+
<EstimatedTimeAndFees
|
1123
|
+
quoteIsLoading={quoteQuery.isLoading}
|
1124
|
+
estimatedSeconds={
|
1125
|
+
quoteQuery.data?.swapDetails.estimated.durationSeconds
|
1126
|
+
}
|
1127
|
+
onViewFees={showFees}
|
1128
|
+
/>
|
1129
|
+
)}
|
1060
1130
|
<Spacer y="md" />
|
1061
|
-
<Text size="sm">Send to</Text>
|
1062
|
-
<Spacer y="xs" />
|
1063
|
-
<WalletSelectorButton
|
1064
|
-
client={props.client}
|
1065
|
-
disabled={disableReceiverSelection}
|
1066
|
-
disableChevron={disableReceiverSelection}
|
1067
|
-
onClick={() => {
|
1068
|
-
setIsOpen(true);
|
1069
|
-
setDrawerScreen("receiver");
|
1070
|
-
}}
|
1071
|
-
address={receiverAddress}
|
1072
|
-
walletId={undefined}
|
1073
|
-
/>
|
1074
1131
|
</div>
|
1075
1132
|
|
1076
1133
|
{/* Error message */}
|
@@ -1097,6 +1154,17 @@ function SwapScreenContent(props: {
|
|
1097
1154
|
</div>
|
1098
1155
|
)}
|
1099
1156
|
|
1157
|
+
{!errorMsg && isNotEnoughBalance && (
|
1158
|
+
<div>
|
1159
|
+
<Text color="danger" size="sm" center multiline>
|
1160
|
+
Not enough funds.
|
1161
|
+
</Text>
|
1162
|
+
<Text color="danger" size="sm" center multiline>
|
1163
|
+
Try a different wallet or token.
|
1164
|
+
</Text>
|
1165
|
+
</div>
|
1166
|
+
)}
|
1167
|
+
|
1100
1168
|
{/* Button */}
|
1101
1169
|
{errorMsg?.minAmount ? (
|
1102
1170
|
<Button
|
@@ -1133,9 +1201,7 @@ function SwapScreenContent(props: {
|
|
1133
1201
|
}}
|
1134
1202
|
gap="xs"
|
1135
1203
|
>
|
1136
|
-
{
|
1137
|
-
<Text color="danger">Not Enough Funds</Text>
|
1138
|
-
) : quoteQuery.isLoading ? (
|
1204
|
+
{quoteQuery.isLoading ? (
|
1139
1205
|
<>
|
1140
1206
|
Getting price quote
|
1141
1207
|
<Spinner size="sm" color="accentText" />
|
@@ -1158,9 +1224,7 @@ function FiatScreenContent(props: {
|
|
1158
1224
|
showCurrencySelector: () => void;
|
1159
1225
|
payOptions: PayUIOptions;
|
1160
1226
|
theme: "light" | "dark" | Theme;
|
1161
|
-
buyForTx: BuyForTx | null;
|
1162
1227
|
client: ThirdwebClient;
|
1163
|
-
onViewPendingTx: () => void;
|
1164
1228
|
onDone: () => void;
|
1165
1229
|
isEmbed: boolean;
|
1166
1230
|
payer: PayerInfo;
|
@@ -1177,11 +1241,13 @@ function FiatScreenContent(props: {
|
|
1177
1241
|
showCurrencySelector,
|
1178
1242
|
selectedCurrency,
|
1179
1243
|
} = props;
|
1180
|
-
const
|
1181
|
-
props.payOptions
|
1182
|
-
);
|
1244
|
+
const defaultRecipientAddress = (
|
1245
|
+
props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
|
1246
|
+
)?.paymentInfo?.sellerAddress;
|
1247
|
+
const receiverAddress =
|
1248
|
+
defaultRecipientAddress || props.payer.account.address;
|
1183
1249
|
const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
|
1184
|
-
const [drawerScreen, setDrawerScreen] = useState<"fees"
|
1250
|
+
const [drawerScreen, setDrawerScreen] = useState<"fees">("fees");
|
1185
1251
|
|
1186
1252
|
const buyWithFiatOptions = props.payOptions.buyWithFiat;
|
1187
1253
|
|
@@ -1269,8 +1335,6 @@ function FiatScreenContent(props: {
|
|
1269
1335
|
|
1270
1336
|
const disableSubmit = !fiatQuoteQuery.data;
|
1271
1337
|
|
1272
|
-
const disableReceiverSelection = !!props.payOptions.recipientAddress;
|
1273
|
-
|
1274
1338
|
const errorMsg =
|
1275
1339
|
!fiatQuoteQuery.isLoading && fiatQuoteQuery.error
|
1276
1340
|
? getErrorMessage(fiatQuoteQuery.error)
|
@@ -1292,15 +1356,6 @@ function FiatScreenContent(props: {
|
|
1292
1356
|
<FiatFees quote={fiatQuoteQuery.data} />
|
1293
1357
|
</div>
|
1294
1358
|
)}
|
1295
|
-
|
1296
|
-
{drawerScreen === "receiver" && (
|
1297
|
-
<ReceiverWalletDrawerScreen
|
1298
|
-
client={props.client}
|
1299
|
-
onSelect={(x) => setReceiverAddress(x)}
|
1300
|
-
receiverAddress={receiverAddress}
|
1301
|
-
onBack={() => setIsOpen(false)}
|
1302
|
-
/>
|
1303
|
-
)}
|
1304
1359
|
</Drawer>
|
1305
1360
|
</>
|
1306
1361
|
)}
|
@@ -1320,19 +1375,6 @@ function FiatScreenContent(props: {
|
|
1320
1375
|
onViewFees={showFees}
|
1321
1376
|
/>
|
1322
1377
|
<Spacer y="md" />
|
1323
|
-
<Text size="sm">Send to</Text>
|
1324
|
-
<Spacer y="xs" />
|
1325
|
-
<WalletSelectorButton
|
1326
|
-
client={props.client}
|
1327
|
-
onClick={() => {
|
1328
|
-
setDrawerScreen("receiver");
|
1329
|
-
setIsOpen(true);
|
1330
|
-
}}
|
1331
|
-
address={receiverAddress}
|
1332
|
-
disabled={disableReceiverSelection}
|
1333
|
-
disableChevron={disableReceiverSelection}
|
1334
|
-
walletId={undefined}
|
1335
|
-
/>
|
1336
1378
|
</div>
|
1337
1379
|
|
1338
1380
|
{/* Error message */}
|
@@ -1393,86 +1435,6 @@ function FiatScreenContent(props: {
|
|
1393
1435
|
);
|
1394
1436
|
}
|
1395
1437
|
|
1396
|
-
function BuyForTxUI(props: {
|
1397
|
-
amountNeeded: string;
|
1398
|
-
buyForTx: BuyForTx;
|
1399
|
-
client: ThirdwebClient;
|
1400
|
-
}) {
|
1401
|
-
const chainNameQuery = useChainName(props.buyForTx.tx.chain);
|
1402
|
-
|
1403
|
-
return (
|
1404
|
-
<Container>
|
1405
|
-
<Spacer y="xs" />
|
1406
|
-
<Container
|
1407
|
-
flex="row"
|
1408
|
-
style={{
|
1409
|
-
justifyContent: "space-between",
|
1410
|
-
}}
|
1411
|
-
>
|
1412
|
-
<Text size="sm">Amount Needed</Text>
|
1413
|
-
<Container
|
1414
|
-
flex="column"
|
1415
|
-
style={{
|
1416
|
-
alignItems: "flex-end",
|
1417
|
-
}}
|
1418
|
-
>
|
1419
|
-
<Container flex="row" gap="xs" center="y">
|
1420
|
-
<Text color="primaryText" size="sm">
|
1421
|
-
{props.amountNeeded} {props.buyForTx.tokenSymbol}
|
1422
|
-
</Text>
|
1423
|
-
<TokenIcon
|
1424
|
-
chain={props.buyForTx.tx.chain}
|
1425
|
-
client={props.client}
|
1426
|
-
size="sm"
|
1427
|
-
token={NATIVE_TOKEN}
|
1428
|
-
/>
|
1429
|
-
</Container>
|
1430
|
-
<Spacer y="xxs" />
|
1431
|
-
{chainNameQuery.name ? (
|
1432
|
-
<Text size="sm">{chainNameQuery.name}</Text>
|
1433
|
-
) : (
|
1434
|
-
<Skeleton height={fontSize.sm} width="50px" />
|
1435
|
-
)}
|
1436
|
-
</Container>
|
1437
|
-
</Container>
|
1438
|
-
|
1439
|
-
<Spacer y="md" />
|
1440
|
-
<Line />
|
1441
|
-
<Spacer y="md" />
|
1442
|
-
|
1443
|
-
<Container
|
1444
|
-
flex="row"
|
1445
|
-
style={{
|
1446
|
-
justifyContent: "space-between",
|
1447
|
-
}}
|
1448
|
-
>
|
1449
|
-
<Text size="sm">Your Balance</Text>
|
1450
|
-
<Container flex="row" gap="xs">
|
1451
|
-
<Text color="primaryText" size="sm">
|
1452
|
-
{formatNumber(Number(toEther(props.buyForTx.balance)), 6)}{" "}
|
1453
|
-
{props.buyForTx.tokenSymbol}
|
1454
|
-
</Text>
|
1455
|
-
<TokenIcon
|
1456
|
-
chain={props.buyForTx.tx.chain}
|
1457
|
-
client={props.client}
|
1458
|
-
size="sm"
|
1459
|
-
token={NATIVE_TOKEN}
|
1460
|
-
/>
|
1461
|
-
</Container>
|
1462
|
-
</Container>
|
1463
|
-
|
1464
|
-
<Spacer y="md" />
|
1465
|
-
<Line />
|
1466
|
-
<Spacer y="xl" />
|
1467
|
-
|
1468
|
-
<Text center size="sm">
|
1469
|
-
Purchase
|
1470
|
-
</Text>
|
1471
|
-
<Spacer y="xxs" />
|
1472
|
-
</Container>
|
1473
|
-
);
|
1474
|
-
}
|
1475
|
-
|
1476
1438
|
function createSupportedTokens(
|
1477
1439
|
data: SupportedChainAndTokens,
|
1478
1440
|
payOptions: PayUIOptions,
|
@@ -1483,6 +1445,8 @@ function createSupportedTokens(
|
|
1483
1445
|
const isBuyWithFiatDisabled = payOptions.buyWithFiat === false;
|
1484
1446
|
const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false;
|
1485
1447
|
|
1448
|
+
// FIXME (pay) when buywithFiat is disabled, missing a bunch of tokens on base??
|
1449
|
+
|
1486
1450
|
for (const x of data) {
|
1487
1451
|
tokens[x.chain.id] = x.tokens.filter((t) => {
|
1488
1452
|
// it token supports both - include it
|