Skip to content

Commit

Permalink
Fix: status widget for 1271 messages (#2415)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Aug 17, 2023
1 parent 916edcf commit 1d5838c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/components/tx-flow/common/TxLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type TxLayoutProps = {
hideNonce?: boolean
isBatch?: boolean
isReplacement?: boolean
isMessage?: boolean
}

const TxLayout = ({
Expand All @@ -70,6 +71,7 @@ const TxLayout = ({
hideNonce = false,
isBatch = false,
isReplacement = false,
isMessage = false,
}: TxLayoutProps): ReactElement => {
const [statusVisible, setStatusVisible] = useState<boolean>(true)

Expand Down Expand Up @@ -142,6 +144,7 @@ const TxLayout = ({
handleClose={() => setStatusVisible(false)}
isReplacement={isReplacement}
isBatch={isBatch}
isMessage={isMessage}
/>
)}

Expand Down
25 changes: 13 additions & 12 deletions src/components/tx-flow/common/TxStatusWidget/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useContext } from 'react'
import { Divider, IconButton, List, ListItem, ListItemIcon, ListItemText, Paper, Typography } from '@mui/material'
import CreatedIcon from '@/public/images/messages/created.svg'
import SignedIcon from '@/public/images/messages/signed.svg'
Expand All @@ -9,29 +10,22 @@ import css from './styles.module.css'
import CloseIcon from '@mui/icons-material/Close'
import useWallet from '@/hooks/wallets/useWallet'
import SafeLogo from '@/public/images/logo-no-text.svg'
import { useContext } from 'react'
import { SafeTxContext } from '@/components/tx-flow/SafeTxProvider'

const confirmedMessage = (threshold: number, confirmations: number) => {
return (
<>
Confirmed ({confirmations} of {threshold})
</>
)
}

const TxStatusWidget = ({
step,
txSummary,
handleClose,
isReplacement = false,
isBatch = false,
isMessage = false,
}: {
step: number
txSummary?: TransactionSummary
handleClose: () => void
isReplacement?: boolean
isBatch?: boolean
isMessage?: boolean
}) => {
const wallet = useWallet()
const { safe } = useSafeInfo()
Expand All @@ -49,8 +43,9 @@ const TxStatusWidget = ({
<div className={css.header}>
<Typography fontWeight="700" display="flex" alignItems="center" gap={1}>
<SafeLogo width={16} height={16} className={css.logo} />
Transaction status
{isMessage ? 'Message' : 'Transaction'} status
</Typography>

<IconButton className={css.close} aria-label="close" onClick={handleClose} size="small">
<CloseIcon />
</IconButton>
Expand All @@ -64,6 +59,7 @@ const TxStatusWidget = ({
<ListItemIcon>
<CreatedIcon />
</ListItemIcon>

<ListItemText primaryTypographyProps={{ fontWeight: 700 }}>
{isReplacement ? 'Create replacement transaction' : isBatch ? 'Queue transactions' : 'Create'}
</ListItemText>
Expand All @@ -73,14 +69,17 @@ const TxStatusWidget = ({
<ListItemIcon>
<SignedIcon />
</ListItemIcon>

<ListItemText primaryTypographyProps={{ fontWeight: 700 }}>
{isBatch ? (
'Create batch'
) : !nonceNeeded ? (
'Confirmed'
) : isMessage ? (
'Collect signatures'
) : (
<>
{confirmedMessage(threshold, confirmationsSubmitted)}
Confirmed ({confirmationsSubmitted} of {threshold})
{canSign && (
<Typography variant="body2" component="span" className={css.badge}>
+1
Expand All @@ -95,14 +94,16 @@ const TxStatusWidget = ({
<ListItemIcon>
<SignedIcon />
</ListItemIcon>
<ListItemText primaryTypographyProps={{ fontWeight: 700 }}>Execute</ListItemText>

<ListItemText primaryTypographyProps={{ fontWeight: 700 }}>{isMessage ? 'Done' : 'Execute'}</ListItemText>
</ListItem>

{isReplacement && (
<ListItem className={css.incomplete}>
<ListItemIcon>
<SignedIcon />
</ListItemIcon>

<ListItemText primaryTypographyProps={{ fontWeight: 700 }}>Transaction is replaced</ListItemText>
</ListItem>
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/tx-flow/flows/SignMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const SignMessageFlow = ({ ...props }: ProposeProps | ConfirmProps) => {
subtitle={<AppTitle name={props.name} logoUri={props.logoUri} />}
step={0}
hideNonce
isMessage
>
<SignMessage {...props} />
</TxLayout>
Expand Down

0 comments on commit 1d5838c

Please sign in to comment.