Add approve and cancel txs notifications

This commit is contained in:
Germán Martínez 2019-09-23 09:47:23 +02:00
parent 6ea3b679ca
commit 1b61a0294c
2 changed files with 32 additions and 7 deletions

View File

@ -13,7 +13,7 @@ import Row from '~/components/layout/Row'
import Bold from '~/components/layout/Bold' 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 Variant } from '~/components/Header' import { NOTIFIED_TRANSACTIONS } from '~/logic/safe/transactions'
import { type Transaction } from '~/routes/safe/store/models/transaction' import { type Transaction } from '~/routes/safe/store/models/transaction'
import { styles } from './style' import { styles } from './style'
@ -30,7 +30,8 @@ type Props = {
threshold: number, threshold: number,
thresholdReached: boolean, thresholdReached: boolean,
userAddress: string, userAddress: string,
enqueueSnackbar: (message: string, variant: Variant) => void, enqueueSnackbar: Function,
closeSnackbar: Function,
} }
const getModalTitleAndDescription = (thresholdReached: boolean) => { const getModalTitleAndDescription = (thresholdReached: boolean) => {
@ -58,6 +59,7 @@ const ApproveTxModal = ({
thresholdReached, thresholdReached,
userAddress, userAddress,
enqueueSnackbar, enqueueSnackbar,
closeSnackbar,
}: Props) => { }: Props) => {
const [approveAndExecute, setApproveAndExecute] = useState<boolean>(false) const [approveAndExecute, setApproveAndExecute] = useState<boolean>(false)
const { title, description } = getModalTitleAndDescription(thresholdReached) const { title, description } = getModalTitleAndDescription(thresholdReached)
@ -66,7 +68,14 @@ const ApproveTxModal = ({
const handleExecuteCheckbox = () => setApproveAndExecute((prevApproveAndExecute) => !prevApproveAndExecute) const handleExecuteCheckbox = () => setApproveAndExecute((prevApproveAndExecute) => !prevApproveAndExecute)
const approveTx = () => { const approveTx = () => {
processTransaction(safeAddress, tx, enqueueSnackbar, userAddress, enqueueSnackbar) processTransaction(
safeAddress,
tx,
userAddress,
NOTIFIED_TRANSACTIONS.CONFIRMATION_TX,
enqueueSnackbar,
closeSnackbar,
)
onClose() onClose()
} }

View File

@ -13,7 +13,7 @@ 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 { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { type Variant } from '~/components/Header' import { NOTIFIED_TRANSACTIONS } from '~/logic/safe/transactions'
import { styles } from './style' import { styles } from './style'
type Props = { type Props = {
@ -23,14 +23,30 @@ type Props = {
createTransaction: Function, createTransaction: Function,
tx: Transaction, tx: Transaction,
safeAddress: string, safeAddress: string,
enqueueSnackbar: (message: string, variant: Variant) => void, enqueueSnackbar: Function,
closeSnackbar: Function,
} }
const CancelTxModal = ({ const CancelTxModal = ({
onClose, isOpen, classes, createTransaction, tx, safeAddress, enqueueSnackbar, onClose,
isOpen,
classes,
createTransaction,
tx,
safeAddress,
enqueueSnackbar,
closeSnackbar,
}: Props) => { }: Props) => {
const sendReplacementTransaction = () => { const sendReplacementTransaction = () => {
createTransaction(safeAddress, safeAddress, 0, EMPTY_DATA, enqueueSnackbar) createTransaction(
safeAddress,
safeAddress,
0,
EMPTY_DATA,
NOTIFIED_TRANSACTIONS.CANCELLATION_TX,
enqueueSnackbar,
closeSnackbar,
)
onClose() onClose()
} }