Skip to content

Commit

Permalink
Omit abstract functions from initializers, fix tests to satisfy new r…
Browse files Browse the repository at this point in the history
…ules
  • Loading branch information
ericglau committed Nov 29, 2024
1 parent ab0ca0c commit cfadde9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/core/contracts/test/cli/excludes/AbstractUUPS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ abstract contract AbstractUUPS is UUPSUpgradeable, Abstract1, Abstract2 {
constructor(uint256 _x, uint256 _y, uint256 _z) Abstract1(_x) Abstract2(_y) {
z = _z;
}

function initialize() initializer public {
__UUPSUpgradeable_init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ contract UsesAbstractUUPS is AbstractUUPS {
function _authorizeUpgrade(address newImplementation) internal pure override {
revert("Upgrade disabled");
}

function initializeChild() initializer public {
super.initialize();
}
}
8 changes: 4 additions & 4 deletions packages/core/src/validate/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,6 @@ function* getInitializerErrors(
!skipCheck('missing-initializer-call', contractDef) &&
!skipCheck('missing-initializer-call', contractInitializer)
) {
console.log('contractDef', contractDef.name);
console.log('uninitializedBaseContracts', uninitializedBaseContracts);
yield {
kind: 'missing-initializer-call',
name: contractDef.name,
Expand All @@ -756,9 +754,11 @@ function getPossibleInitializers(contractDef: ContractDefinition) {
const fns = [...findAll('FunctionDefinition', contractDef)];
return fns.filter(
fnDef =>
fnDef.modifiers.some(modifier =>
(fnDef.modifiers.some(modifier =>
['initializer', 'reinitializer', 'onlyInitializing'].includes(modifier.modifierName.name),
) || ['initialize', 'initializer', 'reinitialize', 'reinitializer'].includes(fnDef.name),
) || ['initialize', 'initializer', 'reinitialize', 'reinitializer'].includes(fnDef.name))

Check warning on line 759 in packages/core/src/validate/run.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `·['initialize',·'initializer',·'reinitialize',·'reinitializer'].includes(fnDef.name))⏎·······` with `⏎········['initialize',·'initializer',·'reinitialize',·'reinitializer'].includes(fnDef.name))`
&&
!(fnDef.virtual && !fnDef.body) // Skip virtual functions without a body, since that indicates an abstract function and is not itself an initializer

Check warning on line 761 in packages/core/src/validate/run.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
);
}

Expand Down

0 comments on commit cfadde9

Please sign in to comment.