truffle
truffle copied to clipboard
Json artifacts are not generated for top-level structures and enums.
Hi,
Recently Solidity added the support for top-level structures and enums. Their corresponding AST are not correctly generated by Truffle during compilation, which prevents their analyses with Slither (and probably other third-parties).
Issue
Truffle does not generate the json artifacts related to top-level structures and enums.
Steps to Reproduce
$ cat truffle-config.js
module.exports = {
compilers: {
solc: {
version: "0.6.9"
}
}
}
$ cat contracts/A.sol
import "./Struct.sol";
contract A{
St s;
}
$ cat contracts/Struct.sol
struct St{
uint a;
}
$ truffle compile
Expected Behavior
The build directory should contain a json file with the StructDefinition for St's AST.
Actual Results
Only the AST of the contract A is present, and the AST of St is missing
Environment
Truffle v5.1.31 (core: 5.1.31)
Node v12.18.0
@montyly thanks for bringing this up! A workaround for now is to make sure there is a contract in the same file. YMMV. We are working on a solution to this that is more elegant/helpful.
Would it be possible for truffle to emit a warning if one of the top-level element does not generate a json artifact?
As we are seeing more and more codebase using this pattern, it breaks many analyses with Slither.
@montyly yep, this is a good idea. Would you mind opening a separate issue for just the warning? That way it won't get lost
Would it be possible to revisit fixing this issue as it negatively impacts the experience of truffle users who want to use Slither? https://github.com/crytic/slither/issues/1834#issuecomment-1500868916