Resolved bugs in step manager

pull/5370/head
ioedeveloper 4 years ago
parent 955f57a873
commit 13c4487491
  1. 4
      libs/remix-ui/debugger-ui/src/lib/button-navigator/button-navigator.tsx
  2. 12
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
  3. 42
      libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx
  4. 33
      libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx
  5. 21
      libs/remix-ui/debugger-ui/src/lib/tx-browser/tx-browser.tsx

@ -44,8 +44,8 @@ export const ButtonNavigation = ({ stepManager, revertedReason, stepState, jumpO
jumpPreviousBreakpointDisabled: stepState === 'initial', jumpPreviousBreakpointDisabled: stepState === 'initial',
intoForwardDisabled: stepState === 'end', intoForwardDisabled: stepState === 'end',
overForwardDisabled: stepState === 'end', overForwardDisabled: stepState === 'end',
jumpNextBreakpointDisabled: jumpOutDisabled, jumpNextBreakpointDisabled: jumpOutDisabled ? jumpOutDisabled : stepState === 'end',
jumpOutDisabled jumpOutDisabled: jumpOutDisabled ? jumpOutDisabled : true
} }
}) })
} }

@ -27,7 +27,7 @@ export const DebuggerUI = ({ debuggerModule, fetchContractAndCompile, debugHash,
to: null to: null
}, },
blockNumber: null, blockNumber: null,
txNumber: null, txNumber: '',
visibility: { visibility: {
vmDebugger: false, vmDebugger: false,
stepManager: false, stepManager: false,
@ -74,7 +74,9 @@ export const DebuggerUI = ({ debuggerModule, fetchContractAndCompile, debugHash,
debuggerInstance.event.register('debuggerStatus', async (isActive) => { debuggerInstance.event.register('debuggerStatus', async (isActive) => {
await debuggerModule.call('editor', 'discardHighlight') await debuggerModule.call('editor', 'discardHighlight')
setState({ ...state, isActive }) setState( prevState => {
return { ...prevState, isActive }
})
}) })
debuggerInstance.event.register('newSourceLocation', async (lineColumnPos, rawLocation) => { debuggerInstance.event.register('newSourceLocation', async (lineColumnPos, rawLocation) => {
@ -192,7 +194,9 @@ const getTrace = (hash) => {
const web3 = await getDebugWeb3() const web3 = await getDebugWeb3()
const currentReceipt = await web3.eth.getTransactionReceipt(hash) const currentReceipt = await web3.eth.getTransactionReceipt(hash)
setState({ ...state, currentReceipt }) setState(prevState => {
return { ...prevState, currentReceipt }
})
const debug = new Debugger({ const debug = new Debugger({
web3, web3,
@ -224,7 +228,7 @@ const deleteHighlights = async () => {
return ( return (
<div> <div>
<div className="px-2"> <div className="px-2">
<TxBrowser requestDebug={requestDebug} unloadRequested={unloadRequested} transactionNumber={state.txNumber} /> <TxBrowser requestDebug={requestDebug} unloadRequested={unloadRequested} transactionNumber={state.txNumber} debugging={state.debugging} />
<StepManager stepManager={state.debugger ? state.debugger.step_manager : null} /> <StepManager stepManager={state.debugger ? state.debugger.step_manager : null} />
{/*<VmDebuggerHead vmDebuggerLogic={state.debugger.vmDebuggerLogic} /> */} {/*<VmDebuggerHead vmDebuggerLogic={state.debugger.vmDebuggerLogic} /> */}
</div> </div>

@ -1,46 +1,26 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
export const Slider = ({ stepManager, sliderLength, sliderValue }) => { export const Slider = ({ stepManager, sliderValue }) => {
const [state, setState] = useState({ const [state, setState] = useState({
max: null, currentValue: ''
disabled: true,
previousValue: null,
currentValue: null
}) })
useEffect(() => {
setState(prevState => {
return {
...prevState,
max: sliderLength - 1,
disabled: (sliderLength === 0)
}
})
setValue(0)
}, [sliderLength])
useEffect(() => { useEffect(() => {
setValue(sliderValue) setValue(sliderValue)
}, [sliderValue]) }, [sliderValue])
const setValue = (value) => { const setValue = (value) => {
setState({ ...state, currentValue: value }) if (value === state.currentValue) return
setState(prevState => {
return { ...prevState, currentValue: value }
})
stepManager && stepManager.jumpTo(value)
} }
const handleChange = (e) => { const handleChange = (e) => {
console.log('e.target: ', e.target)
const value = parseInt(e.target.value) const value = parseInt(e.target.value)
if (value === state.previousValue) return setValue(value)
setState(prevState => {
return {
...prevState,
previousValue: value,
currentValue: value
}
})
stepManager.jumpTo(value)
} }
return ( return (
@ -50,10 +30,10 @@ export const Slider = ({ stepManager, sliderLength, sliderValue }) => {
className='w-100 my-0' className='w-100 my-0'
type='range' type='range'
min={0} min={0}
max={state.max} max={stepManager ? stepManager.traceLength - 1 : 0}
defaultValue={state.currentValue} value={state.currentValue}
onChange={handleChange} onChange={handleChange}
disabled={state.disabled} disabled={stepManager ? stepManager.traceLength === 0 : true}
/> />
</div> </div>
) )

@ -4,7 +4,6 @@ import ButtonNavigator from '../button-navigator/button-navigator'
export const StepManager = ({ stepManager }) => { export const StepManager = ({ stepManager }) => {
const [state, setState] = useState({ const [state, setState] = useState({
sliderLength: null,
sliderValue: 0, sliderValue: 0,
revertWarning: '', revertWarning: '',
stepState: '', stepState: '',
@ -12,45 +11,27 @@ export const StepManager = ({ stepManager }) => {
}) })
useEffect(() => { useEffect(() => {
stepManager.event.register('traceLengthChanged', setSliderLength) stepManager && stepManager.event.register('revertWarning', setRevertWarning)
stepManager.event.register('revertWarning', setRevertWarning) stepManager && stepManager.event.register('stepChanged', updateStep)
stepManager.event.register('stepChanged', updateStep) }, [stepManager])
}, [])
const setSliderLength = (length) => {
setState(prevState => {
return {
...prevState,
sliderLength: length
}
})
}
const setRevertWarning = (warning) => { const setRevertWarning = (warning) => {
setState(prevState => { setState(prevState => {
return { return { ...prevState, revertWarning: warning }
...prevState,
revertWarning: warning
}
}) })
} }
const updateStep = (step, stepState, jumpOutDisabled) => { const updateStep = (step, stepState, jumpOutDisabled) => {
setState(prevState => { setState(prevState => {
return { return { ...prevState, sliderValue: step, stepState, jumpOutDisabled }
...prevState,
sliderValue: step,
stepState,
jumpOutDisabled
}
}) })
} }
const { sliderLength, sliderValue, revertWarning, stepState, jumpOutDisabled } = state const { sliderValue, revertWarning, stepState, jumpOutDisabled } = state
return ( return (
<div className="py-1"> <div className="py-1">
<Slider stepManager={stepManager} sliderLength={sliderLength} sliderValue={sliderValue} /> <Slider stepManager={stepManager} sliderValue={sliderValue} />
<ButtonNavigator stepManager={stepManager} revertedReason={revertWarning} stepState={stepState} jumpOutDisabled={jumpOutDisabled} /> <ButtonNavigator stepManager={stepManager} revertedReason={revertWarning} stepState={stepState} jumpOutDisabled={jumpOutDisabled} />
</div> </div>
) )

@ -1,10 +1,9 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import './tx-browser.css' import './tx-browser.css'
export const TxBrowser = ({ requestDebug, unloadRequested, transactionNumber }) => { export const TxBrowser = ({ requestDebug, unloadRequested, transactionNumber, debugging }) => {
const [state, setState] = useState({ const [state, setState] = useState({
txNumber: undefined, txNumber: ''
debugging: false
}) })
useEffect(() => { useEffect(() => {
@ -17,7 +16,7 @@ export const TxBrowser = ({ requestDebug, unloadRequested, transactionNumber })
}, [transactionNumber]) }, [transactionNumber])
const handleSubmit = () => { const handleSubmit = () => {
if (state.debugging) { if (debugging) {
unload() unload()
} else { } else {
requestDebug(undefined, state.txNumber) requestDebug(undefined, state.txNumber)
@ -44,30 +43,30 @@ export const TxBrowser = ({ requestDebug, unloadRequested, transactionNumber })
} }
return ( return (
<div className="container"> <div className="container px-0">
<div className="txContainer"> <div className="txContainer">
<div className="py-1 d-flex justify-content-center w-100 input-group"> <div className="py-1 d-flex justify-content-center w-100 input-group">
<input <input
defaultValue={state.txNumber || ''} value={state.txNumber}
className="form-control m-0 css.txinput" className="form-control m-0 txinput"
id='txinput' id='txinput'
type='text' type='text'
onChange={txInputChanged} onChange={txInputChanged}
placeholder={'Transaction hash, should start with 0x'} placeholder={'Transaction hash, should start with 0x'}
data-id="debuggerTransactionInput" data-id="debuggerTransactionInput"
disabled={state.debugging} disabled={debugging}
/> />
</div> </div>
<div className="d-flex justify-content-center w-100 btn-group py-1"> <div className="d-flex justify-content-center w-100 btn-group py-1">
<button <button
className="btn btn-primary btn-sm txbutton" className="btn btn-primary btn-sm txbutton"
id="load" id="load"
title={state.debugging ? 'Stop debugging' : 'Start debugging'} title={debugging ? 'Stop debugging' : 'Start debugging'}
onClick={handleSubmit} onClick={handleSubmit}
data-id="debuggerTransactionStartButton" data-id="debuggerTransactionStartButton"
disabled={!state.txNumber ? true : !state.debugging ? false : true } disabled={!state.txNumber ? true : !debugging ? true : false }
> >
{ state.debugging ? 'Stop' : 'Start' } debugging { debugging ? 'Stop' : 'Start' } debugging
</button> </button>
</div> </div>
</div> </div>

Loading…
Cancel
Save