33import { useEffect , useState } from "react" ;
44import type { Chain } from "../../../chains/types.js" ;
55import type { ThirdwebClient } from "../../../client/client.js" ;
6+ import type { Address } from "../../../utils/address.js" ;
67import type { Wallet } from "../../../wallets/interfaces/wallet.js" ;
78import type { SmartWalletOptions } from "../../../wallets/smart/types.js" ;
89import type { AppMetadata } from "../../../wallets/types.js" ;
@@ -22,11 +23,12 @@ import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js";
2223import { useConnectionManager } from "../../core/providers/connection-manager.js" ;
2324import type { SupportedTokens } from "../../core/utils/defaultTokens.js" ;
2425import { AutoConnect } from "../../web/ui/AutoConnect/AutoConnect.js" ;
25- import { webWindowAdapter } from "../adapters/WindowAdapter.js" ;
26+ import { BuyWidget } from "./Bridge/BuyWidget.js" ;
27+ import { CheckoutWidget } from "./Bridge/CheckoutWidget.js" ;
28+ import { TransactionWidget } from "./Bridge/TransactionWidget.js" ;
2629import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js" ;
2730import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js" ;
2831import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js" ;
29- import { ExecutingTxScreen } from "./TransactionButton/ExecutingScreen.js" ;
3032import { DynamicHeight } from "./components/DynamicHeight.js" ;
3133import { Spinner } from "./components/Spinner.js" ;
3234import type { LocaleId } from "./types.js" ;
@@ -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