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

Commit

Permalink
single bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dd0sxx committed Dec 4, 2023
1 parent 1e7889a commit 1975c88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
20 changes: 7 additions & 13 deletions src/llama-scripts/LlamaGovernanceScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,47 +259,41 @@ contract LlamaGovernanceScript is LlamaBaseScript {
/// @notice Batch set strategy logic authorizations.
/// @param strategyLogics Array of strategy logic contracts to set authorization for.
/// @param authorized Array of booleans to determine whether an address is being authorized or unauthorized.
function setStrategyLogicAuthorizations(ILlamaStrategy[] calldata strategyLogics, bool[] calldata authorized)
function setStrategyLogicAuthorizations(ILlamaStrategy[] calldata strategyLogics, bool authorized)
public
onlyDelegateCall
{
(LlamaCore core,) = _context();
if (strategyLogics.length != authorized.length) revert MismatchedArrayLengths();
for (uint256 i = 0; i < strategyLogics.length; i = LlamaUtils.uncheckedIncrement(i)) {
core.setStrategyLogicAuthorization(strategyLogics[i], authorized[i]);
core.setStrategyLogicAuthorization(strategyLogics[i], authorized);
}
}

/// @notice Batch set account logic authorizations.
/// @param accountLogics Array of account logic contracts to set authorization for.
/// @param authorized Array of booleans to determine whether an address is being authorized or unauthorized.
function setAccountLogicAuthorizations(ILlamaAccount[] calldata accountLogics, bool[] calldata authorized)
function setAccountLogicAuthorizations(ILlamaAccount[] calldata accountLogics, bool authorized)
public
onlyDelegateCall
{
(LlamaCore core,) = _context();
if (accountLogics.length != authorized.length) revert MismatchedArrayLengths();
for (uint256 i = 0; i < accountLogics.length; i = LlamaUtils.uncheckedIncrement(i)) {
core.setAccountLogicAuthorization(accountLogics[i], authorized[i]);
core.setAccountLogicAuthorization(accountLogics[i], authorized);
}
}

/// @notice Batch set strategy authorizations.
/// @param strategies Array of strategies to set authorization for.
/// @param authorized Array of booleans to determine whether an address is being authorized or unauthorized.
function setStrategyAuthorizations(ILlamaStrategy[] calldata strategies, bool[] calldata authorized)
public
onlyDelegateCall
{
function setStrategyAuthorizations(ILlamaStrategy[] calldata strategies, bool authorized) public onlyDelegateCall {
(LlamaCore core,) = _context();
if (strategies.length != authorized.length) revert MismatchedArrayLengths();
for (uint256 i = 0; i < strategies.length; i = LlamaUtils.uncheckedIncrement(i)) {
core.setStrategyAuthorization(strategies[i], authorized[i]);
core.setStrategyAuthorization(strategies[i], authorized);
}
}

/// @notice Set strategy logic authorization and create new strategies.
/// @param strategyLogic Array of strategy logic contracts to set authorization for.
/// @param strategyLogic Strategy logic contracts to set authorization for.
/// @param strategies Array of configurations to initialize new strategies with.
function setStrategyLogicAuthAndNewStrategies(ILlamaStrategy strategyLogic, bytes[] calldata strategies)
public
Expand Down
32 changes: 10 additions & 22 deletions test/llama-scripts/LlamaGovernanceScript.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -691,66 +691,54 @@ contract UpdateRoleDescriptions is LlamaGovernanceScriptTest {
}

contract SetStrategyLogicAuthorizations is LlamaGovernanceScriptTest {
function test_setStrategyLogicAuthorizations() public {
function test_setStrategyLogicAuthorizations(bool authorized) public {
ILlamaStrategy[] memory strategies = new ILlamaStrategy[](3);
strategies[0] = relativeHolderQuorumLogic;
strategies[1] = absolutePeerReviewLogic;
strategies[2] = absoluteQuorumLogic;

bool[] memory authorizations = new bool[](3);
authorizations[0] = false;
authorizations[1] = true;
authorizations[2] = true;

bytes memory data =
abi.encodeWithSelector(LlamaGovernanceScript.setStrategyLogicAuthorizations.selector, strategies, authorizations);
abi.encodeWithSelector(LlamaGovernanceScript.setStrategyLogicAuthorizations.selector, strategies, authorized);
(ActionInfo memory actionInfo) = _createAction(data);

vm.expectEmit();
emit StrategyLogicAuthorizationSet(relativeHolderQuorumLogic, false);
emit StrategyLogicAuthorizationSet(relativeHolderQuorumLogic, authorized);
vm.expectEmit();
emit StrategyLogicAuthorizationSet(absolutePeerReviewLogic, true);
emit StrategyLogicAuthorizationSet(absolutePeerReviewLogic, authorized);
vm.expectEmit();
emit StrategyLogicAuthorizationSet(absoluteQuorumLogic, true);
emit StrategyLogicAuthorizationSet(absoluteQuorumLogic, authorized);

mpCore.executeAction(actionInfo);
}
}

contract SetStrategyAuthorizations is LlamaGovernanceScriptTest {
function test_setStrategyAuthorizations() public {
function test_setStrategyAuthorizations(bool authorized) public {
ILlamaStrategy[] memory strategies = new ILlamaStrategy[](1);
strategies[0] = mpStrategy1;

bool[] memory authorizations = new bool[](1);
authorizations[0] = false;

bytes memory data =
abi.encodeWithSelector(LlamaGovernanceScript.setStrategyAuthorizations.selector, strategies, authorizations);
abi.encodeWithSelector(LlamaGovernanceScript.setStrategyAuthorizations.selector, strategies, authorized);
(ActionInfo memory actionInfo) = _createAction(data);

vm.expectEmit();
emit StrategyAuthorizationSet(mpStrategy1, false);
emit StrategyAuthorizationSet(mpStrategy1, authorized);

mpCore.executeAction(actionInfo);
}
}

contract SetAccountLogicAuthorizations is LlamaGovernanceScriptTest {
function test_SetAccountLogicAuthorizations(ILlamaAccount[] calldata accountLogics) public {
function test_SetAccountLogicAuthorizations(ILlamaAccount[] calldata accountLogics, bool authorized) public {
vm.assume(accountLogics.length < 5);
bool[] memory authorized = new bool[](accountLogics.length);
for (uint256 i = 0; i < accountLogics.length; i++) {
authorized[i] = true;
}

bytes memory data =
abi.encodeWithSelector(LlamaGovernanceScript.setAccountLogicAuthorizations.selector, accountLogics, authorized);
(ActionInfo memory actionInfo) = _createAction(data);

for (uint256 i = 0; i < accountLogics.length; i++) {
vm.expectEmit();
emit AccountLogicAuthorizationSet(accountLogics[i], authorized[i]);
emit AccountLogicAuthorizationSet(accountLogics[i], authorized);
}

mpCore.executeAction(actionInfo);
Expand Down

0 comments on commit 1975c88

Please sign in to comment.