Skip to content

Commit

Permalink
Prevent setting address(0) as the initialAdmin in AccessManager (#4570)
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco <fg@frang.io>
  • Loading branch information
Amxx and frangio authored Sep 5, 2023
1 parent 5abbd04 commit bb7ca7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contracts/access/manager/AccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ contract AccessManager is Context, Multicall, IAccessManager {
}

constructor(address initialAdmin) {
if (initialAdmin == address(0)) {
revert AccessManagerInvalidInitialAdmin(address(0));
}

// admin is active immediately and without any execution delay.
_grantGroup(ADMIN_GROUP, initialAdmin, 0, 0);
}
Expand Down
1 change: 1 addition & 0 deletions contracts/access/manager/IAccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface IAccessManager {
error AccessManagerUnauthorizedAccount(address msgsender, uint64 groupId);
error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);
error AccessManagerCannotCancel(address msgsender, address caller, address target, bytes4 selector);
error AccessManagerInvalidInitialAdmin(address initialAdmin);

function canCall(
address caller,
Expand Down
8 changes: 7 additions & 1 deletion test/access/manager/AccessManager.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { web3 } = require('hardhat');
const { expectEvent, time } = require('@openzeppelin/test-helpers');
const { constants, expectEvent, time } = require('@openzeppelin/test-helpers');
const { expectRevertCustomError } = require('../../helpers/customError');
const { selector } = require('../../helpers/methods');
const { clockFromReceipt } = require('../../helpers/time');
Expand Down Expand Up @@ -38,6 +38,12 @@ contract('AccessManager', function (accounts) {
await this.manager.$_grantGroup(GROUPS.SOME, member, 0, 0);
});

it('rejects zero address for initialAdmin', async function () {
await expectRevertCustomError(AccessManager.new(constants.ZERO_ADDRESS), 'AccessManagerInvalidInitialAdmin', [
constants.ZERO_ADDRESS,
]);
});

it('default minsetback is 1 day', async function () {
expect(await this.manager.minSetback()).to.be.bignumber.equal(MINSETBACK);
});
Expand Down

0 comments on commit bb7ca7d

Please sign in to comment.