thirdweb 5.108.6 → 5.108.7
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/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/core/hooks/usePaymentMethods.js +1 -2
- package/dist/cjs/react/core/hooks/usePaymentMethods.js.map +1 -1
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
- package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +185 -99
- package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js +210 -56
- package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/DirectPayment.js +7 -7
- package/dist/cjs/react/web/ui/Bridge/DirectPayment.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/FundWallet.js +233 -105
- package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js +1 -7
- package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js +16 -12
- package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js +199 -36
- package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js +2 -2
- package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/common/WithHeader.js +4 -5
- package/dist/cjs/react/web/ui/Bridge/common/WithHeader.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/common/active-wallet-details.js +52 -0
- package/dist/cjs/react/web/ui/Bridge/common/active-wallet-details.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/common/decimal-input.js +36 -0
- package/dist/cjs/react/web/ui/Bridge/common/decimal-input.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/common/selected-token-button.js +58 -0
- package/dist/cjs/react/web/ui/Bridge/common/selected-token-button.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/common/token-balance.js +20 -0
- package/dist/cjs/react/web/ui/Bridge/common/token-balance.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/common/token-query.js +34 -0
- package/dist/cjs/react/web/ui/Bridge/common/token-query.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js +3 -3
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js +7 -7
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js +1 -4
- package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js +3 -3
- package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js +8 -11
- package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js +19 -147
- package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/types.js +3 -0
- package/dist/cjs/react/web/ui/Bridge/types.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +4 -2
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +17 -10
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/cjs/react/web/ui/components/CopyIcon.js +1 -1
- package/dist/cjs/react/web/ui/components/CopyIcon.js.map +1 -1
- package/dist/cjs/stories/Bridge/CheckoutWidget.stories.js +115 -0
- package/dist/cjs/stories/Bridge/CheckoutWidget.stories.js.map +1 -0
- package/dist/cjs/stories/Bridge/ErrorBanner.stories.js +7 -111
- package/dist/cjs/stories/Bridge/ErrorBanner.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/PaymentDetails.stories.js +27 -306
- package/dist/cjs/stories/Bridge/PaymentDetails.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/PaymentSelection.stories.js +21 -128
- package/dist/cjs/stories/Bridge/PaymentSelection.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/StepRunner.stories.js +13 -39
- package/dist/cjs/stories/Bridge/StepRunner.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/SuccessScreen.stories.js +13 -101
- package/dist/cjs/stories/Bridge/SuccessScreen.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/Transaction/TransactionWidget.stories.js +49 -0
- package/dist/cjs/stories/Bridge/Transaction/TransactionWidget.stories.js.map +1 -0
- package/dist/cjs/stories/Bridge/Transaction/useSendTransactionModal.stories.js +53 -0
- package/dist/cjs/stories/Bridge/Transaction/useSendTransactionModal.stories.js.map +1 -0
- package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js +11 -79
- package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
- package/dist/cjs/stories/Bridge/fixtures.js +21 -62
- package/dist/cjs/stories/Bridge/fixtures.js.map +1 -1
- package/dist/cjs/stories/BuyWidget.stories.js +44 -8
- package/dist/cjs/stories/BuyWidget.stories.js.map +1 -1
- package/dist/cjs/stories/utils.js +5 -2
- package/dist/cjs/stories/utils.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/x402/common.js +3 -5
- package/dist/cjs/x402/common.js.map +1 -1
- package/dist/cjs/x402/facilitator.js +0 -1
- package/dist/cjs/x402/facilitator.js.map +1 -1
- package/dist/cjs/x402/schemas.js +4 -0
- package/dist/cjs/x402/schemas.js.map +1 -1
- package/dist/cjs/x402/settle-payment.js +6 -5
- package/dist/cjs/x402/settle-payment.js.map +1 -1
- package/dist/cjs/x402/sign.js +2 -6
- package/dist/cjs/x402/sign.js.map +1 -1
- package/dist/cjs/x402/types.js.map +1 -1
- package/dist/cjs/x402/verify-payment.js +6 -5
- package/dist/cjs/x402/verify-payment.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/core/hooks/usePaymentMethods.js +1 -2
- package/dist/esm/react/core/hooks/usePaymentMethods.js.map +1 -1
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
- package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/BuyWidget.js +185 -99
- package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js +211 -57
- package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/DirectPayment.js +7 -7
- package/dist/esm/react/web/ui/Bridge/DirectPayment.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/FundWallet.js +237 -109
- package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/QuoteLoader.js +1 -7
- package/dist/esm/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/TransactionPayment.js +16 -12
- package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/TransactionWidget.js +198 -36
- package/dist/esm/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js +2 -2
- package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/common/WithHeader.js +4 -5
- package/dist/esm/react/web/ui/Bridge/common/WithHeader.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/common/active-wallet-details.js +49 -0
- package/dist/esm/react/web/ui/Bridge/common/active-wallet-details.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/common/decimal-input.js +33 -0
- package/dist/esm/react/web/ui/Bridge/common/decimal-input.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/common/selected-token-button.js +55 -0
- package/dist/esm/react/web/ui/Bridge/common/selected-token-button.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/common/token-balance.js +17 -0
- package/dist/esm/react/web/ui/Bridge/common/token-balance.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/common/token-query.js +31 -0
- package/dist/esm/react/web/ui/Bridge/common/token-query.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js +3 -3
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js +7 -7
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js +1 -4
- package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js +3 -3
- package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js +8 -11
- package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js +16 -144
- package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/types.js +2 -0
- package/dist/esm/react/web/ui/Bridge/types.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +4 -2
- package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +1 -1
- package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +17 -10
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/esm/react/web/ui/components/CopyIcon.js +1 -1
- package/dist/esm/react/web/ui/components/CopyIcon.js.map +1 -1
- package/dist/esm/stories/Bridge/CheckoutWidget.stories.js +112 -0
- package/dist/esm/stories/Bridge/CheckoutWidget.stories.js.map +1 -0
- package/dist/esm/stories/Bridge/ErrorBanner.stories.js +7 -111
- package/dist/esm/stories/Bridge/ErrorBanner.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/PaymentDetails.stories.js +28 -307
- package/dist/esm/stories/Bridge/PaymentDetails.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/PaymentSelection.stories.js +22 -129
- package/dist/esm/stories/Bridge/PaymentSelection.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/StepRunner.stories.js +12 -38
- package/dist/esm/stories/Bridge/StepRunner.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/SuccessScreen.stories.js +14 -102
- package/dist/esm/stories/Bridge/SuccessScreen.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/Transaction/TransactionWidget.stories.js +46 -0
- package/dist/esm/stories/Bridge/Transaction/TransactionWidget.stories.js.map +1 -0
- package/dist/esm/stories/Bridge/Transaction/useSendTransactionModal.stories.js +50 -0
- package/dist/esm/stories/Bridge/Transaction/useSendTransactionModal.stories.js.map +1 -0
- package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js +12 -80
- package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
- package/dist/esm/stories/Bridge/fixtures.js +15 -56
- package/dist/esm/stories/Bridge/fixtures.js.map +1 -1
- package/dist/esm/stories/BuyWidget.stories.js +37 -9
- package/dist/esm/stories/BuyWidget.stories.js.map +1 -1
- package/dist/esm/stories/utils.js +6 -3
- package/dist/esm/stories/utils.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/x402/common.js +3 -5
- package/dist/esm/x402/common.js.map +1 -1
- package/dist/esm/x402/facilitator.js +0 -1
- package/dist/esm/x402/facilitator.js.map +1 -1
- package/dist/esm/x402/schemas.js +5 -1
- package/dist/esm/x402/schemas.js.map +1 -1
- package/dist/esm/x402/settle-payment.js +6 -5
- package/dist/esm/x402/settle-payment.js.map +1 -1
- package/dist/esm/x402/sign.js +2 -6
- package/dist/esm/x402/sign.js.map +1 -1
- package/dist/esm/x402/types.js.map +1 -1
- package/dist/esm/x402/verify-payment.js +6 -5
- package/dist/esm/x402/verify-payment.js.map +1 -1
- package/dist/scripts/bridge-widget.d.ts +3 -3
- package/dist/scripts/bridge-widget.js +113 -150
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +6 -0
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/core/hooks/usePaymentMethods.d.ts +1 -2
- package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
- package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts +7 -12
- package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts +5 -8
- package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts +15 -12
- package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/FundWallet.d.ts +33 -15
- package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts +9 -12
- package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/StepRunner.d.ts +7 -7
- package/dist/types/react/web/ui/Bridge/StepRunner.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts +14 -7
- package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts +3 -5
- package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/UnsupportedTokenScreen.d.ts +4 -3
- package/dist/types/react/web/ui/Bridge/UnsupportedTokenScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts +3 -3
- package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/common/WithHeader.d.ts +4 -4
- package/dist/types/react/web/ui/Bridge/common/WithHeader.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/common/active-wallet-details.d.ts +8 -0
- package/dist/types/react/web/ui/Bridge/common/active-wallet-details.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/common/decimal-input.d.ts +6 -0
- package/dist/types/react/web/ui/Bridge/common/decimal-input.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/common/selected-token-button.d.ts +13 -0
- package/dist/types/react/web/ui/Bridge/common/selected-token-button.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/common/token-balance.d.ts +8 -0
- package/dist/types/react/web/ui/Bridge/common/token-balance.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/common/token-query.d.ts +15 -0
- package/dist/types/react/web/ui/Bridge/common/token-query.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts +13 -11
- package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/payment-details/PaymentOverview.d.ts +8 -3
- package/dist/types/react/web/ui/Bridge/payment-details/PaymentOverview.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts +12 -16
- package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/payment-selection/TokenSelection.d.ts +1 -1
- package/dist/types/react/web/ui/Bridge/payment-selection/TokenSelection.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts +6 -6
- package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/swap-widget/swap-ui.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/types.d.ts +39 -0
- package/dist/types/react/web/ui/Bridge/types.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts +2 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +0 -1
- package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +3 -1
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/CopyIcon.d.ts +1 -0
- package/dist/types/react/web/ui/components/CopyIcon.d.ts.map +1 -1
- package/dist/types/script-exports/bridge-widget-script.d.ts +3 -3
- package/dist/types/script-exports/bridge-widget-script.d.ts.map +1 -1
- package/dist/types/stories/Bridge/CheckoutWidget.stories.d.ts +25 -0
- package/dist/types/stories/Bridge/CheckoutWidget.stories.d.ts.map +1 -0
- package/dist/types/stories/Bridge/ErrorBanner.stories.d.ts +3 -47
- package/dist/types/stories/Bridge/ErrorBanner.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts +3 -56
- package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts +5 -63
- package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/StepRunner.stories.d.ts +4 -52
- package/dist/types/stories/Bridge/StepRunner.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts +4 -54
- package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/Transaction/TransactionWidget.stories.d.ts +11 -0
- package/dist/types/stories/Bridge/Transaction/TransactionWidget.stories.d.ts.map +1 -0
- package/dist/types/stories/Bridge/Transaction/useSendTransactionModal.stories.d.ts +18 -0
- package/dist/types/stories/Bridge/Transaction/useSendTransactionModal.stories.d.ts.map +1 -0
- package/dist/types/stories/Bridge/UnsupportedTokenScreen.stories.d.ts +3 -34
- package/dist/types/stories/Bridge/UnsupportedTokenScreen.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/fixtures.d.ts +19 -17
- package/dist/types/stories/Bridge/fixtures.d.ts.map +1 -1
- package/dist/types/stories/BuyWidget.stories.d.ts +9 -1
- package/dist/types/stories/BuyWidget.stories.d.ts.map +1 -1
- package/dist/types/stories/utils.d.ts +0 -2
- package/dist/types/stories/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/x402/common.d.ts.map +1 -1
- package/dist/types/x402/facilitator.d.ts +2 -3
- package/dist/types/x402/facilitator.d.ts.map +1 -1
- package/dist/types/x402/schemas.d.ts +21 -0
- package/dist/types/x402/schemas.d.ts.map +1 -1
- package/dist/types/x402/settle-payment.d.ts.map +1 -1
- package/dist/types/x402/types.d.ts +5 -4
- package/dist/types/x402/types.d.ts.map +1 -1
- package/dist/types/x402/verify-payment.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/react/core/hooks/transaction/useSendTransaction.ts +6 -0
- package/src/react/core/hooks/usePaymentMethods.ts +1 -4
- package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
- package/src/react/web/ui/Bridge/BuyWidget.tsx +355 -160
- package/src/react/web/ui/Bridge/CheckoutWidget.tsx +384 -107
- package/src/react/web/ui/Bridge/DirectPayment.tsx +34 -26
- package/src/react/web/ui/Bridge/FundWallet.tsx +610 -266
- package/src/react/web/ui/Bridge/QuoteLoader.tsx +10 -20
- package/src/react/web/ui/Bridge/StepRunner.tsx +7 -7
- package/src/react/web/ui/Bridge/TransactionPayment.tsx +35 -25
- package/src/react/web/ui/Bridge/TransactionWidget.tsx +395 -71
- package/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx +3 -3
- package/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx +16 -14
- package/src/react/web/ui/Bridge/common/WithHeader.tsx +13 -19
- package/src/react/web/ui/Bridge/common/active-wallet-details.tsx +103 -0
- package/src/react/web/ui/Bridge/common/decimal-input.tsx +61 -0
- package/src/react/web/ui/Bridge/common/selected-token-button.tsx +168 -0
- package/src/react/web/ui/Bridge/common/token-balance.tsx +23 -0
- package/src/react/web/ui/Bridge/common/token-query.ts +49 -0
- package/src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx +23 -14
- package/src/react/web/ui/Bridge/payment-details/PaymentOverview.tsx +36 -22
- package/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx +11 -22
- package/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx +1 -1
- package/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx +7 -8
- package/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx +14 -12
- package/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx +19 -332
- package/src/react/web/ui/Bridge/types.ts +47 -0
- package/src/react/web/ui/ConnectWallet/Details.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +1 -5
- package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +5 -1
- package/src/react/web/ui/TransactionButton/DepositScreen.tsx +1 -2
- package/src/react/web/ui/TransactionButton/TransactionModal.tsx +44 -27
- package/src/react/web/ui/components/CopyIcon.tsx +11 -2
- package/src/script-exports/bridge-widget-script.tsx +3 -3
- package/src/script-exports/readme.md +1 -8
- package/src/stories/Bridge/CheckoutWidget.stories.tsx +147 -0
- package/src/stories/Bridge/ErrorBanner.stories.tsx +13 -138
- package/src/stories/Bridge/PaymentDetails.stories.tsx +34 -349
- package/src/stories/Bridge/PaymentSelection.stories.tsx +28 -156
- package/src/stories/Bridge/StepRunner.stories.tsx +18 -65
- package/src/stories/Bridge/SuccessScreen.stories.tsx +21 -130
- package/src/stories/Bridge/Transaction/TransactionWidget.stories.tsx +63 -0
- package/src/stories/Bridge/Transaction/useSendTransactionModal.stories.tsx +68 -0
- package/src/stories/Bridge/UnsupportedTokenScreen.stories.tsx +19 -108
- package/src/stories/Bridge/fixtures.ts +36 -63
- package/src/stories/BuyWidget.stories.tsx +103 -8
- package/src/stories/utils.tsx +16 -9
- package/src/version.ts +1 -1
- package/src/x402/common.ts +2 -5
- package/src/x402/facilitator.ts +3 -3
- package/src/x402/schemas.ts +10 -0
- package/src/x402/settle-payment.ts +7 -6
- package/src/x402/sign.ts +3 -8
- package/src/x402/types.ts +5 -4
- package/src/x402/verify-payment.ts +7 -6
- package/dist/cjs/react/core/machines/paymentMachine.js +0 -191
- package/dist/cjs/react/core/machines/paymentMachine.js.map +0 -1
- package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js +0 -129
- package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +0 -1
- package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js +0 -258
- package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js.map +0 -1
- package/dist/cjs/stories/Bridge/DirectPayment.stories.js +0 -222
- package/dist/cjs/stories/Bridge/DirectPayment.stories.js.map +0 -1
- package/dist/cjs/stories/Bridge/FundWallet.stories.js +0 -201
- package/dist/cjs/stories/Bridge/FundWallet.stories.js.map +0 -1
- package/dist/cjs/stories/Bridge/TransactionPayment.stories.js +0 -168
- package/dist/cjs/stories/Bridge/TransactionPayment.stories.js.map +0 -1
- package/dist/esm/react/core/machines/paymentMachine.js +0 -188
- package/dist/esm/react/core/machines/paymentMachine.js.map +0 -1
- package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js +0 -126
- package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +0 -1
- package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js +0 -255
- package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js.map +0 -1
- package/dist/esm/stories/Bridge/DirectPayment.stories.js +0 -219
- package/dist/esm/stories/Bridge/DirectPayment.stories.js.map +0 -1
- package/dist/esm/stories/Bridge/FundWallet.stories.js +0 -198
- package/dist/esm/stories/Bridge/FundWallet.stories.js.map +0 -1
- package/dist/esm/stories/Bridge/TransactionPayment.stories.js +0 -165
- package/dist/esm/stories/Bridge/TransactionPayment.stories.js.map +0 -1
- package/dist/types/react/core/machines/paymentMachine.d.ts +0 -89
- package/dist/types/react/core/machines/paymentMachine.d.ts.map +0 -1
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts +0 -99
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +0 -1
- package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts +0 -97
- package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +0 -1
- package/dist/types/stories/Bridge/DirectPayment.stories.d.ts +0 -69
- package/dist/types/stories/Bridge/DirectPayment.stories.d.ts.map +0 -1
- package/dist/types/stories/Bridge/FundWallet.stories.d.ts +0 -67
- package/dist/types/stories/Bridge/FundWallet.stories.d.ts.map +0 -1
- package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts +0 -60
- package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts.map +0 -1
- package/src/react/core/machines/paymentMachine.test.ts +0 -519
- package/src/react/core/machines/paymentMachine.ts +0 -295
- package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +0 -425
- package/src/stories/Bridge/BridgeOrchestrator.stories.tsx +0 -298
- package/src/stories/Bridge/DirectPayment.stories.tsx +0 -256
- package/src/stories/Bridge/FundWallet.stories.tsx +0 -227
- package/src/stories/Bridge/TransactionPayment.stories.tsx +0 -202
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
5
|
import { trackPayEvent } from "../../../../analytics/track/pay.js";
|
|
5
|
-
import type {
|
|
6
|
+
import type { TokenWithPrices } from "../../../../bridge/index.js";
|
|
6
7
|
import type { Chain } from "../../../../chains/types.js";
|
|
7
8
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
|
8
9
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
|
9
|
-
import { getToken } from "../../../../pay/convert/get-token.js";
|
|
10
10
|
import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
|
|
11
11
|
import type { PurchaseData } from "../../../../pay/types.js";
|
|
12
|
-
import {
|
|
13
|
-
import { stringify } from "../../../../utils/json.js";
|
|
12
|
+
import type { Address } from "../../../../utils/address.js";
|
|
14
13
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
|
15
14
|
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
|
|
16
15
|
import type { AppMetadata } from "../../../../wallets/types.js";
|
|
@@ -19,16 +18,28 @@ import { CustomThemeProvider } from "../../../core/design-system/CustomThemeProv
|
|
|
19
18
|
import type { Theme } from "../../../core/design-system/index.js";
|
|
20
19
|
import type { SiweAuthOptions } from "../../../core/hooks/auth/useSiweAuth.js";
|
|
21
20
|
import type { ConnectButton_connectModalOptions } from "../../../core/hooks/connection/ConnectButtonProps.js";
|
|
21
|
+
import type {
|
|
22
|
+
BridgePrepareRequest,
|
|
23
|
+
BridgePrepareResult,
|
|
24
|
+
} from "../../../core/hooks/useBridgePrepare.js";
|
|
25
|
+
import type { CompletedStatusResult } from "../../../core/hooks/useStepExecutor.js";
|
|
22
26
|
import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
|
|
27
|
+
import { webWindowAdapter } from "../../adapters/WindowAdapter.js";
|
|
23
28
|
import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
|
|
29
|
+
import type { ConnectLocale } from "../ConnectWallet/locale/types.js";
|
|
24
30
|
import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
|
|
25
|
-
import { Container } from "../components/basic.js";
|
|
26
|
-
import { Button } from "../components/buttons.js";
|
|
27
31
|
import { DynamicHeight } from "../components/DynamicHeight.js";
|
|
28
32
|
import { Spinner } from "../components/Spinner.js";
|
|
29
|
-
import { Text } from "../components/text.js";
|
|
30
33
|
import type { LocaleId } from "../types.js";
|
|
31
|
-
import {
|
|
34
|
+
import { useTokenQuery } from "./common/token-query.js";
|
|
35
|
+
import { DirectPayment } from "./DirectPayment.js";
|
|
36
|
+
import { ErrorBanner } from "./ErrorBanner.js";
|
|
37
|
+
import { PaymentDetails } from "./payment-details/PaymentDetails.js";
|
|
38
|
+
import { PaymentSelection } from "./payment-selection/PaymentSelection.js";
|
|
39
|
+
import { SuccessScreen } from "./payment-success/SuccessScreen.js";
|
|
40
|
+
import { QuoteLoader } from "./QuoteLoader.js";
|
|
41
|
+
import { StepRunner } from "./StepRunner.js";
|
|
42
|
+
import type { PaymentMethod } from "./types.js";
|
|
32
43
|
import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
|
|
33
44
|
|
|
34
45
|
export type CheckoutWidgetProps = {
|
|
@@ -151,11 +162,6 @@ export type CheckoutWidgetProps = {
|
|
|
151
162
|
*/
|
|
152
163
|
feePayer?: "user" | "seller";
|
|
153
164
|
|
|
154
|
-
/**
|
|
155
|
-
* Preset fiat amounts to display in the UI. Defaults to [5, 10, 20].
|
|
156
|
-
*/
|
|
157
|
-
presetOptions?: [number, number, number];
|
|
158
|
-
|
|
159
165
|
/**
|
|
160
166
|
* Arbitrary data to be included in the returned status and webhook events.
|
|
161
167
|
*/
|
|
@@ -164,17 +170,17 @@ export type CheckoutWidgetProps = {
|
|
|
164
170
|
/**
|
|
165
171
|
* Callback triggered when the purchase is successful.
|
|
166
172
|
*/
|
|
167
|
-
onSuccess?: () => void;
|
|
173
|
+
onSuccess?: (quote: BridgePrepareResult) => void;
|
|
168
174
|
|
|
169
175
|
/**
|
|
170
176
|
* Callback triggered when the purchase encounters an error.
|
|
171
177
|
*/
|
|
172
|
-
onError?: (error: Error) => void;
|
|
178
|
+
onError?: (error: Error, quote: BridgePrepareResult | undefined) => void;
|
|
173
179
|
|
|
174
180
|
/**
|
|
175
181
|
* Callback triggered when the user cancels the purchase.
|
|
176
182
|
*/
|
|
177
|
-
onCancel?: () => void;
|
|
183
|
+
onCancel?: (quote: BridgePrepareResult | undefined) => void;
|
|
178
184
|
|
|
179
185
|
/**
|
|
180
186
|
* @hidden
|
|
@@ -204,20 +210,6 @@ export type CheckoutWidgetProps = {
|
|
|
204
210
|
buttonLabel?: string;
|
|
205
211
|
};
|
|
206
212
|
|
|
207
|
-
// Enhanced UIOptions to handle unsupported token state
|
|
208
|
-
type UIOptionsResult =
|
|
209
|
-
| { type: "success"; data: UIOptions }
|
|
210
|
-
| {
|
|
211
|
-
type: "indexing_token";
|
|
212
|
-
token: Token;
|
|
213
|
-
chain: Chain;
|
|
214
|
-
}
|
|
215
|
-
| {
|
|
216
|
-
type: "unsupported_token";
|
|
217
|
-
tokenAddress: Address;
|
|
218
|
-
chain: Chain;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
213
|
/**
|
|
222
214
|
* Widget a prebuilt UI for purchasing a specific token.
|
|
223
215
|
*
|
|
@@ -321,8 +313,24 @@ type UIOptionsResult =
|
|
|
321
313
|
* @bridge
|
|
322
314
|
*/
|
|
323
315
|
export function CheckoutWidget(props: CheckoutWidgetProps) {
|
|
324
|
-
|
|
325
|
-
|
|
316
|
+
return (
|
|
317
|
+
<CheckoutWidgetContainer
|
|
318
|
+
theme={props.theme}
|
|
319
|
+
className={props.className}
|
|
320
|
+
style={props.style}
|
|
321
|
+
>
|
|
322
|
+
<CheckoutWidgetContentWrapper {...props} />
|
|
323
|
+
</CheckoutWidgetContainer>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function CheckoutWidgetContentWrapper(props: CheckoutWidgetProps) {
|
|
328
|
+
const localQuery = useConnectLocale(props.locale || "en_US");
|
|
329
|
+
const tokenQuery = useTokenQuery({
|
|
330
|
+
tokenAddress: props.tokenAddress,
|
|
331
|
+
chainId: props.chain.id,
|
|
332
|
+
client: props.client,
|
|
333
|
+
});
|
|
326
334
|
|
|
327
335
|
useQuery({
|
|
328
336
|
queryFn: () => {
|
|
@@ -337,50 +345,22 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
|
|
|
337
345
|
queryKey: ["checkout_widget:render"],
|
|
338
346
|
});
|
|
339
347
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
props.client,
|
|
344
|
-
checksumAddress(props.tokenAddress || NATIVE_TOKEN_ADDRESS),
|
|
345
|
-
props.chain.id,
|
|
346
|
-
).catch((err) =>
|
|
347
|
-
err.message.includes("not supported") ? undefined : Promise.reject(err),
|
|
348
|
-
);
|
|
349
|
-
if (!token) {
|
|
350
|
-
return {
|
|
351
|
-
chain: props.chain,
|
|
352
|
-
tokenAddress: checksumAddress(
|
|
353
|
-
props.tokenAddress || NATIVE_TOKEN_ADDRESS,
|
|
354
|
-
),
|
|
355
|
-
type: "unsupported_token",
|
|
356
|
-
};
|
|
357
|
-
}
|
|
348
|
+
// if branding is disabled for widget, disable it for connect options too
|
|
349
|
+
const connectOptions = useMemo(() => {
|
|
350
|
+
if (props.showThirdwebBranding === false) {
|
|
358
351
|
return {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
title: props.name,
|
|
364
|
-
},
|
|
365
|
-
mode: "direct_payment",
|
|
366
|
-
currency: props.currency || "USD",
|
|
367
|
-
buttonLabel: props.buttonLabel,
|
|
368
|
-
paymentInfo: {
|
|
369
|
-
amount: props.amount,
|
|
370
|
-
feePayer: props.feePayer === "seller" ? "receiver" : "sender",
|
|
371
|
-
sellerAddress: props.seller,
|
|
372
|
-
token, // User is sender, seller is receiver
|
|
373
|
-
},
|
|
352
|
+
...props.connectOptions,
|
|
353
|
+
connectModal: {
|
|
354
|
+
...props.connectOptions?.connectModal,
|
|
355
|
+
showThirdwebBranding: false,
|
|
374
356
|
},
|
|
375
|
-
type: "success",
|
|
376
357
|
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
});
|
|
358
|
+
}
|
|
359
|
+
return props.connectOptions;
|
|
360
|
+
}, [props.connectOptions, props.showThirdwebBranding]);
|
|
380
361
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
content = (
|
|
362
|
+
if (tokenQuery.isPending || !localQuery.data) {
|
|
363
|
+
return (
|
|
384
364
|
<div
|
|
385
365
|
style={{
|
|
386
366
|
alignItems: "center",
|
|
@@ -392,65 +372,362 @@ export function CheckoutWidget(props: CheckoutWidgetProps) {
|
|
|
392
372
|
<Spinner color="secondaryText" size="xl" />
|
|
393
373
|
</div>
|
|
394
374
|
);
|
|
395
|
-
} else if (
|
|
396
|
-
|
|
397
|
-
content = (
|
|
375
|
+
} else if (tokenQuery.data?.type === "unsupported_token") {
|
|
376
|
+
return (
|
|
398
377
|
<UnsupportedTokenScreen
|
|
399
|
-
chain={
|
|
378
|
+
chain={props.chain}
|
|
400
379
|
client={props.client}
|
|
401
|
-
tokenAddress={props.tokenAddress}
|
|
380
|
+
tokenAddress={props.tokenAddress || NATIVE_TOKEN_ADDRESS}
|
|
402
381
|
/>
|
|
403
382
|
);
|
|
404
|
-
} else if (
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
383
|
+
} else if (tokenQuery.data?.type === "success") {
|
|
384
|
+
return (
|
|
385
|
+
<CheckoutWidgetContent
|
|
386
|
+
{...props}
|
|
387
|
+
connectLocale={localQuery.data}
|
|
388
|
+
destinationToken={tokenQuery.data.token}
|
|
389
|
+
currency={props.currency || "USD"}
|
|
390
|
+
paymentMethods={props.paymentMethods || ["crypto", "card"]}
|
|
391
|
+
connectOptions={connectOptions}
|
|
392
|
+
showThirdwebBranding={
|
|
393
|
+
props.showThirdwebBranding === undefined
|
|
394
|
+
? true
|
|
395
|
+
: props.showThirdwebBranding
|
|
396
|
+
}
|
|
397
|
+
/>
|
|
398
|
+
);
|
|
399
|
+
} else if (tokenQuery.error) {
|
|
400
|
+
return (
|
|
401
|
+
<ErrorBanner
|
|
409
402
|
client={props.client}
|
|
410
|
-
|
|
411
|
-
|
|
403
|
+
error={tokenQuery.error}
|
|
404
|
+
onRetry={() => {
|
|
405
|
+
tokenQuery.refetch();
|
|
406
|
+
}}
|
|
412
407
|
onCancel={() => {
|
|
413
|
-
props.onCancel?.();
|
|
408
|
+
props.onCancel?.(undefined);
|
|
414
409
|
}}
|
|
415
|
-
|
|
416
|
-
|
|
410
|
+
/>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
type CheckoutWidgetScreen =
|
|
418
|
+
| { id: "1:init-ui" }
|
|
419
|
+
| {
|
|
420
|
+
id: "2:methodSelection";
|
|
421
|
+
destinationAmount: string;
|
|
422
|
+
destinationToken: TokenWithPrices;
|
|
423
|
+
receiverAddress: Address;
|
|
424
|
+
}
|
|
425
|
+
| {
|
|
426
|
+
id: "3:load-quote";
|
|
427
|
+
destinationAmount: string;
|
|
428
|
+
destinationToken: TokenWithPrices;
|
|
429
|
+
receiverAddress: Address;
|
|
430
|
+
paymentMethod: PaymentMethod;
|
|
431
|
+
}
|
|
432
|
+
| {
|
|
433
|
+
id: "4:preview";
|
|
434
|
+
preparedQuote: BridgePrepareResult;
|
|
435
|
+
request: BridgePrepareRequest;
|
|
436
|
+
destinationAmount: string;
|
|
437
|
+
destinationToken: TokenWithPrices;
|
|
438
|
+
paymentMethod: PaymentMethod;
|
|
439
|
+
receiverAddress: Address;
|
|
440
|
+
}
|
|
441
|
+
| {
|
|
442
|
+
id: "5:execute";
|
|
443
|
+
preparedQuote: BridgePrepareResult;
|
|
444
|
+
request: BridgePrepareRequest;
|
|
445
|
+
destinationAmount: string;
|
|
446
|
+
destinationToken: TokenWithPrices;
|
|
447
|
+
paymentMethod: PaymentMethod;
|
|
448
|
+
receiverAddress: Address;
|
|
449
|
+
}
|
|
450
|
+
| {
|
|
451
|
+
id: "6:success";
|
|
452
|
+
completedStatuses: CompletedStatusResult[];
|
|
453
|
+
preparedQuote: BridgePrepareResult;
|
|
454
|
+
}
|
|
455
|
+
| {
|
|
456
|
+
id: "error";
|
|
457
|
+
error: Error;
|
|
458
|
+
preparedQuote: BridgePrepareResult | undefined;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
type RequiredParams<T extends object, keys extends keyof T> = T & {
|
|
462
|
+
[K in keys]-?: T[K];
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
function CheckoutWidgetContent(
|
|
466
|
+
props: RequiredParams<
|
|
467
|
+
CheckoutWidgetProps,
|
|
468
|
+
"currency" | "showThirdwebBranding" | "paymentMethods"
|
|
469
|
+
> & {
|
|
470
|
+
connectLocale: ConnectLocale;
|
|
471
|
+
destinationToken: TokenWithPrices;
|
|
472
|
+
},
|
|
473
|
+
) {
|
|
474
|
+
const [screen, setScreen] = useState<CheckoutWidgetScreen>({
|
|
475
|
+
id: "1:init-ui",
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
const mappedFeePayer: "receiver" | "sender" =
|
|
479
|
+
props.feePayer === "seller" ? "receiver" : "sender";
|
|
480
|
+
|
|
481
|
+
const handleError = useCallback(
|
|
482
|
+
(error: Error, quote: BridgePrepareResult | undefined) => {
|
|
483
|
+
console.error(error);
|
|
484
|
+
props.onError?.(error, quote);
|
|
485
|
+
setScreen({
|
|
486
|
+
id: "error",
|
|
487
|
+
preparedQuote: quote,
|
|
488
|
+
error,
|
|
489
|
+
});
|
|
490
|
+
},
|
|
491
|
+
[props.onError],
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
const handleCancel = useCallback(
|
|
495
|
+
(preparedQuote: BridgePrepareResult | undefined) => {
|
|
496
|
+
props.onCancel?.(preparedQuote);
|
|
497
|
+
},
|
|
498
|
+
[props.onCancel],
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
if (screen.id === "1:init-ui") {
|
|
502
|
+
return (
|
|
503
|
+
<DirectPayment
|
|
504
|
+
// from props
|
|
505
|
+
client={props.client}
|
|
506
|
+
paymentInfo={{
|
|
507
|
+
amount: props.amount,
|
|
508
|
+
feePayer: props.feePayer === "seller" ? "receiver" : "sender",
|
|
509
|
+
sellerAddress: props.seller,
|
|
510
|
+
token: props.destinationToken,
|
|
417
511
|
}}
|
|
418
|
-
|
|
419
|
-
|
|
512
|
+
showThirdwebBranding={props.showThirdwebBranding}
|
|
513
|
+
metadata={{
|
|
514
|
+
title: props.name,
|
|
515
|
+
description: props.description,
|
|
516
|
+
image: props.image,
|
|
420
517
|
}}
|
|
421
|
-
|
|
518
|
+
currency={props.currency}
|
|
519
|
+
buttonLabel={props.buttonLabel}
|
|
520
|
+
// others
|
|
521
|
+
onContinue={(destinationAmount, destinationToken, receiverAddress) => {
|
|
522
|
+
setScreen({
|
|
523
|
+
id: "2:methodSelection",
|
|
524
|
+
destinationAmount,
|
|
525
|
+
destinationToken,
|
|
526
|
+
receiverAddress,
|
|
527
|
+
});
|
|
528
|
+
}}
|
|
529
|
+
/>
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (screen.id === "2:methodSelection") {
|
|
534
|
+
return (
|
|
535
|
+
<PaymentSelection
|
|
536
|
+
// from props
|
|
537
|
+
client={props.client}
|
|
538
|
+
feePayer={mappedFeePayer}
|
|
539
|
+
connectLocale={props.connectLocale}
|
|
540
|
+
connectOptions={props.connectOptions}
|
|
422
541
|
paymentMethods={props.paymentMethods}
|
|
423
|
-
|
|
424
|
-
purchaseData={props.purchaseData}
|
|
425
|
-
receiverAddress={props.seller}
|
|
426
|
-
showThirdwebBranding={props.showThirdwebBranding}
|
|
427
|
-
uiOptions={bridgeDataQuery.data.data}
|
|
542
|
+
currency={props.currency}
|
|
428
543
|
supportedTokens={props.supportedTokens}
|
|
544
|
+
country={props.country}
|
|
545
|
+
// others
|
|
546
|
+
destinationAmount={screen.destinationAmount}
|
|
547
|
+
destinationToken={screen.destinationToken}
|
|
548
|
+
receiverAddress={screen.receiverAddress}
|
|
549
|
+
onBack={() => {
|
|
550
|
+
setScreen({ id: "1:init-ui" });
|
|
551
|
+
}}
|
|
552
|
+
onError={(error) => {
|
|
553
|
+
handleError(error, undefined);
|
|
554
|
+
}}
|
|
555
|
+
onPaymentMethodSelected={(paymentMethod) => {
|
|
556
|
+
setScreen({
|
|
557
|
+
...screen,
|
|
558
|
+
id: "3:load-quote",
|
|
559
|
+
paymentMethod,
|
|
560
|
+
});
|
|
561
|
+
}}
|
|
562
|
+
/>
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (screen.id === "3:load-quote") {
|
|
567
|
+
return (
|
|
568
|
+
<QuoteLoader
|
|
569
|
+
// from props
|
|
570
|
+
paymentLinkId={props.paymentLinkId}
|
|
571
|
+
purchaseData={props.purchaseData}
|
|
572
|
+
client={props.client}
|
|
573
|
+
feePayer={mappedFeePayer}
|
|
574
|
+
// others
|
|
575
|
+
sender={undefined}
|
|
576
|
+
mode="direct_payment"
|
|
577
|
+
amount={screen.destinationAmount}
|
|
578
|
+
destinationToken={screen.destinationToken}
|
|
579
|
+
onBack={() => {
|
|
580
|
+
setScreen({
|
|
581
|
+
...screen,
|
|
582
|
+
id: "2:methodSelection",
|
|
583
|
+
});
|
|
584
|
+
}}
|
|
585
|
+
onError={(error) => {
|
|
586
|
+
handleError(error, undefined);
|
|
587
|
+
}}
|
|
588
|
+
onQuoteReceived={(preparedQuote, request) => {
|
|
589
|
+
setScreen({
|
|
590
|
+
...screen,
|
|
591
|
+
id: "4:preview",
|
|
592
|
+
preparedQuote,
|
|
593
|
+
request,
|
|
594
|
+
});
|
|
595
|
+
}}
|
|
596
|
+
paymentMethod={screen.paymentMethod}
|
|
597
|
+
receiver={screen.receiverAddress}
|
|
598
|
+
/>
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (screen.id === "4:preview") {
|
|
603
|
+
return (
|
|
604
|
+
<PaymentDetails
|
|
605
|
+
// from props
|
|
606
|
+
client={props.client}
|
|
607
|
+
currency={props.currency}
|
|
608
|
+
metadata={{
|
|
609
|
+
title: props.name,
|
|
610
|
+
description: props.description,
|
|
611
|
+
}}
|
|
612
|
+
// others
|
|
613
|
+
confirmButtonLabel={undefined}
|
|
614
|
+
onBack={() => {
|
|
615
|
+
setScreen({
|
|
616
|
+
...screen,
|
|
617
|
+
id: "2:methodSelection",
|
|
618
|
+
});
|
|
619
|
+
}}
|
|
620
|
+
onConfirm={() => {
|
|
621
|
+
setScreen({
|
|
622
|
+
...screen,
|
|
623
|
+
id: "5:execute",
|
|
624
|
+
});
|
|
625
|
+
}}
|
|
626
|
+
onError={(error) => {
|
|
627
|
+
handleError(error, screen.preparedQuote);
|
|
628
|
+
}}
|
|
629
|
+
paymentMethod={screen.paymentMethod}
|
|
630
|
+
preparedQuote={screen.preparedQuote}
|
|
631
|
+
modeInfo={{
|
|
632
|
+
mode: "direct_payment",
|
|
633
|
+
paymentInfo: {
|
|
634
|
+
amount: screen.destinationAmount,
|
|
635
|
+
feePayer: mappedFeePayer,
|
|
636
|
+
sellerAddress: props.seller,
|
|
637
|
+
token: screen.destinationToken,
|
|
638
|
+
},
|
|
639
|
+
}}
|
|
640
|
+
/>
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (screen.id === "5:execute") {
|
|
645
|
+
return (
|
|
646
|
+
<StepRunner
|
|
647
|
+
// from props
|
|
648
|
+
client={props.client}
|
|
649
|
+
// others
|
|
650
|
+
title={undefined}
|
|
651
|
+
preparedQuote={screen.preparedQuote}
|
|
652
|
+
autoStart={true}
|
|
653
|
+
onBack={() => {
|
|
654
|
+
setScreen({
|
|
655
|
+
...screen,
|
|
656
|
+
id: "4:preview",
|
|
657
|
+
});
|
|
658
|
+
}}
|
|
659
|
+
onCancel={() => {
|
|
660
|
+
handleCancel(screen.preparedQuote);
|
|
661
|
+
}}
|
|
662
|
+
onComplete={(completedStatuses) => {
|
|
663
|
+
props.onSuccess?.(screen.preparedQuote);
|
|
664
|
+
setScreen({
|
|
665
|
+
id: "6:success",
|
|
666
|
+
preparedQuote: screen.preparedQuote,
|
|
667
|
+
completedStatuses,
|
|
668
|
+
});
|
|
669
|
+
}}
|
|
670
|
+
request={screen.request}
|
|
671
|
+
wallet={screen.paymentMethod.payerWallet}
|
|
672
|
+
windowAdapter={webWindowAdapter}
|
|
429
673
|
/>
|
|
430
674
|
);
|
|
431
675
|
}
|
|
432
676
|
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
<
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
677
|
+
if (screen.id === "6:success") {
|
|
678
|
+
return (
|
|
679
|
+
<SuccessScreen
|
|
680
|
+
// from props
|
|
681
|
+
client={props.client}
|
|
682
|
+
hasPaymentId={!!props.paymentLinkId}
|
|
683
|
+
completedStatuses={screen.completedStatuses}
|
|
684
|
+
// others
|
|
685
|
+
onDone={() => {
|
|
686
|
+
setScreen({ id: "1:init-ui" });
|
|
687
|
+
}}
|
|
688
|
+
preparedQuote={screen.preparedQuote}
|
|
689
|
+
showContinueWithTx={false}
|
|
690
|
+
windowAdapter={webWindowAdapter}
|
|
691
|
+
/>
|
|
443
692
|
);
|
|
444
693
|
}
|
|
445
694
|
|
|
695
|
+
if (screen.id === "error") {
|
|
696
|
+
return (
|
|
697
|
+
<ErrorBanner
|
|
698
|
+
client={props.client}
|
|
699
|
+
error={screen.error}
|
|
700
|
+
onCancel={() => {
|
|
701
|
+
setScreen({ id: "1:init-ui" });
|
|
702
|
+
handleCancel(screen.preparedQuote);
|
|
703
|
+
}}
|
|
704
|
+
onRetry={() => {
|
|
705
|
+
setScreen({ id: "1:init-ui" });
|
|
706
|
+
}}
|
|
707
|
+
/>
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* @internal
|
|
716
|
+
*/
|
|
717
|
+
function CheckoutWidgetContainer(props: {
|
|
718
|
+
theme: CheckoutWidgetProps["theme"];
|
|
719
|
+
className: string | undefined;
|
|
720
|
+
style?: React.CSSProperties | undefined;
|
|
721
|
+
children: React.ReactNode;
|
|
722
|
+
}) {
|
|
446
723
|
return (
|
|
447
|
-
<CustomThemeProvider theme={theme}>
|
|
724
|
+
<CustomThemeProvider theme={props.theme || "dark"}>
|
|
448
725
|
<EmbedContainer
|
|
449
726
|
className={props.className}
|
|
450
727
|
modalSize="compact"
|
|
451
728
|
style={props.style}
|
|
452
729
|
>
|
|
453
|
-
<DynamicHeight>{
|
|
730
|
+
<DynamicHeight>{props.children}</DynamicHeight>
|
|
454
731
|
</EmbedContainer>
|
|
455
732
|
</CustomThemeProvider>
|
|
456
733
|
);
|