@ -15,7 +15,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
const debuggerModule = props . debuggerAPI
const debuggerModule = props . debuggerAPI
const [ state , setState ] = useState ( {
const [ state , setState ] = useState ( {
isActive : false ,
isActive : false ,
statusMessage : '' ,
debugger : null ,
debugger : null ,
currentReceipt : {
currentReceipt : {
contractAddress : null ,
contractAddress : null ,
@ -25,7 +24,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber : '' ,
txNumber : '' ,
debugging : false ,
debugging : false ,
opt : {
opt : {
debugWithGeneratedSources : false
debugWithGeneratedSources : false ,
debugWithLocalNode : false
} ,
} ,
toastMessage : '' ,
toastMessage : '' ,
validationError : '' ,
validationError : '' ,
@ -132,7 +132,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return {
return {
. . . prevState ,
. . . prevState ,
isActive : false ,
isActive : false ,
statusMessage : '' ,
debugger : null ,
debugger : null ,
currentReceipt : {
currentReceipt : {
contractAddress : null ,
contractAddress : null ,
@ -166,7 +165,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return
return
}
}
const web3 = await debuggerModule . getDebugWeb3 ( )
const web3 = state . opt . debugWithLocalNode ? await debuggerModule . web3 ( ) : await debuggerModule . getDebugWeb3 ( )
try {
try {
const networkId = await web3 . eth . net . getId ( )
const networkId = await web3 . eth . net . getId ( )
_paq . push ( [ 'trackEvent' , 'debugger' , 'startDebugging' , networkId ] )
_paq . push ( [ 'trackEvent' , 'debugger' , 'startDebugging' , networkId ] )
@ -211,7 +210,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
debugWithGeneratedSources : state.opt.debugWithGeneratedSources
debugWithGeneratedSources : state.opt.debugWithGeneratedSources
} )
} )
debuggerInstance . debug ( blockNumber , txNumber , tx , ( ) = > {
try {
await debuggerInstance . debug ( blockNumber , txNumber , tx , ( ) = > {
listenToEvents ( debuggerInstance , currentReceipt )
listenToEvents ( debuggerInstance , currentReceipt )
setState ( prevState = > {
setState ( prevState = > {
return {
return {
@ -225,19 +225,16 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
validationError : ''
validationError : ''
}
}
} )
} )
} ) . catch ( ( error ) = > {
} )
if ( JSON . stringify ( error ) !== '{}' ) {
} catch ( error ) {
let message = 'Error: ' + JSON . stringify ( error )
unLoad ( )
message = message . split ( '\\"' ) . join ( '\'' )
setState ( prevState = > {
setState ( prevState = > {
return {
return {
. . . prevState ,
. . . prevState ,
validationError : message
validationError : error. message || error
}
}
} )
} )
}
}
unLoad ( )
} )
}
}
const debug = ( txHash ) = > {
const debug = ( txHash ) = > {
@ -277,18 +274,25 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
< div className = "mt-2 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 : { debugWithGeneratedSources : checked } }
return { . . . prevState , opt : { . . . 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 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 > }
{ state . validationError && < span className = "w-100 py-1 text-danger validationError" > { state . validationError } < / span > }
< / div >
< / div >
< TxBrowser requestDebug = { requestDebug } unloadRequested = { unloadRequested } updateTxNumberFlag = { updateTxNumberFlag } transactionNumber = { state . txNumber } debugging = { state . debugging } / >
< TxBrowser requestDebug = { requestDebug } unloadRequested = { unloadRequested } updateTxNumberFlag = { updateTxNumberFlag } 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 && < VmDebugger vmDebugger = { vmDebugger } / > }
{ state . debugging && < VmDebugger vmDebugger = { vmDebugger } / > }
< / div >
< / div >
)
)