add debug endpoint to remix-simulator

fixUsageOfRemixSimulator
yann300 4 years ago
parent d093484605
commit caf8d6cd3b
  1. 10
      libs/remix-lib/src/web3Provider/web3VmProvider.js
  2. 33
      libs/remix-simulator/src/methods/debug.js
  3. 3
      libs/remix-simulator/src/methods/transactions.js
  4. 2
      libs/remix-simulator/src/provider.js

@ -72,9 +72,9 @@ web3VmProvider.prototype.txWillProcess = function (self, data) {
}
let tx = {}
tx.hash = self.processingHash
tx.from = util.hexConvert(data.getSenderAddress())
tx.from = ethutil.toChecksumAddress(util.hexConvert(data.getSenderAddress()))
if (data.to && data.to.length) {
tx.to = util.hexConvert(data.to)
tx.to = ethutil.toChecksumAddress(util.hexConvert(data.to))
}
this.processingAddress = tx.to
tx.data = util.hexConvert(data.data)
@ -128,8 +128,8 @@ web3VmProvider.prototype.txProcessed = function (self, data) {
if (data.createdAddress) {
const address = util.hexConvert(data.createdAddress)
self.vmTraces[self.processingHash].return = address
self.txsReceipt[self.processingHash].contractAddress = address
self.vmTraces[self.processingHash].return = ethutil.toChecksumAddress(address)
self.txsReceipt[self.processingHash].contractAddress = ethutil.toChecksumAddress(address)
} else if (data.execResult.returnValue) {
self.vmTraces[self.processingHash].return = util.hexConvert(data.execResult.returnValue)
} else {
@ -196,6 +196,7 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
}
web3VmProvider.prototype.getCode = function (address, cb) {
address = ethutil.toChecksumAddress(address)
const account = ethutil.toBuffer(address)
this.vm.stateManager.getContractCode(account, (error, result) => {
cb(error, util.hexConvert(result))
@ -219,6 +220,7 @@ web3VmProvider.prototype.traceTransaction = function (txHash, options, cb) {
web3VmProvider.prototype.storageRangeAt = function (blockNumber, txIndex, address, start, maxLength, cb) { // txIndex is the hash in the case of the VM
// we don't use the range params here
address = ethutil.toChecksumAddress(address)
if (txIndex === 'latest') {
txIndex = this.lastProcessedStorageTxHash[address]

@ -0,0 +1,33 @@
class Debug {
constructor (executionContext) {
this.executionContext = executionContext
}
methods () {
return {
debug_traceTransaction: this.debug_traceTransaction.bind(this),
debug_preimage: this.debug_preimage.bind(this),
debug_storageRangeAt: this.debug_storageRangeAt.bind(this),
}
}
debug_traceTransaction (payload, cb) {
this.executionContext.web3().debug.traceTransaction(payload.params[0], {}, cb)
}
debug_preimage (payload, cb) {
this.executionContext.web3().debug.preimage(payload.params[0], cb)
}
debug_storageRangeAt (payload, cb) {
this.executionContext.web3().debug.storageRangeAt(
payload.params[0],
payload.params[1],
payload.params[2],
payload.params[3],
payload.params[4],
cb)
}
}
module.exports = Debug

@ -52,7 +52,8 @@ class Transactions{
'cumulativeGasUsed': Web3.utils.toHex(receipt.gas),
'contractAddress': receipt.contractAddress,
'logs': receipt.logs,
'status': receipt.status
'status': receipt.status,
'to': receipt.to
}
if (r.blockNumber === '0x') {

@ -10,6 +10,7 @@ const Filters = require('./methods/filters.js')
const Misc = require('./methods/misc.js')
const Net = require('./methods/net.js')
const Transactions = require('./methods/transactions.js')
const Debug = require('./methods/debug.js')
const generateBlock = require('./genesis.js')
@ -28,6 +29,7 @@ class Provider {
this.methods = merge(this.methods, (new Filters(this.executionContext)).methods())
this.methods = merge(this.methods, (new Net()).methods())
this.methods = merge(this.methods, this.Transactions.methods())
this.methods = merge(this.methods, (new Debug(this.executionContext)).methods())
generateBlock(this.executionContext)
this.init()

Loading…
Cancel
Save