-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add zone manager role to ImmutableSignedZoneV2 (#210)
- Loading branch information
Showing
8 changed files
with
342 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
contracts/trading/seaport/zones/immutable-signed-zone/v2/ZoneAccessControl.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Immutable Pty Ltd 2018 - 2024 | ||
// SPDX-License-Identifier: Apache-2 | ||
|
||
// solhint-disable-next-line compiler-version | ||
pragma solidity ^0.8.20; | ||
|
||
import {AccessControl} from "openzeppelin-contracts-5.0.2/access/AccessControl.sol"; | ||
import {IAccessControl} from "openzeppelin-contracts-5.0.2/access/IAccessControl.sol"; | ||
import {AccessControlEnumerable} from "openzeppelin-contracts-5.0.2/access/extensions/AccessControlEnumerable.sol"; | ||
import {ZoneAccessControlEventsAndErrors} from | ||
"../../../../../../contracts/trading/seaport/zones/immutable-signed-zone/v2/interfaces/ZoneAccessControlEventsAndErrors.sol"; | ||
|
||
/** | ||
* @notice ZoneAccessControl encapsulates access control functionality for the zone. | ||
*/ | ||
abstract contract ZoneAccessControl is AccessControlEnumerable, ZoneAccessControlEventsAndErrors { | ||
/// @dev Zone manager manages the zone. | ||
bytes32 public constant ZONE_MANAGER_ROLE = bytes32("ZONE_MANAGER"); | ||
|
||
/** | ||
* @notice Constructor to setup initial default admin. | ||
* | ||
* @param owner The address to assign the DEFAULT_ADMIN_ROLE. | ||
*/ | ||
constructor(address owner) { | ||
// Grant admin role to the specified owner. | ||
_grantRole(DEFAULT_ADMIN_ROLE, owner); | ||
} | ||
|
||
/** | ||
* @inheritdoc AccessControl | ||
*/ | ||
function revokeRole(bytes32 role, address account) public override(AccessControl, IAccessControl) onlyRole(getRoleAdmin(role)) { | ||
super.revokeRole(role, account); | ||
|
||
if (role == DEFAULT_ADMIN_ROLE && super.getRoleMemberCount(DEFAULT_ADMIN_ROLE) == 0) { | ||
revert LastDefaultAdminRole(account); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc AccessControl | ||
*/ | ||
function renounceRole(bytes32 role, address callerConfirmation) public override(AccessControl, IAccessControl) { | ||
super.renounceRole(role, callerConfirmation); | ||
|
||
if (role == DEFAULT_ADMIN_ROLE && super.getRoleMemberCount(DEFAULT_ADMIN_ROLE) == 0) { | ||
revert LastDefaultAdminRole(callerConfirmation); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ng/seaport/zones/immutable-signed-zone/v2/interfaces/ZoneAccessControlEventsAndErrors.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Immutable Pty Ltd 2018 - 2024 | ||
// SPDX-License-Identifier: Apache-2 | ||
|
||
// solhint-disable compiler-version | ||
pragma solidity ^0.8.17; | ||
|
||
/** | ||
* @notice ZoneAccessControlEventsAndErrors contains errors and events | ||
* related to zone access control. | ||
*/ | ||
interface ZoneAccessControlEventsAndErrors { | ||
/** | ||
* @dev Revert with an error if revoking last DEFAULT_ADMIN_ROLE. | ||
*/ | ||
error LastDefaultAdminRole(address account); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.