Skip to content
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/great-pears-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@relayprotocol/relay-kit-ui': patch
---

Remove canonical logic and ui
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ const InnerDepositAddressModal: FC<InnerDepositAddressModalProps> = ({
seconds={seconds ?? 0}
onOpenChange={onOpenChange}
timeEstimate={timeEstimate?.formattedTime}
isCanonical={false}
details={details}
isLoadingTransaction={isLoadingTransaction}
requestId={requestId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ type TransactionModalProps = {
fromToken?: Token
toToken?: Token
address?: Address | string
isCanonical?: boolean
useExternalLiquidity: boolean
slippageTolerance?: string
wallet?: AdaptedWallet
linkedWallets?: LinkedWallet[]
Expand Down Expand Up @@ -59,9 +57,7 @@ export const TransactionModal: FC<TransactionModalProps> = (
address,
fromToken,
toToken,
useExternalLiquidity,
slippageTolerance,
isCanonical,
wallet,
onOpenChange,
onAnalyticEvent,
Expand Down Expand Up @@ -131,7 +127,6 @@ export const TransactionModal: FC<TransactionModalProps> = (
currency_out_address: details?.currencyOut?.currency?.address,
currency_out_decimals: toToken?.decimals,
currency_out_usd: details?.currencyOut?.amountUsd,
is_canonical: useExternalLiquidity,
quote_id: quoteId,
txHashes: steps
?.map((step) => {
Expand Down Expand Up @@ -165,7 +160,6 @@ export const TransactionModal: FC<TransactionModalProps> = (
<InnerTransactionModal
address={address}
onAnalyticEvent={onAnalyticEvent}
isCanonical={isCanonical}
{...transactionModalProps}
{...rendererProps}
/>
Expand Down Expand Up @@ -200,7 +194,6 @@ const InnerTransactionModal: FC<InnerTransactionModalProps> = ({
seconds,
onAnalyticEvent,
timeEstimate,
isCanonical,
fromChain,
toChain,
isLoadingTransaction,
Expand Down Expand Up @@ -302,7 +295,6 @@ const InnerTransactionModal: FC<InnerTransactionModalProps> = ({
seconds={seconds ?? 0}
onOpenChange={onOpenChange}
timeEstimate={timeEstimate?.formattedTime}
isCanonical={isCanonical}
details={details}
isLoadingTransaction={isLoadingTransaction}
requestId={requestId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type SwapSuccessStepProps = {
seconds: number
fillTime: string
timeEstimate?: string
isCanonical?: boolean
details?: Execute['details'] | null
isLoadingTransaction?: boolean
onOpenChange: (open: boolean) => void
Expand All @@ -59,7 +58,6 @@ export const SwapSuccessStep: FC<SwapSuccessStepProps> = ({
fillTime,
seconds,
timeEstimate,
isCanonical,
details,
isLoadingTransaction,
onOpenChange,
Expand Down Expand Up @@ -122,16 +120,11 @@ export const SwapSuccessStep: FC<SwapSuccessStepProps> = ({
// Show delayed screen when:
// 1. Bitcoin as origin: Immediately (no status check needed, tx takes 10+ mins)
// 2. Bitcoin as destination: When status reaches 'submitted'
// 3. Canonical routes: When time estimate exceeds polling timeout

const isDelayedTx =
isBitcoinOrigin ||
(isBitcoinDestination &&
(currentCheckStatus === 'submitted' ||
currentCheckStatus === 'success')) ||
(isCanonical &&
timeEstimateMs >
(relayClient?.maxPollingAttemptsBeforeTimeout ?? 30) *
(relayClient?.pollingInterval ?? 5000))
(currentCheckStatus === 'submitted' || currentCheckStatus === 'success'))

// Bitcoin transactions typically take 10+ minutes for confirmation
const estimatedMinutes =
Expand Down
76 changes: 3 additions & 73 deletions packages/ui/src/components/widgets/FeeBreakdown.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { useState, type FC } from 'react'
import { Box, Button, Flex, Pill, Text } from '../primitives/index.js'
import { Box, Button, Flex, Text } from '../primitives/index.js'
import type { ChildrenProps } from './SwapWidgetRenderer.js'
import { formatBN, formatDollar } from '../../utils/numbers.js'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faGasPump } from '@fortawesome/free-solid-svg-icons/faGasPump'
import { faChevronDown } from '@fortawesome/free-solid-svg-icons/faChevronDown'
import FetchingQuoteLoader from '../widgets/FetchingQuoteLoader.js'
import SwapRouteSelector from '../widgets/SwapRouteSelector.js'
import type { RelayChain } from '@relayprotocol/relay-sdk'
import {
CollapsibleContent,
CollapsibleRoot,
CollapsibleTrigger
} from '../primitives/Collapsible.js'
import {
faChevronRight,
faClock,
faInfoCircle
} from '@fortawesome/free-solid-svg-icons'
import { faClock, faInfoCircle } from '@fortawesome/free-solid-svg-icons'
import { PriceImpactTooltip } from './PriceImpactTooltip.js'
import { getSlippageRating, ratingToColor } from '../../utils/slippage.js'
import Tooltip from '../primitives/Tooltip.js'
Expand All @@ -31,10 +26,6 @@ type Props = Pick<
| 'toToken'
| 'fromToken'
| 'timeEstimate'
| 'supportsExternalLiquidity'
| 'useExternalLiquidity'
| 'setUseExternalLiquidity'
| 'canonicalTimeEstimate'
> & {
toChain?: RelayChain
isSingleChainLocked?: boolean
Expand All @@ -56,11 +47,7 @@ const FeeBreakdown: FC<Props> = ({
toToken,
fromToken,
toChain,
supportsExternalLiquidity,
useExternalLiquidity,
setUseExternalLiquidity,
timeEstimate,
canonicalTimeEstimate,
isSingleChainLocked,
fromChainWalletVMSupported,
isAutoSlippage,
Expand Down Expand Up @@ -176,38 +163,6 @@ const FeeBreakdown: FC<Props> = ({
}
]

if (!isSingleChainLocked && fromChainWalletVMSupported) {
breakdown.unshift({
title: 'Route',
value: (
<SwapRouteSelector
chain={toChain}
supportsExternalLiquidity={supportsExternalLiquidity}
externalLiquidtySelected={useExternalLiquidity}
onExternalLiquidityChange={(selected) => {
setUseExternalLiquidity(selected)
}}
canonicalTimeEstimate={canonicalTimeEstimate?.formattedTime}
error={error}
trigger={
<Button color="ghost" size="none">
<Flex css={{ gap: '2', alignItems: 'center' }}>
<Text style="subtitle2">
{useExternalLiquidity ? 'Native' : 'Relay'}
</Text>
{supportsExternalLiquidity || useExternalLiquidity ? (
<Box css={{ color: 'gray11', width: 14, flexShrink: 0 }}>
<FontAwesomeIcon icon={faChevronRight} width={14} />
</Box>
) : null}
</Flex>
</Button>
}
/>
)
})
}

if (!feeBreakdown) {
if (isFetchingQuote) {
return (
Expand Down Expand Up @@ -403,11 +358,6 @@ const FeeBreakdown: FC<Props> = ({
}}
>
{breakdown.map((item) => {
const showNativeBridgeWarning =
item.title === 'Estimated time' &&
useExternalLiquidity &&
timeEstimate?.time &&
timeEstimate?.time > 86400
return (
<React.Fragment key={item.title}>
<Flex
Expand All @@ -417,33 +367,13 @@ const FeeBreakdown: FC<Props> = ({
>
<Text
style="subtitle2"
color={
showNativeBridgeWarning ? 'warningSecondary' : 'subtle'
}
color={'subtle'}
css={{ alignSelf: 'flex-start' }}
>
{item.title}
</Text>
{item.value}
</Flex>
{showNativeBridgeWarning ? (
<Flex
align="center"
css={{
gap: '2',
py: '2',
px: '3',
backgroundColor: 'amber2',
borderRadius: 12
}}
>
<Text style="subtitle3" css={{ color: 'amber12' }}>
Native bridge routes are expected to take{' '}
{timeEstimate.formattedTime} but could be longer due to
unexpected delays
</Text>
</Flex>
) : null}
</React.Fragment>
)
})}
Expand Down
Loading