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

Solidity code not fully imported from NPM Dependencies resulting in solc compiler errors #5325

Open
CJ42 opened this issue Oct 24, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@CJ42
Copy link

CJ42 commented Oct 24, 2024

Describe the bug
I have the following code below that does not compile, because it cannot find a custom error from one of the dependency (@erc725/smart-contracts) part of @lukso/lsp7-contracts. But this custom error exists in the dependency, and it seems like Remix cannot find it / resolve it for some reasons.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the Remix website
  2. Create a new file Test.sol
  3. Paste the following Solidity code below
  4. Click on Compile and see the Solidity compile error
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

// Import LSP7 standard from Lukso and Ownable from OpenZeppelin
import "@lukso/lsp7-contracts/contracts/LSP7DigitalAsset.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title FloouToken
 * @dev Token contract for $FLOOU based on LSP7 standard
 */
contract FloouToken is LSP7Mintable, LSP7Burnable {
    constructor(
        address tokenContractOwner_
    )
        LSP7Mintable(
            "FloouElixirs.com is your natural support for mental health issues.", // tokenName_
            "FLOOU", // tokenSymbol_
            tokenContractOwner_,
            0, // lsp4TokenType_
            false // isNonDivisible_
        )
    {
        // Mint initial tokens to the deployer
        mint(
            msg.sender, // deployer will receive initial tokens
            20_000 * 10 ** decimals(), // will mint 20k tokens
            true, // force parameter
            ""  // optional transaction data
        );
    }
}
image

Expected behaviour
There should not be any compiler errors.

Screenshots
Looking at Remix, it seems to not load the file fully, or all the contracts part of the @erc725/smart-contracts package.
This is the code from errors.sol.

image

While the actual file from this dependency should be like this:

https://github.com/ERC725Alliance/ERC725/blob/v7.0.0/implementations/contracts/errors.sol

image
@Aniket-Engg
Copy link
Collaborator

I can reproduce this

@Aniket-Engg Aniket-Engg added the bug Something isn't working label Oct 25, 2024
@eslinko
Copy link

eslinko commented Oct 25, 2024

I have the same issue
image
image

@bunsenstraat
Copy link
Collaborator

bunsenstraat commented Dec 9, 2024

OwnableCallerNotTheOwner is not part of the latest version of this errors.sol ( 8.0.0 ). Remix will always get the latest version if it can find it on jsdelivr or unpkg unless you specify which version you want. You will see if you load version 7 it will be correct, this can be done using a package.json file in the remix workspace, for example ( replace it with the version you need )

{
  "dependencies": {
    "@erc725/smart-contracts": "7.0.0"
  }
}

The example above compiles this lib fine but there are other errors in your project which can probably also be resolved by restriction the package versions that are loaded in the project. you just need to figure out which ones they are.
IMO this wouldn't compile in other environments unless you specified which versions you needed. out of the box it won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@bunsenstraat @eslinko @Aniket-Engg @CJ42 and others