-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathGuardians.sol
76 lines (64 loc) · 2.07 KB
/
Guardians.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {Ownable2Step} from "openzeppelin/contracts/access/Ownable2Step.sol";
import {Pausable} from "openzeppelin/contracts/security/Pausable.sol";
import {IGuardians} from "../interfaces/abstract/IGuardians.sol";
abstract contract Guardians is IGuardians, Ownable2Step, Pausable {
/**
* @notice Mapping of addresses to guardian status.
*/
mapping(address guardian => bool isGuardian) public guardians;
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
/**
* @notice Allow only the owner or a guardian to call the
* protected function.
*/
modifier onlyGuardian() {
if (msg.sender != owner() && !guardians[msg.sender]) {
revert OnlyGuardian();
}
_;
}
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
/**
* @notice Set the initial owner address.
*
* @param _initialOwner Address of the contract owner.
*/
constructor(address _initialOwner) {
_transferOwnership(_initialOwner);
}
/*//////////////////////////////////////////////////////////////
PERMISSIONED FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @inheritdoc IGuardians
*/
function addGuardian(address guardian) external onlyOwner {
guardians[guardian] = true;
emit Add(guardian);
}
/**
* @inheritdoc IGuardians
*/
function removeGuardian(address guardian) external onlyOwner {
guardians[guardian] = false;
emit Remove(guardian);
}
/**
* @inheritdoc IGuardians
*/
function pause() external onlyGuardian {
_pause();
}
/**
* @inheritdoc IGuardians
*/
function unpause() external onlyOwner {
_unpause();
}
}