@@ -38,14 +38,12 @@ contract AllocationExchange is Governed {
38
38
39
39
IStaking private immutable staking;
40
40
IGraphToken private immutable graphToken;
41
- address public authority;
42
-
43
- // Tracks redeemed allocationIDs. An allocation can only be redeemed once.
41
+ mapping (address => bool ) public authority;
44
42
mapping (address => bool ) public allocationsRedeemed;
45
43
46
44
// -- Events
47
45
48
- event AuthoritySet (address indexed account );
46
+ event AuthoritySet (address indexed account , bool authorized );
49
47
event AllocationRedeemed (address indexed allocationID , uint256 amount );
50
48
event TokensWithdrawn (address indexed to , uint256 amount );
51
49
@@ -69,7 +67,7 @@ contract AllocationExchange is Governed {
69
67
70
68
graphToken = _graphToken;
71
69
staking = _staking;
72
- _setAuthority (_authority);
70
+ _setAuthority (_authority, true );
73
71
}
74
72
75
73
/**
@@ -97,25 +95,27 @@ contract AllocationExchange is Governed {
97
95
* @notice Set the authority allowed to sign vouchers.
98
96
* @dev Only the governor can set the authority
99
97
* @param _authority Address of the signing authority
98
+ * @param _authorized True if the authority is authorized to sign vouchers, false to unset
100
99
*/
101
- function setAuthority (address _authority ) external onlyGovernor {
102
- _setAuthority (_authority);
100
+ function setAuthority (address _authority , bool _authorized ) external onlyGovernor {
101
+ _setAuthority (_authority, _authorized );
103
102
}
104
103
105
104
/**
106
105
* @notice Set the authority allowed to sign vouchers.
107
106
* @param _authority Address of the signing authority
107
+ * @param _authorized True if the authority is authorized to sign vouchers, false to unset
108
108
*/
109
- function _setAuthority (address _authority ) private {
109
+ function _setAuthority (address _authority , bool _authorized ) private {
110
110
require (_authority != address (0 ), "Exchange: empty authority " );
111
111
// This will help catch some operational errors but not all.
112
112
// The validation will fail under the following conditions:
113
113
// - a contract in construction
114
114
// - an address where a contract will be created
115
115
// - an address where a contract lived, but was destroyed
116
116
require (! Address.isContract (_authority), "Exchange: authority must be EOA " );
117
- authority = _authority ;
118
- emit AuthoritySet (authority );
117
+ authority[_authority] = _authorized ;
118
+ emit AuthoritySet (_authority, _authorized );
119
119
}
120
120
121
121
/**
@@ -155,10 +155,8 @@ contract AllocationExchange is Governed {
155
155
156
156
// Signature check
157
157
bytes32 messageHash = keccak256 (abi.encodePacked (_voucher.allocationID, _voucher.amount));
158
- require (
159
- authority == ECDSA.recover (messageHash, _voucher.signature),
160
- "Exchange: invalid signer "
161
- );
158
+ address voucherSigner = ECDSA.recover (messageHash, _voucher.signature);
159
+ require (authority[voucherSigner], "Exchange: invalid signer " );
162
160
163
161
// Mark allocation as collected
164
162
allocationsRedeemed[_voucher.allocationID] = true ;
0 commit comments