Skip to content

Commit

Permalink
fix: replace transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Feb 5, 2020
1 parent 7097411 commit 4812b40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/transaction/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function transactionReducer(
action.payload.hash === transaction.hash
? {
...transaction,
status: TransactionStatus.REVERTED,
status: TransactionStatus.REPLACED,
replacedBy: action.payload.replaceBy
}
: transaction
Expand Down
10 changes: 8 additions & 2 deletions src/modules/transaction/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,18 @@ function* handleWatchRevertedTransaction(

do {
yield delay(TRANSACTION_FETCH_DELAY)
const tx: AnyTransaction | null = yield call(() =>
const txInNetwork: AnyTransaction | null = yield call(() =>
getTransactionFromNetwork(hash)
)
if (tx != null && tx.status === TransactionStatus.CONFIRMED) {
if (
txInNetwork != null &&
txInNetwork.status === TransactionStatus.CONFIRMED
) {
yield put(fixRevertedTransaction(hash))
return
} else if (txInNetwork == null && txInState.nonce) {
yield put(replaceTransactionRequest(hash, txInState.nonce))
return
}
} while (!isExpired(txInState, REVERTED_TRANSACTION_THRESHOLD))
}
Expand Down

0 comments on commit 4812b40

Please sign in to comment.