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