frangio / hardhat-exposed

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

Exclude contracts with no changes #17

Closed HardlyDifficult closed 1 year ago

HardlyDifficult commented 1 year ago

Etherscan verification is failing with the following error. In this scenario, the hardhat-exposed generated file is basically a no-op. Since it's not helpful for testing and causes a conflict with the etherscan plugin, could it be excluded from the build?

The verification error:

Verification failed for 0x67ebCaF4E627137615bc7010169910ef73aCEFbD NomicLabsHardhatPluginError: More than one contract was found to match the deployed bytecode.
Please use the contract parameter with one of the following contracts:
  * contracts-exposed/FETH.sol:$FETH
  * contracts/FETH.sol:FETH

For example:

  hardhat verify --contract contracts/Example.sol:ExampleContract <other args>

If you are running the verify subtask from within Hardhat instead:

  await run("verify:verify", {
    <other args>,
    contract: "contracts/Example.sol:ExampleContract"
  };
    at inferContract (/home/circleci/repo/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:581:11)
    at async SimpleTaskDefinition.action (/home/circleci/repo/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:716:31)
    at async Environment._runTaskDefinition (/home/circleci/repo/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at async Environment.run (/home/circleci/repo/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)
    at async SimpleTaskDefinition.verifySubtask [as action] (/home/circleci/repo/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:254:60)
    at async Environment._runTaskDefinition (/home/circleci/repo/node_modules/hardhat/src/internal/core/runtime-environment.ts:308:14)
    at async Environment.run (/home/circleci/repo/node_modules/hardhat/src/internal/core/runtime-environment.ts:156:14)

The exposed generated file looks like this:

// SPDX-License-Identifier: UNLICENSED

pragma solidity >=0.6.0;

import "../contracts/FETH.sol";

contract $FETH is FETH {
    constructor(address payable _foundationMarket, address payable _foundationDropMarket, uint256 _lockupDuration) FETH(_foundationMarket, _foundationDropMarket, _lockupDuration) {}
}
frangio commented 1 year ago

I've published a new version that adds a marker so that the Etherscan plugin doesn't pick up the exposed contract. (https://github.com/frangio/hardhat-exposed/commit/48ceff946f15e4976b28b2d0f78e671fc3cbd6cc)

Let me know if it works!

HardlyDifficult commented 1 year ago

it worked great -- nice approach. thanks for the super fast turn around!