refactor: move `Dispatch` type to a common place
This commit is contained in:
parent
c74b79bf67
commit
ad9ee25b36
|
@ -1,8 +1,6 @@
|
|||
import { useMemo } from 'react'
|
||||
import { batch, useDispatch } from 'react-redux'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { AnyAction } from 'redux'
|
||||
import { ThunkDispatch } from 'redux-thunk'
|
||||
|
||||
import fetchCollectibles from 'src/logic/collectibles/store/actions/fetchCollectibles'
|
||||
import { fetchCurrencyValues } from 'src/logic/currencyValues/store/actions/fetchCurrencyValues'
|
||||
|
@ -10,9 +8,7 @@ import activateAssetsByBalance from 'src/logic/tokens/store/actions/activateAsse
|
|||
import fetchSafeTokens from 'src/logic/tokens/store/actions/fetchSafeTokens'
|
||||
import { fetchTokens } from 'src/logic/tokens/store/actions/fetchTokens'
|
||||
import { COINS_LOCATION_REGEX, COLLECTIBLES_LOCATION_REGEX } from 'src/routes/safe/components/Balances'
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
type Dispatch = ThunkDispatch<AppReduxState, undefined, AnyAction>
|
||||
import { Dispatch } from 'src/routes/safe/store/actions/types'
|
||||
|
||||
export const useFetchTokens = (safeAddress: string): void => {
|
||||
const dispatch = useDispatch<Dispatch>()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { useEffect } from 'react'
|
||||
import { useDispatch } from 'react-redux'
|
||||
import { AnyAction } from 'redux'
|
||||
import { ThunkDispatch } from 'redux-thunk'
|
||||
|
||||
import loadAddressBookFromStorage from 'src/logic/addressBook/store/actions/loadAddressBookFromStorage'
|
||||
import addViewedSafe from 'src/logic/currentSession/store/actions/addViewedSafe'
|
||||
|
@ -10,9 +8,7 @@ import fetchLatestMasterContractVersion from 'src/routes/safe/store/actions/fetc
|
|||
import fetchSafe from 'src/routes/safe/store/actions/fetchSafe'
|
||||
import fetchTransactions from 'src/routes/safe/store/actions/transactions/fetchTransactions'
|
||||
import fetchSafeCreationTx from 'src/routes/safe/store/actions/fetchSafeCreationTx'
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
type Dispatch = ThunkDispatch<AppReduxState, undefined, AnyAction>
|
||||
import { Dispatch } from 'src/routes/safe/store/actions/types'
|
||||
|
||||
export const useLoadSafe = (safeAddress: string): void => {
|
||||
const dispatch = useDispatch<Dispatch>()
|
||||
|
|
|
@ -3,7 +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 { ThunkAction } from 'redux-thunk'
|
||||
|
||||
import { onboardUser } from 'src/components/ConnectButton'
|
||||
import { getGnosisSafeInstanceAt } from 'src/logic/contracts/safeContracts'
|
||||
|
@ -39,11 +39,12 @@ import { safeTransactionsSelector } from 'src/routes/safe/store/selectors'
|
|||
import { Transaction, TransactionStatus, TxArgs } from 'src/routes/safe/store/models/types/transaction'
|
||||
import { AnyAction } from 'redux'
|
||||
import { AppReduxState } from 'src/store'
|
||||
import { Dispatch } from './types'
|
||||
|
||||
export const removeTxFromStore = (
|
||||
tx: Transaction,
|
||||
safeAddress: string,
|
||||
dispatch: CTADispatch,
|
||||
dispatch: Dispatch,
|
||||
state: AppReduxState,
|
||||
): void => {
|
||||
if (tx.isCancellationTx) {
|
||||
|
@ -65,7 +66,7 @@ export const removeTxFromStore = (
|
|||
export const storeTx = async (
|
||||
tx: Transaction,
|
||||
safeAddress: string,
|
||||
dispatch: CTADispatch,
|
||||
dispatch: Dispatch,
|
||||
state: AppReduxState,
|
||||
): Promise<void> => {
|
||||
if (tx.isCancellationTx) {
|
||||
|
@ -106,7 +107,6 @@ interface CreateTransaction extends WithSnackbarProps {
|
|||
}
|
||||
|
||||
type CreateTransactionAction = ThunkAction<Promise<void>, AppReduxState, undefined, AnyAction>
|
||||
type CTADispatch = ThunkDispatch<AppReduxState, undefined, AnyAction>
|
||||
|
||||
const createTransaction = ({
|
||||
safeAddress,
|
||||
|
@ -121,7 +121,7 @@ const createTransaction = ({
|
|||
navigateToTransactionsTab = true,
|
||||
origin = null,
|
||||
}: CreateTransaction): CreateTransactionAction => async (
|
||||
dispatch: CTADispatch,
|
||||
dispatch: Dispatch,
|
||||
getState: () => AppReduxState,
|
||||
): Promise<void> => {
|
||||
const state = getState()
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import { ThunkDispatch } from 'redux-thunk'
|
||||
import { AnyAction } from 'redux'
|
||||
|
||||
import { AppReduxState } from 'src/store'
|
||||
|
||||
export type Dispatch = ThunkDispatch<AppReduxState, undefined, AnyAction>
|
Loading…
Reference in New Issue