frangio / hardhat-exposed

Automatically expose internal Solidity functions for smart contract testing.
82 stars 13 forks source link

Incompatible with Typechain #9

Closed ItsNickBarry closed 4 months ago

ItsNickBarry commented 2 years ago

I am getting this error when using this plugin in combination with @hardhat/typechain:

Error: EEXIST: file already exists, mkdir '/home/nickbarry/workspace/abdk-math-utils/contracts-exposed/Contract.sol'

It's fixed by setting a different prefix in the exposed config, such as x or _.

This may be a typechain issue (in fact, the stack trace points to typechain files), but I couldn't reproduce with typechain alone by adding the $ character to contract names. Need to better understand the context before reporting to them.

ItsNickBarry commented 2 years ago

It seems like the $ prefix works if compilation has already been run and the most recent compilation used a different prefix.

  1. hardhat clean
  2. compile with $ prefix => error
  3. compile with _ prefix => okay
  4. compile with $ prefix => okay
  5. compile with $ prefix => error
  6. compile with _ prefix => okay
  7. compile with $ prefix => okay
frangio commented 2 years ago

I wasn't able to reproduce this. Could you submit a repository with reproduction?

ItsNickBarry commented 2 years ago

Could be an OS issue? Using Ubuntu 20.04. Node 16.13.1.


Can reproduce in this repository: https://github.com/ItsNickBarry/hardhat-waffle-template

Add this contract:

contract Test {
    function fnExternal() external pure returns (uint256) {
        return fnInternal();
    }

    function fnInternal() internal pure returns (uint256) {
        return 12;
    }
}

Install with yarn: yarn add --dev hardhat-exposed

Add import to HH config.

frangio commented 2 years ago

Thanks. It's not the prefix. There's something else going wrong. I'll open an issue and see if the TypeChain team can identify the problem.

https://github.com/dethcrypto/TypeChain/issues/691

ndavd commented 1 year ago

Any updates on this?

frangio commented 1 year ago

These plugins still don't work together. hardhat-exposed seems to do something that is unexpected for Typechain and causes it to fail. I don't understand Typechain internals in order to suggest a fix.

ItsNickBarry commented 4 months ago

Closing because Typechain is deprecated.