|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
import Web3 from 'web3' |
|
|
|
|
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line
|
|
|
|
|
import { DebuggerApiMixin } from '@remixproject/debugger-plugin' // eslint-disable-line
|
|
|
|
|
import { ViewPlugin } from '@remixproject/engine-web' |
|
|
|
@ -10,7 +11,7 @@ const css = require('./styles/debugger-tab-styles') |
|
|
|
|
const profile = { |
|
|
|
|
name: 'debugger', |
|
|
|
|
displayName: 'Debugger', |
|
|
|
|
methods: ['debug', 'getTrace', 'decodeLocalVariable', 'decodeStateVariable'], |
|
|
|
|
methods: ['debug', 'getTrace', 'decodeLocalVariable', 'decodeStateVariable', 'globalContext'], |
|
|
|
|
events: [], |
|
|
|
|
icon: 'assets/img/debuggerLogo.webp', |
|
|
|
|
description: 'Debug transactions', |
|
|
|
@ -51,7 +52,8 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) { |
|
|
|
|
this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => { |
|
|
|
|
this.call('notification', 'toast', sourceVerificationNotAvailableToastMsg()) |
|
|
|
|
}) |
|
|
|
|
return <div className="overflow-hidden px-1" id='debugView'><DebuggerUI debuggerAPI={this} /></div> |
|
|
|
|
const onReady = (api) => { this.api = api } |
|
|
|
|
return <div className="overflow-hidden px-1" id='debugView'><DebuggerUI debuggerAPI={this} onReady={onReady} /></div> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showMessage (title, message) { |
|
|
|
@ -75,4 +77,42 @@ export class DebuggerTab extends DebuggerApiMixin(ViewPlugin) { |
|
|
|
|
if (!this.debuggerBackend) return null |
|
|
|
|
return await this.debuggerBackend.debugger.decodeStateVariableByIdAtCurrentStep(this.debuggerBackend.step_manager.currentStepIndex, variableId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async globalContext () { |
|
|
|
|
if (this.api?.globalContext) { |
|
|
|
|
const { tx, block } = await this.api.globalContext() |
|
|
|
|
const blockContext = { |
|
|
|
|
'chainid': tx.chainId, |
|
|
|
|
'coinbase': block.miner, |
|
|
|
|
'difficulty': block.difficulty, |
|
|
|
|
'gaslimit': block.gasLimit, |
|
|
|
|
'number': block.number, |
|
|
|
|
'timestamp': block.timestamp, |
|
|
|
|
} |
|
|
|
|
if (block.baseFeePerGas) { |
|
|
|
|
blockContext['basefee'] = Web3.utils.toBN(block.baseFeePerGas).toString(10) + ` Wei (${block.baseFeePerGas})` |
|
|
|
|
} |
|
|
|
|
const msg = {
|
|
|
|
|
'sender': tx.from, |
|
|
|
|
'sig': tx.input.substring(0, 10), |
|
|
|
|
'value': tx.value + ' Wei' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const txOrigin = { |
|
|
|
|
'origin': tx.from |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
block: blockContext, |
|
|
|
|
msg, |
|
|
|
|
tx: txOrigin |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return { |
|
|
|
|
block: null, |
|
|
|
|
msg: null, |
|
|
|
|
tx: null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|