Skip to content

Commit

Permalink
setup protocol pauser
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramarti committed Apr 13, 2024
1 parent d333838 commit 7f00590
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 24 deletions.
1 change: 1 addition & 0 deletions contracts/interfaces/pause/IPausable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pragma solidity 0.8.23;
interface IPausable {
function pause() external;
function unpause() external;
function paused() external view returns (bool);
}
23 changes: 0 additions & 23 deletions contracts/pause/ProtocolPausable.sol

This file was deleted.

4 changes: 4 additions & 0 deletions contracts/pause/ProtocolPausableUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ abstract contract ProtocolPausableUpgradeable is IPausable, PausableUpgradeable,
function unpause() external override restricted {
_unpause();
}

function paused() public view override(IPausable, PausableUpgradeable) returns (bool) {
return super.paused();
}
}
10 changes: 10 additions & 0 deletions contracts/pause/ProtocolPauser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ contract ProtocolPauser is IProtocolPauser, AccessManaged {
emit ProtocolUnpaused();
}

function isAllProtocolPaused() external view returns (bool) {
uint256 length = _pausables.length();
for (uint256 i = 0; i < length; i++) {
if (!IPausable(_pausables.at(i)).paused()) {
return false;
}
}
return true;
}

/// @notice Checks if a pausable contract is registered.
function isPausableRegistered(address pausable) external view returns (bool) {
return _pausables.contains(pausable);
Expand Down
12 changes: 11 additions & 1 deletion script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessMana
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

// contracts
import { ProtocolPauser } from "contracts/pause/ProtocolPauser.sol";
import { ProtocolPausableUpgradeable } from "contracts/pause/ProtocolPausableUpgradeable.sol";
import { AccessController } from "contracts/access/AccessController.sol";
import { IPAccountImpl } from "contracts/IPAccountImpl.sol";
Expand Down Expand Up @@ -86,6 +87,9 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
AccessManager internal protocolAccessManager; // protocol roles
AccessController internal accessController; // per IPA roles

// Pause
ProtocolPauser internal protocolPauser;

// License system
LicenseToken internal licenseToken;
PILicenseTemplate internal pilTemplate;
Expand Down Expand Up @@ -161,6 +165,11 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
protocolAccessManager = new AccessManager(deployer);
_postdeploy(contractKey, address(protocolAccessManager));

contractKey = "ProtocolPauser";
_predeploy(contractKey);
protocolPauser = new ProtocolPauser(address(protocolAccessManager));
_postdeploy(contractKey, address(protocolPauser));

contractKey = "AccessController";
_predeploy(contractKey);

Expand Down Expand Up @@ -447,7 +456,8 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
protocolAccessManager.setTargetFunctionRole(address(royaltyModule), selectors, ProtocolAdmin.PAUSE_ADMIN_ROLE);
protocolAccessManager.setTargetFunctionRole(address(royaltyPolicyLAP), selectors, ProtocolAdmin.PAUSE_ADMIN_ROLE);
protocolAccessManager.setTargetFunctionRole(address(ipAssetRegistry), selectors, ProtocolAdmin.PAUSE_ADMIN_ROLE);

protocolAccessManager.setTargetFunctionRole(address(licenseRegistry), selectors, ProtocolAdmin.PAUSE_ADMIN_ROLE);
protocolAccessManager.setTargetFunctionRole(address(protocolPauser), selectors, ProtocolAdmin.PAUSE_ADMIN_ROLE);
///////// Role Granting /////////
protocolAccessManager.grantRole(ProtocolAdmin.UPGRADER_ROLE, multisig, upgraderExecDelay);
protocolAccessManager.grantRole(ProtocolAdmin.PAUSE_ADMIN_ROLE, multisig, 0);
Expand Down
32 changes: 32 additions & 0 deletions test/foundry/pause/ProtocolPauser.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.23;

import { Errors } from "contracts/lib/Errors.sol";

import { MODULE_TYPE_DEFAULT, MODULE_TYPE_HOOK } from "contracts/lib/modules/Module.sol";
import { IModule } from "contracts/interfaces/modules/base/IModule.sol";
import { IHookModule } from "contracts/interfaces/modules/base/IHookModule.sol";

import { MockModule } from "../mocks/module/MockModule.sol";
import { ICustomModule, CustomModule } from "../mocks/CustomModuleType.sol";
import { MockTokenGatedHook } from "../mocks/MockTokenGatedHook.sol";
import { BaseTest } from "../utils/BaseTest.t.sol";

contract ProtocolPauser is BaseTest {

function test_protocolPauser_addPausable() public {

}

function test_protocolPauser_removePausable() public {

}

function test_ProtocolPauser_pause() public {

}

function test_ProtocolPauser_unpause() public {

}
}

0 comments on commit 7f00590

Please sign in to comment.