diff --git a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx index bd48748f8c2..469a29a5e30 100644 --- a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx +++ b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx @@ -24,6 +24,7 @@ import { selectActiveQuoteErrors, selectHopExecutionMetadata, } from 'state/slices/tradeQuoteSlice/selectors' +import { TransactionExecutionState } from 'state/slices/tradeQuoteSlice/types' import { useAppSelector, useSelectorWithArgs } from 'state/store' import { StepperStep as StepperStepComponent } from '../MultiHopTradeConfirm/components/StepperStep' @@ -136,6 +137,28 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP swap: lastHopSwap, } = useSelectorWithArgs(selectHopExecutionMetadata, lastHopExecutionMetadataFilter) + const transactionExecutionStateError = useMemo(() => { + return [ + firstHopAllowanceApproval.state, + lastHopAllowanceApproval.state, + firstHopPermit2.state, + lastHopPermit2.state, + firstHopSwap.state, + lastHopSwap.state, + firstHopAllowanceReset.state, + lastHopAllowanceReset.state, + ].includes(TransactionExecutionState.Failed) + }, [ + firstHopAllowanceApproval.state, + firstHopAllowanceReset.state, + firstHopPermit2.state, + firstHopSwap.state, + lastHopAllowanceApproval.state, + lastHopAllowanceReset.state, + lastHopPermit2.state, + lastHopSwap.state, + ]) + const { currentTradeStepIndex: currentStep } = useStepperSteps() const stepIndicator = useMemo( @@ -143,10 +166,12 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP ), - [activeQuoteError], + [activeQuoteError, transactionExecutionStateError], ) const firstHopAllowanceResetTitle = useMemo(() => { @@ -338,6 +363,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP ]) const { tradeSteps, currentTradeStep } = useStepperSteps() + const isError = activeQuoteError || transactionExecutionStateError return ( @@ -347,7 +373,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.FirstHopReset} + isError={isError && currentTradeStep === StepperStep.FirstHopReset} stepIndicatorVariant='innerSteps' /> ) : null} @@ -357,7 +383,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.FirstHopApproval} + isError={isError && currentTradeStep === StepperStep.FirstHopApproval} stepIndicatorVariant='innerSteps' /> ) : null} @@ -366,7 +392,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.FirstHopSwap} + isError={isError && currentTradeStep === StepperStep.FirstHopSwap} stepIndicatorVariant='innerSteps' /> {tradeSteps[StepperStep.LastHopReset] ? ( @@ -375,7 +401,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.LastHopReset} + isError={isError && currentTradeStep === StepperStep.LastHopReset} stepIndicatorVariant='innerSteps' /> ) : null} @@ -385,7 +411,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.LastHopApproval} + isError={isError && currentTradeStep === StepperStep.LastHopApproval} stepIndicatorVariant='innerSteps' /> ) : null} @@ -395,7 +421,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicator={stepIndicator} stepProps={stepProps} useSpacer={false} - isError={activeQuoteError && currentTradeStep === StepperStep.LastHopSwap} + isError={isError && currentTradeStep === StepperStep.LastHopSwap} stepIndicatorVariant='innerSteps' /> ) : null}