-
Notifications
You must be signed in to change notification settings - Fork 349
/
ProxyGovernance.sol
67 lines (53 loc) · 2.41 KB
/
ProxyGovernance.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
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;
import "../components/Governance.sol";
import "../components/GovernanceStorage.sol";
/**
The Proxy contract is governed by one or more Governors of which the initial one is the
deployer of the contract.
A governor has the sole authority to perform the following operations:
1. Nominate additional governors (:sol:func:`proxyNominateNewGovernor`)
2. Remove other governors (:sol:func:`proxyRemoveGovernor`)
3. Add new `implementations` (proxied contracts)
4. Remove (new or old) `implementations`
5. Update `implementations` after a timelock allows it
Adding governors is performed in a two step procedure:
1. First, an existing governor nominates a new governor (:sol:func:`proxyNominateNewGovernor`)
2. Then, the new governor must accept governance to become a governor (:sol:func:`proxyAcceptGovernance`)
This two step procedure ensures that a governor public key cannot be nominated unless there is an
entity that has the corresponding private key. This is intended to prevent errors in the addition
process.
The governor private key should typically be held in a secure cold wallet or managed via a
multi-sig contract.
*/
/*
Implements Governance for the proxy contract.
It is a thin wrapper to the Governance contract,
which is needed so that it can have non-colliding function names,
and a specific tag (key) to allow unique state storage.
*/
contract ProxyGovernance is GovernanceStorage, Governance {
// The tag is the string key that is used in the Governance storage mapping.
string public constant PROXY_GOVERNANCE_TAG = "StarkEx.Proxy.2019.GovernorsInformation";
/*
Returns the GovernanceInfoStruct associated with the governance tag.
*/
function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage) {
return governanceInfo[PROXY_GOVERNANCE_TAG];
}
function proxyIsGovernor(address user) external view returns (bool) {
return _isGovernor(user);
}
function proxyNominateNewGovernor(address newGovernor) external {
_nominateNewGovernor(newGovernor);
}
function proxyRemoveGovernor(address governorForRemoval) external {
_removeGovernor(governorForRemoval);
}
function proxyAcceptGovernance() external {
_acceptGovernance();
}
function proxyCancelNomination() external {
_cancelNomination();
}
}