submit replacement transaction to cancel existing one
This commit is contained in:
parent
9801e68343
commit
fd74fd3b9a
|
@ -7,7 +7,7 @@ import styles from './index.scss'
|
||||||
const cx = cn.bind(styles)
|
const cx = cn.bind(styles)
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
type: 'button' | 'submit' | 'reset',
|
type?: 'button' | 'submit' | 'reset',
|
||||||
size?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl',
|
size?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl',
|
||||||
weight?: 'light' | 'regular' | 'bolder' | 'bold',
|
weight?: 'light' | 'regular' | 'bolder' | 'bold',
|
||||||
color?: 'soft' | 'medium' | 'dark' | 'white' | 'fancy' | 'primary' | 'secondary' | 'warning' | 'disabled' | 'error',
|
color?: 'soft' | 'medium' | 'dark' | 'white' | 'fancy' | 'primary' | 'secondary' | 'warning' | 'disabled' | 'error',
|
||||||
|
|
|
@ -168,6 +168,7 @@ class Layout extends React.Component<Props, State> {
|
||||||
safeAddress={address}
|
safeAddress={address}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
|
createTransaction={createTransaction}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{tabIndex === 2 && (
|
{tabIndex === 2 && (
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React from 'react'
|
||||||
import Close from '@material-ui/icons/Close'
|
import Close from '@material-ui/icons/Close'
|
||||||
import IconButton from '@material-ui/core/IconButton'
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
|
import { SharedSnackbarConsumer } from '~/components/SharedSnackBar'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
import Hairline from '~/components/layout/Hairline'
|
import Hairline from '~/components/layout/Hairline'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
|
@ -11,6 +12,7 @@ import Bold from '~/components/layout/Bold'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||||
|
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||||
import { styles } from './style'
|
import { styles } from './style'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -19,11 +21,20 @@ type Props = {
|
||||||
isOpen: boolean,
|
isOpen: boolean,
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
tx: Transaction,
|
tx: Transaction,
|
||||||
|
safeAddress: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CancelTxModal = ({
|
const CancelTxModal = ({
|
||||||
onClose, isOpen, classes, createTransaction, tx,
|
onClose, isOpen, classes, createTransaction, tx, safeAddress,
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
|
<SharedSnackbarConsumer>
|
||||||
|
{({ openSnackbar }) => {
|
||||||
|
const sendReplacementTransaction = () => {
|
||||||
|
createTransaction(safeAddress, safeAddress, 0, EMPTY_DATA, openSnackbar)
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title="Cancel Transaction"
|
title="Cancel Transaction"
|
||||||
description="Cancel Transaction"
|
description="Cancel Transaction"
|
||||||
|
@ -43,7 +54,8 @@ const CancelTxModal = ({
|
||||||
<Block className={classes.container}>
|
<Block className={classes.container}>
|
||||||
<Row>
|
<Row>
|
||||||
<Paragraph>
|
<Paragraph>
|
||||||
This action will cancel this transaction. A separate transaction will be performed to submit the cancellation.
|
This action will cancel this transaction. A separate transaction will be performed to submit the
|
||||||
|
cancellation.
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph size="sm" color="medium">
|
<Paragraph size="sm" color="medium">
|
||||||
Transaction nonce:
|
Transaction nonce:
|
||||||
|
@ -63,12 +75,15 @@ const CancelTxModal = ({
|
||||||
minWidth={214}
|
minWidth={214}
|
||||||
minHeight={42}
|
minHeight={42}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
data-testid="review-tx-btn"
|
onClick={sendReplacementTransaction}
|
||||||
>
|
>
|
||||||
Cancel Transaction
|
Cancel Transaction
|
||||||
</Button>
|
</Button>
|
||||||
</Row>
|
</Row>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
|
}}
|
||||||
|
</SharedSnackbarConsumer>
|
||||||
|
)
|
||||||
|
|
||||||
export default withStyles(styles)(CancelTxModal)
|
export default withStyles(styles)(CancelTxModal)
|
||||||
|
|
|
@ -34,6 +34,8 @@ type Props = {
|
||||||
owners: List<Owner>,
|
owners: List<Owner>,
|
||||||
granted: boolean,
|
granted: boolean,
|
||||||
userAddress: string,
|
userAddress: string,
|
||||||
|
safeAddress: string,
|
||||||
|
createTransaction: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenModal = 'cancelTx' | 'approveTx' | null
|
type OpenModal = 'cancelTx' | 'approveTx' | null
|
||||||
|
@ -49,7 +51,7 @@ const txStatusToLabel = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExpandedTx = ({
|
const ExpandedTx = ({
|
||||||
classes, tx, threshold, owners, granted, userAddress,
|
classes, tx, threshold, owners, granted, userAddress, safeAddress, createTransaction,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [tabIndex, setTabIndex] = useState<number>(0)
|
const [tabIndex, setTabIndex] = useState<number>(0)
|
||||||
const [openModal, setOpenModal] = useState<OpenModal>(null)
|
const [openModal, setOpenModal] = useState<OpenModal>(null)
|
||||||
|
@ -155,8 +157,8 @@ to:
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Block>
|
</Block>
|
||||||
<CancelTxModal isOpen={openModal === 'cancelTx'} onClose={closeModal} tx={tx} />
|
<CancelTxModal isOpen={openModal === 'cancelTx'} createTransaction={createTransaction} onClose={closeModal} tx={tx} safeAddress={safeAddress} />
|
||||||
<ApproveTxModal isOpen={openModal === 'approveTx'} onClose={closeModal} tx={tx} />
|
<ApproveTxModal isOpen={openModal === 'approveTx'} createTransaction={createTransaction} onClose={closeModal} tx={tx} safeAddress={safeAddress} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,19 @@ type Props = {
|
||||||
owners: List<Owner>,
|
owners: List<Owner>,
|
||||||
userAddress: string,
|
userAddress: string,
|
||||||
granted: boolean,
|
granted: boolean,
|
||||||
|
safeAddress: string,
|
||||||
|
createTransaction: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
const TxsTable = ({
|
const TxsTable = ({
|
||||||
classes, transactions, threshold, owners, granted, userAddress,
|
classes,
|
||||||
|
transactions,
|
||||||
|
threshold,
|
||||||
|
owners,
|
||||||
|
granted,
|
||||||
|
userAddress,
|
||||||
|
safeAddress,
|
||||||
|
createTransaction,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const [expandedTx, setExpandedTx] = useState<string | null>(null)
|
const [expandedTx, setExpandedTx] = useState<string | null>(null)
|
||||||
|
|
||||||
|
@ -103,6 +112,8 @@ const TxsTable = ({
|
||||||
owners={owners}
|
owners={owners}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
|
createTransaction={createTransaction}
|
||||||
|
safeAddress={safeAddress}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { List } from 'immutable'
|
import { List } from 'immutable'
|
||||||
import NoTransactions from '~/routes/safe/components/TransactionsNew/NoTransactions'
|
import NoTransactions from '~/routes/safe/components/TransactionsNew/NoTransactions'
|
||||||
import TxsTable from '~/routes/safe/components/TransactionsNew/TxsTable'
|
import TxsTable from '~/routes/safe/components/TransactionsNew/TxsTable'
|
||||||
|
@ -14,19 +14,23 @@ type Props = {
|
||||||
owners: List<Owner>,
|
owners: List<Owner>,
|
||||||
userAddress: string,
|
userAddress: string,
|
||||||
granted: boolean,
|
granted: boolean,
|
||||||
|
createTransaction: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
class Transactions extends React.Component<Props, {}> {
|
const Transactions = ({
|
||||||
componentDidMount() {
|
transactions = List(),
|
||||||
const { safeAddress, fetchTransactions } = this.props
|
owners,
|
||||||
|
threshold,
|
||||||
|
userAddress,
|
||||||
|
granted,
|
||||||
|
safeAddress,
|
||||||
|
createTransaction,
|
||||||
|
fetchTransactions,
|
||||||
|
}: Props) => {
|
||||||
|
useEffect(() => {
|
||||||
fetchTransactions(safeAddress)
|
fetchTransactions(safeAddress)
|
||||||
}
|
}, [safeAddress])
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
transactions, owners, threshold, userAddress, granted,
|
|
||||||
} = this.props
|
|
||||||
const hasTransactions = transactions.size > 0
|
const hasTransactions = transactions.size > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -38,6 +42,8 @@ class Transactions extends React.Component<Props, {}> {
|
||||||
owners={owners}
|
owners={owners}
|
||||||
userAddress={userAddress}
|
userAddress={userAddress}
|
||||||
granted={granted}
|
granted={granted}
|
||||||
|
safeAddress={safeAddress}
|
||||||
|
createTransaction={createTransaction}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NoTransactions />
|
<NoTransactions />
|
||||||
|
@ -45,10 +51,5 @@ class Transactions extends React.Component<Props, {}> {
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Transactions.defaultProps = {
|
|
||||||
transactions: List(),
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Transactions
|
export default Transactions
|
||||||
|
|
Loading…
Reference in New Issue