Skip to content

Commit

Permalink
fix: old swapper flow fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jan 8, 2025
1 parent e3b14cc commit 1fc3905
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ApprovalContentProps = {
isLoading: boolean
subHeadingTranslation?: string | [string, InterpolationOptions]
titleTranslation: string
tooltipTranslation: string
tooltipTranslation: string | [string, InterpolationOptions]
topRightContent?: JSX.Element
transactionExecutionState: TransactionExecutionState
onSubmit: () => void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { isSome } from '@shapeshiftoss/utils'
import type { InterpolationOptions } from 'node-polyglot'
import { useMemo } from 'react'
import { useGetTradeQuotes } from 'components/MultiHopTrade/hooks/useGetTradeQuotes/useGetTradeQuotes'
import { selectHopExecutionMetadata } from 'state/slices/tradeQuoteSlice/selectors'
import {
selectActiveSwapperName,
selectHopExecutionMetadata,
} from 'state/slices/tradeQuoteSlice/selectors'
import { HopExecutionState, TransactionExecutionState } from 'state/slices/tradeQuoteSlice/types'
import { useAppSelector } from 'state/store'

Expand Down Expand Up @@ -37,6 +40,8 @@ export const usePermit2Content = ({
allowanceApproval,
} = useAppSelector(state => selectHopExecutionMetadata(state, hopExecutionMetadataFilter))

const swapperName = useAppSelector(selectActiveSwapperName)

const { signPermit2 } = useSignPermit2(tradeQuoteStep, hopIndex, activeTradeId)

const { isLoading: isTradeQuotesLoading } = useGetTradeQuotes()
Expand All @@ -55,6 +60,10 @@ export const usePermit2Content = ({
return ['trade.permit2Allowance.description', { symbol: tradeQuoteStep.sellAsset.symbol }]
}, [tradeQuoteStep])

const tooltipTranslation: [string, InterpolationOptions] = useMemo(() => {
return ['trade.permit2Eip712.tooltip', { swapperName }]
}, [swapperName])

const content = useMemo(() => {
if (hopExecutionState !== HopExecutionState.AwaitingPermit2Eip712Sign) return
return (
Expand All @@ -66,8 +75,8 @@ export const usePermit2Content = ({
isTradeQuotesLoading
}
subHeadingTranslation={subHeadingTranslation}
titleTranslation='trade.permit2Allowance.title'
tooltipTranslation='trade.permit2Allowance.tooltip'
titleTranslation='trade.permit2Eip712.title'
tooltipTranslation={tooltipTranslation}
transactionExecutionState={permit2.state}
onSubmit={signPermit2}
/>
Expand All @@ -79,6 +88,7 @@ export const usePermit2Content = ({
permit2.state,
signPermit2,
subHeadingTranslation,
tooltipTranslation,
])

const description = useMemo(() => {
Expand Down

0 comments on commit 1fc3905

Please sign in to comment.