mirror of https://gitlab.com/ecentrics/drizzle
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
4 years ago
|
import * as TransactionsActions from './constants'
|
||
|
|
||
|
const initialState = {}
|
||
|
|
||
|
const transactionsReducer = (state = initialState, action) => {
|
||
|
if (action.type === TransactionsActions.TX_BROADCASTED) {
|
||
|
return {
|
||
|
...state,
|
||
|
[action.txHash]: {
|
||
|
status: 'pending',
|
||
|
confirmations: []
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (action.type === TransactionsActions.TX_CONFIRMATION) {
|
||
|
return {
|
||
|
...state,
|
||
|
[action.txHash]: {
|
||
|
...state[action.txHash],
|
||
|
confirmations: [
|
||
|
...state[action.txHash].confirmations,
|
||
|
action.confirmationReceipt
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (action.type === TransactionsActions.TX_SUCCESSFUL) {
|
||
|
return {
|
||
|
...state,
|
||
|
[action.txHash]: {
|
||
|
...state[action.txHash],
|
||
|
status: 'success',
|
||
|
receipt: action.receipt
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (action.type === TransactionsActions.TX_ERROR) {
|
||
|
return {
|
||
|
...state,
|
||
|
[action.stackTempKey]: {
|
||
|
...state[action.stackTempKey],
|
||
|
status: 'error',
|
||
|
error: {
|
||
|
message: action.error && action.error.message
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return state
|
||
|
}
|
||
|
|
||
|
export default transactionsReducer
|