question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flatten: Inherited contracts need to be defined before Derived contracts

See original GitHub issue

Using 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
naddison36commented, Aug 3, 2022

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-algorithms package for limiting the depth of class diagrams.

I’ve tested for 0xB92336759618F55bd0F8313bd843604592E27bd8 and 0x0074F83a6a78555Cc784504358028fed2B145F4A.

The changes are in v2.1.2

0reactions
plotchycommented, Aug 3, 2022

Wow, this works incredibly well! I’ll have to read up on those graph algorithms. Great job

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found