Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eduardonunesp opened this issue Aug 29, 2018 · 2 comments
Closed

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

eduardonunesp opened this issue Aug 29, 2018 · 2 comments
Assignees
Labels
bug Something isn't working EVM

Comments

@eduardonunesp
Copy link
Contributor

eduardonunesp commented Aug 29, 2018

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

@eduardonunesp eduardonunesp added the bug Something isn't working label Aug 29, 2018
@Sriep
Copy link
Contributor

Sriep commented May 1, 2019

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

@enlight enlight added the EVM label Oct 7, 2019
@enlight
Copy link
Contributor

enlight commented Oct 15, 2019

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

@enlight enlight closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working EVM
Projects
None yet
Development

No branches or pull requests

3 participants