Skip to content

Commit

Permalink
Merge branch 'develop' into feat_regenerate_asset_data
Browse files Browse the repository at this point in the history
  • Loading branch information
NeOMakinG authored Dec 30, 2024
2 parents 36f0489 + 40fa274 commit 93c3e77
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const cardBorderRadius = { base: 'xl' }

type SharedConfirmProps = {
bodyContent: JSX.Element
footerContent: JSX.Element
footerContent: JSX.Element | null
isLoading: boolean
onBack: () => void
headerTranslation: TextPropTypes['translation']
Expand Down Expand Up @@ -40,9 +40,11 @@ export const SharedConfirm = ({
<CardBody py={0} px={0}>
{bodyContent}
</CardBody>
<CardFooter bg='background.surface.overlay.base' borderBottomRadius='xl'>
{footerContent}
</CardFooter>
{footerContent && (
<CardFooter bg='background.surface.overlay.base' borderBottomRadius='xl'>
{footerContent}
</CardFooter>
)}
</Card>
</TradeSlideTransition>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { useStepperSteps } from './hooks/useStepperSteps'

const collapseStyle = { width: '100%' }

export const ExpandableStepperSteps = () => {
type ExpandableStepperStepsProps = {
isExpanded?: boolean
}

export const ExpandableStepperSteps = (props: ExpandableStepperStepsProps) => {
const [isExpanded, setIsExpanded] = useState(false)
const confirmedTradeExecutionState = useAppSelector(selectConfirmedTradeExecutionState)
const summaryStepProps = useMemo(
Expand Down Expand Up @@ -100,7 +104,7 @@ export const ExpandableStepperSteps = () => {
stepProps={summaryStepProps}
useSpacer={false}
/>
<Collapse in={isExpanded} style={collapseStyle}>
<Collapse in={props.isExpanded ?? isExpanded} style={collapseStyle}>
<Box py={4} pl={0}>
{activeTradeQuote && <ExpandedStepperSteps activeTradeQuote={activeTradeQuote} />}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Stepper } from '@chakra-ui/react'
import { isArbitrumBridgeTradeQuoteOrRate } from '@shapeshiftoss/swapper/dist/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote'
import { useCallback, useEffect, useMemo } from 'react'
import { useHistory } from 'react-router-dom'
import { TradeRoutePaths } from 'components/MultiHopTrade/types'
import type { TextPropTypes } from 'components/Text/Text'
import { fromBaseUnit } from 'lib/math'
import {
selectActiveQuote,
selectConfirmedTradeExecutionState,
Expand All @@ -14,6 +17,8 @@ import { useAppDispatch, useAppSelector } from 'state/store'

import { useIsApprovalInitiallyNeeded } from '../MultiHopTradeConfirm/hooks/useIsApprovalInitiallyNeeded'
import { SharedConfirm } from '../SharedConfirm/SharedConfirm'
import { TradeSuccess } from '../TradeSuccess/TradeSuccess'
import { ExpandableStepperSteps } from './ExpandableStepperSteps'
import { useCurrentHopIndex } from './hooks/useCurrentHopIndex'
import { TradeConfirmBody } from './TradeConfirmBody'
import { TradeConfirmFooter } from './TradeConfirmFooter'
Expand Down Expand Up @@ -64,12 +69,44 @@ export const TradeConfirm = () => {
}, [dispatch, isLoading, activeQuote, confirmedTradeExecutionState])

const footer = useMemo(() => {
if (isTradeComplete && activeQuote && tradeQuoteLastHop) return null
if (!tradeQuoteStep || !activeTradeId) return null
return <TradeConfirmFooter tradeQuoteStep={tradeQuoteStep} activeTradeId={activeTradeId} />
}, [tradeQuoteStep, activeTradeId])
const body = useMemo(() => <TradeConfirmBody />, [])
}, [isTradeComplete, activeQuote, tradeQuoteLastHop, tradeQuoteStep, activeTradeId])

if (!headerTranslation || !footer) return null
const isArbitrumBridgeWithdraw = useMemo(() => {
return isArbitrumBridgeTradeQuoteOrRate(activeQuote) && activeQuote.direction === 'withdrawal'
}, [activeQuote])

const body = useMemo(() => {
if (isTradeComplete && activeQuote && tradeQuoteLastHop)
return (
<TradeSuccess
handleBack={handleBack}
titleTranslation={
isArbitrumBridgeWithdraw ? 'bridge.arbitrum.success.tradeSuccess' : undefined
}
sellAsset={activeQuote?.steps[0].sellAsset}
buyAsset={activeQuote?.steps[0].buyAsset}
sellAmountCryptoPrecision={fromBaseUnit(
activeQuote.steps[0].sellAmountIncludingProtocolFeesCryptoBaseUnit,
activeQuote.steps[0].sellAsset.precision,
)}
buyAmountCryptoPrecision={fromBaseUnit(
tradeQuoteLastHop.buyAmountAfterFeesCryptoBaseUnit,
tradeQuoteLastHop.buyAsset.precision,
)}
>
<Stepper index={-1} orientation='vertical' gap='0' my={6}>
<ExpandableStepperSteps isExpanded />
</Stepper>
</TradeSuccess>
)

return <TradeConfirmBody />
}, [activeQuote, handleBack, isArbitrumBridgeWithdraw, isTradeComplete, tradeQuoteLastHop])

if (!headerTranslation) return null

return (
<SharedConfirm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const TradeSuccess = ({
</Button>
<TwirlyToggle isOpen={isOpen} onToggle={handleToggle} />
</HStack>
<Box mx={-4}>
<Box>
<Collapse in={isOpen}>{children}</Collapse>
</Box>
</SlideTransition>
Expand Down
5 changes: 5 additions & 0 deletions src/context/WalletProvider/WalletConnectV2/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export const walletConnectV2ProviderConfig: EthereumProviderOptions = {
'eth_signTransaction',
],
showQrModal: true,
qrModalOptions: {
themeVariables: {
'--wcm-z-index': '2000',
},
},
rpcMap: {
[CHAIN_REFERENCE.AvalancheCChain]: REACT_APP_AVALANCHE_NODE_URL,
[CHAIN_REFERENCE.OptimismMainnet]: REACT_APP_OPTIMISM_NODE_URL,
Expand Down

0 comments on commit 93c3e77

Please sign in to comment.