Skip to main content
added code example
Source Link
leonprou
  • 429
  • 1
  • 5
  • 11

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?

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.

Any thoughs about this pattern? Other solution?

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?

Source Link
leonprou
  • 429
  • 1
  • 5
  • 11

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.

Any thoughs about this pattern? Other solution?