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
The issue was reported from a user on Telegram chat, saying that the call from
getPastEventsfromweb3wasn't working onloom, when there are two contracts:ContractAandContractBand whenContractAemits an event onContractBthe event wasn't reachable.contracta.solcontractb.solSo testing, like this it works:
But like this isn't works:
It was tested on
ganacheandgethand on both it works, however onloomfor some reason it fails.The test is available on loomnetwork/loom-js#89