sample implementation

pull/5370/head
aniket-engg 3 years ago committed by Aniket
parent f77c9b531a
commit eefc0272b4
  1. 5
      apps/debugger/src/app/debugger-api.ts
  2. 3
      apps/remix-ide/src/app/tabs/test-tab.js
  3. 12
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
  4. 2
      libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts

@ -121,9 +121,10 @@ export const DebuggerApiMixin = (Base) => class extends Base {
return await debug.debugger.traceManager.getTrace(hash)
}
debug (hash) {
debug (hash, web3?) {
this.debugHash = hash
if (this.onDebugRequestedListener) this.onDebugRequestedListener(hash)
if(web3) remixDebug.init.extendWeb3(web3)
if (this.onDebugRequestedListener) this.onDebugRequestedListener(hash, web3)
}
onActivation () {

@ -240,6 +240,9 @@ module.exports = class TestTab extends ViewPlugin {
</div>
`)
} else if (result.type === 'testFailure') {
const txHash = JSON.parse(result.errMsg.replace('Transaction has been reverted by the EVM:', '')).transactionHash
this.call('menuicons', 'select', 'debugger')
this.call('debugger', 'debug', txHash, result.web3)
if (result.hhLogs && result.hhLogs.length) this.printHHLogs(result.hhLogs, result.value)
if (!result.assertMethod) {
this.testsOutput.appendChild(yo`

@ -39,8 +39,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return unLoad()
}, [])
debuggerModule.onDebugRequested((hash) => {
if (hash) debug(hash)
debuggerModule.onDebugRequested((hash, web3?) => {
if (hash) debug(hash, web3)
})
debuggerModule.onRemoveHighlights(async () => {
@ -162,7 +162,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
}
})
}
const startDebugging = async (blockNumber, txNumber, tx) => {
const startDebugging = async (blockNumber, txNumber, tx, optWeb3?) => {
if (state.debugger) unLoad()
if (!txNumber) return
setState(prevState => {
@ -181,7 +181,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return
}
const web3 = state.opt.debugWithLocalNode ? await debuggerModule.web3() : await debuggerModule.getDebugWeb3()
const web3 = state.opt.debugWithLocalNode ? await debuggerModule.web3() : ( optWeb3 ? optWeb3 : await debuggerModule.getDebugWeb3())
try {
const networkId = await web3.eth.net.getId()
_paq.push(['trackEvent', 'debugger', 'startDebugging', networkId])
@ -259,7 +259,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
}
}
const debug = (txHash) => {
const debug = (txHash, web3?) => {
setState(prevState => {
return {
...prevState,
@ -267,7 +267,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber: txHash
}
})
startDebugging(null, txHash, null)
startDebugging(null, txHash, null, web3)
}
const stepManager = {

@ -45,7 +45,7 @@ export interface TransactionReceipt {
export type onBreakpointClearedListener = (params: string, row: number) => void
export type onBreakpointAddedListener = (params: string, row: number) => void
export type onEditorContentChanged = () => void
export type onDebugRequested = (hash: string) => void
export type onDebugRequested = (hash: string, web3?: any) => void
export type onEnvChangedListener = (provider: string) => void
export interface IDebuggerApi {

Loading…
Cancel
Save