|
@ -4,22 +4,26 @@ const initialState = [] |
|
|
|
|
|
|
|
|
const transactionStackReducer = (state = initialState, action) => { |
|
|
const transactionStackReducer = (state = initialState, action) => { |
|
|
if (action.type === TransactionsActions.PUSH_TO_TXSTACK) { |
|
|
if (action.type === TransactionsActions.PUSH_TO_TXSTACK) { |
|
|
return [...state, action.stackTempKey] |
|
|
return [...state, action.stackTempKey]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (action.type === TransactionsActions.POP_FROM_TXSTACK) { |
|
|
if (action.type === TransactionsActions.POP_FROM_TXSTACK) { |
|
|
state.pop() |
|
|
return [...state.slice(0, -1)]; |
|
|
|
|
|
|
|
|
return [...state] |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (action.type === TransactionsActions.TX_BROADCASTED) { |
|
|
if (action.type === TransactionsActions.TX_BROADCASTED) { |
|
|
state[action.stackId] = action.txHash |
|
|
return state.map((txHash, index) => { |
|
|
|
|
|
if (index !== action.stackId) { |
|
|
|
|
|
// This isn't the item we care about - keep it as-is
|
|
|
|
|
|
return txHash; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return [...state] |
|
|
// Otherwise, this is the one we want - return an updated value
|
|
|
|
|
|
return action.txHash; |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return state |
|
|
return state; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default transactionStackReducer |
|
|
export default transactionStackReducer |
|
|