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
@@ -18,7 +18,7 @@ import type { SupportedTokens } from "../../core/utils/defaultTokens.js";
|
|
18
18
|
import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js";
|
19
19
|
import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js";
|
20
20
|
import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js";
|
21
|
-
import {
|
21
|
+
import { ExecutingTxScreen } from "./TransactionButton/ExecutingScreen.js";
|
22
22
|
import { DynamicHeight } from "./components/DynamicHeight.js";
|
23
23
|
import { Spinner } from "./components/Spinner.js";
|
24
24
|
import type { LocaleId } from "./types.js";
|
@@ -125,13 +125,6 @@ export type PayEmbedProps = {
|
|
125
125
|
*/
|
126
126
|
connectOptions?: PayEmbedConnectOptions;
|
127
127
|
|
128
|
-
/**
|
129
|
-
* Customize the display of the PayEmbed UI.
|
130
|
-
*/
|
131
|
-
metadata?: {
|
132
|
-
title?: string;
|
133
|
-
};
|
134
|
-
|
135
128
|
style?: React.CSSProperties;
|
136
129
|
};
|
137
130
|
|
@@ -159,7 +152,7 @@ export type PayEmbedProps = {
|
|
159
152
|
*/
|
160
153
|
export function PayEmbed(props: PayEmbedProps) {
|
161
154
|
const localeQuery = useConnectLocale(props.locale || "en_US");
|
162
|
-
const [screen, setScreen] = useState<"buy" | "tx
|
155
|
+
const [screen, setScreen] = useState<"buy" | "execute-tx">("buy");
|
163
156
|
const theme = props.theme || "dark";
|
164
157
|
|
165
158
|
// to update cached chains ASAP, we skip using useEffect - this does not trigger a re-render so it's fine
|
@@ -172,6 +165,10 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
172
165
|
}
|
173
166
|
|
174
167
|
let content = null;
|
168
|
+
const metadata =
|
169
|
+
props.payOptions && "metadata" in props.payOptions
|
170
|
+
? props.payOptions.metadata
|
171
|
+
: null;
|
175
172
|
|
176
173
|
if (!localeQuery.data) {
|
177
174
|
content = (
|
@@ -190,41 +187,43 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
190
187
|
// show and hide screens with CSS to not lose state when switching between them
|
191
188
|
content = (
|
192
189
|
<>
|
193
|
-
<div style={{ display: screen === "
|
190
|
+
<div style={{ display: screen === "buy" ? "inherit" : "none" }}>
|
194
191
|
<BuyScreen
|
195
|
-
title={
|
192
|
+
title={metadata?.name || "Buy"}
|
196
193
|
isEmbed={true}
|
197
194
|
supportedTokens={props.supportedTokens}
|
198
195
|
theme={theme}
|
199
196
|
client={props.client}
|
200
197
|
connectLocale={localeQuery.data}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
198
|
+
payOptions={
|
199
|
+
props.payOptions || {
|
200
|
+
mode: "fund_wallet",
|
201
|
+
}
|
202
|
+
}
|
205
203
|
onDone={() => {
|
206
|
-
|
204
|
+
if (props.payOptions?.mode === "transaction") {
|
205
|
+
setScreen("execute-tx");
|
206
|
+
}
|
207
207
|
}}
|
208
208
|
connectOptions={props.connectOptions}
|
209
|
-
buyForTx={undefined}
|
210
209
|
onBack={undefined}
|
211
210
|
/>
|
212
211
|
</div>
|
213
|
-
|
214
|
-
{screen === "tx
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
212
|
+
|
213
|
+
{screen === "execute-tx" &&
|
214
|
+
props.payOptions?.mode === "transaction" &&
|
215
|
+
props.payOptions.transaction && (
|
216
|
+
<ExecutingTxScreen
|
217
|
+
tx={props.payOptions.transaction}
|
218
|
+
closeModal={() => {
|
219
|
+
setScreen("buy");
|
220
|
+
}}
|
221
|
+
onBack={() => {
|
222
|
+
setScreen("buy");
|
223
|
+
}}
|
224
|
+
onTxSent={() => {}}
|
225
|
+
/>
|
226
|
+
)}
|
228
227
|
</>
|
229
228
|
);
|
230
229
|
}
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import { CheckCircledIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
3
|
+
import type { Hex } from "viem";
|
4
|
+
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
5
|
+
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
6
|
+
import { iconSize } from "../../../core/design-system/index.js";
|
7
|
+
import { useChainExplorers } from "../../../core/hooks/others/useChainQuery.js";
|
8
|
+
import { useSendTransaction } from "../../hooks/transaction/useSendTransaction.js";
|
9
|
+
import { AccentFailIcon } from "../ConnectWallet/icons/AccentFailIcon.js";
|
10
|
+
import { Spacer } from "../components/Spacer.js";
|
11
|
+
import { Spinner } from "../components/Spinner.js";
|
12
|
+
import { Container, ModalHeader } from "../components/basic.js";
|
13
|
+
import { Button, ButtonLink } from "../components/buttons.js";
|
14
|
+
import { Text } from "../components/text.js";
|
15
|
+
|
16
|
+
export function ExecutingTxScreen(props: {
|
17
|
+
tx: PreparedTransaction;
|
18
|
+
closeModal: () => void;
|
19
|
+
onTxSent: (data: WaitForReceiptOptions) => void;
|
20
|
+
onBack?: () => void;
|
21
|
+
}) {
|
22
|
+
const sendTxCore = useSendTransaction({
|
23
|
+
payModal: false,
|
24
|
+
});
|
25
|
+
const [txHash, setTxHash] = useState<Hex | undefined>();
|
26
|
+
const chainExplorers = useChainExplorers(props.tx.chain);
|
27
|
+
const [status, setStatus] = useState<"loading" | "failed" | "sent">(
|
28
|
+
"loading",
|
29
|
+
);
|
30
|
+
|
31
|
+
const sendTx = useCallback(async () => {
|
32
|
+
setStatus("loading");
|
33
|
+
try {
|
34
|
+
const txData = await sendTxCore.mutateAsync(props.tx);
|
35
|
+
setTxHash(txData.transactionHash);
|
36
|
+
props.onTxSent(txData);
|
37
|
+
setStatus("sent");
|
38
|
+
} catch (e) {
|
39
|
+
// Do not reject the transaction here, because the user may want to try again
|
40
|
+
// we only reject on modal close
|
41
|
+
console.error(e);
|
42
|
+
setStatus("failed");
|
43
|
+
}
|
44
|
+
}, [sendTxCore, props.tx, props.onTxSent]);
|
45
|
+
|
46
|
+
const done = useRef(false);
|
47
|
+
useEffect(() => {
|
48
|
+
if (done.current) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
|
52
|
+
done.current = true;
|
53
|
+
sendTx();
|
54
|
+
}, [sendTx]);
|
55
|
+
|
56
|
+
return (
|
57
|
+
<Container p="lg">
|
58
|
+
<ModalHeader title="Transaction" onBack={props.onBack} />
|
59
|
+
|
60
|
+
<Spacer y="xxl" />
|
61
|
+
<Spacer y="xxl" />
|
62
|
+
|
63
|
+
<Container flex="row" center="x">
|
64
|
+
{status === "loading" && <Spinner size="xxl" color="accentText" />}
|
65
|
+
{status === "failed" && <AccentFailIcon size={iconSize["3xl"]} />}
|
66
|
+
{status === "sent" && (
|
67
|
+
<Container color="success" flex="row" center="both">
|
68
|
+
<CheckCircledIcon
|
69
|
+
width={iconSize["3xl"]}
|
70
|
+
height={iconSize["3xl"]}
|
71
|
+
/>
|
72
|
+
</Container>
|
73
|
+
)}
|
74
|
+
</Container>
|
75
|
+
<Spacer y="lg" />
|
76
|
+
|
77
|
+
<Text color="primaryText" center size="lg">
|
78
|
+
{status === "loading" && "Sending transaction"}
|
79
|
+
{status === "failed" && "Transaction failed"}
|
80
|
+
{status === "sent" && "Transaction sent"}
|
81
|
+
</Text>
|
82
|
+
<Spacer y="sm" />
|
83
|
+
<Text color="danger" center size="sm">
|
84
|
+
{status === "failed" && sendTxCore.error
|
85
|
+
? sendTxCore.error.message
|
86
|
+
: ""}
|
87
|
+
</Text>
|
88
|
+
|
89
|
+
<Spacer y="xxl" />
|
90
|
+
<Spacer y="xxl" />
|
91
|
+
|
92
|
+
{status === "failed" && (
|
93
|
+
<Button variant="accent" fullWidth onClick={sendTx}>
|
94
|
+
Try Again
|
95
|
+
</Button>
|
96
|
+
)}
|
97
|
+
|
98
|
+
{status === "sent" && (
|
99
|
+
<>
|
100
|
+
<Button variant="accent" fullWidth onClick={props.closeModal}>
|
101
|
+
Done
|
102
|
+
</Button>
|
103
|
+
{txHash && (
|
104
|
+
<>
|
105
|
+
<Spacer y="sm" />
|
106
|
+
<ButtonLink
|
107
|
+
fullWidth
|
108
|
+
variant="outline"
|
109
|
+
href={`${chainExplorers.explorers[0]?.url}/tx/${txHash}`}
|
110
|
+
target="_blank"
|
111
|
+
as="a"
|
112
|
+
gap="xs"
|
113
|
+
style={{
|
114
|
+
textDecoration: "none",
|
115
|
+
color: "inherit",
|
116
|
+
}}
|
117
|
+
>
|
118
|
+
View on Explorer{" "}
|
119
|
+
<ExternalLinkIcon width={iconSize.sm} height={iconSize.sm} />
|
120
|
+
</ButtonLink>
|
121
|
+
</>
|
122
|
+
)}
|
123
|
+
</>
|
124
|
+
)}
|
125
|
+
</Container>
|
126
|
+
);
|
127
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { useState } from "react";
|
2
|
+
import type { ThirdwebClient } from "../../../../client/client.js";
|
3
|
+
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
|
4
|
+
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
|
5
|
+
import { CustomThemeProvider } from "../../../core/design-system/CustomThemeProvider.js";
|
6
|
+
import type { Theme } from "../../../core/design-system/index.js";
|
7
|
+
import type { PayUIOptions } from "../../../core/hooks/connection/ConnectButtonProps.js";
|
8
|
+
import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
|
9
|
+
import { LoadingScreen } from "../../wallets/shared/LoadingScreen.js";
|
10
|
+
import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
|
11
|
+
import { LazyBuyScreen } from "../ConnectWallet/screens/Buy/LazyBuyScreen.js";
|
12
|
+
import { Modal } from "../components/Modal.js";
|
13
|
+
import type { LocaleId } from "../types.js";
|
14
|
+
import { ExecutingTxScreen } from "./ExecutingScreen.js";
|
15
|
+
|
16
|
+
export type ModalProps = {
|
17
|
+
title: string;
|
18
|
+
onComplete: () => void;
|
19
|
+
onClose: () => void;
|
20
|
+
client: ThirdwebClient;
|
21
|
+
localeId: LocaleId;
|
22
|
+
supportedTokens?: SupportedTokens;
|
23
|
+
theme: Theme | "light" | "dark";
|
24
|
+
tx: PreparedTransaction;
|
25
|
+
payOptions: PayUIOptions;
|
26
|
+
onTxSent: (data: WaitForReceiptOptions) => void;
|
27
|
+
};
|
28
|
+
|
29
|
+
export function TransactionModal(props: ModalProps) {
|
30
|
+
return (
|
31
|
+
<CustomThemeProvider theme={props.theme}>
|
32
|
+
<Modal
|
33
|
+
open={true}
|
34
|
+
size="compact"
|
35
|
+
setOpen={(_open) => {
|
36
|
+
if (!_open) {
|
37
|
+
props.onClose();
|
38
|
+
}
|
39
|
+
}}
|
40
|
+
>
|
41
|
+
<TransactionModalContent {...props} />
|
42
|
+
</Modal>
|
43
|
+
</CustomThemeProvider>
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
47
|
+
export function TransactionModalContent(
|
48
|
+
props: ModalProps & { onBack?: () => void },
|
49
|
+
) {
|
50
|
+
const localeQuery = useConnectLocale(props.localeId);
|
51
|
+
const [screen, setScreen] = useState<"buy" | "execute-tx">("buy");
|
52
|
+
|
53
|
+
if (!localeQuery.data) {
|
54
|
+
return <LoadingScreen />;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (screen === "execute-tx") {
|
58
|
+
return (
|
59
|
+
<ExecutingTxScreen
|
60
|
+
tx={props.tx}
|
61
|
+
closeModal={props.onClose}
|
62
|
+
onTxSent={props.onTxSent}
|
63
|
+
/>
|
64
|
+
);
|
65
|
+
}
|
66
|
+
|
67
|
+
return (
|
68
|
+
<LazyBuyScreen
|
69
|
+
title={props.title}
|
70
|
+
isEmbed={false}
|
71
|
+
client={props.client}
|
72
|
+
onBack={props.onBack}
|
73
|
+
supportedTokens={props.supportedTokens}
|
74
|
+
connectLocale={localeQuery.data}
|
75
|
+
theme={typeof props.theme === "string" ? props.theme : props.theme.type}
|
76
|
+
payOptions={props.payOptions}
|
77
|
+
onDone={() => {
|
78
|
+
setScreen("execute-tx");
|
79
|
+
}}
|
80
|
+
connectOptions={undefined}
|
81
|
+
/>
|
82
|
+
);
|
83
|
+
}
|
@@ -7,6 +7,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
7
7
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
8
8
|
import { getEcosystemWalletAuthOptions } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
9
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
|
+
import { loginWithOauthRedirect } from "../../../../wallets/in-app/web/lib/auth/oauth.js";
|
10
11
|
import type { Account, Wallet } from "../../../../wallets/interfaces/wallet.js";
|
11
12
|
import {
|
12
13
|
type AuthOption,
|
@@ -37,7 +38,7 @@ import { InputSelectionUI } from "../in-app/InputSelectionUI.js";
|
|
37
38
|
import { validateEmail } from "../in-app/validateEmail.js";
|
38
39
|
import { LoadingScreen } from "./LoadingScreen.js";
|
39
40
|
import type { InAppWalletLocale } from "./locale/types.js";
|
40
|
-
import { openOauthSignInWindow } from "./
|
41
|
+
import { openOauthSignInWindow } from "./oauthSignIn.js";
|
41
42
|
|
42
43
|
export type ConnectWalletSelectUIState =
|
43
44
|
| undefined
|
@@ -164,6 +165,19 @@ export const ConnectWalletSocialOptions = (
|
|
164
165
|
|
165
166
|
// Need to trigger login on button click to avoid popup from being blocked
|
166
167
|
const handleSocialLogin = async (strategy: SocialAuthOption) => {
|
168
|
+
const walletConfig = wallet.getConfig();
|
169
|
+
if (
|
170
|
+
walletConfig &&
|
171
|
+
"auth" in walletConfig &&
|
172
|
+
walletConfig?.auth?.mode === "redirect"
|
173
|
+
) {
|
174
|
+
return loginWithOauthRedirect({
|
175
|
+
authOption: strategy,
|
176
|
+
client: props.client,
|
177
|
+
ecosystem: ecosystemInfo,
|
178
|
+
});
|
179
|
+
}
|
180
|
+
|
167
181
|
try {
|
168
182
|
const socialLoginWindow = openOauthSignInWindow({
|
169
183
|
authOption: strategy,
|
@@ -205,10 +219,10 @@ export const ConnectWalletSocialOptions = (
|
|
205
219
|
|
206
220
|
props.select(); // show Connect UI
|
207
221
|
|
208
|
-
// Note: do not call done() here, it will be called
|
209
|
-
// we simply trigger the connect and save promise here - its resolution is handled in
|
222
|
+
// Note: do not call done() here, it will be called SocialLogin component
|
223
|
+
// we simply trigger the connect and save promise here - its resolution is handled in SocialLogin
|
210
224
|
} catch (e) {
|
211
|
-
console.error(`Error
|
225
|
+
console.error(`Error signing in with ${strategy}`, e);
|
212
226
|
}
|
213
227
|
};
|
214
228
|
|
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
5
5
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
6
6
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
7
7
|
import type { InAppWalletSocialAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
8
|
+
import { loginWithOauthRedirect } from "../../../../wallets/in-app/web/lib/auth/oauth.js";
|
8
9
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
9
10
|
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
10
11
|
import { setLastAuthProvider } from "../../../core/utils/storage.js";
|
@@ -15,7 +16,7 @@ import { Button } from "../../ui/components/buttons.js";
|
|
15
16
|
import { Text } from "../../ui/components/text.js";
|
16
17
|
import type { ConnectWalletSelectUIState } from "./ConnectWalletSocialOptions.js";
|
17
18
|
import type { InAppWalletLocale } from "./locale/types.js";
|
18
|
-
import { openOauthSignInWindow } from "./
|
19
|
+
import { openOauthSignInWindow } from "./oauthSignIn.js";
|
19
20
|
|
20
21
|
/**
|
21
22
|
* @internal
|
@@ -42,6 +43,24 @@ export function SocialLogin(props: {
|
|
42
43
|
);
|
43
44
|
|
44
45
|
const handleSocialLogin = async () => {
|
46
|
+
const walletConfig = wallet.getConfig();
|
47
|
+
if (
|
48
|
+
walletConfig &&
|
49
|
+
"auth" in walletConfig &&
|
50
|
+
walletConfig?.auth?.mode === "redirect"
|
51
|
+
) {
|
52
|
+
return loginWithOauthRedirect({
|
53
|
+
authOption: props.socialAuth,
|
54
|
+
client: props.client,
|
55
|
+
ecosystem: isEcosystemWallet(wallet)
|
56
|
+
? {
|
57
|
+
id: wallet.id,
|
58
|
+
partnerId: wallet.getConfig()?.partnerId,
|
59
|
+
}
|
60
|
+
: undefined,
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
45
64
|
try {
|
46
65
|
const socialWindow = openOauthSignInWindow({
|
47
66
|
authOption: props.socialAuth,
|
@@ -41,7 +41,6 @@ function getOauthLoginPath(
|
|
41
41
|
}
|
42
42
|
|
43
43
|
/**
|
44
|
-
*
|
45
44
|
* @internal
|
46
45
|
*/
|
47
46
|
export function openOauthSignInWindow({
|
@@ -137,7 +136,7 @@ const spinnerWindowHtml = `
|
|
137
136
|
@keyframes spin {
|
138
137
|
100% {
|
139
138
|
transform: rotate(360deg);
|
140
|
-
|
139
|
+
}
|
141
140
|
}
|
142
141
|
</style>
|
143
142
|
`;
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.
|
1
|
+
export const version = "5.40.0";
|
@@ -6,6 +6,9 @@ import type { Ecosystem } from "../in-app/web/types.js";
|
|
6
6
|
|
7
7
|
export type EcosystemWalletCreationOptions = {
|
8
8
|
partnerId?: string;
|
9
|
+
auth?: {
|
10
|
+
mode?: "popup" | "redirect";
|
11
|
+
};
|
9
12
|
};
|
10
13
|
|
11
14
|
export type EcosystemWalletConnectionOptions = InAppWalletConnectionOptions & {
|
@@ -1,7 +1,9 @@
|
|
1
|
+
import type { SocialAuthOption } from "../../../../wallets/types.js";
|
1
2
|
import type { Account } from "../../../interfaces/wallet.js";
|
2
3
|
import type {
|
3
4
|
AuthArgsType,
|
4
5
|
AuthLoginReturnType,
|
6
|
+
AuthStoredTokenWithCookieReturnType,
|
5
7
|
GetUser,
|
6
8
|
LogoutReturnType,
|
7
9
|
PreAuthArgsType,
|
@@ -12,6 +14,10 @@ export interface InAppConnector {
|
|
12
14
|
getUser(): Promise<GetUser>;
|
13
15
|
getAccount(): Promise<Account>;
|
14
16
|
preAuthenticate(args: PreAuthArgsType): Promise<SendEmailOtpReturnType>;
|
17
|
+
authenticateWithRedirect?(strategy: SocialAuthOption): void;
|
18
|
+
loginWithAuthToken?(
|
19
|
+
authResult: AuthStoredTokenWithCookieReturnType,
|
20
|
+
): Promise<AuthLoginReturnType>;
|
15
21
|
authenticate(args: AuthArgsType): Promise<AuthLoginReturnType>;
|
16
22
|
logout(): Promise<LogoutReturnType>;
|
17
23
|
}
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
|
2
2
|
import type { Chain } from "../../../../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
|
+
import {
|
5
|
+
type SocialAuthOption,
|
6
|
+
socialAuthOptions,
|
7
|
+
} from "../../../../wallets/types.js";
|
4
8
|
import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
5
9
|
import type { EcosystemWalletId, WalletId } from "../../../wallet-types.js";
|
6
10
|
import type {
|
@@ -35,6 +39,20 @@ export async function connectInAppWallet(
|
|
35
39
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
36
40
|
connector: InAppConnector,
|
37
41
|
): Promise<[Account, Chain]> {
|
42
|
+
if (
|
43
|
+
createOptions?.auth?.mode === "redirect" &&
|
44
|
+
connector.authenticateWithRedirect
|
45
|
+
) {
|
46
|
+
const strategy = options.strategy;
|
47
|
+
if (!socialAuthOptions.includes(strategy as SocialAuthOption)) {
|
48
|
+
throw new Error("This authentication method does not support redirects");
|
49
|
+
}
|
50
|
+
connector.authenticateWithRedirect(strategy as SocialAuthOption);
|
51
|
+
}
|
52
|
+
// If we don't have authenticateWithRedirect then it's likely react native, so the default is to redirect and we can carry on
|
53
|
+
// IF WE EVER ADD MORE CONNECTOR TYPES, this could cause redirect to be ignored despite being specified
|
54
|
+
// TODO: In V6, make everything redirect auth
|
55
|
+
|
38
56
|
const authResult = await connector.authenticate(options);
|
39
57
|
const authAccount = authResult.user.account;
|
40
58
|
|
@@ -66,6 +84,10 @@ export async function autoConnectInAppWallet(
|
|
66
84
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
67
85
|
connector: InAppConnector,
|
68
86
|
): Promise<[Account, Chain]> {
|
87
|
+
if (options.authResult && connector.loginWithAuthToken) {
|
88
|
+
await connector.loginWithAuthToken(options.authResult);
|
89
|
+
}
|
90
|
+
|
69
91
|
const user = await getAuthenticatedUser(connector);
|
70
92
|
if (!user) {
|
71
93
|
throw new Error("Failed to authenticate user.");
|
@@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
|
|
3
3
|
import type { SmartWalletOptions } from "../../../smart/types.js";
|
4
4
|
import type { AuthOption, SocialAuthOption } from "../../../types.js";
|
5
5
|
import type {
|
6
|
+
AuthStoredTokenWithCookieReturnType,
|
6
7
|
MultiStepAuthArgsType,
|
7
8
|
SingleStepAuthArgsType,
|
8
9
|
} from "../authentication/type.js";
|
@@ -13,10 +14,12 @@ export type InAppWalletConnectionOptions = (
|
|
13
14
|
) & {
|
14
15
|
client: ThirdwebClient;
|
15
16
|
chain?: Chain;
|
17
|
+
redirect?: boolean;
|
16
18
|
};
|
17
19
|
|
18
20
|
export type InAppWalletAutoConnectOptions = {
|
19
21
|
client: ThirdwebClient;
|
22
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
20
23
|
chain?: Chain;
|
21
24
|
};
|
22
25
|
|
@@ -27,6 +30,7 @@ export type InAppWalletCreationOptions =
|
|
27
30
|
| {
|
28
31
|
auth?: {
|
29
32
|
options: InAppWalletAuth[];
|
33
|
+
mode?: "popup" | "redirect";
|
30
34
|
};
|
31
35
|
metadata?: {
|
32
36
|
image?: {
|
@@ -53,6 +53,16 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
|
|
53
53
|
* hidePrivateKeyExport: true
|
54
54
|
* });
|
55
55
|
* ```
|
56
|
+
*
|
57
|
+
* Open the Oauth window in the same tab
|
58
|
+
* ```ts
|
59
|
+
* import { inAppWallet } from "thirdweb/wallets";
|
60
|
+
* const wallet = inAppWallet({
|
61
|
+
* auth: {
|
62
|
+
* mode: "redirect"
|
63
|
+
* }
|
64
|
+
* });
|
65
|
+
* ```
|
56
66
|
* @wallet
|
57
67
|
*/
|
58
68
|
export function inAppWallet(
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
2
|
+
import type { OneOf } from "../../../../../utils/type-utils.js";
|
3
|
+
import type { SocialAuthOption } from "../../../../../wallets/types.js";
|
2
4
|
import {
|
3
5
|
type AuthArgsType,
|
4
|
-
type AuthLoginReturnType,
|
5
6
|
type GetAuthenticatedUserParams,
|
6
7
|
type PreAuthArgsType,
|
7
8
|
UserWalletStatus,
|
@@ -143,8 +144,18 @@ export async function preAuthenticate(args: PreAuthArgsType) {
|
|
143
144
|
* @wallet
|
144
145
|
*/
|
145
146
|
export async function authenticate(
|
146
|
-
args:
|
147
|
-
|
147
|
+
args: OneOf<
|
148
|
+
| AuthArgsType
|
149
|
+
| {
|
150
|
+
strategy: SocialAuthOption;
|
151
|
+
client: ThirdwebClient;
|
152
|
+
ecosystem?: Ecosystem;
|
153
|
+
redirect: boolean;
|
154
|
+
}
|
155
|
+
>,
|
156
|
+
) {
|
148
157
|
const connector = await getInAppWalletConnector(args.client, args.ecosystem);
|
158
|
+
if (args.redirect && connector.authenticateWithRedirect)
|
159
|
+
return connector.authenticateWithRedirect(args.strategy);
|
149
160
|
return connector.authenticate(args);
|
150
161
|
}
|
@@ -40,6 +40,18 @@ export const getSocialAuthLoginPath = (
|
|
40
40
|
return baseUrl;
|
41
41
|
};
|
42
42
|
|
43
|
+
export const loginWithOauthRedirect = (options: {
|
44
|
+
authOption: SocialAuthOption;
|
45
|
+
client: ThirdwebClient;
|
46
|
+
ecosystem?: Ecosystem;
|
47
|
+
}): void => {
|
48
|
+
const redirectUrl = new URL(window.location.href);
|
49
|
+
redirectUrl.searchParams.set("walletId", options.ecosystem?.id || "inApp");
|
50
|
+
redirectUrl.searchParams.set("authProvider", options.authOption);
|
51
|
+
const loginUrl = `${getSocialAuthLoginPath(options.authOption, options.client, options.ecosystem)}&redirectUrl=${encodeURIComponent(redirectUrl.toString())}`;
|
52
|
+
window.location.href = loginUrl;
|
53
|
+
};
|
54
|
+
|
43
55
|
export const loginWithOauth = async (options: {
|
44
56
|
authOption: SocialAuthOption;
|
45
57
|
client: ThirdwebClient;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { AuthOption } from "../../../../wallets/types.js";
|
2
|
+
import type { WalletId } from "../../../wallet-types.js";
|
3
|
+
import type { AuthStoredTokenWithCookieReturnType } from "../../core/authentication/type.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Checks for an auth token and associated metadata in the current URL
|
7
|
+
*/
|
8
|
+
export function getUrlToken(): {
|
9
|
+
walletId?: WalletId;
|
10
|
+
authResult?: AuthStoredTokenWithCookieReturnType;
|
11
|
+
authProvider?: AuthOption;
|
12
|
+
} {
|
13
|
+
if (!window) {
|
14
|
+
throw new Error("Attempted to fetch a URL token on the server");
|
15
|
+
}
|
16
|
+
|
17
|
+
const queryString = window.location.search;
|
18
|
+
const params = new URLSearchParams(queryString);
|
19
|
+
const authResultString = params.get("authResult");
|
20
|
+
const walletId = params.get("walletId") as WalletId | undefined;
|
21
|
+
const authProvider = params.get("authProvider") as AuthOption | undefined;
|
22
|
+
|
23
|
+
if (authResultString && walletId) {
|
24
|
+
const authResult = JSON.parse(authResultString);
|
25
|
+
params.delete("authResult");
|
26
|
+
params.delete("walletId");
|
27
|
+
params.delete("authProvider");
|
28
|
+
window.history.pushState(
|
29
|
+
{},
|
30
|
+
"",
|
31
|
+
`${window.location.pathname}?${params.toString()}`,
|
32
|
+
);
|
33
|
+
return { walletId, authResult, authProvider };
|
34
|
+
}
|
35
|
+
return {};
|
36
|
+
}
|