Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
SetScriptAuthAndSetPermissions single bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dd0sxx committed Dec 3, 2023
1 parent 273adde commit f70dc13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/llama-scripts/LlamaGovernanceScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,20 @@ contract LlamaGovernanceScript is LlamaBaseScript {
/// @param role Role to set permissions for.
/// @param selectors Array of selectors to use as part of the permissions.
/// @param strategies Array of strategies to use as part of the permissions.
/// @param hasPermissions Array of booleans to use as part of the permissions.
function setScriptAuthAndSetPermissions(
address script,
bool authorized,
uint8 role,
bytes4[] calldata selectors,
ILlamaStrategy[] calldata strategies,
bool[] calldata hasPermissions
ILlamaStrategy[] calldata strategies
) external onlyDelegateCall {
(LlamaCore core,) = _context();
if (selectors.length != strategies.length && strategies.length != hasPermissions.length) {
revert MismatchedArrayLengths();
}
if (selectors.length != strategies.length) revert MismatchedArrayLengths();
core.setScriptAuthorization(script, authorized);
RolePermissionData[] memory permissions = new RolePermissionData[](selectors.length);
for (uint256 i = 0; i < selectors.length; i = LlamaUtils.uncheckedIncrement(i)) {
permissions[i] =
RolePermissionData(role, PermissionData(address(script), selectors[i], strategies[i]), hasPermissions[i]);
RolePermissionData(role, PermissionData(address(script), selectors[i], strategies[i]), authorized);
}
setRolePermissions(permissions);
}
Expand Down
12 changes: 2 additions & 10 deletions test/llama-scripts/LlamaGovernanceScript.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -796,21 +796,13 @@ contract SetScriptAuthAndSetPermissions is LlamaGovernanceScriptTest {
function test_SetScriptAuthAndSetPermissions(address script, bool authorized, bytes4[] calldata selectors) public {
ILlamaStrategy[] memory strategies = new ILlamaStrategy[](selectors.length);

bool[] memory hasPermissions = new bool[](selectors.length);

for (uint256 i = 0; i < selectors.length; i++) {
hasPermissions[i] = true;
strategies[i] = mpStrategy2;
}

bytes memory data = abi.encodeWithSelector(
LlamaGovernanceScript.setScriptAuthAndSetPermissions.selector,
script,
authorized,
uint8(Roles.ActionCreator),
selectors,
strategies,
hasPermissions
strategies
);
(ActionInfo memory actionInfo) = _createAction(data);

Expand All @@ -820,7 +812,7 @@ contract SetScriptAuthAndSetPermissions is LlamaGovernanceScriptTest {
PermissionData memory permissionData = PermissionData(script, selectors[i], mpStrategy2);
bytes32 permissionId = lens.computePermissionId(permissionData);
vm.expectEmit();
emit RolePermissionAssigned(uint8(Roles.ActionCreator), permissionId, permissionData, true);
emit RolePermissionAssigned(uint8(Roles.ActionCreator), permissionId, permissionData, authorized);
}
mpCore.executeAction(actionInfo);
}
Expand Down

0 comments on commit f70dc13

Please sign in to comment.