Make transpilation setup local to this repo (#4041)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
Francisco
2023-05-09 19:52:23 +01:00
committed by GitHub
parent 34d926dd7e
commit 51294b7480
19 changed files with 894 additions and 162 deletions

24
hardhat/env-artifacts.js Normal file
View File

@ -0,0 +1,24 @@
const { HardhatError } = require('hardhat/internal/core/errors');
// Modifies `artifacts.require(X)` so that instead of X it loads the XUpgradeable contract.
// This allows us to run the same test suite on both the original and the transpiled and renamed Upgradeable contracts.
extendEnvironment(env => {
const artifactsRequire = env.artifacts.require;
env.artifacts.require = name => {
for (const suffix of ['UpgradeableWithInit', 'Upgradeable', '']) {
try {
return artifactsRequire(name + suffix);
} catch (e) {
// HH700: Artifact not found - from https://hardhat.org/hardhat-runner/docs/errors#HH700
if (HardhatError.isHardhatError(e) && e.number === 700 && suffix !== '') {
continue;
} else {
throw e;
}
}
}
throw new Error('Unreachable');
};
});