Skip to content

Commit c2dc87e

Browse files
authored
Merge pull request #281 from PolymathNetwork/clean_warnings
Clean compile warnings
2 parents d205c98 + d2073ef commit c2dc87e

File tree

5 files changed

+67
-63
lines changed

5 files changed

+67
-63
lines changed

contracts/SecurityTokenRegistry.sol

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,34 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
9191
bool _fromAdmin
9292
);
9393

94+
/////////////////////////////
95+
// Modifiers
96+
/////////////////////////////
97+
98+
/**
99+
* @dev Throws if called by any account other than the owner.
100+
*/
101+
modifier onlyOwner() {
102+
require(msg.sender == getAddress(Encoder.getKey("owner")));
103+
_;
104+
}
105+
106+
/**
107+
* @notice Modifier to make a function callable only when the contract is not paused.
108+
*/
109+
modifier whenNotPaused() {
110+
require(!getBool(Encoder.getKey("paused")), "Already paused");
111+
_;
112+
}
113+
114+
/**
115+
* @notice Modifier to make a function callable only when the contract is paused.
116+
*/
117+
modifier whenPaused() {
118+
require(getBool(Encoder.getKey("paused")), "Should not be paused");
119+
_;
120+
}
121+
94122
/////////////////////////////
95123
// Initialization
96124
/////////////////////////////
@@ -110,7 +138,7 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
110138
* @param _polyToken is the address of the POLY ERC20 token
111139
* @param _owner is the owner of the STR
112140
*/
113-
function initialize(address _polymathRegistry, address _STFactory, uint256 _stLaunchFee, uint256 _tickerRegFee, address _polyToken, address _owner) payable public {
141+
function initialize(address _polymathRegistry, address _STFactory, uint256 _stLaunchFee, uint256 _tickerRegFee, address _polyToken, address _owner) payable external {
114142
require(!getBool(Encoder.getKey("initialised")));
115143
require(_STFactory != address(0) && _polyToken != address(0) && _owner != address(0) && _polymathRegistry != address(0), "0x address is in-valid");
116144
require(_stLaunchFee != 0 && _tickerRegFee != 0, "Fees should not be 0");
@@ -481,7 +509,7 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
481509
* @param _ticker is the ticker of the security token
482510
* @return address
483511
*/
484-
function getSecurityTokenAddress(string _ticker) public view returns (address) {
512+
function getSecurityTokenAddress(string _ticker) external view returns (address) {
485513
string memory __ticker = Util.upper(_ticker);
486514
return getAddress(Encoder.getKey("tickerToSecurityToken", __ticker));
487515
}
@@ -507,30 +535,6 @@ contract SecurityTokenRegistry is ISecurityTokenRegistry, EternalStorage {
507535
// Ownership, lifecycle & Utility
508536
/////////////////////////////
509537

510-
/**
511-
* @dev Throws if called by any account other than the owner.
512-
*/
513-
modifier onlyOwner() {
514-
require(msg.sender == getAddress(Encoder.getKey("owner")));
515-
_;
516-
}
517-
518-
/**
519-
* @notice Modifier to make a function callable only when the contract is not paused.
520-
*/
521-
modifier whenNotPaused() {
522-
require(!getBool(Encoder.getKey("paused")), "Already paused");
523-
_;
524-
}
525-
526-
/**
527-
* @notice Modifier to make a function callable only when the contract is paused.
528-
*/
529-
modifier whenPaused() {
530-
require(getBool(Encoder.getKey("paused")), "Should not be paused");
531-
_;
532-
}
533-
534538
/**
535539
* @dev Allows the current owner to transfer control of the contract to a newOwner.
536540
* @param _newOwner The address to transfer ownership to.

contracts/interfaces/ISecurityTokenRegistry.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface ISecurityTokenRegistry {
6262
* @param _ticker Symbol of the Scurity token
6363
* @return address
6464
*/
65-
function getSecurityTokenAddress(string _ticker) public view returns (address);
65+
function getSecurityTokenAddress(string _ticker) external view returns (address);
6666

6767
/**
6868
* @notice Get security token data by its address
@@ -77,7 +77,7 @@ interface ISecurityTokenRegistry {
7777
/**
7878
* @notice Get the current STFactory Address
7979
*/
80-
function getSTFactoryAddress() public view returns(address);
80+
function getSTFactoryAddress() external view returns(address);
8181

8282
/**
8383
* @notice Use to get the ticker list as per the owner

contracts/proxy/OwnedUpgradeabilityProxy.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import './UpgradeabilityProxy.sol';
77
* @dev This contract combines an upgradeability proxy with basic authorization control functionalities
88
*/
99
contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
10-
10+
1111
// Owner of the contract
1212
address private __upgradeabilityOwner;
13-
13+
1414
/**
1515
* @dev Event to show ownership has been transferred
1616
* @param _previousOwner representing the address of the previous owner
@@ -63,23 +63,23 @@ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
6363
* @dev Tells the address of the proxy owner
6464
* @return the address of the proxy owner
6565
*/
66-
function proxyOwner() external view ifOwner returns (address) {
66+
function proxyOwner() external ifOwner returns (address) {
6767
return _upgradeabilityOwner();
6868
}
6969

7070
/**
7171
* @dev Tells the version name of the current implementation
7272
* @return string representing the name of the current version
7373
*/
74-
function version() external view ifOwner returns (string) {
74+
function version() external ifOwner returns (string) {
7575
return __version;
7676
}
7777

7878
/**
7979
* @dev Tells the address of the current implementation
8080
* @return address of the current implementation
8181
*/
82-
function implementation() external view ifOwner returns (address) {
82+
function implementation() external ifOwner returns (address) {
8383
_implementation();
8484
}
8585

@@ -115,4 +115,4 @@ contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
115115
require(address(this).call.value(msg.value)(_data), "Fail in executing the function of implementation contract");
116116
}
117117

118-
}
118+
}

contracts/storage/EternalStorage.sol

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pragma solidity ^0.4.24;
22

33
contract 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+
}

contracts/tokens/SecurityToken.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr
134134
event LogDisableController(uint256 _timestamp);
135135

136136
function isModule(address _module, uint8 _type) internal view returns (bool) {
137-
require(modulesToData[msg.sender].module == msg.sender, "Address mismatch");
138-
require(modulesToData[msg.sender].moduleType == _type, "Type mismatch");
139-
require(!modulesToData[msg.sender].isArchived, "Module archived");
137+
require(modulesToData[_module].module == _module, "Address mismatch");
138+
require(modulesToData[_module].moduleType == _type, "Type mismatch");
139+
require(!modulesToData[_module].isArchived, "Module archived");
140140
return true;
141141
}
142142

0 commit comments

Comments
 (0)