Switch to transaction list after creating tx, fix typos and missing type imports for notifications
This commit is contained in:
parent
7eed7419a9
commit
712fc80b1e
|
@ -5,7 +5,7 @@ import { Close as IconClose } from '@material-ui/icons'
|
||||||
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
|
import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
|
||||||
import { type Notification, NOTIFICATIONS } from './notificationTypes'
|
import { type Notification, NOTIFICATIONS } from './notificationTypes'
|
||||||
|
|
||||||
type NotificationsQueue = {
|
export type NotificationsQueue = {
|
||||||
beforeExecution: Notification,
|
beforeExecution: Notification,
|
||||||
pendingExecution: {
|
pendingExecution: {
|
||||||
noMoreConfirmationsNeeded: Notification,
|
noMoreConfirmationsNeeded: Notification,
|
||||||
|
@ -104,7 +104,7 @@ const defaultNotificationsQueue: NotificationsQueue = {
|
||||||
afterExecutionError: NOTIFICATIONS.TX_FAILED_MSG,
|
afterExecutionError: NOTIFICATIONS.TX_FAILED_MSG,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getNofiticationsFromTxType = (txType: string) => {
|
export const getNotificationsFromTxType = (txType: string) => {
|
||||||
let notificationsQueue: NotificationsQueue
|
let notificationsQueue: NotificationsQueue
|
||||||
|
|
||||||
switch (txType) {
|
switch (txType) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import GnoForm from '~/components/forms/GnoForm'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Button from '~/components/layout/Button'
|
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 { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
|
||||||
import { styles } from './style'
|
import { styles } from './style'
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const ChangeSafeName = (props: Props) => {
|
||||||
const handleSubmit = (values) => {
|
const handleSubmit = (values) => {
|
||||||
updateSafe({ address: safeAddress, name: values.safeName })
|
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)
|
showSnackbar(notification.afterExecution, enqueueSnackbar, closeSnackbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import TextField from '~/components/forms/TextField'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Identicon from '~/components/Identicon'
|
import Identicon from '~/components/Identicon'
|
||||||
import { composeValidators, required, minMaxLength } from '~/components/forms/validator'
|
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 { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions'
|
||||||
import { getEtherScanLink } from '~/logic/wallets/getWeb3'
|
import { getEtherScanLink } from '~/logic/wallets/getWeb3'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
|
@ -57,7 +57,7 @@ const EditOwnerComponent = ({
|
||||||
const handleSubmit = (values) => {
|
const handleSubmit = (values) => {
|
||||||
editSafeOwner({ safeAddress, ownerAddress, ownerName: values.ownerName })
|
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)
|
showSnackbar(notification.afterExecution, enqueueSnackbar, closeSnackbar)
|
||||||
|
|
||||||
onClose()
|
onClose()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import type { Dispatch as ReduxDispatch, GetState } from 'redux'
|
import type { Dispatch as ReduxDispatch, GetState } from 'redux'
|
||||||
|
import { push } from 'connected-react-router'
|
||||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||||
import { userAccountSelector } from '~/logic/wallets/store/selectors'
|
import { userAccountSelector } from '~/logic/wallets/store/selectors'
|
||||||
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
|
import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
|
||||||
|
@ -17,11 +18,12 @@ import {
|
||||||
import {
|
import {
|
||||||
type Notification,
|
type Notification,
|
||||||
type NotificationsQueue,
|
type NotificationsQueue,
|
||||||
getNofiticationsFromTxType,
|
getNotificationsFromTxType,
|
||||||
showSnackbar,
|
showSnackbar,
|
||||||
} from '~/logic/notifications'
|
} from '~/logic/notifications'
|
||||||
import { getErrorMessage } from '~/test/utils/ethereumErrors'
|
import { getErrorMessage } from '~/test/utils/ethereumErrors'
|
||||||
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
|
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
|
||||||
|
import { SAFELIST_ADDRESS } from '~/routes/routes'
|
||||||
|
|
||||||
const createTransaction = (
|
const createTransaction = (
|
||||||
safeAddress: string,
|
safeAddress: string,
|
||||||
|
@ -35,6 +37,8 @@ const createTransaction = (
|
||||||
) => async (dispatch: ReduxDispatch<GlobalState>, getState: GetState<GlobalState>) => {
|
) => async (dispatch: ReduxDispatch<GlobalState>, getState: GetState<GlobalState>) => {
|
||||||
const state: GlobalState = getState()
|
const state: GlobalState = getState()
|
||||||
|
|
||||||
|
dispatch(push(`${SAFELIST_ADDRESS}/${safeAddress}/transactions`))
|
||||||
|
|
||||||
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
||||||
const from = userAccountSelector(state)
|
const from = userAccountSelector(state)
|
||||||
const threshold = await safeInstance.getThreshold()
|
const threshold = await safeInstance.getThreshold()
|
||||||
|
@ -47,7 +51,7 @@ const createTransaction = (
|
||||||
'',
|
'',
|
||||||
)}000000000000000000000000000000000000000000000000000000000000000001`
|
)}000000000000000000000000000000000000000000000000000000000000000001`
|
||||||
|
|
||||||
const notificationsQueue: NotificationsQueue = getNofiticationsFromTxType(notifiedTransaction)
|
const notificationsQueue: NotificationsQueue = getNotificationsFromTxType(notifiedTransaction)
|
||||||
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
||||||
let pendingExecutionKey
|
let pendingExecutionKey
|
||||||
|
|
||||||
|
@ -99,6 +103,7 @@ const createTransaction = (
|
||||||
if (isExecution) {
|
if (isExecution) {
|
||||||
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
|
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
|
||||||
}
|
}
|
||||||
|
dispatch(fetchTransactions(safeAddress))
|
||||||
|
|
||||||
return receipt.transactionHash
|
return receipt.transactionHash
|
||||||
})
|
})
|
||||||
|
@ -114,8 +119,6 @@ const createTransaction = (
|
||||||
console.error(`Error executing the TX: ${errMsg}`)
|
console.error(`Error executing the TX: ${errMsg}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(fetchTransactions(safeAddress))
|
|
||||||
|
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions'
|
||||||
import { type GlobalState } from '~/store'
|
import { type GlobalState } from '~/store'
|
||||||
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
|
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
|
||||||
import {
|
import {
|
||||||
|
type NotifiedTransaction,
|
||||||
getApprovalTransaction,
|
getApprovalTransaction,
|
||||||
getExecutionTransaction,
|
getExecutionTransaction,
|
||||||
CALL,
|
CALL,
|
||||||
|
@ -16,7 +17,7 @@ import {
|
||||||
import {
|
import {
|
||||||
type Notification,
|
type Notification,
|
||||||
type NotificationsQueue,
|
type NotificationsQueue,
|
||||||
getNofiticationsFromTxType,
|
getNotificationsFromTxType,
|
||||||
showSnackbar,
|
showSnackbar,
|
||||||
} from '~/logic/notifications'
|
} from '~/logic/notifications'
|
||||||
import { getErrorMessage } from '~/test/utils/ethereumErrors'
|
import { getErrorMessage } from '~/test/utils/ethereumErrors'
|
||||||
|
@ -68,7 +69,7 @@ const processTransaction = (
|
||||||
)}000000000000000000000000000000000000000000000000000000000000000001`
|
)}000000000000000000000000000000000000000000000000000000000000000001`
|
||||||
}
|
}
|
||||||
|
|
||||||
const notificationsQueue: NotificationsQueue = getNofiticationsFromTxType(notifiedTransaction)
|
const notificationsQueue: NotificationsQueue = getNotificationsFromTxType(notifiedTransaction)
|
||||||
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
||||||
let pendingExecutionKey
|
let pendingExecutionKey
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ const processTransaction = (
|
||||||
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
||||||
)
|
)
|
||||||
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
|
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
|
||||||
|
dispatch(fetchTransactions(safeAddress))
|
||||||
|
|
||||||
return receipt.transactionHash
|
return receipt.transactionHash
|
||||||
})
|
})
|
||||||
|
@ -137,8 +139,6 @@ const processTransaction = (
|
||||||
console.error(`Error executing the TX: ${errMsg}`)
|
console.error(`Error executing the TX: ${errMsg}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(fetchTransactions(safeAddress))
|
|
||||||
|
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue