diff --git a/wormhole-connect/src/views/v2/Bridge/Routes/SingleRoute.tsx b/wormhole-connect/src/views/v2/Bridge/Routes/SingleRoute.tsx index 0e837568d..c52b7df31 100644 --- a/wormhole-connect/src/views/v2/Bridge/Routes/SingleRoute.tsx +++ b/wormhole-connect/src/views/v2/Bridge/Routes/SingleRoute.tsx @@ -10,7 +10,7 @@ import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import WarningIcon from '@mui/icons-material/Report'; import { makeStyles } from 'tss-react/mui'; -import { amount, routes } from '@wormhole-foundation/sdk'; +import { amount, routes, Chain } from '@wormhole-foundation/sdk'; import config from 'config'; import TokenIcon from 'icons/TokenIcons'; @@ -262,26 +262,36 @@ const SingleRoute = (props: Props) => { ); } + // Scan for any warnings that might indicate a risk of transfer delay + const maxDelay = + quote?.warnings?.reduce((max, warning) => { + if ( + warning.type === 'DestinationCapacityWarning' && + warning.delayDurationSec + ) { + return Math.max(max, warning.delayDurationSec); + } else if (warning.type === 'GovernorLimitWarning') { + return Math.max(max, 24 * 60 * 60); + } else { + return max; + } + }, 0) || 0; + + if (maxDelay > 0) { + messages.push( + , + ); + } + for (const warning of quote?.warnings || []) { if ( warning.type === 'DestinationCapacityWarning' && warning.delayDurationSec ) { - const symbol = config.tokens[destToken].symbol; - const duration = formatDuration(warning.delayDurationSec); - messages.push( -
- - - - - - {`Your transfer to ${destChain} may be delayed due to rate limits set by ${symbol}. If your transfer is delayed, you will need to return after ${duration} to complete the transfer. Please consider this before proceeding.`} - - - -
, - ); } } @@ -459,4 +469,31 @@ const SingleRoute = (props: Props) => { ); }; +const TransferDelayWarning = (props: { + token: string; + chain?: Chain; + duration: number; +}) => { + const theme = useTheme(); + const duration = formatDuration(props.duration); + + return ( +
+ + + + + + {`Your transfer ${ + props.chain ? `to ${props.chain} ` : '' + }may be delayed due to rate limits set by ${ + props.token + }. If your transfer is delayed, you will need to return after ${duration} to complete the transfer. Please consider this before proceeding.`} + + + +
+ ); +}; + export default SingleRoute;