primitive-dodoc icon indicating copy to clipboard operation
primitive-dodoc copied to clipboard

Events which are inherited display `undefined` in the description

Open 0xCourtney opened this issue 2 years ago • 0 comments

If an event is inherited it will not display anything in the description. After digging through this a bit I found that the devdoc and userdoc contain different sets of information if the event was inherited compared to if it was defined on the contract or interface directly. This was not obvious at first but it became very clear after logging the output of the info object for Bar.sol and IBar.sol.

const buildInfo = await hre.artifacts.getBuildInfo(qualifiedName);
const info = buildInfo?.output.contracts[source][name] as CompilerOutputContractWithDocumentation;

const dd: any = buildInfo?.output.contracts[source][name]

console.log(name)
console.log("devdoc event", dd.devdoc.events)
console.log("userdoc event", dd.userdoc.events)
Bar
devdoc event undefined
userdoc event { 'Transfer(uint256)': { notice: 'Emitted when transfer' } }

IBar
devdoc event {
  'Transfer(uint256)': {
    details: 'Transfer some stuff',
    params: { foo: 'Amount of stuff' }
  }
}
userdoc event { 'Transfer(uint256)': { notice: 'Emitted when transfer' } }

Given that the issue is with the incoming data perhaps it makes sense to do the following, 1) when the docs have been created, check if more than one event with the same name, description, and params exists 2) combine the matched events such that they all use the most complete set of information.

0xCourtney avatar Sep 20 '22 01:09 0xCourtney