|
|
@ -5,7 +5,6 @@ import VmDebugger from './vm-debugger/vm-debugger' |
|
|
|
import VmDebuggerHead from './vm-debugger/vm-debugger-head' |
|
|
|
import VmDebuggerHead from './vm-debugger/vm-debugger-head' |
|
|
|
import { TransactionDebugger as Debugger } from '@remix-project/remix-debug' |
|
|
|
import { TransactionDebugger as Debugger } from '@remix-project/remix-debug' |
|
|
|
import { DebuggerAPI, DebuggerUIProps } from './DebuggerAPI' |
|
|
|
import { DebuggerAPI, DebuggerUIProps } from './DebuggerAPI' |
|
|
|
import { ModalDialog } from '@remix-ui/modal-dialog' |
|
|
|
|
|
|
|
/* eslint-disable-next-line */ |
|
|
|
/* eslint-disable-next-line */ |
|
|
|
import './debugger-ui.css' |
|
|
|
import './debugger-ui.css' |
|
|
|
|
|
|
|
|
|
|
@ -24,11 +23,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
debugging: false, |
|
|
|
debugging: false, |
|
|
|
opt: { |
|
|
|
opt: { |
|
|
|
debugWithGeneratedSources: false |
|
|
|
debugWithGeneratedSources: false |
|
|
|
}, |
|
|
|
|
|
|
|
showModal: false, |
|
|
|
|
|
|
|
modalOpt: { |
|
|
|
|
|
|
|
title: '', |
|
|
|
|
|
|
|
message: '' |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -53,11 +47,13 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
editor.event.register('breakpointCleared', (fileName, row) => { |
|
|
|
editor.event.register('breakpointCleared', (fileName, row) => { |
|
|
|
if (state.debugger) state.debugger.breakPointManager.remove({fileName: fileName, row: row}) |
|
|
|
if (state.debugger) state.debugger.breakPointManager.remove({fileName: fileName, row: row}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
editor.event.register('breakpointAdded', (fileName, row) => { |
|
|
|
editor.event.register('breakpointAdded', (fileName, row) => { |
|
|
|
if (state.debugger) { |
|
|
|
if (state.debugger) { |
|
|
|
state.debugger.breakPointManager.add({fileName: fileName, row: row}) |
|
|
|
state.debugger.breakPointManager.add({fileName: fileName, row: row}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
editor.event.register('contentChanged', () => { |
|
|
|
editor.event.register('contentChanged', () => { |
|
|
|
unLoad() |
|
|
|
unLoad() |
|
|
|
}) |
|
|
|
}) |
|
|
@ -93,7 +89,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
content = await debuggerModule.getFile(path) |
|
|
|
content = await debuggerModule.getFile(path) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
showMsg('Error', e.message) |
|
|
|
|
|
|
|
console.log('unable to fetch generated sources, the file probably doesn\'t exist yet', e) |
|
|
|
console.log('unable to fetch generated sources, the file probably doesn\'t exist yet', e) |
|
|
|
} |
|
|
|
} |
|
|
|
if (content !== source.contents) { |
|
|
|
if (content !== source.contents) { |
|
|
@ -121,6 +116,10 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
unLoad() |
|
|
|
unLoad() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isDebuggerActive = () => { |
|
|
|
|
|
|
|
return state.isActive |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const unLoad = () => { |
|
|
|
const unLoad = () => { |
|
|
|
if (state.debugger) state.debugger.unload() |
|
|
|
if (state.debugger) state.debugger.unload() |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
@ -147,13 +146,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
if (state.debugger) unLoad() |
|
|
|
if (state.debugger) unLoad() |
|
|
|
if (!txNumber) return |
|
|
|
if (!txNumber) return |
|
|
|
const web3 = await debuggerModule.getDebugWeb3() |
|
|
|
const web3 = await debuggerModule.getDebugWeb3() |
|
|
|
let currentReceipt |
|
|
|
const currentReceipt = await web3.eth.getTransactionReceipt(txNumber) |
|
|
|
try { |
|
|
|
|
|
|
|
currentReceipt = await web3.eth.getTransactionReceipt(txNumber) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
showMsg('Error', e.message) |
|
|
|
|
|
|
|
console.log('cant get tx', e.message) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const debuggerInstance = new Debugger({ |
|
|
|
const debuggerInstance = new Debugger({ |
|
|
|
web3, |
|
|
|
web3, |
|
|
|
offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter, |
|
|
|
offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter, |
|
|
@ -161,8 +154,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return await debuggerModule.fetchContractAndCompile(address, currentReceipt) |
|
|
|
return await debuggerModule.fetchContractAndCompile(address, currentReceipt) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
showMsg('Error', e.message) |
|
|
|
|
|
|
|
console.log('cant fetch tx') |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
console.error(e) |
|
|
|
} |
|
|
|
} |
|
|
|
return null |
|
|
|
return null |
|
|
@ -181,7 +172,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
debugger: debuggerInstance |
|
|
|
debugger: debuggerInstance |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}).catch(() => { |
|
|
|
}).catch((error) => { |
|
|
|
|
|
|
|
// toaster(error, null, null)
|
|
|
|
unLoad() |
|
|
|
unLoad() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -189,21 +181,13 @@ export const DebuggerUI = (props: DebuggerUIProps) => { |
|
|
|
const debug = (txHash) => { |
|
|
|
const debug = (txHash) => { |
|
|
|
startDebugging(null, txHash, null) |
|
|
|
startDebugging(null, txHash, null) |
|
|
|
} |
|
|
|
} |
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const deleteHighlights = async () => { |
|
|
|
const deleteHighlights = async () => { |
|
|
|
await debuggerModule.discardHighlight() |
|
|
|
await debuggerModule.discardHighlight() |
|
|
|
} |
|
|
|
} |
|
|
|
======= |
|
|
|
|
|
|
|
const deleteHighlights = async () => { |
|
|
|
|
|
|
|
await debuggerModule.call('editor', 'discardHighlight') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
>>>>>>> 1b1d8f0c7... modal dialog in react |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>>>>>>> c941558da... fixing conflict |
|
|
|
|
|
|
|
const stepManager = { |
|
|
|
const stepManager = { |
|
|
|
jumpTo: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpTo.bind(state.debugger.step_manager) : null, |
|
|
|
jumpTo: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpTo.bind(state.debugger.step_manager) : null, |
|
|
|
stepOverBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverBack.bind(state.debugger.step_manager) : null, |
|
|
|
stepOverBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverBack.bind(state.debugger.step_manager) : null, |
|
|
@ -222,47 +206,25 @@ const deleteHighlights = async () => { |
|
|
|
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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const hideModal = () => { |
|
|
|
|
|
|
|
setState((prevState) => { return { ...prevState, showModal: false } }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const showMsg = (title, message) => { |
|
|
|
|
|
|
|
setState((prevState) => { return { ...prevState, showModal: true, modalOpt: { title, message } } }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
{state.showModal && |
|
|
|
<div className="px-2"> |
|
|
|
<ModalDialog |
|
|
|
<div className="mt-3"> |
|
|
|
title={state.modalOpt.title} |
|
|
|
<p className="mt-2 debuggerLabel">Debugger Configuration</p> |
|
|
|
ok={{ label: 'Yes', fn: () => { console.log('OK') } }} |
|
|
|
<div className="mt-2 debuggerConfig custom-control custom-checkbox"> |
|
|
|
cancel={{ label: 'No', fn: () => { console.log('cancel') } }} |
|
|
|
<input className="custom-control-input" id="debugGeneratedSourcesInput" onChange={({ target: { checked } }) => { |
|
|
|
hide={hideModal} |
|
|
|
|
|
|
|
content={<span>{state.modalOpt.message} <textarea onKeyDown={(e) => { e.stopPropagation() }} name="" id="" cols="30" rows="10" /></span>} |
|
|
|
|
|
|
|
opts={{ class: 'p-2', hideClose: false }} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
<div className='px-2'> |
|
|
|
|
|
|
|
<div className='mt-3'> |
|
|
|
|
|
|
|
<p className='mt-2 debuggerLabel'>Debugger Configuration</p> |
|
|
|
|
|
|
|
<div className='mt-2 debuggerConfig custom-control custom-checkbox'> |
|
|
|
|
|
|
|
<input className='custom-control-input' id='debugGeneratedSourcesInput' onChange={({ target: { checked } }) => { |
|
|
|
|
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, opt: { debugWithGeneratedSources: checked }} |
|
|
|
return { ...prevState, opt: { debugWithGeneratedSources: checked }} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}} 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 (from Solidity v0.7.2)</label> |
|
|
|
<label data-id="debugGeneratedSourcesLabel" className="form-check-label custom-control-label" htmlFor="debugGeneratedSourcesInput">Use generated sources (from Solidity v0.7.2)</label> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<TxBrowser |
|
|
|
<TxBrowser requestDebug={ requestDebug } unloadRequested={ unloadRequested } transactionNumber={ state.txNumber } debugging={ state.debugging } /> |
|
|
|
requestDebug={ requestDebug } |
|
|
|
|
|
|
|
unloadRequested={ unloadRequested } |
|
|
|
|
|
|
|
transactionNumber={ state.txNumber } |
|
|
|
|
|
|
|
debugging={ state.debugging } |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
{ state.debugging && <StepManager stepManager={ stepManager } /> } |
|
|
|
{ state.debugging && <StepManager stepManager={ stepManager } /> } |
|
|
|
{ state.debugging && <VmDebuggerHead vmDebugger={ vmDebugger } /> } |
|
|
|
{ state.debugging && <VmDebuggerHead vmDebugger={ vmDebugger } /> } |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{ state.debugging && <div className='statusMessage'>{ state.statusMessage }</div> } |
|
|
|
{ state.debugging && <div className="statusMessage">{ state.statusMessage }</div> } |
|
|
|
{ state.debugging && <VmDebugger vmDebugger={ vmDebugger } /> } |
|
|
|
{ state.debugging && <VmDebugger vmDebugger={ vmDebugger } /> } |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|