-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccessible.sol
68 lines (53 loc) · 2.41 KB
/
accessible.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
68
pragma solidity 0.5.4;
/* -- Revision history --
Accessible20190222135900ML: First versioned released
Accessible20190315141600ML: Migrated to 0.4.24
Accessible20200107160900ML: Moved Visibility filter from BaseContentObject to Accessible
Accessible20200210095300ML: Changed API to V3
Accessible20200316121600ML: Implements hasAccess
*/
import "./ownable.sol";
import "./access_indexor.sol";
import "./user_space.sol";
interface ICheckAccess {
function hasAccess(address candidate) external view returns (bool);
}
contract Accessible is Ownable, ICheckAccess {
bytes32 public version ="Accessible20200626121600PO"; //class name (max 16), date YYYYMMDD, time HHMMSS and Developer initials XX
uint8 public visibility = 1;
uint8 public constant CAN_SEE = 1;
uint8 public constant CAN_ACCESS = 10;
uint8 public constant CAN_EDIT = 100;
uint8 public indexCategory = 0;
event AccessRequestV3(
uint256 requestNonce,
address parentAddress, // likely will need for tenancy - but could be something else ...?
bytes32 contextHash,
address accessor, // I've called this 'userAddress' - don't care too much but ideally it's the same name wherever it means the same thing!
uint256 requestTimestamp // always millis - either set from context or with blockchain now()
);
function hasAccess(address candidate) public view returns (bool) {
if ((candidate == owner) || (visibility >= 10) ) {
return true;
}
if (indexCategory > 0) {
address payable walletAddress = address(uint160(IUserSpace(contentSpace).userWallets(candidate)));
return AccessIndexor(walletAddress).checkRights(indexCategory, address(this), 1/*AccessIndexor TYPE_ACCESS*/);
} else {
return false;
}
}
function accessRequestV3(
bytes32[] memory,
address payable[] memory
) public payable returns (bool) {
require(hasAccess(msg.sender));
emit AccessRequestV3(uint256(keccak256(abi.encodePacked(address(this), now))), address(0x0), bytes32(0x0), msg.sender, now * 1000);
return true;
}
event VisibilityChanged(address contentSpace, address parentAddress, uint8 visibility);
function setVisibility(uint8 _visibility_code) public onlyOwner {
visibility = _visibility_code;
emit VisibilityChanged(contentSpace, contentSpace, visibility);
}
}