/
Admin.sol
44 lines (36 loc) · 994 Bytes
/
Admin.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
pragma solidity >=0.8.0 <0.9.0;
//Copyright of DataX Protocol contributors
// SPDX-License-Identifier: BSU-1.1
contract Admin {
address public admin;
address public pendingAdmin;
constructor() {
admin = msg.sender;
}
modifier adminOnly() {
require(msg.sender == admin, "admin only");
_;
}
/*********************/
/**** Admin *****/
/*********************/
/**
* Request a new admin to be set for the contract.
*
* @param newAdmin New admin address
*/
function setPendingAdmin(address newAdmin) public adminOnly {
pendingAdmin = newAdmin;
}
/**
* Accept admin transfer from the current admin to the new.
*/
function acceptPendingAdmin() public {
require(
msg.sender == pendingAdmin && pendingAdmin != address(0),
"Caller must be the pending admin"
);
admin = pendingAdmin;
pendingAdmin = address(0);
}
}