Skip to content

Commit

Permalink
feat: add Pauser
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmer1in committed Aug 9, 2024
1 parent fb6be9d commit 28afcd4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
25 changes: 25 additions & 0 deletions contracts/Pauser.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {IPauser, IPauseContract} from "./interfaces/IPauser.sol";

contract Pauser is IPauser, Ownable {

mapping(address => bool) public isPauseRole;

modifier onlyPauseRole() {
require(msg.sender == owner() || isPauseRole[msg.sender], "Pauser: not pause role");
_;
}

function pause(address pauseContract) external onlyPauseRole {
IPauseContract(pauseContract).pause();
}

function setPauseRole(address addr, bool flag) external onlyOwner {
isPauseRole[addr] = flag;
emit PauseRoleUpdated(addr, flag);
}
}
53 changes: 53 additions & 0 deletions contracts/interfaces/IPauser.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

/*
░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝
*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

interface IPauser {
/* ----- Events ----- */

event PauseRoleUpdated(address indexed addr, bool flag);

/* ----- External Functions ----- */

function isPauseRole(address account) external view returns (bool);

}

interface IPauseContract {

/* ----- External Functions ----- */

function pause() external;
}

0 comments on commit 28afcd4

Please sign in to comment.