Commit 1e92428f authored by aniket-engg's avatar aniket-engg Committed by Aniket

Integrate hardhat console log

parent eac4fd8f
This diff is collapsed.
import { hexListFromBNs, formatMemory } from '../util'
import { normalizeHexAddress } from '../helpers/uiHelper'
import { ConsoleLogs } from '../helpers/hhconsoleSigs'
import { toChecksumAddress, BN, bufferToHex, Address } from 'ethereumjs-util'
import Web3 from 'web3'
import { ethers } from 'ethers'
export class Web3VmProvider {
web3
......@@ -206,6 +208,22 @@ export class Web3VmProvider {
error: data.error === false ? undefined : data.error
}
this.vmTraces[this.processingHash].structLogs.push(step)
if (step.op === 'STATICCALL' && step.stack[step.stack.length - 2] === "0x000000000000000000000000000000000000000000636f6e736f6c652e6c6f67") {
const stackLength = step.stack.length
const address = step.stack[stackLength-2]
const payloadStart = parseInt(step.stack[stackLength-3], 16)
const memory = step.memory.join('')
const payloadLength = parseInt(step.stack[stackLength-4], 16)
console.log('payloadLength in pushTrace--->', payloadLength)
const payload = memory.substring(payloadStart*2, payloadStart*2 + payloadLength)
console.log('memory payload in pushTrace--->', payload)
const fnselector = parseInt('0x' + payload.substring(0, 8))
const iface = new ethers.utils.Interface([`function log${ConsoleLogs[fnselector]} view`])
console.log('iface--->', iface)
console.log('---->', iface.decodeFunctionData("log", '0x' + payload))
}
// console.log('processingAddress in ==', normalizeHexAddress(step.stack[step.stack.length - 2]))
if (step.op === 'CREATE' || step.op === 'CALL') {
if (step.op === 'CREATE') {
this.processingAddress = '(Contract Creation - Step ' + this.processingIndex + ')'
......
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