Skip to content

Commit

Permalink
feat: move mass-role management to permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
failingtwice committed Jan 30, 2025
1 parent 23a4fa9 commit 19755bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
36 changes: 0 additions & 36 deletions contracts/0.8.25/vaults/Dashboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ interface IWstETH is IERC20, IERC20Permit {
* including funding, withdrawing, minting, burning, and rebalancing operations.
*/
contract Dashboard is Permissions {
/**
* @notice Struct containing an account and a role for granting/revoking roles.
*/
struct RoleAssignment {
address account;
bytes32 role;
}

/**
* @notice Total basis points for fee calculations; equals to 100%.
*/
Expand Down Expand Up @@ -462,34 +454,6 @@ contract Dashboard is Permissions {
_resumeBeaconChainDeposits();
}

// ==================== Role Management Functions ====================

/**
* @notice Mass-grants multiple roles to multiple accounts.
* @param _assignments An array of role assignments.
* @dev Performs the role admin checks internally.
*/
function grantRoles(RoleAssignment[] memory _assignments) external {
if (_assignments.length == 0) revert ZeroArgument("_assignments");

for (uint256 i = 0; i < _assignments.length; i++) {
grantRole(_assignments[i].role, _assignments[i].account);
}
}

/**
* @notice Mass-revokes multiple roles from multiple accounts.
* @param _assignments An array of role assignments.
* @dev Performs the role admin checks internally.
*/
function revokeRoles(RoleAssignment[] memory _assignments) external {
if (_assignments.length == 0) revert ZeroArgument("_assignments");

for (uint256 i = 0; i < _assignments.length; i++) {
revokeRole(_assignments[i].role, _assignments[i].account);
}
}

// ==================== Internal Functions ====================

/**
Expand Down
36 changes: 36 additions & 0 deletions contracts/0.8.25/vaults/Permissions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import {VaultHub} from "./VaultHub.sol";
* @notice Provides granular permissions for StakingVault operations.
*/
abstract contract Permissions is AccessControlVoteable {
/**
* @notice Struct containing an account and a role for granting/revoking roles.
*/
struct RoleAssignment {
address account;
bytes32 role;
}

/**
* @notice Permission for funding the StakingVault.
*/
Expand Down Expand Up @@ -107,6 +115,34 @@ abstract contract Permissions is AccessControlVoteable {
return IStakingVault(addr);
}

// ==================== Role Management Functions ====================

/**
* @notice Mass-grants multiple roles to multiple accounts.
* @param _assignments An array of role assignments.
* @dev Performs the role admin checks internally.
*/
function grantRoles(RoleAssignment[] memory _assignments) external {
if (_assignments.length == 0) revert ZeroArgument("_assignments");

for (uint256 i = 0; i < _assignments.length; i++) {
grantRole(_assignments[i].role, _assignments[i].account);
}
}

/**
* @notice Mass-revokes multiple roles from multiple accounts.
* @param _assignments An array of role assignments.
* @dev Performs the role admin checks internally.
*/
function revokeRoles(RoleAssignment[] memory _assignments) external {
if (_assignments.length == 0) revert ZeroArgument("_assignments");

for (uint256 i = 0; i < _assignments.length; i++) {
revokeRole(_assignments[i].role, _assignments[i].account);
}
}

function _votingCommittee() internal pure virtual returns (bytes32[] memory) {
bytes32[] memory roles = new bytes32[](1);
roles[0] = DEFAULT_ADMIN_ROLE;
Expand Down

0 comments on commit 19755bb

Please sign in to comment.