Skip to content

Commit

Permalink
fix: vernacular
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jan 8, 2025
1 parent 163b84d commit e3b14cc
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const ApprovalStep = ({
allowanceApproval.state === TransactionExecutionState.Complete
? TransactionExecutionState.AwaitingConfirmation
: allowanceApproval.state
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return permit2.state
case HopExecutionState.AwaitingSwap:
case HopExecutionState.Complete:
Expand Down Expand Up @@ -118,7 +118,7 @@ export const ApprovalStep = ({
return allowanceResetContent
case HopExecutionState.AwaitingAllowanceApproval:
return allowanceApprovalContent
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return permit2Content
case HopExecutionState.AwaitingSwap:
case HopExecutionState.Complete:
Expand Down Expand Up @@ -172,7 +172,7 @@ export const ApprovalStep = ({
return allowanceResetDescription
case HopExecutionState.AwaitingAllowanceApproval:
return allowanceApprovalDescription
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return permit2Description
case HopExecutionState.AwaitingSwap:
case HopExecutionState.Complete:
Expand Down Expand Up @@ -213,7 +213,7 @@ export const ApprovalStep = ({
allowanceReset.state === TransactionExecutionState.AwaitingConfirmation) ||
(hopExecutionState === HopExecutionState.AwaitingAllowanceApproval &&
allowanceApproval.state === TransactionExecutionState.AwaitingConfirmation) ||
(hopExecutionState === HopExecutionState.AwaitingPermit2Allowance &&
(hopExecutionState === HopExecutionState.AwaitingPermit2Eip712Sign &&
permit2.state === TransactionExecutionState.AwaitingConfirmation)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const usePermit2Content = ({
const { isLoading: isTradeQuotesLoading } = useGetTradeQuotes()

const isButtonDisabled = useMemo(() => {
const isAwaitingPermit2 = hopExecutionState === HopExecutionState.AwaitingPermit2Allowance
const isAwaitingPermit2 = hopExecutionState === HopExecutionState.AwaitingPermit2Eip712Sign
const isError = permit2.state === TransactionExecutionState.Failed
const isAwaitingConfirmation = permit2.state === TransactionExecutionState.AwaitingConfirmation
const isDisabled =
Expand All @@ -56,7 +56,7 @@ export const usePermit2Content = ({
}, [tradeQuoteStep])

const content = useMemo(() => {
if (hopExecutionState !== HopExecutionState.AwaitingPermit2Allowance) return
if (hopExecutionState !== HopExecutionState.AwaitingPermit2Eip712Sign) return
return (
<ApprovalContent
buttonTranslation='trade.permit2Eip712.signMessage'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const Hop = ({
// fallthrough
case HopExecutionState.AwaitingAllowanceApproval:
// fallthrough
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return hopIndex === 0 ? 1 : 0
case HopExecutionState.AwaitingSwap:
return hopIndex === 0 ? 2 : 1
Expand Down Expand Up @@ -226,7 +226,7 @@ export const Hop = ({
)
case HopExecutionState.AwaitingAllowanceReset:
case HopExecutionState.AwaitingAllowanceApproval:
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
case HopExecutionState.AwaitingSwap:
return (
<Circle size={8} bg='background.surface.raised.base'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP
const firstHopAllowanceApprovalTitle = useMemo(() => {
const content = (() => {
// Awaiting Permit2 contract allowance grant
if (hopExecutionState === HopExecutionState.AwaitingPermit2Allowance)
if (
firstHopPermit2.isRequired &&
hopExecutionState === HopExecutionState.AwaitingAllowanceApproval
)
return (
<>
<Text translation='trade.permit2Allowance.title' />
Expand All @@ -209,7 +212,10 @@ 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)
if (
firstHopPermit2.isRequired &&
hopExecutionState === HopExecutionState.AwaitingPermit2Eip712Sign
)
return (
<>
<Text translation='trade.permit2Eip712.title' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getHopExecutionStateButtonTranslation = (hopExecutionState: HopExec
return 'common.reset'
case HopExecutionState.AwaitingAllowanceApproval:
return 'common.approve'
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return 'trade.permit2Eip712.signMessage'
case HopExecutionState.AwaitingSwap:
return 'trade.signAndSwap'
Expand All @@ -33,7 +33,7 @@ export const getHopExecutionStateSummaryStepTranslation = (
return 'trade.awaitingAllowanceReset'
case HopExecutionState.AwaitingAllowanceApproval:
return 'trade.awaitingApproval'
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return 'trade.awaitingPermit2Approval'
case HopExecutionState.AwaitingSwap:
return ['trade.awaitingSwap', { swapperName }]
Expand Down Expand Up @@ -108,7 +108,7 @@ export const countStepperSteps = (params: StepperStepParams): number => {
const isInApprovalState = (state: HopExecutionState): boolean => {
return [
HopExecutionState.AwaitingAllowanceApproval,
HopExecutionState.AwaitingPermit2Allowance,
HopExecutionState.AwaitingPermit2Eip712Sign,
].includes(state)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const useTradeButtonProps = ({
isLoading: isAllowanceApprovalPending,
isDisabled: isAllowanceApprovalLoading,
}
case HopExecutionState.AwaitingPermit2Allowance:
case HopExecutionState.AwaitingPermit2Eip712Sign:
return {
onSubmit: signPermit2,
buttonText,
Expand Down
4 changes: 2 additions & 2 deletions src/state/slices/tradeQuoteSlice/tradeQuoteSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const tradeQuoteSlice = createSlice({
break
case permit2Required:
state.tradeExecution[tradeQuoteId].firstHop.state =
HopExecutionState.AwaitingPermit2Allowance
HopExecutionState.AwaitingPermit2Eip712Sign
break
default:
state.tradeExecution[tradeQuoteId].firstHop.state = HopExecutionState.AwaitingSwap
Expand Down Expand Up @@ -220,7 +220,7 @@ export const tradeQuoteSlice = createSlice({

const permit2Required = state.tradeExecution[id][key].permit2.isRequired
state.tradeExecution[id][key].state = permit2Required
? HopExecutionState.AwaitingPermit2Allowance
? HopExecutionState.AwaitingPermit2Eip712Sign
: HopExecutionState.AwaitingSwap
},
setSwapTxPending: (
Expand Down
2 changes: 1 addition & 1 deletion src/state/slices/tradeQuoteSlice/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export enum HopExecutionState {
Pending = 'Pending',
AwaitingAllowanceReset = 'AwaitingAllowanceReset',
AwaitingAllowanceApproval = 'AwaitingAllowanceApproval',
AwaitingPermit2Allowance = 'AwaitingPermit2Allowance',
AwaitingPermit2Eip712Sign = 'AwaitingPermit2Eip712Sign',
AwaitingSwap = 'AwaitingSwap',
Complete = 'Complete',
}
Expand Down

0 comments on commit e3b14cc

Please sign in to comment.