Verified contractExactLGPL-3.0-only
PauseGuard
Address0xa97b0e1936e05f7ccf2280b295ae2344ee85b979
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.6
- Same code
Only this contract
Details
- Compiler
- solc 0.8.6+commit.11564f7e
- Language
- solidity
- Optimization
- No
- License
- LGPL-3.0-only
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,401,760
- Creation transaction
- 0x35ab1dfb92…eda272af43
contracts/helpers/PauseGuard.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol";
/// @title PauseGuard - Blocks Delay executions while paused.
/// @dev Attach with `setGuard` on a Zodiac Delay modifier. executeNextTx is the
/// only Delay entry point that reaches Module.exec, so this guard sees
/// executions and never queueing: execTransactionFromModule and
/// execTransactionFromModuleReturnData write the queue and return without
/// calling exec. Queueing therefore stays open while paused, as do the Delay's
/// owner functions (setTxNonce, setGuard, setTxCooldown, ...), which do not go
/// through exec either.
contract PauseGuard is BaseGuard {
/// @dev The one account allowed to unpause and to set the pauser. Fixed at
/// deployment.
address public immutable admin;
/// @dev The one account allowed to pause.
address public pauser;
/// @dev While true, every execution through a Delay this guard is
/// installed on reverts.
bool public paused;
event Paused(address indexed account);
event Unpaused(address indexed account);
event PauserSet(address indexed previousPauser, address indexed newPauser);
/// Admin or pauser is the zero address
error ZeroAddress();
/// Already paused
error AlreadyPaused();
/// Not currently paused
error NotPaused();
/// Caller is not the pauser
error NotPauser(address caller);
/// Caller is not the admin
error NotAdmin(address caller);
/// Executions are paused
error ExecutionPaused();
constructor(address _admin, address _pauser) {
if (_admin == address(0) || _pauser == address(0)) {
revert ZeroAddress();
}
admin = _admin;
pauser = _pauser;
emit PauserSet(address(0), _pauser);
}
/// @dev Blocks every execution through the Delay until the admin
/// unpauses. Entries keep ageing while paused, but the Delay checks expiry
/// against its current txCooldown and txExpiration, so its owner can revive
/// an entry that expired during the pause, for example by raising
/// txCooldown or setting txExpiration to 0. Calling Delay.skipExpired first
/// (anyone, even while paused) drops it for good, unless txExpiration is 0.
function pause() external {
if (msg.sender != pauser) {
revert NotPauser(msg.sender);
}
if (paused) {
revert AlreadyPaused();
}
paused = true;
emit Paused(msg.sender);
}
/// @dev Lifts the pause. Every queue entry that is past its cooldown and
/// has not expired becomes executable by anyone again immediately.
function unpause() external {
if (msg.sender != admin) {
revert NotAdmin(msg.sender);
}
if (!paused) {
revert NotPaused();
}
paused = false;
emit Unpaused(msg.sender);
}
/// @dev Replaces the account allowed to pause. There is no way to leave it
/// unset: to stand the pauser down, point it at an account that cannot act.
/// @param account New pauser
function setPauser(address account) external {
if (msg.sender != admin) {
revert NotAdmin(msg.sender);
}
if (account == address(0)) {
revert ZeroAddress();
}
emit PauserSet(pauser, account);
pauser = account;
}
/// @dev Reverts while paused, which makes Delay.executeNextTx revert. The
/// revert rolls back that call's txNonce increment, so the head entry stays
/// at the head of the queue and blocks every entry behind it.
function checkTransaction(
address,
uint256,
bytes memory,
Enum.Operation,
uint256,
uint256,
uint256,
address,
address payable,
bytes memory,
address
) external view override {
if (paused) {
revert ExecutionPaused();
}
}
function checkAfterExecution(bytes32, bool) external view override {}
}
@gnosis.pm/safe-contracts/contracts/common/Enum.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title Enum - Collection of enums
/// @author Richard Meissner - <[email protected]>
contract Enum {
enum Operation {Call, DelegateCall}
}
@gnosis.pm/safe-contracts/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@gnosis.pm/zodiac/contracts/guard/BaseGuard.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
import "@gnosis.pm/safe-contracts/contracts/interfaces/IERC165.sol";
import "../interfaces/IGuard.sol";
abstract contract BaseGuard is IERC165 {
function supportsInterface(bytes4 interfaceId)
external
pure
override
returns (bool)
{
return
interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a
interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7
}
/// Module transactions only use the first four parameters: to, value, data, and operation.
/// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.
/// This interface is used to maintain compatibilty with Gnosis Safe transaction guards.
function checkTransaction(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address msgSender
) external virtual;
function checkAfterExecution(bytes32 txHash, bool success) external virtual;
}
@gnosis.pm/zodiac/contracts/interfaces/IGuard.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
interface IGuard {
function checkTransaction(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address msgSender
) external;
function checkAfterExecution(bytes32 txHash, bool success) external;
}
Compiler settingsShow
{
"metadata": {
"useLiteralContent": true
},
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.