fix fetchTransaction/createTransaction types
This commit is contained in:
parent
fa30de45a8
commit
211749aab8
|
@ -3,6 +3,7 @@ import { List, Map } from 'immutable'
|
|||
import { WithSnackbarProps } from 'notistack'
|
||||
import { batch } from 'react-redux'
|
||||
import semverSatisfies from 'semver/functions/satisfies'
|
||||
import { ThunkAction, ThunkDispatch } from 'redux-thunk'
|
||||
|
||||
import { onboardUser } from 'src/components/ConnectButton'
|
||||
import { getGnosisSafeInstanceAt } from 'src/logic/contracts/safeContracts'
|
||||
|
@ -35,11 +36,16 @@ import { getErrorMessage } from 'src/test/utils/ethereumErrors'
|
|||
import { makeConfirmation } from '../models/confirmation'
|
||||
import fetchTransactions from './transactions/fetchTransactions'
|
||||
import { safeTransactionsSelector } from 'src/routes/safe/store/selectors'
|
||||
import { TransactionStatus, TxArgs } from 'src/routes/safe/store/models/types/transaction'
|
||||
import { Dispatch } from 'redux'
|
||||
import { Transaction, TransactionStatus, TxArgs } from 'src/routes/safe/store/models/types/transaction'
|
||||
import { AnyAction } from 'redux'
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
export const removeTxFromStore = (tx, safeAddress, dispatch, state) => {
|
||||
export const removeTxFromStore = (
|
||||
tx: Transaction,
|
||||
safeAddress: string,
|
||||
dispatch: CTADispatch,
|
||||
state: AppReduxState,
|
||||
): void => {
|
||||
if (tx.isCancellationTx) {
|
||||
const newTxStatus = TransactionStatus.AWAITING_YOUR_CONFIRMATION
|
||||
const transactions = safeTransactionsSelector(state)
|
||||
|
@ -56,7 +62,12 @@ export const removeTxFromStore = (tx, safeAddress, dispatch, state) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const storeTx = async (tx, safeAddress, dispatch, state) => {
|
||||
export const storeTx = async (
|
||||
tx: Transaction,
|
||||
safeAddress: string,
|
||||
dispatch: CTADispatch,
|
||||
state: AppReduxState,
|
||||
): Promise<void> => {
|
||||
if (tx.isCancellationTx) {
|
||||
let newTxStatus: TransactionStatus = TransactionStatus.AWAITING_YOUR_CONFIRMATION
|
||||
|
||||
|
@ -94,6 +105,9 @@ interface CreateTransaction extends WithSnackbarProps {
|
|||
valueInWei: string
|
||||
}
|
||||
|
||||
type CreateTransactionAction = ThunkAction<Promise<void>, AppReduxState, undefined, AnyAction>
|
||||
type CTADispatch = ThunkDispatch<AppReduxState, undefined, AnyAction>
|
||||
|
||||
const createTransaction = ({
|
||||
safeAddress,
|
||||
to,
|
||||
|
@ -106,7 +120,10 @@ const createTransaction = ({
|
|||
operation = CALL,
|
||||
navigateToTransactionsTab = true,
|
||||
origin = null,
|
||||
}: CreateTransaction) => async (dispatch: Dispatch, getState: () => AppReduxState): Promise<void> => {
|
||||
}: CreateTransaction): CreateTransactionAction => async (
|
||||
dispatch: CTADispatch,
|
||||
getState: () => AppReduxState,
|
||||
): Promise<void> => {
|
||||
const state = getState()
|
||||
|
||||
if (navigateToTransactionsTab) {
|
||||
|
@ -262,7 +279,7 @@ const createTransaction = ({
|
|||
dispatch,
|
||||
state,
|
||||
)
|
||||
;(await fetchTransactions(safeAddress))(dispatch)
|
||||
await dispatch(fetchTransactions(safeAddress))
|
||||
|
||||
return receipt.transactionHash
|
||||
})
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { batch } from 'react-redux'
|
||||
import { ThunkAction, ThunkDispatch } from 'redux-thunk'
|
||||
import { AnyAction } from 'redux'
|
||||
import { backOff } from 'exponential-backoff'
|
||||
|
||||
import { addIncomingTransactions } from '../../addIncomingTransactions'
|
||||
|
||||
|
@ -7,12 +10,13 @@ import { loadOutgoingTransactions } from './loadOutgoingTransactions'
|
|||
|
||||
import { addOrUpdateCancellationTransactions } from 'src/routes/safe/store/actions/transactions/addOrUpdateCancellationTransactions'
|
||||
import { addOrUpdateTransactions } from 'src/routes/safe/store/actions/transactions/addOrUpdateTransactions'
|
||||
import { Dispatch } from 'redux'
|
||||
import { backOff } from 'exponential-backoff'
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
const noFunc = () => {}
|
||||
|
||||
export default (safeAddress: string) => async (dispatch: Dispatch): Promise<void> => {
|
||||
export default (safeAddress: string): ThunkAction<Promise<void>, AppReduxState, undefined, AnyAction> => async (
|
||||
dispatch: ThunkDispatch<AppReduxState, undefined, AnyAction>,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const transactions = await backOff(() => loadOutgoingTransactions(safeAddress))
|
||||
|
||||
|
|
Loading…
Reference in New Issue