Flatten: Inherited contracts need to be defined before Derived contracts
See original GitHub issueUsing flatten on the Replica.sol contract of Nomad bridge.
sol2uml flatten 0xB92336759618F55bd0F8313bd843604592E27bd8
Attempted to compile with foundry suite:
forge build
Error:
error[2449]: src/Replica.sol:19:21: TypeError: Definition of base has to precede definition of derived contract
contract Replica is Version0, NomadBase {
^------^
contract Replica declaration is L19
contract Version0 declaration is L341
Can there be logic inside sol2uml flatten to rearrange contracts from {most inherited -> most derived} inside the flattened file?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Solidity 0.6.x features: inheritance
With version 0.6 for the example above the compiler raises a type error: Derived contract must override function "setValue". Two or more base ......
Read more >Solidity - Inheritance - GeeksforGeeks
In Single or single level inheritance the functions and variables of one base contract are inherited to only one derived contract.
Read more >Solidity Tutorial: all about Contracts | by Jean Cvllr - Medium
For multiple inheritance, the most derived base contracts that define the same function must be specified explicitly after the override keyword.
Read more >solidity/inheritance.rst at develop · ethereum/solidity - GitHub
State variable shadowing is considered as an error. A derived contract can only declare a state variable x , if there is no...
Read more >Learn Solidity: What is function visibility? - Alchemy
Inheritance is when the contents of one contract are copied into another contract (a “derived contract”) by using the “is” keyword, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

After sleeping on it, I’ve come up with a solution.
sol2uml already parses and identifies dependencies for generating the class diagrams. I was able to reuse this and then load these dependencies into a directed acyclic graph and do a topological sort to identify the order to merge the source files. This sounds complicated but was pretty easy as I was already using the
js-graph-algorithmspackage for limiting the depth of class diagrams.I’ve tested for 0xB92336759618F55bd0F8313bd843604592E27bd8 and 0x0074F83a6a78555Cc784504358028fed2B145F4A.
The changes are in v2.1.2
Wow, this works incredibly well! I’ll have to read up on those graph algorithms. Great job