Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
Prevent setting address(0) as the initialAdmin
  • Loading branch information
Amxx committed Sep 4, 2023
commit 6ac3691f61e37607c05b4d97c1f9fa9c7f82ab8a
4 changes: 4 additions & 0 deletions contracts/access/manager/AccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,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 @@ -52,6 +52,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);

function canCall(
address caller,
Expand Down
10 changes: 9 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 @@ -37,6 +37,14 @@ 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('groups are correctly initialized', async function () {
// group admin
expect(await this.manager.getGroupAdmin(GROUPS.ADMIN)).to.be.bignumber.equal(GROUPS.ADMIN);
Expand Down