Skip to content

Commit cd4a7f9

Browse files
maxsam4adamdossa
authored andcommitted
Solidity 0.5.0 (#478)
* Added truffle next * Added refactor plugin * Capped STO refactor * constant to view * Updated refactor * added storage location to return params * pm fixes * Oraclize fixes * Custom datatype fixes * Updated refactor * PM fixes * Updated Oraclize * wip * It's compiling! * Updated CI config * Updated CI config * Updated circleCI config * Updated circleCI * Updated CircleCI config * Payable address changes * reduced contract size for test * Updated truffle * Deployment fixed * merge refactor * Revert oraclize changes * WIP * Migrations refactoring complete * Prettier * refactor js * wip * Create insctance fixed * Create instance changes * await at * log watch refactor * Getsig fixed * cappedsto init fn fixed * Block number and timestamp fixed * Await at * toWei to BN * Time travel fixed * Time travel changed * wip * Minor fixes * WIP * bug fix * WIP * capped stro tests fixed * Investor details fixed * ST instance name fixed * Checkpoint tests fixed * CTM tests fixed * empty bytes to 0x0 * wip * toNumber to toString * Whitelist changes * ERC20 tests fixed * WIP * Ether dividend tests fixed * Added fixed address * Permissions to hex * GPM tests fixed * gtm tests fixed * Coverage fixed * updated oz * Updated circleCI docker image * updated coverage script * Updated circleci config * Updated travis script * Updated ci scripts * Issuance tests fixed * MATM tests fixed * Module registry tests fixed * percentage tm tests fixed * Presale tests fixed * STR tests fixed * ST tests fixed * fixed z_general_permission_manager_fuzzer.js * fixed y_scheduled_checkpoints.js * fixed v_tracked_redemptions.js * fixed u_module_registry_proxy.js * fixed t_security_token_registry_proxy.js * Updated usd tiered sto tests * fixed r_concurrent_STO.js * simulation WIP * USDTSTO sim fixed * minor cleanup * added tolerance * Tolerance fixed * update version to 0.5.0 * fixed compilation errors * Coverage script fixed * Tests updated * fixed 2_deploy_contracts.js * Tests fixed * time travel updated * STR test fixed * suggested changes * Merge compilation fix * test fixed * STR proxy tests fixed * reformatting * fixed typo * non payable owner * triggering travis * ST optimization * uncommented tests
1 parent ef2e32f commit cd4a7f9

File tree

166 files changed

+9308
-7796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+9308
-7796
lines changed

.circleci/config.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:8
5+
- image: maxsam4/solidity-kit
66
steps:
77
- checkout
88
- restore_cache:
99
key: dependency-cache-{{ checksum "package.json" }}
1010
- run: yarn install
11-
- run: sudo npm i truffle -g
1211
- run: node --version
1312
- run: truffle version
1413
- run: truffle compile
@@ -18,14 +17,13 @@ jobs:
1817
- node_modules
1918
test:
2019
docker:
21-
- image: circleci/node:8
20+
- image: maxsam4/solidity-kit
2221
parallelism: 2
2322
steps:
2423
- checkout
2524
- restore_cache:
2625
key: dependency-cache-{{ checksum "package.json" }}
2726
- run: yarn install
28-
- run: sudo npm i truffle -g
2927
- run: node --version
3028
- run: truffle version
3129
- run: npm run test
@@ -39,13 +37,12 @@ jobs:
3937
path: ./test-results/mocha/results.xml
4038
coverage:
4139
docker:
42-
- image: circleci/node:8
40+
- image: maxsam4/solidity-kit
4341
steps:
4442
- checkout
4543
- restore_cache:
4644
key: dependency-cache-{{ checksum "package.json" }}
4745
- run: yarn install
48-
- run: sudo npm i truffle -g
4946
- run: node --version
5047
- run: truffle version
5148
- run:
@@ -59,13 +56,12 @@ jobs:
5956
path: ./coverage/lcov.info
6057
docs:
6158
docker:
62-
- image: circleci/node:8
59+
- image: maxsam4/solidity-kit
6360
steps:
6461
- checkout
6562
- restore_cache:
6663
key: dependency-cache-{{ checksum "package.json" }}
6764
- run: yarn install
68-
- run: sudo npm i truffle -g
6965
- run: node --version
7066
- run: truffle version
7167
- run: npm run docs

.solcover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ module.exports = {
55
testCommand: 'node ../node_modules/.bin/truffle test `find test/*.js ! -name a_poly_oracle.js -and ! -name s_v130_to_v140_upgrade.js -and ! -name q_usd_tiered_sto_sim.js -and ! -name z_general_permission_manager_fuzzer.js` --network coverage',
66
deepSkip: true,
77
skipFiles: ['external', 'flat', 'helpers', 'mocks', 'oracles', 'libraries/KindMath.sol', 'libraries/BokkyPooBahsDateTimeLibrary.sol', 'storage', 'modules/Experimental'],
8-
forceParse: ['mocks', 'oracles', 'modules/Experimental']
8+
forceParse: ['mocks', 'oracles', 'helpers', 'modules/Experimental']
99
};

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ cache:
66
- node_modules
77
jobs:
88
include:
9-
- stage: test
9+
- stage: Test
10+
install:
11+
- echo -ne '\n' | sudo add-apt-repository ppa:ethereum/ethereum
12+
- sudo apt-get update
13+
- sudo apt-get install -y dpkg
14+
- sudo apt-get install -y solc
15+
- yarn install
1016
before_script: truffle version
1117
script: npm run test
1218
notifications:

contracts/FeatureRegistry.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.4.24;
1+
pragma solidity ^0.5.0;
22

33
import "./ReclaimTokens.sol";
44
import "./interfaces/IFeatureRegistry.sol";
@@ -7,8 +7,7 @@ import "./interfaces/IFeatureRegistry.sol";
77
* @title Registry for managing polymath feature switches
88
*/
99
contract FeatureRegistry is IFeatureRegistry, ReclaimTokens {
10-
11-
mapping (bytes32 => bool) public featureStatus;
10+
mapping(bytes32 => bool) public featureStatus;
1211

1312
event ChangeFeatureStatus(string _nameKey, bool _newStatus);
1413

@@ -17,7 +16,7 @@ contract FeatureRegistry is IFeatureRegistry, ReclaimTokens {
1716
* @param _nameKey is the key for the feature status mapping
1817
* @return bool
1918
*/
20-
function getFeatureStatus(string _nameKey) external view returns(bool) {
19+
function getFeatureStatus(string calldata _nameKey) external view returns(bool) {
2120
bytes32 key = keccak256(bytes(_nameKey));
2221
return featureStatus[key];
2322
}
@@ -28,7 +27,7 @@ contract FeatureRegistry is IFeatureRegistry, ReclaimTokens {
2827
* @param _nameKey is the key for the feature status mapping
2928
* @param _newStatus is the new feature status
3029
*/
31-
function setFeatureStatus(string _nameKey, bool _newStatus) public onlyOwner {
30+
function setFeatureStatus(string calldata _nameKey, bool _newStatus) external onlyOwner {
3231
bytes32 key = keccak256(bytes(_nameKey));
3332
require(featureStatus[key] != _newStatus, "Status unchanged");
3433
emit ChangeFeatureStatus(_nameKey, _newStatus);

contracts/Migrations.sol

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
pragma solidity ^0.4.24;
2-
1+
pragma solidity ^0.5.0;
32

43
contract Migrations {
5-
64
address public owner;
75

86
uint public lastCompletedMigration;
@@ -16,11 +14,11 @@ contract Migrations {
1614
owner = msg.sender;
1715
}
1816

19-
function setCompleted(uint _completed)public restricted {
17+
function setCompleted(uint _completed) public restricted {
2018
lastCompletedMigration = _completed;
2119
}
2220

23-
function upgrade(address _newAddress)public restricted {
21+
function upgrade(address _newAddress) public restricted {
2422
Migrations upgraded = Migrations(_newAddress);
2523
upgraded.setCompleted(lastCompletedMigration);
2624
}

contracts/ModuleRegistry.sol

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.4.24;
1+
pragma solidity ^0.5.0;
22

33
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
44
import "./interfaces/IModuleRegistry.sol";
@@ -41,7 +41,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
4141

4242
// Emit when network becomes paused
4343
event Pause(uint256 _timestammp);
44-
// Emit when network becomes unpaused
44+
// Emit when network becomes unpaused
4545
event Unpause(uint256 _timestamp);
4646
// Emit when Module is used by the SecurityToken
4747
event ModuleUsed(address indexed _moduleFactory, address indexed _securityToken);
@@ -62,16 +62,15 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
6262
* @dev Throws if called by any account other than the owner.
6363
*/
6464
modifier onlyOwner() {
65-
require(msg.sender == owner(),"sender must be owner");
65+
require(msg.sender == owner(), "sender must be owner");
6666
_;
6767
}
6868

6969
/**
7070
* @notice Modifier to make a function callable only when the contract is not paused.
7171
*/
7272
modifier whenNotPausedOrOwner() {
73-
if (msg.sender == owner())
74-
_;
73+
if (msg.sender == owner()) _;
7574
else {
7675
require(!isPaused(), "Already paused");
7776
_;
@@ -99,13 +98,12 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
9998
/////////////////////////////
10099

101100
// Constructor
102-
constructor () public
103-
{
101+
constructor() public {
104102

105103
}
106104

107105
function initialize(address _polymathRegistry, address _owner) external payable {
108-
require(!getBool(Encoder.getKey("initialised")),"already initialized");
106+
require(!getBool(Encoder.getKey("initialised")), "already initialized");
109107
require(_owner != address(0) && _polymathRegistry != address(0), "0x address is invalid");
110108
set(Encoder.getKey("polymathRegistry"), _polymathRegistry);
111109
set(Encoder.getKey("owner"), _owner);
@@ -124,7 +122,10 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
124122
// This if statement is required to be able to add modules from the token proxy contract during deployment
125123
if (ISecurityTokenRegistry(getAddress(Encoder.getKey("securityTokenRegistry"))).isSecurityToken(msg.sender)) {
126124
if (IFeatureRegistry(getAddress(Encoder.getKey("featureRegistry"))).getFeatureStatus("customModulesAllowed")) {
127-
require(getBool(Encoder.getKey("verified", _moduleFactory)) || IOwnable(_moduleFactory).owner() == IOwnable(msg.sender).owner(),"ModuleFactory must be verified or SecurityToken owner must be ModuleFactory owner");
125+
require(
126+
getBool(Encoder.getKey("verified", _moduleFactory)) || IOwnable(_moduleFactory).owner() == IOwnable(msg.sender).owner(),
127+
"ModuleFactory must be verified or SecurityToken owner must be ModuleFactory owner"
128+
);
128129
} else {
129130
require(getBool(Encoder.getKey("verified", _moduleFactory)), "ModuleFactory must be verified");
130131
}
@@ -149,7 +150,10 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
149150
*/
150151
function registerModule(address _moduleFactory) external whenNotPausedOrOwner {
151152
if (IFeatureRegistry(getAddress(Encoder.getKey("featureRegistry"))).getFeatureStatus("customModulesAllowed")) {
152-
require(msg.sender == IOwnable(_moduleFactory).owner() || msg.sender == owner(),"msg.sender must be the Module Factory owner or registry curator");
153+
require(
154+
msg.sender == IOwnable(_moduleFactory).owner() || msg.sender == owner(),
155+
"msg.sender must be the Module Factory owner or registry curator"
156+
);
153157
} else {
154158
require(msg.sender == owner(), "Only owner allowed to register modules");
155159
}
@@ -173,7 +177,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
173177
uint256(getArrayAddress(Encoder.getKey("moduleList", uint256(moduleType))).length)
174178
);
175179
pushArray(Encoder.getKey("moduleList", uint256(moduleType)), _moduleFactory);
176-
emit ModuleRegistered (_moduleFactory, IOwnable(_moduleFactory).owner());
180+
emit ModuleRegistered(_moduleFactory, IOwnable(_moduleFactory).owner());
177181
}
178182

179183
/**
@@ -232,7 +236,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
232236
* @return list of tags
233237
* @return corresponding list of module factories
234238
*/
235-
function getTagsByTypeAndToken(uint8 _moduleType, address _securityToken) external view returns(bytes32[], address[]) {
239+
function getTagsByTypeAndToken(uint8 _moduleType, address _securityToken) external view returns(bytes32[] memory, address[] memory) {
236240
address[] memory modules = getModulesByTypeAndToken(_moduleType, _securityToken);
237241
return _tagsByModules(modules);
238242
}
@@ -243,7 +247,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
243247
* @return list of tags
244248
* @return corresponding list of module factories
245249
*/
246-
function getTagsByType(uint8 _moduleType) external view returns(bytes32[], address[]) {
250+
function getTagsByType(uint8 _moduleType) external view returns(bytes32[] memory, address[] memory) {
247251
address[] memory modules = getModulesByType(_moduleType);
248252
return _tagsByModules(modules);
249253
}
@@ -254,7 +258,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
254258
* @return list of tags
255259
* @return corresponding list of module factories
256260
*/
257-
function _tagsByModules(address[] _modules) internal view returns(bytes32[], address[]) {
261+
function _tagsByModules(address[] memory _modules) internal view returns(bytes32[] memory, address[] memory) {
258262
uint256 counter = 0;
259263
uint256 i;
260264
uint256 j;
@@ -281,7 +285,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
281285
* @param _factoryAddress is the address of the module factory
282286
* @return address array which contains the list of securityTokens that use that module factory
283287
*/
284-
function getReputationByFactory(address _factoryAddress) external view returns(address[]) {
288+
function getReputationByFactory(address _factoryAddress) external view returns(address[] memory) {
285289
return getArrayAddress(Encoder.getKey("reputation", _factoryAddress));
286290
}
287291

@@ -290,7 +294,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
290294
* @param _moduleType Type of Module
291295
* @return address array that contains the list of addresses of module factory contracts.
292296
*/
293-
function getModulesByType(uint8 _moduleType) public view returns(address[]) {
297+
function getModulesByType(uint8 _moduleType) public view returns(address[] memory) {
294298
return getArrayAddress(Encoder.getKey("moduleList", uint256(_moduleType)));
295299
}
296300

@@ -300,37 +304,38 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
300304
* @param _securityToken is the address of SecurityToken
301305
* @return address array that contains the list of available addresses of module factory contracts.
302306
*/
303-
function getModulesByTypeAndToken(uint8 _moduleType, address _securityToken) public view returns (address[]) {
307+
function getModulesByTypeAndToken(uint8 _moduleType, address _securityToken) public view returns(address[] memory) {
304308
uint256 _len = getArrayAddress(Encoder.getKey("moduleList", uint256(_moduleType))).length;
305309
address[] memory _addressList = getArrayAddress(Encoder.getKey("moduleList", uint256(_moduleType)));
306-
bool _isCustomModuleAllowed = IFeatureRegistry(getAddress(Encoder.getKey("featureRegistry"))).getFeatureStatus("customModulesAllowed");
310+
bool _isCustomModuleAllowed = IFeatureRegistry(getAddress(Encoder.getKey("featureRegistry"))).getFeatureStatus(
311+
"customModulesAllowed"
312+
);
307313
uint256 counter = 0;
308314
for (uint256 i = 0; i < _len; i++) {
309315
if (_isCustomModuleAllowed) {
310-
if (IOwnable(_addressList[i]).owner() == IOwnable(_securityToken).owner() || getBool(Encoder.getKey("verified", _addressList[i])))
311-
if(_isCompatibleModule(_addressList[i], _securityToken))
312-
counter++;
313-
}
314-
else if (getBool(Encoder.getKey("verified", _addressList[i]))) {
315-
if(_isCompatibleModule(_addressList[i], _securityToken))
316-
counter++;
316+
if (IOwnable(_addressList[i]).owner() == IOwnable(_securityToken).owner() || getBool(
317+
Encoder.getKey("verified", _addressList[i])
318+
)) if (_isCompatibleModule(_addressList[i], _securityToken)) counter++;
319+
} else if (getBool(Encoder.getKey("verified", _addressList[i]))) {
320+
if (_isCompatibleModule(_addressList[i], _securityToken)) counter++;
317321
}
318322
}
319323
address[] memory _tempArray = new address[](counter);
320324
counter = 0;
321325
for (uint256 j = 0; j < _len; j++) {
322326
if (_isCustomModuleAllowed) {
323-
if (IOwnable(_addressList[j]).owner() == IOwnable(_securityToken).owner() || getBool(Encoder.getKey("verified", _addressList[j]))) {
324-
if(_isCompatibleModule(_addressList[j], _securityToken)) {
327+
if (IOwnable(_addressList[j]).owner() == IOwnable(_securityToken).owner() || getBool(
328+
Encoder.getKey("verified", _addressList[j])
329+
)) {
330+
if (_isCompatibleModule(_addressList[j], _securityToken)) {
325331
_tempArray[counter] = _addressList[j];
326-
counter ++;
332+
counter++;
327333
}
328334
}
329-
}
330-
else if (getBool(Encoder.getKey("verified", _addressList[j]))) {
331-
if(_isCompatibleModule(_addressList[j], _securityToken)) {
335+
} else if (getBool(Encoder.getKey("verified", _addressList[j]))) {
336+
if (_isCompatibleModule(_addressList[j], _securityToken)) {
332337
_tempArray[counter] = _addressList[j];
333-
counter ++;
338+
counter++;
334339
}
335340
}
336341
}
@@ -345,7 +350,7 @@ contract ModuleRegistry is IModuleRegistry, EternalStorage {
345350
require(_tokenContract != address(0), "0x address is invalid");
346351
IERC20 token = IERC20(_tokenContract);
347352
uint256 balance = token.balanceOf(address(this));
348-
require(token.transfer(owner(), balance),"token transfer failed");
353+
require(token.transfer(owner(), balance), "token transfer failed");
349354
}
350355

351356
/**

contracts/Pausable.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
pragma solidity ^0.4.24;
1+
pragma solidity ^0.5.0;
22

33
/**
44
* @title Utility contract to allow pausing and unpausing of certain functions
55
*/
66
contract Pausable {
7-
87
event Pause(uint256 _timestammp);
98
event Unpause(uint256 _timestamp);
109

@@ -26,7 +25,7 @@ contract Pausable {
2625
_;
2726
}
2827

29-
/**
28+
/**
3029
* @notice Called by the owner to pause, triggers stopped state
3130
*/
3231
function _pause() internal whenNotPaused {

contracts/PolymathRegistry.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
pragma solidity ^0.4.24;
1+
pragma solidity ^0.5.0;
22

33
import "./ReclaimTokens.sol";
44

55
/**
66
* @title Core functionality for registry upgradability
77
*/
88
contract PolymathRegistry is ReclaimTokens {
9-
10-
mapping (bytes32 => address) public storedAddresses;
9+
mapping(bytes32 => address) public storedAddresses;
1110

1211
event ChangeAddress(string _nameKey, address indexed _oldAddress, address indexed _newAddress);
1312

@@ -16,7 +15,7 @@ contract PolymathRegistry is ReclaimTokens {
1615
* @param _nameKey is the key for the contract address mapping
1716
* @return address
1817
*/
19-
function getAddress(string _nameKey) external view returns(address) {
18+
function getAddress(string calldata _nameKey) external view returns(address) {
2019
bytes32 key = keccak256(bytes(_nameKey));
2120
require(storedAddresses[key] != address(0), "Invalid address key");
2221
return storedAddresses[key];
@@ -27,11 +26,10 @@ contract PolymathRegistry is ReclaimTokens {
2726
* @param _nameKey is the key for the contract address mapping
2827
* @param _newAddress is the new contract address
2928
*/
30-
function changeAddress(string _nameKey, address _newAddress) external onlyOwner {
29+
function changeAddress(string calldata _nameKey, address _newAddress) external onlyOwner {
3130
bytes32 key = keccak256(bytes(_nameKey));
3231
emit ChangeAddress(_nameKey, storedAddresses[key], _newAddress);
3332
storedAddresses[key] = _newAddress;
3433
}
3534

36-
3735
}

0 commit comments

Comments
 (0)