From e8ae3d60873402bea7e1e3efe0785dd2f4d4791e Mon Sep 17 00:00:00 2001 From: has5aan Date: Thu, 14 Dec 2023 13:52:49 +0100 Subject: [PATCH] :recycle: Sets DEFAULT_ADMIN_ROLE as the roleAdmin for BURNER_ROLE --- src/L1/L1LiskToken.sol | 8 +------- test/L1/L1LiskToken.t.sol | 12 ++---------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/L1/L1LiskToken.sol b/src/L1/L1LiskToken.sol index ed598cd9..2c2c6a23 100644 --- a/src/L1/L1LiskToken.sol +++ b/src/L1/L1LiskToken.sol @@ -14,18 +14,12 @@ contract L1LiskToken is ERC20Burnable, AccessControl, ERC20Permit { bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); constructor() ERC20(NAME, SYMBOL) ERC20Permit(NAME) { - bytes32 admin = bytes32(uint256(uint160(msg.sender))); - _setRoleAdmin(DEFAULT_ADMIN_ROLE, admin); - _setRoleAdmin(BURNER_ROLE, admin); + _setRoleAdmin(BURNER_ROLE, DEFAULT_ADMIN_ROLE); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _mint(msg.sender, TOTAL_SUPPLY); } function transferOwnership(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { - bytes32 admin = bytes32(uint256(uint160(account))); - _setRoleAdmin(DEFAULT_ADMIN_ROLE, admin); - _setRoleAdmin(BURNER_ROLE, admin); - _grantRole(DEFAULT_ADMIN_ROLE, account); _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); } diff --git a/test/L1/L1LiskToken.t.sol b/test/L1/L1LiskToken.t.sol index 98b8484a..06de3027 100644 --- a/test/L1/L1LiskToken.t.sol +++ b/test/L1/L1LiskToken.t.sol @@ -159,15 +159,12 @@ contract L1LiskTokenTest is Test { function test_onlyOwnerTransfersTheOwnership() public { address alice = address(0x1); address bob = address(0x2); - bytes32 aliceAsRoleAdmin = bytes32(uint256(uint160(alice))); vm.prank(alice); vm.expectRevert( abi.encodeWithSelector(IAccessControl.AccessControlUnauthorizedAccount.selector, alice, defaultAdminRole) ); l1LiskToken.transferOwnership(bob); - vm.expectEmit(true, true, true, true, address(l1LiskToken)); - emit RoleAdminChanged(defaultAdminRole, bytes32(uint256(uint160(address(this)))), aliceAsRoleAdmin); vm.expectEmit(true, true, true, true, address(l1LiskToken)); emit RoleGranted(defaultAdminRole, alice, address(this)); vm.expectEmit(true, true, true, true, address(l1LiskToken)); @@ -176,14 +173,9 @@ contract L1LiskTokenTest is Test { assertFalse(l1LiskToken.hasRole(defaultAdminRole, address(this))); assertTrue(l1LiskToken.hasRole(defaultAdminRole, alice)); - - assertEq(aliceAsRoleAdmin, l1LiskToken.getRoleAdmin(defaultAdminRole)); - assertEq(aliceAsRoleAdmin, l1LiskToken.getRoleAdmin(l1LiskToken.getBurnerRole())); } - function test_ownerIsAdminForOwnerAndBurnerRole() public { - bytes32 roleAdmin = bytes32(uint256(uint160(address(this)))); - assertEq(roleAdmin, l1LiskToken.getRoleAdmin(defaultAdminRole)); - assertEq(roleAdmin, l1LiskToken.getRoleAdmin(l1LiskToken.getBurnerRole())); + function test_defaultRoleIsRoleAdminForBurnerRole() public { + assertEq(defaultAdminRole, l1LiskToken.getRoleAdmin(l1LiskToken.getBurnerRole())); } }