Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dont fetch UpgradeableWithInit contract when name starts with "$"
  • Loading branch information
Amxx committed Feb 12, 2024
commit d4367bb3edaa93948addbdd047c69ec53050f5ab
12 changes: 10 additions & 2 deletions hardhat/env-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ function isExpectedError(e, suffix) {
// Modifies the artifact require functions 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(hre => {
const suffixes = ['UpgradeableWithInit', 'Upgradeable', ''];
// When getting an exposed contract, "UpgradeableWithInit" should not be considered.
const suffixes = [
{ suffix: 'UpgradeableWithInit', filter: name => !name.startsWith('$') },
{ suffix: 'Upgradeable' },
{ suffix: '' },
];

// Ethers
const originalReadArtifact = hre.artifacts.readArtifact;
hre.artifacts.readArtifact = async function (name) {
for (const suffix of suffixes) {
for (const { suffix, filter } of suffixes) {
if (filter?.(name)) {
continue;
}
try {
return await originalReadArtifact.call(this, name + suffix);
} catch (e) {
Expand Down