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

fix: Safe version/upgrade button improvements #1627

Merged
merged 8 commits into from
Feb 6, 2023
24 changes: 22 additions & 2 deletions src/components/settings/ContractVersion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { useMemo } from 'react'
import { Typography } from '@mui/material'
import { SvgIcon, Typography } from '@mui/material'
import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript-sdk'
import { LATEST_SAFE_VERSION } from '@/config/constants'
import { sameAddress } from '@/utils/addresses'
import type { MasterCopy } from '@/hooks/useMasterCopies'
import { MasterCopyDeployer, useMasterCopies } from '@/hooks/useMasterCopies'
import useSafeInfo from '@/hooks/useSafeInfo'
import CheckBoxIcon from '@mui/icons-material/CheckBox'
import InfoIcon from '@/public/images/notifications/info.svg'

import UpdateSafeDialog from './UpdateSafeDialog'
import ExternalLink from '@/components/common/ExternalLink'
import Tooltip from '@mui/material/Tooltip'

export const ContractVersion = ({ isGranted }: { isGranted: boolean }) => {
const [masterCopies] = useMasterCopies()
Expand All @@ -22,7 +25,6 @@ export const ContractVersion = ({ isGranted }: { isGranted: boolean }) => {
const needsUpdate = safe.implementationVersionState === ImplementationVersionState.OUTDATED
const latestMasterContractVersion = LATEST_SAFE_VERSION
const showUpdateDialog = safeMasterCopy?.deployer === MasterCopyDeployer.GNOSIS && needsUpdate

const getSafeVersionUpdate = () => {
return showUpdateDialog ? ` (there's a newer version: ${latestMasterContractVersion})` : ''
}
Expand All @@ -42,6 +44,24 @@ export const ContractVersion = ({ isGranted }: { isGranted: boolean }) => {
Unsupported contract
</Typography>
)}
<div style={{ marginTop: 15 }}>
{needsUpdate ? (
<Tooltip
title="Update now to take advantage of new features and the highest security standards available.
You will need to confirm this update just like any other transaction."
placement="right-start"
>
<Typography variant="body2" style={{ display: 'flex', alignItems: 'center' }}>
abheektripathy marked this conversation as resolved.
Show resolved Hide resolved
<SvgIcon component={InfoIcon} inheritViewBox fontSize="small" color="border" style={{ marginRight: 4 }} />
iamacook marked this conversation as resolved.
Show resolved Hide resolved
Why should I upgrade?
</Typography>
</Tooltip>
) : (
<Typography style={{ display: 'flex', alignItems: 'center' }}>
abheektripathy marked this conversation as resolved.
Show resolved Hide resolved
<CheckBoxIcon style={{ color: 'secondary', marginRight: 4 }} /> Latest version
abheektripathy marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
)}
</div>

{showUpdateDialog && isGranted && <UpdateSafeDialog />}
</div>
Expand Down