Truffle: Can't capture internal event log

Created on 13 Feb 2018  路  4Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Imagine I have the following contract

contract X{
 event Mint(uint v);
  function mint(uint _d) {
   Mint(_d);
  }
}

contract Y {
   X public x;
   function Y(address _x) {
      x = X(_x);
   }
  event Desposit(_v);
  function deposit(uint _v) {
    x.mint(_v);
    Deposit(_v);
  }
}

Steps to Reproduce

const {logs} = await y.deposit(value, { from: authorities[0] });
console.log(logs) // only 1 event

Expected Behavior

logs should provide 2 events, Mint and Deposit

Actual Results

before I was able to observe all event logs with truffle v3.
in truffle v4, I can only see Deposit event, but I don't see Mint event anymore

Environment

  • Operating System: OSX
  • Truffle version: 4.0.6
  • Ethereum client: truffle test
  • node version: 8.3.0
  • npm version: 5.3.0

Most helpful comment

Ran into this problem as well, also remember it working as described by @rstormsf in v3

The only workaround I had was to use the transaction receipt logs in my tests, and I don't know the best way to decode those logs using the truffle contracts either

All 4 comments

@rstormsf This problem has also been raised in #555 where a global event registry was proposed. The underlying issue is that truffle-contract looks at the contract ABI to decode events but X is not part of Y's interface.

As a stop-gap you could declare an abstract contract that defined a common event interface for X and Y? If that doesn't work for your use case you could manually decode the raw logs on the receipt using a utility like abi-decoder.

AKAIK this behavior hasn't changed between Truffle 3 / 4 but I could be wrong about that. Do you have a view about what the best long-term solution for this might be?

@rstormsf Hope you don't mind but I'm going to close this for house-keeping and we'll continue to track internal event logging at #555. Thanks for highlighting this issue.

Ran into this problem as well, also remember it working as described by @rstormsf in v3

The only workaround I had was to use the transaction receipt logs in my tests, and I don't know the best way to decode those logs using the truffle contracts either

@cgewecke we see this but also note that ERC20 Transfer events are included in the log from one of our internal contracts but not other events from the same internal contract. I went looking and can't see base support for ERC20 decoding in truffle/contract or abiDecoder. Is seeing internal Transfer events expected or is it some anomaly in our (Synthetix) environment?

Was this page helpful?
0 / 5 - 0 ratings