Tenderly / hardhat-tenderly

Tenderly plugin for HardHat
https://www.npmjs.com/package/@tenderly/hardhat-tenderly
Other
158 stars 40 forks source link

Hardhat Tenderly is not compatible with Hardhat Preprocessor #127

Open alexanderattar opened 1 year ago

alexanderattar commented 1 year ago

After much debugging trying to get the tenderly:verify function to work I've realized that these libraries are incompatible. I kept getting the error:

Error: There are multiple definitions of libraries the contract should use. One is defined in the verify request and the other as an compiler config override. Please remove one of them.

Due to these lines of code in util.js:

    if (compiler.settings.libraries !== undefined && compiler.settings.libraries !== null) {
        console.log(compiler.settings.libraries);
        throw new Error(`There are multiple definitions of libraries the contract should use. One is defined in the verify request and the other as an compiler config override. Please remove one of them.`);
    }

After logging the compiler.settings.libraries object I realized a cache buster was getting injected and causing this error to get thrown. Eventually I pinpointed it down to be a result of hardhat-preprocessor injecting this value.

Please consider rethinking how this is handled to avoid others from going down the same rabbit hole I had to 🙏

For context these are the relevant lines in hardhat-preprocessor index.js

        for (const compiler of hre.config.solidity.compilers) {
            compiler.settings.libraries = compiler.settings.libraries || {};
            compiler.settings.libraries[''] = compiler.settings.libraries[''] || {};
            compiler.settings.libraries[''] = {
                __CACHE_BREAKER__: cacheBreaker,
            };
        }
        content = transform(linePreProcessor.transform, { absolutePath }, content);
simplyoptimistic commented 1 year ago

Believe issue #126 is a duplicate of this. I also had this issue, and think it would be useful if this was fixed as foundry/hardhat hybrid repositories are somewhat common. My workaround was to duplicate the dependencies, and remap them in foundry so that they match hardhat (and remove hardhat-preprocessor).

dule-git commented 4 days ago

Hello @alexanderattar,

Is the issue resolved for you in some of the newer versions of the plugin?

Or you are still having the same error?

Thanks for reporting! Also, sorry for the research that you had to go to in order to RCA this :(