Skip to content

Commit 99f3ace

Browse files
committed
Add extra input validations to the AllocationExchange
1 parent 772c460 commit 99f3ace

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

contracts/statechannels/AllocationExchange.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.7.3;
44
pragma experimental ABIEncoderV2;
55

66
import "@openzeppelin/contracts/cryptography/ECDSA.sol";
7+
import "@openzeppelin/contracts/utils/Address.sol";
78

89
import "../governance/Governed.sol";
910
import "../staking/IStaking.sol";
@@ -54,6 +55,7 @@ contract AllocationExchange is Governed {
5455
address _governor,
5556
address _authority
5657
) {
58+
require(_governor != address(0), "Exchange: governor must be set");
5759
Governed._initialize(_governor);
5860

5961
graphToken = _graphToken;
@@ -97,6 +99,12 @@ contract AllocationExchange is Governed {
9799
*/
98100
function _setAuthority(address _authority) private {
99101
require(_authority != address(0), "Exchange: empty authority");
102+
// This will help catch some operational errors but not all.
103+
// The validation will fail under the following conditions:
104+
// - a contract in construction
105+
// - an address where a contract will be created
106+
// - an address where a contract lived, but was destroyed
107+
require(!Address.isContract(_authority), "Exchange: authority must be EOA");
100108
authority = _authority;
101109
emit AuthoritySet(authority);
102110
}

0 commit comments

Comments
 (0)