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

[TX flow] Batch execute fixes #2268

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 14 additions & 10 deletions src/components/tx-flow/common/TxLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type TxLayoutProps = {
txSummary?: TransactionSummary
onBack?: () => void
hideNonce?: boolean
hideStatus?: boolean
isReplacement?: boolean
}

Expand All @@ -36,6 +37,7 @@ const TxLayout = ({
txSummary,
onBack,
hideNonce = false,
hideStatus = false,
isReplacement = false,
}: TxLayoutProps): ReactElement => {
const [statusVisible, setStatusVisible] = useState<boolean>(true)
Expand All @@ -61,21 +63,23 @@ const TxLayout = ({
<Container className={css.container}>
<Grid container alignItems="center" justifyContent="center">
<Grid item container xs={12}>
<Grid item xs={12} md={7} className={css.titleWrapper}>
<Grid item xs={12} md={7} className={classnames(css.titleWrapper, { [css.noStatus]: hideStatus })}>
<Typography variant="h3" component="div" fontWeight="700" className={css.title}>
{title}
</Typography>

<ChainIndicator inline />
</Grid>
<IconButton
className={css.statusButton}
aria-label="Transaction status"
size="large"
onClick={toggleStatus}
>
<SafeLogo width={16} height={16} />
</IconButton>
{!hideStatus && (
<IconButton
className={css.statusButton}
aria-label="Transaction status"
size="large"
onClick={toggleStatus}
>
<SafeLogo width={16} height={16} />
</IconButton>
)}
</Grid>

<Grid item container xs={12} gap={3}>
Expand Down Expand Up @@ -116,7 +120,7 @@ const TxLayout = ({
</Grid>

<Grid item xs={12} md={4} className={classnames(css.widget, { [css.active]: statusVisible })}>
{statusVisible && (
{statusVisible && !hideStatus && (
<TxStatusWidget
step={step}
txSummary={txSummary}
Expand Down
4 changes: 4 additions & 0 deletions src/components/tx-flow/common/TxLayout/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
width: calc(100% - 154px);
}

.noStatus {
width: calc(100% - 100px);
}

.title {
font-size: 16px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tx-flow/flows/ExecuteBatch/DecodedTxs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const DecodedTxs = ({ txs }: { txs: TransactionDetails[] | undefined }) => {
operation: 0,
}}
txData={transaction.txData}
actionTitle={`Action ${idx + 1}`}
actionTitle={`${idx + 1}`}
showDelegateCallWarning={false}
/>
)
Expand Down
11 changes: 7 additions & 4 deletions src/components/tx-flow/flows/ExecuteBatch/ReviewBatch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Typography, Button, CardActions, Divider } from '@mui/material'
import { Typography, Button, CardActions, Divider, Alert } from '@mui/material'
import { encodeMultiSendData } from '@safe-global/safe-core-sdk/dist/src/utils/transactions/utils'
import { useState, useMemo } from 'react'
import { useState, useMemo, useContext } from 'react'
import type { SyntheticEvent } from 'react'
import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'

Expand Down Expand Up @@ -28,6 +28,7 @@ import { asError } from '@/services/exceptions/utils'
import SendToBlock from '@/components/tx-flow/flows/TokenTransfer/SendToBlock'
import ConfirmationTitle, { ConfirmationTitleTypes } from '@/components/tx/SignOrExecuteForm/ConfirmationTitle'
import commonCss from '@/components/tx-flow/common/styles.module.css'
import { TxModalContext } from '@/components/tx-flow'

export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {
const [isSubmittable, setIsSubmittable] = useState<boolean>(true)
Expand All @@ -36,6 +37,7 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {
const chain = useCurrentChain()
const { safe } = useSafeInfo()
const [relays] = useRelaysBySafe()
const { setTxFlow } = useContext(TxModalContext)

// Chain has relaying feature and available relays
const canRelay = hasRemainingRelays(relays)
Expand Down Expand Up @@ -95,6 +97,7 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {

try {
await (willRelay ? onRelay() : onExecute())
setTxFlow(undefined)
} catch (_err) {
const err = asError(_err)
logError(Errors._804, err)
Expand Down Expand Up @@ -159,10 +162,10 @@ export const ReviewBatch = ({ params }: { params: ExecuteBatchFlowProps }) => {
</>
) : null}

<Typography>
<Alert severity="warning">
Be aware that if any of the included transactions revert, none of them will be executed. This will result in
the loss of the allocated transaction fees.
</Typography>
</Alert>

{error && (
<ErrorMessage error={error}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/tx-flow/flows/ExecuteBatch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ExecuteBatchFlowProps = {

const ExecuteBatchFlow = (props: ExecuteBatchFlowProps) => {
return (
<TxLayout title="Confirm transaction" subtitle="Execute batch" icon={BatchIcon} hideNonce>
<TxLayout title="Confirm transaction" subtitle="Execute batch" icon={BatchIcon} hideNonce hideStatus>
<ReviewBatch params={props} />
</TxLayout>
)
Expand Down
Loading