Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Change redux store on success claiming (#2141)
Browse files Browse the repository at this point in the history
* Change redux store on success claiming

* Fix comments and debug log
  • Loading branch information
anxolin authored Jan 14, 2022
1 parent f560da0 commit 75d4d33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/custom/state/claim/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Middleware, isAnyOf } from '@reduxjs/toolkit'
import { AppState } from 'state'
import { finalizeTransaction } from '../enhancedTransactions/actions'
import { setClaimStatus, ClaimStatus } from './actions'

const isFinalizeTransaction = isAnyOf(finalizeTransaction)

// On each Pending, Expired, Fulfilled order action a corresponding sound is dispatched
// Watch for claim tx being finalized and triggers a change of status
export const claimMinedMiddleware: Middleware<Record<string, unknown>, AppState> = (store) => (next) => (action) => {
const result = next(action)

if (isFinalizeTransaction(action)) {
const { chainId, hash, receipt, safeTransaction } = action.payload
const { chainId, hash } = action.payload
const transaction = store.getState().transactions[chainId][hash]

console.log('[stat:claim:middleware] Transaction finalized', transaction, receipt, safeTransaction)
if (transaction.claim) {
// TODO: Update state
console.log('[stat:claim:middleware] It is a CLAIM transaction')
console.debug('[stat:claim:middleware] Claim transaction finalized', transaction.hash, transaction.claim)
store.dispatch(setClaimStatus(ClaimStatus.CONFIRMED))
}
}

Expand Down

0 comments on commit 75d4d33

Please sign in to comment.