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

issue: yarn deploy fails in case of multiple contracts in the same file in the Foundry version #947

Open
1 task done
nzmpi opened this issue Sep 19, 2024 · 0 comments
Open
1 task done

Comments

@nzmpi
Copy link

nzmpi commented Sep 19, 2024

Is there an existing issue for this?

Which method was used to setup Scaffold-ETH 2 ?

npx create-eth@latest

Current Behavior

In the Foundry version if you have a contract A in the same sol-file as the contract B that inherits it, running yarn deploy will throw Error: ENOENT: no such file or directory, open '/[path]/packages/foundry/out/A.sol/A.json'.
Even though json-file is generated, but it's in /[path]/packages/foundry/out/B.sol/A.json.

Expected Behavior

yarn deploy should look for contract's ABI file in every folder of /foundry/out and not only in folders with the same name

Steps To Reproduce

In foundry/contracts create B.sol file with this code:

//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

contract A {
  uint256 x;

  constructor() payable {
    x = 1;
  }

  function update(uint256 y) external virtual {
    x = y;
  }
}

contract B is A {
  function update(uint256 y) external override {
    x = y * 2;
  }
}

Then in foundry/script/Deploy.s.sol in the run function add

    B b = new B();
    console.logString(
      string.concat(
        "B deployed at: ", vm.toString(address(b))
      )
    );

Run yarn deploy

Anything else?

Some projects have multiple contracts (especially abstract contracts) in the same sol-file. They won't work with SE-2 (Foundry). Developers either will need to create every contract in their own sol-file or move json-files to their own folders in the foundry/out folder.

This problem only exists in the Foundry version. The Hardhat version works properly.

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

No branches or pull requests

1 participant