11pragma solidity ^ 0.4.24 ;
22
33contract EternalStorage {
4-
5- /// @notice Internal mappings use to store all kind on data into the contract
4+
5+ /// @notice Internal mappings use to store all kind on data into the contract
66 mapping (bytes32 => uint256 ) internal uintStorage;
77 mapping (bytes32 => string ) internal stringStorage;
88 mapping (bytes32 => address ) internal addressStorage;
@@ -21,34 +21,34 @@ contract EternalStorage {
2121 //// set functions
2222 //////////////////
2323 /// @notice Set the key values using the Overloaded `set` functions
24- /// Ex- string version = "0.0.1"; replace to
24+ /// Ex- string version = "0.0.1"; replace to
2525 /// set(keccak256(abi.encodePacked("version"), "0.0.1");
2626 /// same for the other variables as well some more example listed below
27- /// ex1 - address securityTokenAddress = 0x123; replace to
27+ /// ex1 - address securityTokenAddress = 0x123; replace to
2828 /// set(keccak256(abi.encodePacked("securityTokenAddress"), 0x123);
29- /// ex2 - bytes32 tokenDetails = "I am ST20"; replace to
29+ /// ex2 - bytes32 tokenDetails = "I am ST20"; replace to
3030 /// set(keccak256(abi.encodePacked("tokenDetails"), "I am ST20");
3131 /// ex3 - mapping(string => address) ownedToken;
3232 /// set(keccak256(abi.encodePacked("ownedToken", "Chris")), 0x123);
33- /// ex4 - mapping(string => uint) tokenIndex;
33+ /// ex4 - mapping(string => uint) tokenIndex;
3434 /// tokenIndex["TOKEN"] = 1; replace to set(keccak256(abi.encodePacked("tokenIndex", "TOKEN"), 1);
3535 /// ex5 - mapping(string => SymbolDetails) registeredSymbols; where SymbolDetails is the structure having different type of values as
3636 /// {uint256 date, string name, address owner} etc.
3737 /// registeredSymbols["TOKEN"].name = "MyFristToken"; replace to set(keccak256(abi.encodePacked("registeredSymbols_name", "TOKEN"), "MyFirstToken");
3838 /// More generalized- set(keccak256(abi.encodePacked("registeredSymbols_<struct variable>", "keyname"), "value");
39-
39+
4040 function set (bytes32 _key , uint256 _value ) internal {
4141 uintStorage[_key] = _value;
4242 }
43-
43+
4444 function set (bytes32 _key , address _value ) internal {
4545 addressStorage[_key] = _value;
4646 }
47-
47+
4848 function set (bytes32 _key , bool _value ) internal {
4949 boolStorage[_key] = _value;
5050 }
51-
51+
5252 function set (bytes32 _key , bytes32 _value ) internal {
5353 bytes32Storage[_key] = _value;
5454 }
@@ -68,23 +68,23 @@ contract EternalStorage {
6868 /// Ex3 - mapping(string => SymbolDetails) registeredSymbols; where SymbolDetails is the structure having different type of values as
6969 /// {uint256 date, string name, address owner} etc.
7070 /// string _name = getString(keccak256(abi.encodePacked("registeredSymbols_name", "TOKEN"));
71-
71+
7272 function getBool (bytes32 _key ) internal view returns (bool ) {
7373 return boolStorage[_key];
7474 }
75-
75+
7676 function getUint (bytes32 _key ) internal view returns (uint256 ) {
7777 return uintStorage[_key];
7878 }
79-
79+
8080 function getAddress (bytes32 _key ) internal view returns (address ) {
8181 return addressStorage[_key];
8282 }
83-
83+
8484 function getString (bytes32 _key ) internal view returns (string ) {
8585 return stringStorage[_key];
8686 }
87-
87+
8888 function getBytes32 (bytes32 _key ) internal view returns (bytes32 ) {
8989 return bytes32Storage[_key];
9090 }
@@ -95,11 +95,11 @@ contract EternalStorage {
9595 ////////////////////////////
9696 /// @notice Function use to delete the array element.
9797 /// Ex1- mapping(address => bytes32[]) tokensOwnedByOwner;
98- /// For deleting the item from array developers needs to create a funtion for that similarly
98+ /// For deleting the item from array developers needs to create a funtion for that similarly
9999 /// in this case we have the helper function deleteArrayBytes32() which will do it for us
100100 /// deleteArrayBytes32(keccak256(abi.encodePacked("tokensOwnedByOwner", 0x1), 3); -- it will delete the index 3
101-
102-
101+
102+
103103 //Deletes from mapping (bytes32 => array[]) at index _index
104104 function deleteArrayAddress (bytes32 _key , uint256 _index ) internal {
105105 address [] storage array = addressArrayStorage[_key];
@@ -123,7 +123,7 @@ contract EternalStorage {
123123 array[_index] = array[array.length - 1 ];
124124 array.length = array.length - 1 ;
125125 }
126-
126+
127127 //Deletes from mapping (bytes32 => string[]) at index _index
128128 function deleteArrayString (bytes32 _key , uint256 _index ) internal {
129129 string [] storage array = stringArrayStorage[_key];
@@ -139,7 +139,7 @@ contract EternalStorage {
139139 /// Ex1- mapping(address => bytes32[]) tokensOwnedByTicker;
140140 /// tokensOwnedByTicker[owner] = tokensOwnedByTicker[owner].push("xyz"); replace with
141141 /// pushArray(keccak256(abi.encodePacked("tokensOwnedByTicker", owner), "xyz");
142-
142+
143143 /// @notice use to store the values for the array
144144 /// @param _key bytes32 type
145145 /// @param _value [uint256, string, bytes32, address] any of the data type in array
@@ -168,19 +168,19 @@ contract EternalStorage {
168168 /// Ex2- uint256 _len = tokensOwnedByOwner[0x1].length; replace with
169169 /// getArrayBytes32(keccak256(abi.encodePacked("tokensOwnedByOwner", 0x1)).length;
170170
171- function getArrayAddress (bytes32 _key ) internal returns (address []) {
171+ function getArrayAddress (bytes32 _key ) internal view returns (address []) {
172172 return addressArrayStorage[_key];
173173 }
174174
175- function getArrayBytes32 (bytes32 _key ) internal returns (bytes32 []) {
175+ function getArrayBytes32 (bytes32 _key ) internal view returns (bytes32 []) {
176176 return bytes32ArrayStorage[_key];
177177 }
178178
179- function getArrayString (bytes32 _key ) internal returns (string []) {
179+ function getArrayString (bytes32 _key ) internal view returns (string []) {
180180 return stringArrayStorage[_key];
181181 }
182182
183- function getArrayUint (bytes32 _key ) internal returns (uint []) {
183+ function getArrayUint (bytes32 _key ) internal view returns (uint []) {
184184 return uintArrayStorage[_key];
185185 }
186186
@@ -212,5 +212,5 @@ contract EternalStorage {
212212 function getBytesValues (bytes32 _variable ) public view returns (bytes ) {
213213 return bytesStorage[_variable];
214214 }
215-
216- }
215+
216+ }
0 commit comments