Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds import callback resolution to resolc compiler #146

Closed
wants to merge 2 commits into from

Conversation

davidk-pt
Copy link

Resolves #98

Let me know if this looks good and I'll write NodeJS tests.

Solidity compiler exports all sources, so I just add those in our source code files.

Tested with these two files:
test.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.4.16;

import "./callable.sol";

contract Main {
    function main(Callable callable) public returns(uint) {
        return callable.f(5);
    }
}

callable.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.4.16;

contract Callable {
    function f(uint a) public pure returns(uint) {
        return a * 2;
    }
}

This is the output

➜  revive git:(davidk/add-import-resolution-to-resolc) ✗ resolc ./test.sol
Warning: Function state mutability can be restricted to pure
 --> ./test.sol:8:5:
  |
8 |     function main(Callable callable) public returns(uint) {
  |     ^ (Relevant source part starts here and spans across multiple lines).


Compiler run successful. No output requested. Use --asm and --bin flags.

@davidk-pt davidk-pt requested a review from xermicus January 6, 2025 14:13
Copy link
Member

@xermicus xermicus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this. I just noticed that the PR referenced from matter labs fixes this in fn standard_json instead. Why did you fix it differently?

The matter-labs PR for this also seems much more complete. Don't we need to backport all of those changes too? They seem relevant. Let me know if you want me to have a closer look.

@davidk-pt
Copy link
Author

Won't be able to finish this as I'm leaving parity

@davidk-pt davidk-pt closed this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix automatic import resultion
2 participants