|
|
|
@ -13,6 +13,7 @@ export const initialState = { |
|
|
|
|
}, |
|
|
|
|
display: [], |
|
|
|
|
index: 0, |
|
|
|
|
initialIndex: 0, |
|
|
|
|
nextIndexes: [-1], |
|
|
|
|
returnInstructionIndexes: [], |
|
|
|
|
outOfGasInstructionIndexes: [], |
|
|
|
@ -20,7 +21,10 @@ export const initialState = { |
|
|
|
|
bottom: 0, |
|
|
|
|
isRequesting: false, |
|
|
|
|
isSuccessful: false, |
|
|
|
|
hasError: null |
|
|
|
|
hasError: null, |
|
|
|
|
absoluteCurrentLineIndexes: [], |
|
|
|
|
currentLineIndexes: [], |
|
|
|
|
line: -1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const reducedOpcode = (opCodes, payload) => { |
|
|
|
@ -31,6 +35,7 @@ const reducedOpcode = (opCodes, payload) => { |
|
|
|
|
return { |
|
|
|
|
index: opCodes.index - bottom, |
|
|
|
|
nextIndexes: opCodes.nextIndexes.map(index => index - bottom), |
|
|
|
|
currentLineIndexes: (opCodes.absoluteCurrentLineIndexes && opCodes.absoluteCurrentLineIndexes.map(index => index - bottom)) || [], |
|
|
|
|
display: opCodes.code.slice(bottom, top), |
|
|
|
|
returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom), |
|
|
|
|
outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom) |
|
|
|
@ -49,20 +54,23 @@ export const reducer = (state = initialState, action: Action) => { |
|
|
|
|
} |
|
|
|
|
case 'FETCH_OPCODES_SUCCESS': { |
|
|
|
|
const opCodes = action.payload.address === state.opCodes.address ? { |
|
|
|
|
...state.opCodes, index: action.payload.index, nextIndexes: action.payload.nextIndexes |
|
|
|
|
...state.opCodes, index: action.payload.index, nextIndexes: action.payload.nextIndexes, absoluteCurrentLineIndexes: state.absoluteCurrentLineIndexes |
|
|
|
|
} : deepEqual(action.payload.code, state.opCodes.code) ? state.opCodes : action.payload |
|
|
|
|
|
|
|
|
|
const reduced = reducedOpcode(opCodes, action.payload) |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
opCodes, |
|
|
|
|
display: reduced.display, |
|
|
|
|
initialIndex: action.payload.index, |
|
|
|
|
index: reduced.index, |
|
|
|
|
nextIndexes: reduced.nextIndexes, |
|
|
|
|
isRequesting: false, |
|
|
|
|
isSuccessful: true, |
|
|
|
|
hasError: null, |
|
|
|
|
returnInstructionIndexes: reduced.returnInstructionIndexes, |
|
|
|
|
outOfGasInstructionIndexes: reduced.outOfGasInstructionIndexes |
|
|
|
|
outOfGasInstructionIndexes: reduced.outOfGasInstructionIndexes, |
|
|
|
|
currentLineIndexes: reduced.currentLineIndexes |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
case 'FETCH_OPCODES_ERROR': { |
|
|
|
@ -73,6 +81,16 @@ export const reducer = (state = initialState, action: Action) => { |
|
|
|
|
hasError: action.payload |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
case 'FETCH_INDEXES_FOR_NEW_LINE': { |
|
|
|
|
let bottom = state.initialIndex - 10 |
|
|
|
|
bottom = bottom < 0 ? 0 : bottom |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
absoluteCurrentLineIndexes: action.payload.currentLineIndexes, |
|
|
|
|
currentLineIndexes: action.payload.currentLineIndexes.map(index => index - bottom), |
|
|
|
|
line: action.payload.line |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
throw new Error() |
|
|
|
|
} |
|
|
|
|