Commit 48662e06 authored by aniket-engg's avatar aniket-engg Committed by Aniket

sample implementation

parent 80587dd6
...@@ -121,9 +121,10 @@ export const DebuggerApiMixin = (Base) => class extends Base { ...@@ -121,9 +121,10 @@ export const DebuggerApiMixin = (Base) => class extends Base {
return await debug.debugger.traceManager.getTrace(hash) return await debug.debugger.traceManager.getTrace(hash)
} }
debug (hash) { debug (hash, web3?) {
this.debugHash = hash this.debugHash = hash
if (this.onDebugRequestedListener) this.onDebugRequestedListener(hash) if(web3) remixDebug.init.extendWeb3(web3)
if (this.onDebugRequestedListener) this.onDebugRequestedListener(hash, web3)
} }
onActivation () { onActivation () {
......
...@@ -240,6 +240,9 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -240,6 +240,9 @@ module.exports = class TestTab extends ViewPlugin {
</div> </div>
`) `)
} else if (result.type === 'testFailure') { } 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.hhLogs && result.hhLogs.length) this.printHHLogs(result.hhLogs, result.value)
if (!result.assertMethod) { if (!result.assertMethod) {
this.testsOutput.appendChild(yo` this.testsOutput.appendChild(yo`
......
...@@ -39,8 +39,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -39,8 +39,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return unLoad() return unLoad()
}, []) }, [])
debuggerModule.onDebugRequested((hash) => { debuggerModule.onDebugRequested((hash, web3?) => {
if (hash) debug(hash) if (hash) debug(hash, web3)
}) })
debuggerModule.onRemoveHighlights(async () => { debuggerModule.onRemoveHighlights(async () => {
...@@ -162,7 +162,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -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 (state.debugger) unLoad()
if (!txNumber) return if (!txNumber) return
setState(prevState => { setState(prevState => {
...@@ -181,7 +181,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -181,7 +181,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return 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 { 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])
...@@ -259,7 +259,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -259,7 +259,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
} }
} }
const debug = (txHash) => { const debug = (txHash, web3?) => {
setState(prevState => { setState(prevState => {
return { return {
...prevState, ...prevState,
...@@ -267,7 +267,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -267,7 +267,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber: txHash txNumber: txHash
} }
}) })
startDebugging(null, txHash, null) startDebugging(null, txHash, null, web3)
} }
const stepManager = { const stepManager = {
......
...@@ -45,7 +45,7 @@ export interface TransactionReceipt { ...@@ -45,7 +45,7 @@ export interface TransactionReceipt {
export type onBreakpointClearedListener = (params: string, row: number) => void export type onBreakpointClearedListener = (params: string, row: number) => void
export type onBreakpointAddedListener = (params: string, row: number) => void export type onBreakpointAddedListener = (params: string, row: number) => void
export type onEditorContentChanged = () => 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 type onEnvChangedListener = (provider: string) => void
export interface IDebuggerApi { export interface IDebuggerApi {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment