Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Misieq01 committed Nov 29, 2023
1 parent bb6a5d5 commit 60f4095
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@ export const StructlogPanel: React.FC<StructlogPanelProps> = () => {

const structlogsArray = useMemo(() => Object.values(structLogs), [structLogs])

const previousTrace = React.useRef(null)
// const previousTrace = React.useRef(null)

const setActiveStructlog = useCallback(
(index: number) => {
if (
structLogs[index].op === 'CALL' ||
structLogs[index].op === 'DELEGATECALL' ||
structLogs[index].op === 'STATICCALL' ||
structLogs[index].op === 'CREATE' ||
structLogs[index].op === 'CREATE2'
) {
dispatch(activeBlockActions.loadActiveBlock(traceLogs.find((traceLog) => traceLog.index === structLogs[index].index)))
return
}
if (structLogs[index].op === 'RETURN' || structLogs[index].op === 'REVERT') {
const currentBlockArrayIndex = traceLogs.findIndex((traceLog) => traceLog.index === structlogsArray[0].index - 1)
const currentBlock = traceLogs[currentBlockArrayIndex]
const previousBlock = traceLogs
.slice(0, currentBlockArrayIndex)
.filter((trace) => trace.depth === currentBlock.depth - 1)
.pop()
dispatch(activeBlockActions.loadActiveBlock(previousBlock))
previousTrace.current = index + 1
return
}
// if (
// structLogs[index].op === 'CALL' ||
// structLogs[index].op === 'DELEGATECALL' ||
// structLogs[index].op === 'STATICCALL' ||
// structLogs[index].op === 'CREATE' ||
// structLogs[index].op === 'CREATE2'
// ) {
// dispatch(activeBlockActions.loadActiveBlock(traceLogs.find((traceLog) => traceLog.index === structLogs[index].index)))
// return
// }
// if (structLogs[index].op === 'RETURN' || structLogs[index].op === 'REVERT') {
// const currentBlockArrayIndex = traceLogs.findIndex((traceLog) => traceLog.index === structlogsArray[0].index - 1)
// const currentBlock = traceLogs[currentBlockArrayIndex]
// const previousBlock = traceLogs
// .slice(0, currentBlockArrayIndex)
// .filter((trace) => trace.depth === currentBlock.depth - 1)
// .pop()
// dispatch(activeBlockActions.loadActiveBlock(previousBlock))
// previousTrace.current = index + 1
// return
// }
dispatch(activeStructLogActions.setActiveStrucLog(index))
},
[dispatch, structLogs, structlogsArray, traceLogs],
[dispatch],
)

useEffect(() => {
if (activeStructlog === undefined && structlogsArray.length > 0) {
if (previousTrace.current) {
dispatch(activeStructLogActions.setActiveStrucLog(previousTrace.current))
previousTrace.current = null
return
}
// if (previousTrace.current) {
// dispatch(activeStructLogActions.setActiveStrucLog(previousTrace.current))
// previousTrace.current = null
// return
// }
dispatch(activeStructLogActions.setActiveStrucLog(structlogsArray[0].index))
}
}, [activeStructlog, structlogsArray, setActiveStructlog, dispatch])
}, [activeStructlog, structlogsArray, dispatch])

useEffect(() => {
if (activeStructlog && currentInstructions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSelector } from 'react-redux'
import { activeBlockSelectors } from '../../store/activeBlock/activeBlock.selector'
import { TraceLogsList } from '../../components/TraceLogsList'

import { BytecodePanel, SourceCodePanel, StructlogPanel } from './Panels'
import { BytecodePanel, InformationPanel, SourceCodePanel, StructlogPanel } from './Panels'
import { NotAContractHero } from './TransactionExplorer.styles'
import { LayoutKeys, readLayoutFromLocalStorage, saveLayoutToLocalStorage } from './TransactionExplorer.utils'

Expand All @@ -21,40 +21,49 @@ export const TransactionExplorer: React.FC = () => {
const BytecodeLayoutFromLocalStorage = readLayoutFromLocalStorage(LayoutKeys.BytecodeLayout)
const BytecodeLayout: Layout = BytecodeLayoutFromLocalStorage || {
y: 0,
x: 4,
x: 3,
w: 2,
i: LayoutKeys.BytecodeLayout,
h: 20,
h: 21,
}

const SourceCodeLayoutFromLocalStorage = readLayoutFromLocalStorage(LayoutKeys.SourceCodeLayout)
const SourceCodeLayout: Layout = SourceCodeLayoutFromLocalStorage || {
y: 0,
x: 6,
w: 6,
x: 8,
w: 4,
i: LayoutKeys.SourceCodeLayout,
h: 20,
h: 21,
}

const StructlogLayoutFromLocalStorage = readLayoutFromLocalStorage(LayoutKeys.StructlogLayout)
const StructlogLayout: Layout = StructlogLayoutFromLocalStorage || {
y: 0,
x: 2,
w: 2,
x: 5,
w: 3,
i: LayoutKeys.StructlogLayout,
h: 20,
h: 21,
}

const TraceLogListLayoutFromLocalStorage = readLayoutFromLocalStorage(LayoutKeys.TracelogListLayout)
const TraceLogListLayout: Layout = TraceLogListLayoutFromLocalStorage || {
y: 0,
x: 0,
w: 2,
w: 3,
i: LayoutKeys.TracelogListLayout,
h: 20,
h: 9,
}

const InformationPanelFromLocalStorage = readLayoutFromLocalStorage(LayoutKeys.InformationPanelLayout)
const InformationPanelLayout: Layout = InformationPanelFromLocalStorage || {
y: 9,
x: 0,
w: 3,
i: LayoutKeys.InformationPanelLayout,
h: 12,
}

return [BytecodeLayout, SourceCodeLayout, StructlogLayout, TraceLogListLayout]
return [BytecodeLayout, SourceCodeLayout, StructlogLayout, TraceLogListLayout, InformationPanelLayout]
}, [])

React.useEffect(() => {
Expand Down Expand Up @@ -98,6 +107,9 @@ export const TransactionExplorer: React.FC = () => {
<div key={LayoutKeys.StructlogLayout}>
<StructlogPanel />
</div>
<div key={LayoutKeys.InformationPanelLayout}>
<InformationPanel />
</div>
</GridLayout>
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum LayoutKeys {
SourceCodeLayout = 'SourceCodepanel',
StructlogLayout = 'StructlogPanel',
TracelogListLayout = 'TracelogListLayout',
InformationPanelLayout = 'InformationPanelLayout',
}

export const saveLayoutToLocalStorage = (layout: Layout): void => {
Expand Down

0 comments on commit 60f4095

Please sign in to comment.