get hardhat logs for tx hash method

pull/1460/head
aniket-engg 4 years ago committed by Aniket
parent 2b02be1a61
commit 63b70bf6d3
  1. 2
      apps/remix-ide/src/blockchain/blockchain.js
  2. 5
      libs/remix-lib/src/web3Provider/web3VmProvider.ts
  3. 6
      libs/remix-simulator/src/methods/transactions.ts
  4. 9
      libs/remix-simulator/src/provider.ts

@ -487,6 +487,8 @@ class Blockchain {
let execResult
let returnValue = null
if (isVM) {
const hhlogs = await this.web3().eth.getHHLogsForTx(txResult.transactionHash)
console.log('hhLogs--2->', hhlogs)
execResult = await this.web3().eth.getExecutionResultFromSimulator(txResult.transactionHash)
if (execResult) {
// if it's not the VM, we don't have return value. We only have the transaction, and it does not contain the return value.

@ -11,6 +11,7 @@ export class Web3VmProvider {
vmTraces
txs
txsReceipt
hhLogs
processingHash
processingAddress
processingIndex
@ -43,6 +44,7 @@ export class Web3VmProvider {
this.vmTraces = {}
this.txs = {}
this.txsReceipt = {}
this.hhLogs = {}
this.processingHash = null
this.processingAddress = null
this.processingIndex = null
@ -218,7 +220,8 @@ export class Web3VmProvider {
const iface = new ethers.utils.Interface([`function log${ConsoleLogs[fnselector]} view`])
const functionDesc = iface.getFunction(`log${ConsoleLogs[fnselector]}`)
const consoleArgs = iface.decodeFunctionData(functionDesc, '0x' + payload)
console.log(consoleArgs)
this.hhLogs[this.processingHash] = this.hhLogs[this.processingHash] ? this.hhLogs[this.processingHash] : []
this.hhLogs[this.processingHash].push(consoleArgs)
}
if (step.op === 'CREATE' || step.op === 'CALL') {

@ -57,6 +57,7 @@ export class Transactions {
eth_getTransactionByBlockHashAndIndex: this.eth_getTransactionByBlockHashAndIndex.bind(this),
eth_getTransactionByBlockNumberAndIndex: this.eth_getTransactionByBlockNumberAndIndex.bind(this),
eth_getExecutionResultFromSimulator: this.eth_getExecutionResultFromSimulator.bind(this),
eth_getHHLogsForTx: this.eth_getHHLogsForTx.bind(this),
eth_getHashFromTagBySimulator: this.eth_getHashFromTagBySimulator.bind(this)
}
}
@ -83,6 +84,11 @@ export class Transactions {
cb(null, this.vmContext.exeResults[txHash])
}
eth_getHHLogsForTx (payload, cb) {
const txHash = payload.params[0]
cb(null, this.vmContext.currentVm.web3vm.hhLogs[txHash])
}
eth_getTransactionReceipt (payload, cb) {
this.vmContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => {
if (error) {

@ -103,6 +103,15 @@ export function extend (web3) {
}))
}
if (!(web3.eth && web3.eth.getHHLogsForTx)) {
methods.push(new web3.extend.Method({
name: 'getHHLogsForTx',
call: 'eth_getHHLogsForTx',
inputFormatter: [null],
params: 1
}))
}
if (!(web3.eth && web3.eth.getHashFromTagBySimulator)) {
methods.push(new web3.extend.Method({
name: 'getHashFromTagBySimulator',

Loading…
Cancel
Save