diff --git a/src/modules/transaction/sagas.ts b/src/modules/transaction/sagas.ts index 98a0c493..7cc10aee 100644 --- a/src/modules/transaction/sagas.ts +++ b/src/modules/transaction/sagas.ts @@ -155,9 +155,16 @@ function* handleReplaceTransactionRequest( while (true) { // check if tx has status, this is to recover from a tx that is dropped momentarily - const tx = yield call(() => txUtils.getTransaction(hash)) + const tx: txUtils.Transaction = yield call(() => + txUtils.getTransaction(hash) + ) if (tx != null) { - yield put(fetchTransactionRequest(account, hash, buildActionRef(tx))) + const txInState: Transaction = yield select(state => + getTransaction(state, hash) + ) + yield put( + fetchTransactionRequest(account, hash, buildActionRef(txInState)) + ) break } @@ -195,7 +202,12 @@ function* handleReplaceTransactionRequest( // could be due to a race condition when fetching the account nonce // it will be sent back to the pending tx saga that will mark it as confirmed/reverted if (hash === replacedBy.hash) { - yield put(fetchTransactionRequest(account, hash, buildActionRef(tx))) + const txInState: Transaction = yield select(state => + getTransaction(state, hash) + ) + yield put( + fetchTransactionRequest(account, hash, buildActionRef(txInState)) + ) } else { // replacement found! yield put(replaceTransactionSuccess(hash, replacedBy.hash)) diff --git a/src/modules/transaction/types.ts b/src/modules/transaction/types.ts index 09f41d32..dcfa203a 100644 --- a/src/modules/transaction/types.ts +++ b/src/modules/transaction/types.ts @@ -18,6 +18,7 @@ export interface Transaction { status: txUtils.Transaction['type'] | null withReceipt?: boolean receipt?: Receipt + payload?: any } export interface TransactionPayload { diff --git a/src/modules/transaction/utils.ts b/src/modules/transaction/utils.ts index 57e43a57..30b830e2 100644 --- a/src/modules/transaction/utils.ts +++ b/src/modules/transaction/utils.ts @@ -2,16 +2,13 @@ import { AnyAction } from 'redux' import { Transaction, TransactionPayload, FINISHED_TYPES } from './types' import { txUtils } from 'decentraland-eth' -// Dummy action used as action ref when reinserting a pending transaction into the saga that watches pending txs -export const DUMMY_ACTION_REF = '_dummy_action_ref' - // Special flag used to determine transaction hashes to be monitored export const TRANSACTION_ACTION_FLAG = '_watch_tx' export function buildActionRef(transaction: Transaction) { - const { hash, events, withReceipt, ...payload } = transaction + const { actionType, events, withReceipt, payload } = transaction return { - type: DUMMY_ACTION_REF, + type: actionType, payload: (withReceipt ? buildTransactionWithReceiptPayload : buildTransactionPayload)(transaction.hash, payload, events)