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
@@ -34,13 +34,12 @@ export function OnrampStatusScreen(props: {
|
|
34
34
|
client: ThirdwebClient;
|
35
35
|
onBack: () => void;
|
36
36
|
intentId: string;
|
37
|
-
onViewPendingTx: () => void;
|
38
37
|
hasTwoSteps: boolean;
|
39
38
|
openedWindow: Window | null;
|
40
39
|
quote: BuyWithFiatQuote;
|
41
40
|
onDone: () => void;
|
42
41
|
onShowSwapFlow: (status: BuyWithFiatStatus) => void;
|
43
|
-
|
42
|
+
transactionMode: boolean;
|
44
43
|
isEmbed: boolean;
|
45
44
|
}) {
|
46
45
|
const queryClient = useQueryClient();
|
@@ -117,7 +116,7 @@ export function OnrampStatusScreen(props: {
|
|
117
116
|
onDone={props.onDone}
|
118
117
|
fiatStatus={statusQuery.data}
|
119
118
|
client={props.client}
|
120
|
-
|
119
|
+
transactionMode={props.transactionMode}
|
121
120
|
quote={props.quote}
|
122
121
|
isEmbed={props.isEmbed}
|
123
122
|
/>
|
@@ -130,7 +129,7 @@ function OnrampStatusScreenUI(props: {
|
|
130
129
|
fiatStatus?: BuyWithFiatStatus;
|
131
130
|
onDone: () => void;
|
132
131
|
client: ThirdwebClient;
|
133
|
-
|
132
|
+
transactionMode: boolean;
|
134
133
|
isEmbed: boolean;
|
135
134
|
quote: BuyWithFiatQuote;
|
136
135
|
}) {
|
@@ -189,7 +188,7 @@ function OnrampStatusScreenUI(props: {
|
|
189
188
|
<>
|
190
189
|
<Spacer y="md" />
|
191
190
|
<Container flex="row" center="x">
|
192
|
-
<Spinner size="
|
191
|
+
<Spinner size="xxl" color="accentText" />
|
193
192
|
</Container>
|
194
193
|
<Spacer y="md" />
|
195
194
|
<Text color="primaryText" size="lg" center>
|
@@ -240,7 +239,7 @@ function OnrampStatusScreenUI(props: {
|
|
240
239
|
|
241
240
|
{!props.isEmbed && (
|
242
241
|
<Button variant="accent" fullWidth onClick={props.onDone}>
|
243
|
-
{props.
|
242
|
+
{props.transactionMode ? "Continue Transaction" : "Done"}
|
244
243
|
</Button>
|
245
244
|
)}
|
246
245
|
</>
|
@@ -19,9 +19,8 @@ export function PostOnRampSwap(props: {
|
|
19
19
|
client: ThirdwebClient;
|
20
20
|
buyWithFiatStatus: BuyWithFiatStatus;
|
21
21
|
onBack?: () => void;
|
22
|
-
onViewPendingTx: () => void;
|
23
22
|
onDone: () => void;
|
24
|
-
|
23
|
+
transactionMode: boolean;
|
25
24
|
isEmbed: boolean;
|
26
25
|
payer: PayerInfo;
|
27
26
|
}) {
|
@@ -123,14 +122,13 @@ export function PostOnRampSwap(props: {
|
|
123
122
|
buyWithCryptoQuote={lockedOnRampQuote}
|
124
123
|
client={props.client}
|
125
124
|
onBack={props.onBack}
|
126
|
-
onViewPendingTx={props.onViewPendingTx}
|
127
125
|
isFiatFlow={true}
|
128
126
|
onDone={props.onDone}
|
129
127
|
onTryAgain={() => {
|
130
128
|
setLockedOnRampQuote(undefined);
|
131
129
|
postOnRampQuoteQuery.refetch();
|
132
130
|
}}
|
133
|
-
|
131
|
+
transactionMode={props.transactionMode}
|
134
132
|
isEmbed={props.isEmbed}
|
135
133
|
/>
|
136
134
|
);
|
@@ -17,10 +17,9 @@ export function PostOnRampSwapFlow(props: {
|
|
17
17
|
quote: BuyWithFiatPartialQuote;
|
18
18
|
client: ThirdwebClient;
|
19
19
|
onBack: () => void;
|
20
|
-
onViewPendingTx: () => void;
|
21
20
|
onDone: () => void;
|
22
21
|
onSwapFlowStarted: () => void;
|
23
|
-
|
22
|
+
transactionMode: boolean;
|
24
23
|
isEmbed: boolean;
|
25
24
|
payer: PayerInfo;
|
26
25
|
}) {
|
@@ -35,9 +34,8 @@ export function PostOnRampSwapFlow(props: {
|
|
35
34
|
title={props.title}
|
36
35
|
buyWithFiatStatus={statusForSwap}
|
37
36
|
client={props.client}
|
38
|
-
onViewPendingTx={props.onViewPendingTx}
|
39
37
|
onDone={props.onDone}
|
40
|
-
|
38
|
+
transactionMode={props.transactionMode}
|
41
39
|
isEmbed={props.isEmbed}
|
42
40
|
payer={props.payer}
|
43
41
|
/>
|
@@ -1,22 +1,23 @@
|
|
1
1
|
import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
|
2
2
|
import type { BuyWithFiatQuote } from "../../../../../../../pay/buyWithFiat/getQuote.js";
|
3
|
-
import type {
|
3
|
+
import type { GetWalletBalanceResult } from "../../../../../../../wallets/utils/getWalletBalance.js";
|
4
|
+
import type { TokenInfo } from "../../../../../../core/utils/defaultTokens.js";
|
4
5
|
|
5
|
-
export type
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
export type TransactionCostAndData = {
|
7
|
+
token: TokenInfo;
|
8
|
+
decimals: number;
|
9
|
+
walletBalance: GetWalletBalanceResult;
|
10
|
+
transactionValueWei: bigint;
|
11
|
+
gasCostWei: bigint;
|
11
12
|
};
|
12
13
|
|
13
14
|
export type SelectedScreen =
|
14
15
|
| {
|
15
|
-
id:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
id: "main" | "select-payment-method" | "buy-with-fiat" | "select-wallet";
|
17
|
+
}
|
18
|
+
| {
|
19
|
+
id: "buy-with-crypto";
|
20
|
+
payDisabled?: boolean;
|
20
21
|
}
|
21
22
|
| {
|
22
23
|
id: "select-from-token";
|
@@ -39,6 +40,9 @@ export type SelectedScreen =
|
|
39
40
|
quote: BuyWithFiatQuote;
|
40
41
|
openedWindow: Window | null;
|
41
42
|
}
|
43
|
+
| {
|
44
|
+
id: "transfer-flow";
|
45
|
+
}
|
42
46
|
| {
|
43
47
|
id: "connect-payer-wallet";
|
44
48
|
backScreen: SelectedScreen;
|
@@ -1,76 +1,171 @@
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
1
2
|
import { useEffect, useState } from "react";
|
2
|
-
import {
|
3
|
+
import { getChainMetadata } from "../../../../../../../chains/utils.js";
|
4
|
+
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
|
5
|
+
import { getContract } from "../../../../../../../contract/contract.js";
|
6
|
+
import { getCurrencyMetadata } from "../../../../../../../extensions/erc20/read/getCurrencyMetadata.js";
|
7
|
+
import { getGasPrice } from "../../../../../../../gas/get-gas-price.js";
|
8
|
+
import { encode } from "../../../../../../../transaction/actions/encode.js";
|
9
|
+
import { estimateGasCost } from "../../../../../../../transaction/actions/estimate-gas-cost.js";
|
10
|
+
import type { PreparedTransaction } from "../../../../../../../transaction/prepare-transaction.js";
|
11
|
+
import type { Hex } from "../../../../../../../utils/encoding/hex.js";
|
12
|
+
import { resolvePromisedValue } from "../../../../../../../utils/promise/resolve-promised-value.js";
|
3
13
|
import type { Account } from "../../../../../../../wallets/interfaces/wallet.js";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import type {
|
14
|
+
import { getWalletBalance } from "../../../../../../../wallets/utils/getWalletBalance.js";
|
15
|
+
import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js";
|
16
|
+
import type { TransactionCostAndData } from "./types.js";
|
7
17
|
|
8
|
-
export function
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
account: Account | null;
|
18
|
+
export function useTransactionCostAndData(args: {
|
19
|
+
transaction: PreparedTransaction;
|
20
|
+
account: Account | undefined;
|
21
|
+
supportedDestinations: SupportedChainAndTokens;
|
13
22
|
}) {
|
14
|
-
const {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
const { transaction, account, supportedDestinations } = args;
|
24
|
+
// Compute query key of the transaction first
|
25
|
+
const [txQueryKey, setTxQueryKey] = useState<
|
26
|
+
| {
|
27
|
+
value: string | undefined;
|
28
|
+
erc20Value: string | undefined;
|
29
|
+
erc20Currency: string | undefined;
|
30
|
+
to: string | undefined;
|
31
|
+
data: Hex | undefined;
|
32
|
+
}
|
33
|
+
| undefined
|
34
|
+
>();
|
24
35
|
useEffect(() => {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
Promise.all([
|
37
|
+
resolvePromisedValue(transaction.value),
|
38
|
+
resolvePromisedValue(transaction.erc20Value),
|
39
|
+
resolvePromisedValue(transaction.to),
|
40
|
+
encode(transaction),
|
41
|
+
]).then(([value, erc20Value, to, data]) => {
|
42
|
+
setTxQueryKey({
|
43
|
+
value: value?.toString(),
|
44
|
+
erc20Value: erc20Value?.amountWei?.toString(),
|
45
|
+
erc20Currency: erc20Value?.tokenAddress,
|
46
|
+
to,
|
47
|
+
data,
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}, [transaction]);
|
35
51
|
|
36
|
-
|
37
|
-
|
38
|
-
|
52
|
+
return useQuery({
|
53
|
+
queryKey: [
|
54
|
+
"transaction-cost",
|
55
|
+
transaction.chain.id,
|
56
|
+
account?.address,
|
57
|
+
txQueryKey,
|
58
|
+
],
|
59
|
+
queryFn: async () => {
|
60
|
+
if (!account) {
|
61
|
+
throw new Error("No account");
|
39
62
|
}
|
40
63
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
64
|
+
const erc20Value = await resolvePromisedValue(transaction.erc20Value);
|
65
|
+
if (erc20Value) {
|
66
|
+
const [tokenBalance, tokenMeta, gasCostWei] = await Promise.all([
|
67
|
+
getWalletBalance({
|
68
|
+
address: account.address,
|
69
|
+
chain: transaction.chain,
|
70
|
+
client: transaction.client,
|
71
|
+
tokenAddress: erc20Value.tokenAddress,
|
72
|
+
}),
|
73
|
+
getCurrencyMetadata({
|
74
|
+
contract: getContract({
|
75
|
+
address: erc20Value.tokenAddress,
|
76
|
+
chain: transaction.chain,
|
77
|
+
client: transaction.client,
|
78
|
+
}),
|
79
|
+
}),
|
80
|
+
getTransactionGasCost(transaction, account?.address),
|
81
|
+
]);
|
82
|
+
const transactionValueWei = erc20Value.amountWei;
|
83
|
+
const walletBalance = tokenBalance;
|
84
|
+
const currency = {
|
85
|
+
address: erc20Value.tokenAddress,
|
86
|
+
name: tokenMeta.name,
|
87
|
+
symbol: tokenMeta.symbol,
|
88
|
+
icon: supportedDestinations
|
89
|
+
.find((c) => c.chain.id === transaction.chain.id)
|
90
|
+
?.tokens.find(
|
91
|
+
(t) =>
|
92
|
+
t.address.toLowerCase() ===
|
93
|
+
erc20Value.tokenAddress.toLowerCase(),
|
94
|
+
)?.icon,
|
95
|
+
};
|
96
|
+
return {
|
97
|
+
token: currency,
|
98
|
+
decimals: tokenMeta.decimals,
|
99
|
+
walletBalance,
|
100
|
+
gasCostWei,
|
101
|
+
transactionValueWei,
|
102
|
+
} satisfies TransactionCostAndData;
|
103
|
+
}
|
50
104
|
|
51
|
-
|
105
|
+
const [nativeWalletBalance, chainMetadata, gasCostWei] =
|
106
|
+
await Promise.all([
|
107
|
+
getWalletBalance({
|
108
|
+
address: account.address,
|
109
|
+
chain: transaction.chain,
|
110
|
+
client: transaction.client,
|
111
|
+
}),
|
112
|
+
getChainMetadata(transaction.chain),
|
113
|
+
getTransactionGasCost(transaction, account?.address),
|
114
|
+
]);
|
52
115
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
116
|
+
const walletBalance = nativeWalletBalance;
|
117
|
+
const transactionValueWei =
|
118
|
+
(await resolvePromisedValue(transaction.value)) || 0n;
|
119
|
+
return {
|
120
|
+
token: {
|
121
|
+
address: NATIVE_TOKEN_ADDRESS,
|
122
|
+
name: chainMetadata.nativeCurrency.name,
|
123
|
+
symbol: chainMetadata.nativeCurrency.symbol,
|
124
|
+
icon: chainMetadata.icon?.url,
|
125
|
+
},
|
126
|
+
decimals: 18,
|
127
|
+
walletBalance,
|
128
|
+
gasCostWei,
|
129
|
+
transactionValueWei,
|
130
|
+
} satisfies TransactionCostAndData;
|
131
|
+
},
|
132
|
+
enabled: !!transaction && !!account && !!txQueryKey,
|
133
|
+
refetchInterval: () => {
|
134
|
+
if (transaction.erc20Value) {
|
135
|
+
// if erc20 value is set, we don't need to poll
|
136
|
+
return undefined;
|
60
137
|
}
|
138
|
+
return 30_000;
|
139
|
+
},
|
140
|
+
});
|
141
|
+
}
|
61
142
|
|
62
|
-
|
63
|
-
|
64
|
-
|
143
|
+
export async function getTransactionGasCost(
|
144
|
+
tx: PreparedTransaction,
|
145
|
+
from?: string,
|
146
|
+
) {
|
147
|
+
try {
|
148
|
+
const gasCost = await estimateGasCost({
|
149
|
+
transaction: tx,
|
150
|
+
from,
|
151
|
+
});
|
65
152
|
|
66
|
-
|
153
|
+
const bufferCost = gasCost.wei / 10n;
|
67
154
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
155
|
+
// Note: get tx.value AFTER estimateGasCost
|
156
|
+
// add 10% extra gas cost to the estimate to ensure user buys enough to cover the tx cost
|
157
|
+
return gasCost.wei + bufferCost;
|
158
|
+
} catch (e) {
|
159
|
+
if (from) {
|
160
|
+
// try again without passing from
|
161
|
+
return await getTransactionGasCost(tx);
|
162
|
+
}
|
163
|
+
// fallback if both fail, use the tx value + 2M * gas price
|
164
|
+
const gasPrice = await getGasPrice({
|
165
|
+
client: tx.client,
|
166
|
+
chain: tx.chain,
|
167
|
+
});
|
72
168
|
|
73
|
-
|
74
|
-
|
75
|
-
};
|
169
|
+
return 2_000_000n * gasPrice;
|
170
|
+
}
|
76
171
|
}
|
@@ -7,13 +7,18 @@ import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js"
|
|
7
7
|
// Based on what toToken, toChain, and supportedDestinations are, determine which payment methods should be enabled
|
8
8
|
// change the current method if it should be disabled
|
9
9
|
// return whether the payment selection should be shown or not ( if only one payment method is enabled, don't show the selection )
|
10
|
+
export type PaymentMethods = {
|
11
|
+
showPaymentSelection: boolean;
|
12
|
+
buyWithFiatEnabled: boolean;
|
13
|
+
buyWithCryptoEnabled: boolean;
|
14
|
+
};
|
10
15
|
|
11
16
|
export function useEnabledPaymentMethods(options: {
|
12
17
|
payOptions: PayUIOptions;
|
13
18
|
supportedDestinations: SupportedChainAndTokens;
|
14
19
|
toChain: Chain;
|
15
20
|
toToken: ERC20OrNativeToken;
|
16
|
-
}) {
|
21
|
+
}): PaymentMethods {
|
17
22
|
const { payOptions, supportedDestinations, toChain, toToken } = options;
|
18
23
|
|
19
24
|
function getEnabledPayMethodsForSelectedToken(): {
|
@@ -23,8 +28,8 @@ export function useEnabledPaymentMethods(options: {
|
|
23
28
|
const chain = supportedDestinations.find((c) => c.chain.id === toChain.id);
|
24
29
|
if (!chain) {
|
25
30
|
return {
|
26
|
-
fiat:
|
27
|
-
swap:
|
31
|
+
fiat: false,
|
32
|
+
swap: false,
|
28
33
|
};
|
29
34
|
}
|
30
35
|
|
@@ -1,29 +1,29 @@
|
|
1
1
|
import { useState } from "react";
|
2
2
|
import { polygon } from "../../../../../../../chains/chain-definitions/polygon.js";
|
3
3
|
import type { Chain } from "../../../../../../../chains/types.js";
|
4
|
-
import {
|
5
|
-
|
4
|
+
import type {
|
5
|
+
FundWalletOptions,
|
6
|
+
PayUIOptions,
|
7
|
+
} from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
|
6
8
|
import { useActiveWalletChain } from "../../../../../hooks/wallets/useActiveWalletChain.js";
|
7
9
|
import { useDebouncedValue } from "../../../../hooks/useDebouncedValue.js";
|
8
10
|
import { type ERC20OrNativeToken, NATIVE_TOKEN } from "../../nativeToken.js";
|
9
11
|
import { defaultSelectedCurrency } from "../fiat/currencies.js";
|
10
12
|
import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js";
|
11
|
-
import type { BuyForTx } from "./types.js";
|
12
13
|
|
13
14
|
// handle states for token and chain selection
|
14
15
|
|
15
16
|
export function useUISelectionStates(options: {
|
16
17
|
payOptions: PayUIOptions;
|
17
|
-
buyForTx?: BuyForTx;
|
18
18
|
supportedDestinations: SupportedChainAndTokens;
|
19
19
|
}) {
|
20
20
|
const activeChain = useActiveWalletChain();
|
21
|
-
const { payOptions,
|
21
|
+
const { payOptions, supportedDestinations } = options;
|
22
22
|
|
23
23
|
// buy token amount ---------------------------------------------------------
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
// NOTE - for transaction / direct payment modes, the token amount is set when the user tap continue
|
25
|
+
const prefillBuy = (payOptions as FundWalletOptions)?.prefillBuy;
|
26
|
+
const initialTokenAmount = prefillBuy?.amount || "";
|
27
27
|
|
28
28
|
const [tokenAmount, setTokenAmount] = useState<string>(initialTokenAmount);
|
29
29
|
const deferredTokenAmount = useDebouncedValue(tokenAmount, 300);
|
@@ -33,9 +33,9 @@ export function useUISelectionStates(options: {
|
|
33
33
|
// Destination chain and token selection -----------------------------------
|
34
34
|
const [toChain, setToChain] = useState<Chain>(
|
35
35
|
// use prefill chain if available
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
prefillBuy?.chain ||
|
37
|
+
(payOptions.mode === "transaction" && payOptions.transaction?.chain) ||
|
38
|
+
(payOptions.mode === "direct_payment" && payOptions.paymentInfo?.chain) ||
|
39
39
|
// use active chain if its supported as destination
|
40
40
|
supportedDestinations.find((x) => x.chain.id === activeChain?.id)
|
41
41
|
?.chain ||
|
@@ -44,7 +44,9 @@ export function useUISelectionStates(options: {
|
|
44
44
|
);
|
45
45
|
|
46
46
|
const [toToken, setToToken] = useState<ERC20OrNativeToken>(
|
47
|
-
|
47
|
+
prefillBuy?.token ||
|
48
|
+
(payOptions.mode === "direct_payment" && payOptions.paymentInfo.token) ||
|
49
|
+
NATIVE_TOKEN,
|
48
50
|
);
|
49
51
|
// --------------------------------------------------------------------------
|
50
52
|
|
@@ -53,6 +55,8 @@ export function useUISelectionStates(options: {
|
|
53
55
|
// use prefill chain if available
|
54
56
|
(payOptions.buyWithCrypto !== false &&
|
55
57
|
payOptions.buyWithCrypto?.prefillSource?.chain) ||
|
58
|
+
(payOptions.mode === "transaction" && payOptions.transaction?.chain) ||
|
59
|
+
(payOptions.mode === "direct_payment" && payOptions.paymentInfo?.chain) ||
|
56
60
|
// default to polygon
|
57
61
|
polygon,
|
58
62
|
);
|
@@ -61,6 +65,7 @@ export function useUISelectionStates(options: {
|
|
61
65
|
// use prefill token if available
|
62
66
|
(payOptions.buyWithCrypto !== false &&
|
63
67
|
payOptions.buyWithCrypto?.prefillSource?.token) ||
|
68
|
+
(payOptions.mode === "direct_payment" && payOptions.paymentInfo.token) ||
|
64
69
|
// default to native token
|
65
70
|
NATIVE_TOKEN,
|
66
71
|
);
|
@@ -40,7 +40,7 @@ export function PayTxHistoryScreen(props: {
|
|
40
40
|
onBack?: () => void;
|
41
41
|
client: ThirdwebClient;
|
42
42
|
onDone: () => void;
|
43
|
-
|
43
|
+
transactionMode: boolean;
|
44
44
|
isEmbed: boolean;
|
45
45
|
}) {
|
46
46
|
const [selectedTx, setSelectedTx] = useState<TxStatusInfo | null>(null);
|
@@ -66,7 +66,7 @@ export function PayTxHistoryScreen(props: {
|
|
66
66
|
statusInfo={selectedTx}
|
67
67
|
onBack={() => setSelectedTx(null)}
|
68
68
|
onDone={props.onDone}
|
69
|
-
|
69
|
+
transactionMode={props.transactionMode}
|
70
70
|
isEmbed={props.isEmbed}
|
71
71
|
payer={payer}
|
72
72
|
/>
|
@@ -17,7 +17,7 @@ export function FiatDetailsScreen(props: {
|
|
17
17
|
onBack: () => void;
|
18
18
|
client: ThirdwebClient;
|
19
19
|
onDone: () => void;
|
20
|
-
|
20
|
+
transactionMode: boolean;
|
21
21
|
isEmbed: boolean;
|
22
22
|
payer: PayerInfo;
|
23
23
|
}) {
|
@@ -48,8 +48,7 @@ export function FiatDetailsScreen(props: {
|
|
48
48
|
client={props.client}
|
49
49
|
status={status}
|
50
50
|
onBack={props.onBack}
|
51
|
-
|
52
|
-
isBuyForTx={props.isBuyForTx}
|
51
|
+
transactionMode={props.transactionMode}
|
53
52
|
isEmbed={props.isEmbed}
|
54
53
|
quote={{
|
55
54
|
fromCurrencyAmount: fiatQuote.fromCurrencyWithFees.amount,
|
@@ -289,7 +289,7 @@ export function SwapTxDetailsTable(
|
|
289
289
|
>
|
290
290
|
<Text>Send to</Text>
|
291
291
|
<Container flex="row" gap="xs" center="y">
|
292
|
-
<Text color="primaryText">
|
292
|
+
<Text color="primaryText" size="sm">
|
293
293
|
{shortenAddress(uiData.toAddress)}
|
294
294
|
</Text>
|
295
295
|
</Container>
|
@@ -10,7 +10,7 @@ export function TxDetailsScreen(props: {
|
|
10
10
|
statusInfo: TxStatusInfo;
|
11
11
|
onBack: () => void;
|
12
12
|
onDone: () => void;
|
13
|
-
|
13
|
+
transactionMode: boolean;
|
14
14
|
isEmbed: boolean;
|
15
15
|
payer: PayerInfo;
|
16
16
|
}) {
|
@@ -34,7 +34,7 @@ export function TxDetailsScreen(props: {
|
|
34
34
|
status={statusInfo.status}
|
35
35
|
onBack={props.onBack}
|
36
36
|
onDone={props.onDone}
|
37
|
-
|
37
|
+
transactionMode={props.transactionMode}
|
38
38
|
isEmbed={props.isEmbed}
|
39
39
|
payer={props.payer}
|
40
40
|
/>
|