I've found a straight forward way to solve it by extending the contract B
ABI with the events of contract A
. A
is inside of B
, so B
can call to A
methods and trigger A
events. While A
's methods are encapsulated, A
's events are not. By this line of thinking in makes sense to include A
's events in B
.
This can be done manually by a copy-paste or with code:
const eventsA = extractEvents(AAbi)
const extendedAbi = [...BAbi, ...eventsA]
const contractB = new web3.eth.Contract(extendedAbi, address)
const receipt = await contractB.methods.B().send({ /* options */ })
or even in a more incautious way:
const extendedAbi = [...BAbi, ...AAbi]
Any thoughs about this pattern? Other solution?