From 8e62d29627b8e45ead8e3be5be45e38fc7c9b78f Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Wed, 8 Jan 2025 23:05:26 +0400 Subject: [PATCH 1/2] feat: actually make permit2 allowance/sign distinct steps --- .../TradeConfirm/ExpandedStepperSteps.tsx | 39 +++++++++++-------- .../components/TradeConfirm/helpers.ts | 16 ++++---- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx index 4bcb8249f47..feb6d2154c4 100644 --- a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx +++ b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx @@ -211,21 +211,6 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP ) - // Allowance granted, but still waiting for the actual Permit2 signature granting temp 5mn allowance to the contract - if ( - firstHopPermit2.isRequired && - hopExecutionState === HopExecutionState.AwaitingPermit2Eip712Sign - ) - return ( - <> - - - - - - - - ) // Good ol' allowances return ( @@ -252,11 +237,23 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP firstHopPermit2.isRequired, firstHopSellAccountId, hopExecutionState, - swapperName, tradeQuoteFirstHop, translate, ]) + const firstHopPermit2SignTitle = useMemo(() => { + return ( + + + + + + + + + ) + }, [swapperName, translate]) + const firstHopActionTitle = useMemo(() => { return ( @@ -455,6 +452,16 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP stepIndicatorVariant='innerSteps' /> ) : null} + {tradeSteps[StepperStep.FirstHopPermit2Sign] ? ( + + ) : null} { } const isInApprovalState = (state: HopExecutionState): boolean => { - return [ - HopExecutionState.AwaitingAllowanceApproval, - HopExecutionState.AwaitingPermit2Eip712Sign, - ].includes(state) + return [HopExecutionState.AwaitingAllowanceApproval].includes(state) +} + +const isInPermit2SignState = (state: HopExecutionState): boolean => { + return [HopExecutionState.AwaitingPermit2Eip712Sign].includes(state) } export const getCurrentStepperStep = ( @@ -123,6 +124,7 @@ export const getCurrentStepperStep = ( if (hopExecutionState === HopExecutionState.AwaitingAllowanceReset) return StepperStep.FirstHopReset if (isInApprovalState(hopExecutionState)) return StepperStep.FirstHopApproval + if (isInPermit2SignState(hopExecutionState)) return StepperStep.FirstHopPermit2Sign if (hopExecutionState === HopExecutionState.AwaitingSwap) return StepperStep.FirstHopSwap } else if (currentHopIndex === 1) { if (hopExecutionState === HopExecutionState.AwaitingAllowanceReset) From 8cd9ab3967e381ececec7bd9c22917a6d5a0594a Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Thu, 9 Jan 2025 01:17:24 +0400 Subject: [PATCH 2/2] feat: stylistic --- .../MultiHopTrade/components/TradeConfirm/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeConfirm/helpers.ts b/src/components/MultiHopTrade/components/TradeConfirm/helpers.ts index 67be52fa277..d35e55205b8 100644 --- a/src/components/MultiHopTrade/components/TradeConfirm/helpers.ts +++ b/src/components/MultiHopTrade/components/TradeConfirm/helpers.ts @@ -106,11 +106,11 @@ export const countStepperSteps = (params: StepperStepParams): number => { } const isInApprovalState = (state: HopExecutionState): boolean => { - return [HopExecutionState.AwaitingAllowanceApproval].includes(state) + return state === HopExecutionState.AwaitingAllowanceApproval } const isInPermit2SignState = (state: HopExecutionState): boolean => { - return [HopExecutionState.AwaitingPermit2Eip712Sign].includes(state) + return state === HopExecutionState.AwaitingPermit2Eip712Sign } export const getCurrentStepperStep = (