pull/2681/head
lianahus 2 years ago committed by Aniket
parent 9cb395beba
commit b238cbd718
  1. 2
      apps/remix-ide/src/app/tabs/debugger-tab.js
  2. 3
      apps/remix-ide/src/app/tabs/styles/debugger-tab-styles.js
  3. 4
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.css
  4. 84
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
  5. 2
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx

@ -51,7 +51,7 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) {
this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => { this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => {
this.call('notification', 'toast', sourceVerificationNotAvailableToastMsg()) this.call('notification', 'toast', sourceVerificationNotAvailableToastMsg())
}) })
return <div className={css.debuggerTabView} id='debugView'><DebuggerUI debuggerAPI={this} /></div> return <div className="overflow-hidden px-1" id='debugView'><DebuggerUI debuggerAPI={this} /></div>
} }
showMessage (title, message) { showMessage (title, message) {

@ -1,9 +1,6 @@
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
const css = csjs` const css = csjs`
.debuggerTabView {
padding: 2%;
}
.debugger { .debugger {
margin-bottom: 1%; margin-bottom: 1%;
} }

@ -16,4 +16,8 @@
} }
.validationError { .validationError {
overflow-wrap: break-word; overflow-wrap: break-word;
}
.debuggerPanels {
overflow-y: scroll;
height: fit-content;
} }

@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react' // eslint-disable-line import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line
import TxBrowser from './tx-browser/tx-browser' // eslint-disable-line import TxBrowser from './tx-browser/tx-browser' // eslint-disable-line
import StepManager from './step-manager/step-manager' // eslint-disable-line import StepManager from './step-manager/step-manager' // eslint-disable-line
import VmDebugger from './vm-debugger/vm-debugger' // eslint-disable-line import VmDebugger from './vm-debugger/vm-debugger' // eslint-disable-line
@ -36,6 +36,28 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
sourceLocationStatus: '' sourceLocationStatus: ''
}) })
const panelsRef = useRef<HTMLDivElement>(null)
const debuggerTopRef = useRef(null)
const handleResize = () => {
if (panelsRef.current && debuggerTopRef.current) {
panelsRef.current.style.height = (window.innerHeight - debuggerTopRef.current.clientHeight) - debuggerTopRef.current.offsetTop - 7 +'px'
}
}
useEffect(() => {
handleResize()
})
useEffect(() => {
window.addEventListener('resize', handleResize)
// TODO: not a good way to wait on the ref doms element to be rendered of course
setTimeout(() =>
handleResize(), 2000)
return () => window.removeEventListener('resize', handleResize)
}, [])
useEffect(() => { useEffect(() => {
return unLoad() return unLoad()
}, []) }, [])
@ -260,34 +282,35 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
}) })
setTimeout(async() => { setTimeout(async() => {
try { try {
await debuggerInstance.debug(blockNumber, txNumber, tx, () => { await debuggerInstance.debug(blockNumber, txNumber, tx, () => {
listenToEvents(debuggerInstance, currentReceipt) listenToEvents(debuggerInstance, currentReceipt)
setState(prevState => {
return {
...prevState,
blockNumber,
txNumber,
debugging: true,
currentReceipt,
currentBlock,
currentTransaction,
debugger: debuggerInstance,
toastMessage: `debugging ${txNumber}`,
validationError: ''
}
})
})
} catch (error) {
unLoad()
setState(prevState => { setState(prevState => {
return { return {
...prevState, ...prevState,
blockNumber, validationError: error.message || error
txNumber,
debugging: true,
currentReceipt,
currentBlock,
currentTransaction,
debugger: debuggerInstance,
toastMessage: `debugging ${txNumber}`,
validationError: ''
} }
}) })
}) }
} catch (error) { }, 300)
unLoad() handleResize()
setState(prevState => {
return {
...prevState,
validationError: error.message || error
}
})
}
}, 300)
} }
const debug = (txHash, web3?) => { const debug = (txHash, web3?) => {
@ -315,17 +338,18 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
traceLength: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.traceLength : null, traceLength: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.traceLength : null,
registerEvent: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.event.register.bind(state.debugger.step_manager.event) : null registerEvent: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.event.register.bind(state.debugger.step_manager.event) : null
} }
const vmDebugger = { const vmDebugger = {
registerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.register.bind(state.debugger.vmDebuggerLogic.event) : null, registerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.register.bind(state.debugger.vmDebuggerLogic.event) : null,
triggerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.trigger.bind(state.debugger.vmDebuggerLogic.event) : null triggerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.trigger.bind(state.debugger.vmDebuggerLogic.event) : null
} }
return ( return (
<div> <div>
<Toaster message={state.toastMessage} /> <Toaster message={state.toastMessage} />
<div className="px-2"> <div className="px-2" ref={debuggerTopRef}>
<div> <div>
<p className="my-2 debuggerLabel">Debugger Configuration</p> <div className="mb-2 debuggerConfig custom-control custom-checkbox">
<div className="mt-2 mb-2 debuggerConfig custom-control custom-checkbox">
<input className="custom-control-input" id="debugGeneratedSourcesInput" onChange={({ target: { checked } }) => { <input className="custom-control-input" id="debugGeneratedSourcesInput" onChange={({ target: { checked } }) => {
setState(prevState => { setState(prevState => {
return { ...prevState, opt: { ...prevState.opt, debugWithGeneratedSources: checked } } return { ...prevState, opt: { ...prevState.opt, debugWithGeneratedSources: checked } }
@ -333,7 +357,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
}} type="checkbox" title="Debug with generated sources" /> }} type="checkbox" title="Debug with generated sources" />
<label data-id="debugGeneratedSourcesLabel" className="form-check-label custom-control-label" htmlFor="debugGeneratedSourcesInput">Use generated sources (Solidity {'>='} v0.7.2)</label> <label data-id="debugGeneratedSourcesLabel" className="form-check-label custom-control-label" htmlFor="debugGeneratedSourcesInput">Use generated sources (Solidity {'>='} v0.7.2)</label>
</div> </div>
{ state.isLocalNodeUsed && <div className="mt-2 mb-2 debuggerConfig custom-control custom-checkbox"> { state.isLocalNodeUsed && <div className="mb-2 debuggerConfig custom-control custom-checkbox">
<input className="custom-control-input" id="debugWithLocalNodeInput" onChange={({ target: { checked } }) => { <input className="custom-control-input" id="debugWithLocalNodeInput" onChange={({ target: { checked } }) => {
setState(prevState => { setState(prevState => {
return { ...prevState, opt: { ...prevState.opt, debugWithLocalNode: checked } } return { ...prevState, opt: { ...prevState.opt, debugWithLocalNode: checked } }
@ -356,9 +380,11 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
</span> </span>
</div> } </div> }
{ state.debugging && <StepManager stepManager={ stepManager } /> } { state.debugging && <StepManager stepManager={ stepManager } /> }
</div>
<div className="debuggerPanels" ref={panelsRef}>
{ state.debugging && <VmDebuggerHead vmDebugger={ vmDebugger } /> } { state.debugging && <VmDebuggerHead vmDebugger={ vmDebugger } /> }
{ state.debugging && <VmDebugger vmDebugger={ vmDebugger } currentBlock={ state.currentBlock } currentReceipt={ state.currentReceipt } currentTransaction={ state.currentTransaction } /> }
</div> </div>
{ state.debugging && <VmDebugger vmDebugger={ vmDebugger } currentBlock={ state.currentBlock } currentReceipt={ state.currentReceipt } currentTransaction={ state.currentTransaction } /> }
</div> </div>
) )
} }

@ -98,7 +98,7 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } })
}, [registerEvent]) }, [registerEvent])
return ( return (
<div id='vmheadView' className="mt-1 px-0"> <div id='vmheadView' className="mt-1 px-2">
<div className='d-flex flex-column'> <div className='d-flex flex-column'>
<div className='w-100'> <div className='w-100'>
<FunctionPanel data={functionPanel} /> <FunctionPanel data={functionPanel} />

Loading…
Cancel
Save