11"use client" ;
22
3- import { useCallback , useEffect , useRef , useState } from "react" ;
3+ import { useEffect , useRef , useState } from "react" ;
44import { trackPayEvent } from "../../../../../analytics/track/pay.js" ;
55import type { Buy , Sell } from "../../../../../bridge/index.js" ;
66import type { TokenWithPrices } from "../../../../../bridge/types/Token.js" ;
@@ -16,7 +16,6 @@ import { webWindowAdapter } from "../../../adapters/WindowAdapter.js";
1616import { EmbedContainer } from "../../ConnectWallet/Modal/ConnectEmbed.js" ;
1717import { DynamicHeight } from "../../components/DynamicHeight.js" ;
1818import { ErrorBanner } from "../ErrorBanner.js" ;
19- import { PaymentDetails } from "../payment-details/PaymentDetails.js" ;
2019import { SuccessScreen } from "../payment-success/SuccessScreen.js" ;
2120import { StepRunner } from "../StepRunner.js" ;
2221import { useActiveWalletInfo } from "./hooks.js" ;
@@ -364,19 +363,6 @@ function SwapWidgetContent(
364363 // preload requests
365364 useBridgeChains ( props . client ) ;
366365
367- const handleError = useCallback (
368- ( error : Error , quote : SwapPreparedQuote ) => {
369- console . error ( error ) ;
370- props . onError ?.( error , quote ) ;
371- setScreen ( {
372- id : "error" ,
373- preparedQuote : quote ,
374- error,
375- } ) ;
376- } ,
377- [ props . onError ] ,
378- ) ;
379-
380366 // if wallet suddenly disconnects, show screen 1
381367 if ( screen . id === "1:swap-ui" || ! activeWalletInfo ) {
382368 return (
@@ -399,19 +385,8 @@ function SwapWidgetContent(
399385 amountSelection = { amountSelection }
400386 setAmountSelection = { setAmountSelection }
401387 onSwap = { ( data ) => {
402- trackPayEvent ( {
403- chainId : data . result . intent . originChainId ,
404- client : props . client ,
405- event : "payment_details" ,
406- fromToken : data . result . intent . originTokenAddress ,
407- toChainId : data . result . intent . destinationChainId ,
408- toToken : data . result . intent . destinationTokenAddress ,
409- walletAddress :
410- activeWalletInfo ?. activeWallet ?. getAccount ( ) ?. address ,
411- walletType : activeWalletInfo ?. activeWallet ?. id ,
412- } ) ;
413388 setScreen ( {
414- id : "2:preview " ,
389+ id : "3:execute " ,
415390 buyToken : data . buyToken ,
416391 sellToken : data . sellToken ,
417392 sellTokenBalance : data . sellTokenBalance ,
@@ -425,43 +400,6 @@ function SwapWidgetContent(
425400 ) ;
426401 }
427402
428- if ( screen . id === "2:preview" ) {
429- return (
430- < PaymentDetails
431- metadata = { {
432- title : "Review Swap" ,
433- description : undefined ,
434- } }
435- confirmButtonLabel = "Swap"
436- client = { props . client }
437- onBack = { ( ) => {
438- setScreen ( { id : "1:swap-ui" } ) ;
439- } }
440- onConfirm = { ( ) => {
441- setScreen ( {
442- ...screen ,
443- id : "3:execute" ,
444- } ) ;
445- } }
446- onError = { ( error ) => handleError ( error , screen . preparedQuote ) }
447- paymentMethod = { {
448- quote : screen . quote ,
449- type : "wallet" ,
450- payerWallet : activeWalletInfo . activeWallet ,
451- balance : screen . sellTokenBalance ,
452- originToken : screen . sellToken ,
453- action : screen . mode ,
454- hasEnoughBalance : true ,
455- } }
456- preparedQuote = { screen . preparedQuote }
457- currency = { props . currency }
458- modeInfo = { {
459- mode : "fund_wallet" ,
460- } }
461- />
462- ) ;
463- }
464-
465403 if ( screen . id === "3:execute" ) {
466404 return (
467405 < StepRunner
@@ -472,8 +410,7 @@ function SwapWidgetContent(
472410 onBack = { ( ) => {
473411 setScreen ( {
474412 ...screen ,
475- id : "2:preview" ,
476- sellTokenBalance : screen . sellTokenBalance ,
413+ id : "1:swap-ui" ,
477414 } ) ;
478415 } }
479416 onCancel = { ( ) => props . onCancel ?.( screen . preparedQuote ) }
0 commit comments