@@ -22,14 +22,16 @@ import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js";
2222import { useConnectionManager } from "../../core/providers/connection-manager.js" ;
2323import type { SupportedTokens } from "../../core/utils/defaultTokens.js" ;
2424import { AutoConnect } from "../../web/ui/AutoConnect/AutoConnect.js" ;
25- import { webWindowAdapter } from "../adapters/WindowAdapter.js" ;
2625import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js" ;
2726import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js" ;
2827import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js" ;
29- import { ExecutingTxScreen } from "./TransactionButton/ExecutingScreen.js" ;
3028import { DynamicHeight } from "./components/DynamicHeight.js" ;
3129import { Spinner } from "./components/Spinner.js" ;
3230import type { LocaleId } from "./types.js" ;
31+ import { BuyWidget } from "./Bridge/BuyWidget.js" ;
32+ import type { Address } from "../../../utils/address.js" ;
33+ import { CheckoutWidget } from "./Bridge/CheckoutWidget.js" ;
34+ import { TransactionWidget } from "./Bridge/TransactionWidget.js" ;
3335
3436/**
3537 * Props of [`PayEmbed`](https://portal.thirdweb.com/references/typescript/v5/PayEmbed) component
@@ -345,6 +347,55 @@ export function PayEmbed(props: PayEmbedProps) {
345347 ? props . payOptions . metadata
346348 : null ;
347349
350+ if (
351+ props . payOptions ?. mode === "fund_wallet" &&
352+ props . payOptions ?. prefillBuy
353+ ) {
354+ return (
355+ < BuyWidget
356+ title = { metadata ?. name || "Buy" }
357+ chain = { props . payOptions . prefillBuy . chain }
358+ amount = { props . payOptions . prefillBuy . amount || "0.01" }
359+ tokenAddress = {
360+ props . payOptions . prefillBuy . token ?. address as Address | undefined
361+ }
362+ client = { props . client }
363+ theme = { theme }
364+ />
365+ ) ;
366+ }
367+
368+ if ( props . payOptions ?. mode === "direct_payment" ) {
369+ return (
370+ < CheckoutWidget
371+ name = { metadata ?. name || "Checkout" }
372+ description = { metadata ?. description }
373+ image = { metadata ?. image }
374+ chain = { props . payOptions . paymentInfo . chain }
375+ tokenAddress = {
376+ props . payOptions . paymentInfo . token ?. address as Address | undefined
377+ }
378+ amount = { ( props . payOptions . paymentInfo as { amount : string } ) . amount }
379+ seller = { props . payOptions . paymentInfo . sellerAddress as Address }
380+ client = { props . client }
381+ theme = { theme }
382+ />
383+ ) ;
384+ }
385+
386+ if ( props . payOptions ?. mode === "transaction" ) {
387+ return (
388+ < TransactionWidget
389+ title = { metadata ?. name }
390+ description = { metadata ?. description }
391+ image = { metadata ?. image }
392+ transaction = { props . payOptions . transaction }
393+ client = { props . client }
394+ theme = { theme }
395+ />
396+ ) ;
397+ }
398+
348399 if ( ! localeQuery . data ) {
349400 content = (
350401 < div
@@ -386,28 +437,6 @@ export function PayEmbed(props: PayEmbedProps) {
386437 onBack = { undefined }
387438 />
388439 ) }
389-
390- { screen === "execute-tx" &&
391- props . payOptions ?. mode === "transaction" &&
392- props . payOptions . transaction && (
393- < ExecutingTxScreen
394- tx = { props . payOptions . transaction }
395- closeModal = { ( ) => {
396- setScreen ( "buy" ) ;
397- } }
398- onBack = { ( ) => {
399- setScreen ( "buy" ) ;
400- } }
401- onTxSent = { ( data ) => {
402- props . payOptions ?. onPurchaseSuccess ?.( {
403- type : "transaction" ,
404- chainId : data . chain . id ,
405- transactionHash : data . transactionHash ,
406- } ) ;
407- } }
408- windowAdapter = { webWindowAdapter }
409- />
410- ) }
411440 </ >
412441 ) ;
413442 }
0 commit comments