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.

Support multi-file smart contracts (debugging)

See original GitHub issue

The compiler should support smart contracts that are spread over multiple .java files.

Because Java does not have functionality like C# provides with the keyword partial, another solution is needed for enabling multi-file contracts.
Our proposal is to use an annotation which has a name or ID attribute. That annotation is then applied to every class that is part of the smart contract and the compiler can determine using the name/ID of that annotation if two or more files belong to the same contract.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
csmullercommented, Dec 9, 2020

The className or classNames attribute should contain the “invokable” smart contract class name… and not all the dependencies of that smart contract. That’s how I think about it, ideally.

Yes, i was imagining the same. The contract class is like the entry point to the compilation and the other classes will be processed because the contract class makes use of them. The helper/dependency classes will be discovered automatically because they will be in the classpath of the ClassLoader passed to the Compiler.

However, nothing prevents us to start small: maybe we can list all the classes, and automatically identify which class is the “invokable” one.

I’m not a huge fan of automatically identifying it because I think the developer gets a clearer picture if she actually has to state which class is the contract class.

1reaction
gsmachadocommented, Dec 9, 2020

That does not seem intuitive at all. There should only be one main contract class file that holds all public (invokable) contract methods.

Ok, I agree with this argument: so, the definition of a smart contract in Java, is: “a .java file which contains, among other information, all ‘invokable’ methods which users might interact with”

That doesn’t mean that all contract functionality has to be in the same file. The compiler should still support multiple files (and classes). The files besides the main contract class contain classes that encapsulate parts of the contract’s logic. Custom objects used in the contract for organizing data can also live in their own files.

Yes… so, it means that: all other .java files are “dependencies” of the smart contract, and should be also compiled and “embedded” to the final .avm. Right?

The step to smart contract libraries support isn’t far from here.

Absolutely. I also think that we’re not far from it! 🚀 ⭐

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging an Example Smart Contract - Truffle Suite
Introducing Truffle for VS Code Simplified building, debugging, deploying! ... Press Enter multiple times to cycle through the steps.
Read more >
Debugging Smart Contracts - Ethereum Blockchain Developer
If you are looking into a more advanced way to debugging smart contracts, then wait until we use Truffle, or directly head over...
Read more >
Debugging smart contracts - Algorand Developer Portal
Smart contracts can be debugged using two different methods. The first is an interactive debugger that uses the tealdbg command-line tool to launch...
Read more >
Debugging Smart Contracts with SmartACE - SeaHorn
In this tutorial, we show how smart contract invariants can be expressed in temporal logic, converted into monitors, and then instrumented ...
Read more >
Debugging a Smart Contract
The main method used to debug smart contract is Caveman Debugging, where we utilize the printing functionality to inspect the value of a...
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