Skip to content

Commit

Permalink
Merge pull request #365 from reservoirprotocol/ted/relay-6298-remove-…
Browse files Browse the repository at this point in the history
…route-selector-from-single-chain-mode

Hide route selector in fee breakdown in single chain mode
  • Loading branch information
ted-palmer authored Nov 11, 2024
2 parents feb73b0 + fa63f61 commit eb43db2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-buckets-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Hide route selector in fee breakdown in single chain mode
28 changes: 17 additions & 11 deletions packages/ui/src/components/widgets/FeeBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = Pick<
| 'canonicalTimeEstimate'
> & {
toChain?: RelayChain
isSingleChainLocked?: boolean
}

const formatSwapRate = (rate: number) => {
Expand All @@ -40,7 +41,8 @@ const FeeBreakdown: FC<Props> = ({
useExternalLiquidity,
setUseExternalLiquidity,
timeEstimate,
canonicalTimeEstimate
canonicalTimeEstimate,
isSingleChainLocked
}) => {
const swapRate = price?.details?.rate
const originGasFee = feeBreakdown?.breakdown?.find(
Expand Down Expand Up @@ -86,16 +88,20 @@ const FeeBreakdown: FC<Props> = ({
mb: '6px'
}}
>
<SwapRouteSelector
chain={toChain}
supportsExternalLiquidity={supportsExternalLiquidity}
externalLiquidtySelected={useExternalLiquidity}
onExternalLiquidityChange={(selected) => {
setUseExternalLiquidity(selected)
}}
canonicalTimeEstimate={canonicalTimeEstimate?.formattedTime}
/>
<Box css={{ height: 1, background: 'gray5', width: '100%' }} />
{!isSingleChainLocked ? (
<>
<SwapRouteSelector
chain={toChain}
supportsExternalLiquidity={supportsExternalLiquidity}
externalLiquidtySelected={useExternalLiquidity}
onExternalLiquidityChange={(selected) => {
setUseExternalLiquidity(selected)
}}
canonicalTimeEstimate={canonicalTimeEstimate?.formattedTime}
/>
<Box css={{ height: 1, background: 'gray5', width: '100%' }} />
</>
) : null}
<Flex
justify="between"
css={{
Expand Down
13 changes: 7 additions & 6 deletions packages/ui/src/components/widgets/SwapWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isSingleChainLocked
? [lockChainId]
: fromToken?.chainId !== undefined &&
fromToken?.chainId === lockChainId
? [fromToken?.chainId]
: undefined
fromToken?.chainId === lockChainId
? [fromToken?.chainId]
: undefined
}
restrictedTokensList={tokens?.filter(
(token) => token.chainId === fromToken?.chainId
Expand Down Expand Up @@ -765,9 +765,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isSingleChainLocked
? [lockChainId]
: toToken?.chainId !== undefined &&
toToken?.chainId === lockChainId
? [toToken?.chainId]
: undefined
toToken?.chainId === lockChainId
? [toToken?.chainId]
: undefined
}
restrictedTokensList={tokens?.filter(
(token) => token.chainId === toToken?.chainId
Expand Down Expand Up @@ -883,6 +883,7 @@ const SwapWidget: FC<SwapWidgetProps> = ({
})
}}
canonicalTimeEstimate={canonicalTimeEstimate}
isSingleChainLocked={isSingleChainLocked}
/>
<WidgetErrorWell
hasInsufficientBalance={hasInsufficientBalance}
Expand Down

0 comments on commit eb43db2

Please sign in to comment.