Skip to content

Commit

Permalink
Fix: do not show queue warning for 1.3.0+ upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Dec 23, 2024
1 parent 4ee2c26 commit e441edc
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import type { ReactNode } from 'react'
import { Alert, AlertTitle, Box, Divider, Stack, Typography } from '@mui/material'
import semverSatisfies from 'semver/functions/satisfies'
import { LATEST_SAFE_VERSION } from '@/config/constants'
import { useCurrentChain } from '@/hooks/useChains'
import useSafeInfo from '@/hooks/useSafeInfo'
import { useQueuedTxsLength } from '@/hooks/useTxQueue'
import ExternalLink from '@/components/common/ExternalLink'
import { maybePlural } from '@/utils/formatters'

const QUEUE_WARNING_VERSION = '<1.3.0'

function BgBox({ children, light }: { children: ReactNode; light?: boolean }) {
return (
<Box
Expand All @@ -27,32 +30,34 @@ function UpdateSafe() {
const { safe } = useSafeInfo()
const chain = useCurrentChain()
const queueSize = useQueuedTxsLength()
const safeVersion = safe?.version || ''
const showQueueWarning = queueSize && semverSatisfies(safeVersion, QUEUE_WARNING_VERSION)
const latestSafeVersion = chain?.recommendedMasterCopyVersion || LATEST_SAFE_VERSION

return (
<>
<Stack direction="row" alignItems="center" spacing={2}>
<BgBox>Current version: {safe.version}</BgBox>
<BgBox>Current version: {safeVersion}</BgBox>
<Box fontSize={28}></Box>
<BgBox light>New version: {latestSafeVersion}</BgBox>
</Stack>

<Typography mb={1}>
<Typography>
Read about the updates in the new Safe contracts version in the{' '}
<ExternalLink href={`https://github.com/safe-global/safe-contracts/releases/tag/v${latestSafeVersion}`}>
version {latestSafeVersion} changelog
</ExternalLink>
</Typography>

{queueSize && (
{showQueueWarning && (
<Alert severity="warning">
<AlertTitle sx={{ fontWeight: 700 }}>This upgrade will invalidate all queued transactions!</AlertTitle>
You have {queueSize} unexecuted transaction{maybePlural(parseInt(queueSize))}. Please make sure to execute or
delete them before upgrading, otherwise you&apos;ll have to reject or replace them after the upgrade.
</Alert>
)}

<Divider sx={{ mt: 1, mx: -3 }} />
<Divider sx={{ my: 1, mx: -3 }} />
</>
)
}
Expand Down

0 comments on commit e441edc

Please sign in to comment.