11"use client" ;
22
33import { useQuery } from "@tanstack/react-query" ;
4- import { useEffect , useState } from "react" ;
4+ import { } from "react" ;
55import type { Token } from "../../../bridge/index.js" ;
66import type { Chain } from "../../../chains/types.js" ;
77import type { ThirdwebClient } from "../../../client/client.js" ;
@@ -14,28 +14,19 @@ import type { AppMetadata } from "../../../wallets/types.js";
1414import type { WalletId } from "../../../wallets/wallet-types.js" ;
1515import { CustomThemeProvider } from "../../core/design-system/CustomThemeProvider.js" ;
1616import type { Theme } from "../../core/design-system/index.js" ;
17- import {
18- type SiweAuthOptions ,
19- useSiweAuth ,
20- } from "../../core/hooks/auth/useSiweAuth.js" ;
17+ import type { SiweAuthOptions } from "../../core/hooks/auth/useSiweAuth.js" ;
2118import type {
2219 ConnectButton_connectModalOptions ,
2320 PayUIOptions ,
2421} from "../../core/hooks/connection/ConnectButtonProps.js" ;
25- import { useActiveAccount } from "../../core/hooks/wallets/useActiveAccount.js" ;
26- import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js" ;
27- import { useConnectionManager } from "../../core/providers/connection-manager.js" ;
2822import type { SupportedTokens } from "../../core/utils/defaultTokens.js" ;
29- import { AutoConnect } from "../../web/ui/AutoConnect/AutoConnect.js" ;
3023import {
3124 BridgeOrchestrator ,
3225 type UIOptions ,
3326} from "./Bridge/BridgeOrchestrator.js" ;
3427import { UnsupportedTokenScreen } from "./Bridge/UnsupportedTokenScreen.js" ;
3528import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js" ;
3629import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js" ;
37- import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js" ;
38- import { ExecutingTxScreen } from "./TransactionButton/ExecutingScreen.js" ;
3930import { DynamicHeight } from "./components/DynamicHeight.js" ;
4031import { Spinner } from "./components/Spinner.js" ;
4132import type { LocaleId } from "./types.js" ;
@@ -493,123 +484,6 @@ export function PayEmbed(props: PayEmbedProps) {
493484 ) ;
494485}
495486
496- export function LegacyPayEmbed ( props : PayEmbedProps ) {
497- const localeQuery = useConnectLocale ( props . locale || "en_US" ) ;
498- const [ screen , setScreen ] = useState < "buy" | "execute-tx" > ( "buy" ) ;
499- const theme = props . theme || "dark" ;
500- const connectionManager = useConnectionManager ( ) ;
501- const activeAccount = useActiveAccount ( ) ;
502- const activeWallet = useActiveWallet ( ) ;
503- const siweAuth = useSiweAuth (
504- activeWallet ,
505- activeAccount ,
506- props . connectOptions ?. auth ,
507- ) ;
508-
509- // Add props.chain and props.chains to defined chains store
510- useEffect ( ( ) => {
511- if ( props . connectOptions ?. chain ) {
512- connectionManager . defineChains ( [ props . connectOptions ?. chain ] ) ;
513- }
514- } , [ props . connectOptions ?. chain , connectionManager ] ) ;
515-
516- useEffect ( ( ) => {
517- if ( props . connectOptions ?. chains ) {
518- connectionManager . defineChains ( props . connectOptions ?. chains ) ;
519- }
520- } , [ props . connectOptions ?. chains , connectionManager ] ) ;
521-
522- useEffect ( ( ) => {
523- if ( props . activeWallet ) {
524- connectionManager . setActiveWallet ( props . activeWallet ) ;
525- }
526- } , [ props . activeWallet , connectionManager ] ) ;
527-
528- let content = null ;
529- const metadata =
530- props . payOptions && "metadata" in props . payOptions
531- ? props . payOptions . metadata
532- : null ;
533-
534- if ( ! localeQuery . data ) {
535- content = (
536- < div
537- style = { {
538- minHeight : "350px" ,
539- display : "flex" ,
540- justifyContent : "center" ,
541- alignItems : "center" ,
542- } }
543- >
544- < Spinner size = "xl" color = "secondaryText" />
545- </ div >
546- ) ;
547- } else {
548- content = (
549- < >
550- < AutoConnect client = { props . client } siweAuth = { siweAuth } />
551- { screen === "buy" && (
552- < BuyScreen
553- title = { metadata ?. name || "Buy" }
554- isEmbed = { true }
555- supportedTokens = { props . supportedTokens }
556- theme = { theme }
557- client = { props . client }
558- connectLocale = { localeQuery . data }
559- hiddenWallets = { props . hiddenWallets }
560- paymentLinkId = { props . paymentLinkId }
561- payOptions = {
562- props . payOptions || {
563- mode : "fund_wallet" ,
564- }
565- }
566- onDone = { ( ) => {
567- if ( props . payOptions ?. mode === "transaction" ) {
568- setScreen ( "execute-tx" ) ;
569- }
570- } }
571- connectOptions = { props . connectOptions }
572- onBack = { undefined }
573- />
574- ) }
575-
576- { screen === "execute-tx" &&
577- props . payOptions ?. mode === "transaction" &&
578- props . payOptions . transaction && (
579- < ExecutingTxScreen
580- tx = { props . payOptions . transaction }
581- closeModal = { ( ) => {
582- setScreen ( "buy" ) ;
583- } }
584- onBack = { ( ) => {
585- setScreen ( "buy" ) ;
586- } }
587- onTxSent = { ( data ) => {
588- props . payOptions ?. onPurchaseSuccess ?.( {
589- type : "transaction" ,
590- chainId : data . chain . id ,
591- transactionHash : data . transactionHash ,
592- } ) ;
593- } }
594- />
595- ) }
596- </ >
597- ) ;
598- }
599-
600- return (
601- < CustomThemeProvider theme = { theme } >
602- < EmbedContainer
603- modalSize = "compact"
604- style = { props . style }
605- className = { props . className }
606- >
607- < DynamicHeight > { content } </ DynamicHeight >
608- </ EmbedContainer >
609- </ CustomThemeProvider >
610- ) ;
611- }
612-
613487/**
614488 * Connection options for the `PayEmbed` component
615489 *
0 commit comments