3
3
import { useEffect , useState } from "react" ;
4
4
import type { Chain } from "../../../chains/types.js" ;
5
5
import type { ThirdwebClient } from "../../../client/client.js" ;
6
+ import type { Address } from "../../../utils/address.js" ;
6
7
import type { Wallet } from "../../../wallets/interfaces/wallet.js" ;
7
8
import type { SmartWalletOptions } from "../../../wallets/smart/types.js" ;
8
9
import type { AppMetadata } from "../../../wallets/types.js" ;
@@ -22,11 +23,12 @@ import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js";
22
23
import { useConnectionManager } from "../../core/providers/connection-manager.js" ;
23
24
import type { SupportedTokens } from "../../core/utils/defaultTokens.js" ;
24
25
import { 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" ;
26
29
import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js" ;
27
30
import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js" ;
28
31
import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js" ;
29
- import { ExecutingTxScreen } from "./TransactionButton/ExecutingScreen.js" ;
30
32
import { DynamicHeight } from "./components/DynamicHeight.js" ;
31
33
import { Spinner } from "./components/Spinner.js" ;
32
34
import type { LocaleId } from "./types.js" ;
@@ -345,6 +347,55 @@ export function PayEmbed(props: PayEmbedProps) {
345
347
? props . payOptions . metadata
346
348
: null ;
347
349
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
+
348
399
if ( ! localeQuery . data ) {
349
400
content = (
350
401
< div
@@ -386,28 +437,6 @@ export function PayEmbed(props: PayEmbedProps) {
386
437
onBack = { undefined }
387
438
/>
388
439
) }
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
- ) }
411
440
</ >
412
441
) ;
413
442
}
0 commit comments