Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide route selector in fee breakdown in single chain mode #365

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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