-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGxAuth.sol
More file actions
45 lines (35 loc) · 935 Bytes
/
GxAuth.sol
File metadata and controls
45 lines (35 loc) · 935 Bytes
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
pragma solidity ^0.4.2;
import './GxAuthority.sol';
contract GxAuth {
enum AuthMode {
Owner,
Authority
}
AuthMode public authMode;
GxAuthority public authority;
function GxAuth() {
authority = GxAuthority(msg.sender);
authMode = AuthMode.Owner;
}
modifier auth {
if (isAuthorized()) {
_;
} else {
throw;
}
}
function isAuthorized() internal returns (bool is_authorized) {
if (authMode == AuthMode.Owner) {
return msg.sender == address(authority);
}
if (authMode == AuthMode.Authority) {
return authority.canCall(msg.sender, address(this), msg.sig);
}
throw;
}
function setAuthorityContract(address new_authority, AuthMode new_authMode) auth()
{
authority = GxAuthority(new_authority);
authMode = new_authMode;
}
}