|
|
|
@ -5,7 +5,7 @@ import StepDetail from './step-detail' |
|
|
|
|
import SolidityState from './solidity-state' |
|
|
|
|
import SolidityLocals from './solidity-locals' |
|
|
|
|
|
|
|
|
|
export const VmDebuggerHead = ({ vmDebuggerLogic, ready }) => { |
|
|
|
|
export const VmDebuggerHead = ({ vmDebuggerHead: { registerEvent } }) => { |
|
|
|
|
const [asm, setAsm] = useState({ |
|
|
|
|
code: null, |
|
|
|
|
address: null, |
|
|
|
@ -30,101 +30,97 @@ export const VmDebuggerHead = ({ vmDebuggerLogic, ready }) => { |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
console.log('vmDebuggerLogicHead: ', vmDebuggerLogic) |
|
|
|
|
if (vmDebuggerLogic) { |
|
|
|
|
vmDebuggerLogic.event.register('codeManagerChanged', (code, address, index) => { |
|
|
|
|
setAsm(() => { |
|
|
|
|
return { code, address, index } |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('codeManagerChanged', (code, address, index) => { |
|
|
|
|
setAsm(() => { |
|
|
|
|
return { code, address, index } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceUnloaded', () => { |
|
|
|
|
setAsm(() => { |
|
|
|
|
return { code: [], address: '', index: -1 } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceUnloaded', () => { |
|
|
|
|
setAsm(() => { |
|
|
|
|
return { code: [], address: '', index: -1 } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('functionsStackUpdate', (stack) => { |
|
|
|
|
if (stack === null || stack.length === 0) return |
|
|
|
|
const functions = [] |
|
|
|
|
|
|
|
|
|
for (const func of stack) { |
|
|
|
|
functions.push(func.functionDefinition.name + '(' + func.inputs.join(', ') + ')') |
|
|
|
|
} |
|
|
|
|
setFunctionPanel(() => functions) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('functionsStackUpdate', (stack) => { |
|
|
|
|
if (stack === null || stack.length === 0) return |
|
|
|
|
const functions = [] |
|
|
|
|
|
|
|
|
|
for (const func of stack) { |
|
|
|
|
functions.push(func.functionDefinition.name + '(' + func.inputs.join(', ') + ')') |
|
|
|
|
} |
|
|
|
|
setFunctionPanel(() => functions) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceUnloaded', () => { |
|
|
|
|
setStepDetail(() => { |
|
|
|
|
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceUnloaded', () => { |
|
|
|
|
setStepDetail(() => { |
|
|
|
|
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('newTraceLoaded', () => { |
|
|
|
|
setStepDetail(() => { |
|
|
|
|
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('newTraceLoaded', () => { |
|
|
|
|
setStepDetail(() => { |
|
|
|
|
return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceCurrentStepUpdate', (error, step) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'execution step': (error ? '-' : step) } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceCurrentStepUpdate', (error, step) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'execution step': (error ? '-' : step) } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceMemExpandUpdate', (error, addmem) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'add memory': (error ? '-' : addmem) } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceMemExpandUpdate', (error, addmem) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'add memory': (error ? '-' : addmem) } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceStepCostUpdate', (error, gas) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'gas': (error ? '-' : gas) } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceStepCostUpdate', (error, gas) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'gas': (error ? '-' : gas) } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceCurrentCalledAddressAtUpdate', (error, address) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'loaded address': (error ? '-' : address) } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceCurrentCalledAddressAtUpdate', (error, address) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'loaded address': (error ? '-' : address) } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('traceRemainingGasUpdate', (error, remainingGas) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'remaining gas': (error ? '-' : remainingGas) } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('traceRemainingGasUpdate', (error, remainingGas) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'remaining gas': (error ? '-' : remainingGas) } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('indexUpdate', (index) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'vm trace step': index } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('indexUpdate', (index) => { |
|
|
|
|
setStepDetail(prevState => { |
|
|
|
|
return { ...prevState, 'vm trace step': index } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('solidityState', (calldata) => { |
|
|
|
|
setSolidityState(() => { |
|
|
|
|
return { ...solidityState, calldata } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('solidityState', (calldata) => { |
|
|
|
|
setSolidityState(() => { |
|
|
|
|
return { ...solidityState, calldata } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('solidityStateMessage', (message) => { |
|
|
|
|
setSolidityState(() => { |
|
|
|
|
return { ...solidityState, message } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('solidityStateMessage', (message) => { |
|
|
|
|
setSolidityState(() => { |
|
|
|
|
return { ...solidityState, message } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('solidityLocals', (calldata) => { |
|
|
|
|
setSolidityLocals(() => { |
|
|
|
|
return { ...solidityLocals, calldata } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('solidityLocals', (calldata) => { |
|
|
|
|
setSolidityLocals(() => { |
|
|
|
|
return { ...solidityLocals, calldata } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
registerEvent && registerEvent('solidityLocalsMessage', (message) => { |
|
|
|
|
setSolidityLocals(() => { |
|
|
|
|
return { ...solidityLocals, message } |
|
|
|
|
}) |
|
|
|
|
vmDebuggerLogic.event.register('solidityLocalsMessage', (message) => { |
|
|
|
|
setSolidityLocals(() => { |
|
|
|
|
return { ...solidityLocals, message } |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
ready() |
|
|
|
|
} |
|
|
|
|
}, [vmDebuggerLogic]) |
|
|
|
|
}) |
|
|
|
|
}, [registerEvent]) |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div id="vmheadView" className="mt-1 px-0"> |
|
|
|
|
<div className="d-flex flex-column"> |
|
|
|
|
<div className="w-100"> |
|
|
|
|
<FunctionPanel calldata={functionPanel} /> |
|
|
|
|
<SolidityLocals calldata={solidityLocals.calldata} message={solidityLocals.message} /> |
|
|
|
|
<SolidityState calldata={solidityState.calldata} message={solidityState.message} /> |
|
|
|
|
<FunctionPanel data={functionPanel} /> |
|
|
|
|
{/* <SolidityLocals calldata={solidityLocals.calldata} message={solidityLocals.message} /> |
|
|
|
|
<SolidityState calldata={solidityState.calldata} message={solidityState.message} /> */} |
|
|
|
|
</div> |
|
|
|
|
<div className="w-100"><CodeListView asm={asm} /></div> |
|
|
|
|
<div className="w-100"><StepDetail stepDetail={stepDetail} /></div> |
|
|
|
|
{/* <div className="w-100"><CodeListView asm={asm} /></div> |
|
|
|
|
<div className="w-100"><StepDetail stepDetail={stepDetail} /></div> */} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|