-
Notifications
You must be signed in to change notification settings - Fork 5
/
EthicHubStorage.sol
129 lines (99 loc) · 3.63 KB
/
EthicHubStorage.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
pragma solidity ^0.4.23;
//import "../ownership/Ownable.sol";
/**
* @title EthicHubStorage
* @dev This contract holds all the necessary state variables to carry out the storage of any contract.
*/
contract EthicHubStorage {
mapping(bytes32 => uint256) internal uintStorage;
mapping(bytes32 => string) internal stringStorage;
mapping(bytes32 => address) internal addressStorage;
mapping(bytes32 => bytes) internal bytesStorage;
mapping(bytes32 => bool) internal boolStorage;
mapping(bytes32 => int256) internal intStorage;
/*** Modifiers ************/
/// @dev Only allow access from the latest version of a contract in the Rocket Pool network after deployment
modifier onlyEthicHubContracts() {
// Maje sure the access is permitted to only contracts in our Dapp
require(addressStorage[keccak256("contract.address", msg.sender)] != 0x0);
_;
}
constructor() public {
addressStorage[keccak256("contract.address", msg.sender)] = msg.sender;
}
/**** Get Methods ***********/
/// @param _key The key for the record
function getAddress(bytes32 _key) external view returns (address) {
return addressStorage[_key];
}
/// @param _key The key for the record
function getUint(bytes32 _key) external view returns (uint) {
return uintStorage[_key];
}
/// @param _key The key for the record
function getString(bytes32 _key) external view returns (string) {
return stringStorage[_key];
}
/// @param _key The key for the record
function getBytes(bytes32 _key) external view returns (bytes) {
return bytesStorage[_key];
}
/// @param _key The key for the record
function getBool(bytes32 _key) external view returns (bool) {
return boolStorage[_key];
}
/// @param _key The key for the record
function getInt(bytes32 _key) external view returns (int) {
return intStorage[_key];
}
/**** Set Methods ***********/
/// @param _key The key for the record
function setAddress(bytes32 _key, address _value) onlyEthicHubContracts external {
addressStorage[_key] = _value;
}
/// @param _key The key for the record
function setUint(bytes32 _key, uint _value) onlyEthicHubContracts external {
uintStorage[_key] = _value;
}
/// @param _key The key for the record
function setString(bytes32 _key, string _value) onlyEthicHubContracts external {
stringStorage[_key] = _value;
}
/// @param _key The key for the record
function setBytes(bytes32 _key, bytes _value) onlyEthicHubContracts external {
bytesStorage[_key] = _value;
}
/// @param _key The key for the record
function setBool(bytes32 _key, bool _value) onlyEthicHubContracts external {
boolStorage[_key] = _value;
}
/// @param _key The key for the record
function setInt(bytes32 _key, int _value) onlyEthicHubContracts external {
intStorage[_key] = _value;
}
/**** Delete Methods ***********/
/// @param _key The key for the record
function deleteAddress(bytes32 _key) onlyEthicHubContracts external {
delete addressStorage[_key];
}
/// @param _key The key for the record
function deleteUint(bytes32 _key) onlyEthicHubContracts external {
delete uintStorage[_key];
}
/// @param _key The key for the record
function deleteString(bytes32 _key) onlyEthicHubContracts external {
delete stringStorage[_key];
}
/// @param _key The key for the record
function deleteBytes(bytes32 _key) onlyEthicHubContracts external {
delete bytesStorage[_key];
}
/// @param _key The key for the record
function deleteBool(bytes32 _key) onlyEthicHubContracts external {
delete boolStorage[_key];
}
/// @param _key The key for the record
function deleteInt(bytes32 _key) onlyEthicHubContracts external {
delete intStorage[_key];
}
}