@ -15,7 +15,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
const debuggerModule = props . debuggerAPI
const [ state , setState ] = useState ( {
isActive : false ,
statusMessage : '' ,
debugger : null ,
currentReceipt : {
contractAddress : null ,
@ -25,7 +24,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber : '' ,
debugging : false ,
opt : {
debugWithGeneratedSources : false
debugWithGeneratedSources : false ,
debugWithLocalNode : false
} ,
toastMessage : '' ,
validationError : '' ,
@ -132,7 +132,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return {
. . . prevState ,
isActive : false ,
statusMessage : '' ,
debugger : null ,
currentReceipt : {
contractAddress : null ,
@ -166,7 +165,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return
}
const web3 = await debuggerModule . getDebugWeb3 ( )
const web3 = state . opt . debugWithLocalNode ? await debuggerModule . web3 ( ) : await debuggerModule . getDebugWeb3 ( )
try {
const networkId = await web3 . eth . net . getId ( )
_paq . push ( [ 'trackEvent' , 'debugger' , 'startDebugging' , networkId ] )
@ -211,7 +210,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
debugWithGeneratedSources : state.opt.debugWithGeneratedSources
} )
debuggerInstance . debug ( blockNumber , txNumber , tx , ( ) = > {
try {
await debuggerInstance . debug ( blockNumber , txNumber , tx , ( ) = > {
listenToEvents ( debuggerInstance , currentReceipt )
setState ( prevState = > {
return {
@ -225,19 +225,16 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
validationError : ''
}
} )
} ) . catch ( ( error ) = > {
if ( JSON . stringify ( error ) !== '{}' ) {
let message = 'Error: ' + JSON . stringify ( error )
message = message . split ( '\\"' ) . join ( '\'' )
} )
} catch ( error ) {
unLoad ( )
setState ( prevState = > {
return {
. . . prevState ,
validationError : message
validationError : error. message || error
}
} )
}
unLoad ( )
} )
}
const debug = ( txHash ) = > {
@ -277,18 +274,25 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
< div className = "mt-2 mb-2 debuggerConfig custom-control custom-checkbox" >
< input className = "custom-control-input" id = "debugGeneratedSourcesInput" onChange = { ( { target : { checked } } ) = > {
setState ( prevState = > {
return { . . . prevState , opt : { debugWithGeneratedSources : checked } }
return { . . . prevState , opt : { . . . prevState . opt , debugWithGeneratedSources : checked } }
} )
} } 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 >
< / div >
< div className = "mt-2 mb-2 debuggerConfig custom-control custom-checkbox" >
< input className = "custom-control-input" id = "debugWithLocalNodeInput" onChange = { ( { target : { checked } } ) = > {
setState ( prevState = > {
return { . . . prevState , opt : { . . . prevState . opt , debugWithLocalNode : checked } }
} )
} } type = "checkbox" title = "Force the debugger to use the current local node" / >
< label data - id = "debugLocaNodeLabel" className = "form-check-label custom-control-label" htmlFor = "debugWithLocalNodeInput" > Force using local node < / label >
< / div >
{ state . validationError && < span className = "w-100 py-1 text-danger validationError" > { state . validationError } < / span > }
< / div >
< TxBrowser requestDebug = { requestDebug } unloadRequested = { unloadRequested } updateTxNumberFlag = { updateTxNumberFlag } transactionNumber = { state . txNumber } debugging = { state . debugging } / >
{ state . debugging && < StepManager stepManager = { stepManager } / > }
{ state . debugging && < VmDebuggerHead vmDebugger = { vmDebugger } / > }
< / div >
{ state . debugging && < div className = "statusMessage" > { state . statusMessage } < / div > }
{ state . debugging && < VmDebugger vmDebugger = { vmDebugger } / > }
< / div >
)