Skip to content

EVM can't retrieve events from indirect call of a contract  #326

Description

@eduardonunesp

The issue was reported from a user on Telegram chat, saying that the call from getPastEvents from web3 wasn't working on loom, when there are two contracts: ContractA and ContractB and when ContractA emits an event on ContractB the event wasn't reachable.

contracta.sol

pragma solidity 0.4.24;

interface ContractB {
  function callEvent(uint256 v) external;
}

contract ContractA {
  event ContractAEvent(uint256 v);

  function doEmit(uint256 _v, address _contractBAddr) public {
    emit ContractAEvent(_v);
    ContractB(_contractBAddr).callEvent(_v);
  }
}

contractb.sol

pragma solidity 0.4.24;

contract ContractB {
  event ContractBEvent(uint256 v);

  function callEvent(uint256 _v) public {
    emit ContractBEvent(_v);
  }
}

So testing, like this it works:

let tx = await contractA.methods.doEmit(value, contractB.options.address).send()
t.equal(tx.status, true, `doEmit should return correct status for ${value}`)

contractA.getPastEvents('ContractAEvent', (err: Error, events: any) => {
  t.assert(!err)
  t.assert(events.length > 0, 'should have at least one event')
  const [event] = events
  t.equal(+event.returnValues.v, value, `Should return value ${value}`)
})

But like this isn't works:

contractB.getPastEvents('ContractBEvent', (err: Error, events: any) => {
  t.assert(!err)
  t.assert(events.length > 0, 'Should have at least one event')
  const [event] = events
  t.equal(+event.returnValues.v, value, `Should return value ${value}`)
})

It was tested on ganache and geth and on both it works, however on loom for some reason it fails.

The test is available on loomnetwork/loom-js#89

Activity

  1. Sriep commented on May 1, 2019

    @Sriep
    Contributor

    This should be fixed for the new JSONRPC endpoints, such as eth_getLogs.

  2. enlight commented on Oct 15, 2019

    @enlight
    Contributor

    This now works as expected when using the /eth endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EVMbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions