Switch to transaction list after creating tx, fix typos and missing type imports for notifications

This commit is contained in:
Mikhail Mikheev 2019-10-07 16:44:24 +04:00
parent 7eed7419a9
commit 712fc80b1e
5 changed files with 17 additions and 14 deletions

View File

@ -5,7 +5,7 @@ import { Close as IconClose } from '@material-ui/icons'
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
import { type Notification, NOTIFICATIONS } from './notificationTypes'
type NotificationsQueue = {
export type NotificationsQueue = {
beforeExecution: Notification,
pendingExecution: {
noMoreConfirmationsNeeded: Notification,
@ -104,7 +104,7 @@ const defaultNotificationsQueue: NotificationsQueue = {
afterExecutionError: NOTIFICATIONS.TX_FAILED_MSG,
}
export const getNofiticationsFromTxType = (txType: string) => {
export const getNotificationsFromTxType = (txType: string) => {
let notificationsQueue: NotificationsQueue
switch (txType) {

View File

@ -12,7 +12,7 @@ import GnoForm from '~/components/forms/GnoForm'
import Row from '~/components/layout/Row'
import Paragraph from '~/components/layout/Paragraph'
import Button from '~/components/layout/Button'
import { getNofiticationsFromTxType, showSnackbar } from '~/logic/notifications'
import { getNotificationsFromTxType, showSnackbar } from '~/logic/notifications'
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
import { styles } from './style'
@ -36,7 +36,7 @@ const ChangeSafeName = (props: Props) => {
const handleSubmit = (values) => {
updateSafe({ address: safeAddress, name: values.safeName })
const notification = getNofiticationsFromTxType(TX_NOTIFICATION_TYPES.SAFE_NAME_CHANGE_TX)
const notification = getNotificationsFromTxType(TX_NOTIFICATION_TYPES.SAFE_NAME_CHANGE_TX)
showSnackbar(notification.afterExecution, enqueueSnackbar, closeSnackbar)
}

View File

@ -16,7 +16,7 @@ import TextField from '~/components/forms/TextField'
import Paragraph from '~/components/layout/Paragraph'
import Identicon from '~/components/Identicon'
import { composeValidators, required, minMaxLength } from '~/components/forms/validator'
import { getNofiticationsFromTxType, showSnackbar } from '~/logic/notifications'
import { getNotificationsFromTxType, showSnackbar } from '~/logic/notifications'
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
import { getEtherScanLink } from '~/logic/wallets/getWeb3'
import Modal from '~/components/Modal'
@ -57,7 +57,7 @@ const EditOwnerComponent = ({
const handleSubmit = (values) => {
editSafeOwner({ safeAddress, ownerAddress, ownerName: values.ownerName })
const notification = getNofiticationsFromTxType(TX_NOTIFICATION_TYPES.OWNER_NAME_CHANGE_TX)
const notification = getNotificationsFromTxType(TX_NOTIFICATION_TYPES.OWNER_NAME_CHANGE_TX)
showSnackbar(notification.afterExecution, enqueueSnackbar, closeSnackbar)
onClose()

View File

@ -1,5 +1,6 @@
// @flow
import type { Dispatch as ReduxDispatch, GetState } from 'redux'
import { push } from 'connected-react-router'
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
import { userAccountSelector } from '~/logic/wallets/store/selectors'
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
@ -17,11 +18,12 @@ import {
import {
type Notification,
type NotificationsQueue,
getNofiticationsFromTxType,
getNotificationsFromTxType,
showSnackbar,
} from '~/logic/notifications'
import { getErrorMessage } from '~/test/utils/ethereumErrors'
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
import { SAFELIST_ADDRESS } from '~/routes/routes'
const createTransaction = (
safeAddress: string,
@ -35,6 +37,8 @@ const createTransaction = (
) => async (dispatch: ReduxDispatch<GlobalState>, getState: GetState<GlobalState>) => {
const state: GlobalState = getState()
dispatch(push(`${SAFELIST_ADDRESS}/${safeAddress}/transactions`))
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
const from = userAccountSelector(state)
const threshold = await safeInstance.getThreshold()
@ -47,7 +51,7 @@ const createTransaction = (
'',
)}000000000000000000000000000000000000000000000000000000000000000001`
const notificationsQueue: NotificationsQueue = getNofiticationsFromTxType(notifiedTransaction)
const notificationsQueue: NotificationsQueue = getNotificationsFromTxType(notifiedTransaction)
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
let pendingExecutionKey
@ -99,6 +103,7 @@ const createTransaction = (
if (isExecution) {
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
}
dispatch(fetchTransactions(safeAddress))
return receipt.transactionHash
})
@ -114,8 +119,6 @@ const createTransaction = (
console.error(`Error executing the TX: ${errMsg}`)
}
dispatch(fetchTransactions(safeAddress))
return txHash
}

View File

@ -6,6 +6,7 @@ import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
import { type GlobalState } from '~/store'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import {
type NotifiedTransaction,
getApprovalTransaction,
getExecutionTransaction,
CALL,
@ -16,7 +17,7 @@ import {
import {
type Notification,
type NotificationsQueue,
getNofiticationsFromTxType,
getNotificationsFromTxType,
showSnackbar,
} from '~/logic/notifications'
import { getErrorMessage } from '~/test/utils/ethereumErrors'
@ -68,7 +69,7 @@ const processTransaction = (
)}000000000000000000000000000000000000000000000000000000000000000001`
}
const notificationsQueue: NotificationsQueue = getNofiticationsFromTxType(notifiedTransaction)
const notificationsQueue: NotificationsQueue = getNotificationsFromTxType(notifiedTransaction)
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
let pendingExecutionKey
@ -124,6 +125,7 @@ const processTransaction = (
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
)
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
dispatch(fetchTransactions(safeAddress))
return receipt.transactionHash
})
@ -137,8 +139,6 @@ const processTransaction = (
console.error(`Error executing the TX: ${errMsg}`)
}
dispatch(fetchTransactions(safeAddress))
return txHash
}