Skip to content

Commit

Permalink
Merge pull request #85 from PolymathNetwork/test-solidity-latest-version
Browse files Browse the repository at this point in the history
solidity version changes to 0.4.23
  • Loading branch information
adamdossa authored Apr 23, 2018
2 parents 6c39c4a + 4f805a4 commit 71f583d
Show file tree
Hide file tree
Showing 33 changed files with 117 additions and 114 deletions.
4 changes: 2 additions & 2 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


contract Migrations {
Expand All @@ -12,7 +12,7 @@ contract Migrations {
_;
}

function Migrations() public {
constructor() public {
owner = msg.sender;
}

Expand Down
15 changes: 8 additions & 7 deletions contracts/ModuleRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./interfaces/IModuleRegistry.sol";
import "./interfaces/IModuleFactory.sol";
Expand Down Expand Up @@ -32,9 +32,10 @@ contract ModuleRegistry is IModuleRegistry, Ownable {
function useModule(address _moduleFactory) external {
//msg.sender must be a security token - below will throw if not
ISecurityTokenRegistry(securityTokenRegistry).getSecurityTokenData(msg.sender);
require(registry[_moduleFactory] != 0);
require(registry[_moduleFactory] != 0, "ModuleFactory type should not be 0");
//To use a module, either it must be verified, or owned by the ST owner
require(verified[_moduleFactory]||(IModuleFactory(_moduleFactory).owner() == ISecurityToken(msg.sender).owner()));
require(verified[_moduleFactory]||(IModuleFactory(_moduleFactory).owner() == ISecurityToken(msg.sender).owner()),
"Module factory is not verified as well as not called by the owner");
reputation[_moduleFactory].push(msg.sender);
emit LogModuleUsed (_moduleFactory, msg.sender);
}
Expand All @@ -44,9 +45,9 @@ contract ModuleRegistry is IModuleRegistry, Ownable {
* @param _moduleFactory is the address of the module factory to be registered
*/
function registerModule(address _moduleFactory) external returns(bool) {
require(registry[_moduleFactory] == 0);
require(registry[_moduleFactory] == 0, "Module factory should not be pre-registered");
IModuleFactory moduleFactory = IModuleFactory(_moduleFactory);
require(moduleFactory.getType() != 0);
require(moduleFactory.getType() != 0, "Factory type should not equal to 0");
registry[_moduleFactory] = moduleFactory.getType();
moduleList[moduleFactory.getType()].push(_moduleFactory);
reputation[_moduleFactory] = new address[](0);
Expand All @@ -62,7 +63,7 @@ contract ModuleRegistry is IModuleRegistry, Ownable {
*/
function verifyModule(address _moduleFactory, bool _verified) external onlyOwner returns(bool) {
//Must already have been registered
require(registry[_moduleFactory] != 0);
require(registry[_moduleFactory] != 0, "Module factory should have been already registered");
verified[_moduleFactory] = _verified;
emit LogModuleVerified(_moduleFactory, _verified);
return true;
Expand All @@ -73,7 +74,7 @@ contract ModuleRegistry is IModuleRegistry, Ownable {
* @param _securityTokenRegistry is the address of the token registry
*/
function setTokenRegistry(address _securityTokenRegistry) public onlyOwner {
require(_securityTokenRegistry != address(0));
require(_securityTokenRegistry != address(0), "Address of securityTokenregistry should not be 0x");
securityTokenRegistry = _securityTokenRegistry;
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/SecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./interfaces/ITickerRegistry.sol";
import "./tokens/SecurityToken.sol";
Expand All @@ -16,7 +16,7 @@ contract SecurityTokenRegistry is Ownable, ISecurityTokenRegistry, Util {
* @dev Constructor used to set the essentials addresses to facilitate
* the creation of the security token
*/
function SecurityTokenRegistry(
constructor (
address _polyAddress,
address _moduleRegistry,
address _tickerRegistry,
Expand All @@ -40,8 +40,8 @@ contract SecurityTokenRegistry is Ownable, ISecurityTokenRegistry, Util {
* @param _tokenDetails off-chain details of the token
*/
function generateSecurityToken(string _name, string _symbol, uint8 _decimals, bytes32 _tokenDetails) public {
require(bytes(_name).length > 0 && bytes(_symbol).length > 0);
require(ITickerRegistry(tickerRegistry).checkValidity(_symbol, msg.sender, _name));
require(bytes(_name).length > 0 && bytes(_symbol).length > 0, "Name and Symbol string length should be greater than 0");
require(ITickerRegistry(tickerRegistry).checkValidity(_symbol, msg.sender, _name), "Trying to use non-valid symbol");
string memory symbol = upper(_symbol);
address newSecurityTokenAddress = ISTProxy(protocolVersionST[protocolVersion]).deployToken(
_name,
Expand Down
20 changes: 10 additions & 10 deletions contracts/TickerRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

/*
Allows issuers to reserve their token symbols ahead of actually generating their security token.
Expand Down Expand Up @@ -43,7 +43,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
// Emit when the token symbol expiry get changed
event LogChangeExpiryLimit(uint256 _oldExpiry, uint256 _newExpiry);

function TickerRegistry() public {
constructor() public {

}

Expand All @@ -57,9 +57,9 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
* @param _swarmHash Off-chain details of the issuer and token
*/
function registerTicker(address _owner, string _symbol, string _tokenName, bytes32 _swarmHash) public {
require(bytes(_symbol).length > 0 && bytes(_symbol).length <= 10);
require(bytes(_symbol).length > 0 && bytes(_symbol).length <= 10, "Ticker length should always between 0 & 10");
string memory symbol = upper(_symbol);
require(expiryCheck(symbol));
require(expiryCheck(symbol), "Ticker is already reserved");
registeredSymbols[symbol] = SymbolDetails(_owner, now, _tokenName, _swarmHash, false);
emit LogRegisterTicker (_owner, symbol, _tokenName, _swarmHash, now);
}
Expand All @@ -69,7 +69,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
* @param _newExpiry new time period for token symbol expiry
*/
function changeExpiryLimit(uint256 _newExpiry) public onlyOwner {
require(_newExpiry >= 1 days);
require(_newExpiry >= 1 days, "Expiry should greater than or equal to 1 day");
uint256 _oldExpiry = expiryLimit;
expiryLimit = _newExpiry;
emit LogChangeExpiryLimit(_oldExpiry, _newExpiry);
Expand All @@ -81,7 +81,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
* @return bool
*/
function setTokenRegistry(address _stRegistry) public onlyOwner returns(bool) {
require(_stRegistry != address(0) && strAddress == address(0));
require(_stRegistry != address(0) && strAddress == address(0), "Token registry contract is already set or input argument is 0x");
strAddress = _stRegistry;
return true;
}
Expand All @@ -95,10 +95,10 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util {
*/
function checkValidity(string _symbol, address _owner, string _tokenName) public returns(bool) {
string memory symbol = upper(_symbol);
require(msg.sender == strAddress);
require(registeredSymbols[symbol].status != true);
require(registeredSymbols[symbol].owner == _owner);
require(registeredSymbols[symbol].timestamp.add(expiryLimit) >= now);
require(msg.sender == strAddress, "msg.sender should be SecurityTokenRegistry contract");
require(registeredSymbols[symbol].status != true, "Symbol status should not equal to true");
require(registeredSymbols[symbol].owner == _owner, "Owner of the symbol should matched with the requested issuer address");
require(registeredSymbols[symbol].timestamp.add(expiryLimit) >= now, "Ticker should not be expired");
registeredSymbols[symbol].tokenName = _tokenName;
registeredSymbols[symbol].status = true;
return true;
Expand Down
4 changes: 2 additions & 2 deletions contracts/helpers/PolyToken.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";


contract PolyToken is MintableToken {

function PolyToken() public {
constructor () public {

}

Expand Down
2 changes: 1 addition & 1 deletion contracts/helpers/Util.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


contract Util {
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./ISecurityToken.sol";
import "./IModuleFactory.sol";
Expand All @@ -15,7 +15,7 @@ contract IModule {

ERC20 public polyToken;

function IModule(address _securityToken, address _polyAddress) public {
constructor (address _securityToken, address _polyAddress) public {
securityToken = _securityToken;
factory = msg.sender;
polyToken = ERC20(_polyAddress);
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IModuleFactory.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "zeppelin-solidity/contracts/ownership/Ownable.sol";
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
Expand All @@ -9,7 +9,7 @@ contract IModuleFactory is Ownable {

ERC20 public polyToken;

function IModuleFactory(address _polyAddress) public {
constructor (address _polyAddress) public {
polyToken = ERC20(_polyAddress);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IModuleRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


//Simple interface that any module contracts should implement
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IST20.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


contract IST20 {
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ISTProxy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


contract ISTProxy {
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ISecurityToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./IST20.sol";
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ISecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./ISecurityToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ITickerRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;


contract ITickerRegistry {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./IPermissionManager.sol";

Expand All @@ -25,7 +25,7 @@ contract GeneralPermissionManager is IPermissionManager {
event LogAddPermission(address _delegate, bytes32 _details, uint256 _timestamp);

/// @notice constructor
function GeneralPermissionManager(address _securityToken, address _polyAddress) public
constructor (address _securityToken, address _polyAddress) public
IModule(_securityToken, _polyAddress)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./GeneralPermissionManager.sol";
import "../../interfaces/IModuleFactory.sol";


contract GeneralPermissionManagerFactory is IModuleFactory {

function GeneralPermissionManagerFactory(address _polyAddress) public
IModuleFactory(_polyAddress)
constructor (address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes /* _data */) external returns(address) {
if(getCost() > 0)
require(polyToken.transferFrom(msg.sender, owner, getCost()));
require(polyToken.transferFrom(msg.sender, owner, getCost()), "Failed transferFrom because of sufficent Allowance is not provided");
return address(new GeneralPermissionManager(msg.sender, address(polyToken)));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/PermissionManager/IPermissionManager.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "../../interfaces/IModule.sol";

Expand Down
28 changes: 14 additions & 14 deletions contracts/modules/STO/CappedSTO.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.21;
pragma solidity ^0.4.23;

import "./ISTO.sol";
import "../../interfaces/IST20.sol";
Expand Down Expand Up @@ -41,7 +41,7 @@ contract CappedSTO is ISTO {
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

function CappedSTO(address _securityToken, address _polyAddress) public
constructor (address _securityToken, address _polyAddress) public
IModule(_securityToken, _polyAddress)
{
}
Expand All @@ -66,10 +66,10 @@ contract CappedSTO is ISTO {
public
onlyFactory
{
require(_rate > 0);
require(_fundsReceiver != address(0));
require(_startTime >= now && _endTime > _startTime);
require(_cap > 0);
require(_rate > 0, "Rate of token should be greater than 0");
require(_fundsReceiver != address(0), "Zero address is not permitted");
require(_startTime >= now && _endTime > _startTime, "Date parameters are not valid");
require(_cap > 0, "Cap should be greater than 0");
startTime = _startTime;
endTime = _endTime;
cap = _cap;
Expand All @@ -88,7 +88,7 @@ contract CappedSTO is ISTO {
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
require(fundraiseType == FundraiseType.ETH);
require(fundraiseType == FundraiseType.ETH, "ETH should be the mode of investment");

uint256 weiAmount = msg.value;
_processTx(_beneficiary, weiAmount);
Expand All @@ -102,8 +102,8 @@ contract CappedSTO is ISTO {
* @param _investedPOLY Amount of POLY invested
*/
function buyTokensWithPoly(uint256 _investedPOLY) public {
require(fundraiseType == FundraiseType.POLY);
require(verifyInvestment(msg.sender, _investedPOLY));
require(fundraiseType == FundraiseType.POLY, "POLY should be the mode of investment");
require(verifyInvestment(msg.sender, _investedPOLY), "Not valid Investment");
_processTx(msg.sender, _investedPOLY);
_forwardPoly(msg.sender, wallet, _investedPOLY);
_postValidatePurchase(msg.sender, _investedPOLY);
Expand Down Expand Up @@ -171,10 +171,10 @@ contract CappedSTO is ISTO {
* @param _investedAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _investedAmount) internal view {
require(_beneficiary != address(0));
require(_investedAmount != 0);
require(tokensSold.add(_getTokenAmount(_investedAmount)) <= cap);
require(now >= startTime && now <= endTime);
require(_beneficiary != address(0), "Beneficiary address should not be 0x");
require(_investedAmount != 0, "Amount invested should not be equal to 0");
require(tokensSold.add(_getTokenAmount(_investedAmount)) <= cap, "Investment more than cap is not allowed");
require(now >= startTime && now <= endTime, "Offering is closed/Not yet started");
}

/**
Expand All @@ -192,7 +192,7 @@ contract CappedSTO is ISTO {
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
require(IST20(securityToken).mint(_beneficiary, _tokenAmount));
require(IST20(securityToken).mint(_beneficiary, _tokenAmount), "Error in minting the tokens");
}

/**
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/STO/CappedSTOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import "../../interfaces/IModule.sol";

contract CappedSTOFactory is IModuleFactory {

function CappedSTOFactory(address _polyAddress) public
constructor (address _polyAddress) public
IModuleFactory(_polyAddress)
{

}

function deploy(bytes _data) external returns(address) {
if(getCost() > 0)
require(polyToken.transferFrom(msg.sender, owner, getCost()));
require(polyToken.transferFrom(msg.sender, owner, getCost()), "Failed transferFrom because of sufficent Allowance is not provided");
//Check valid bytes - can only call module init function
CappedSTO cappedSTO = new CappedSTO(msg.sender, address(polyToken));
//Checks that _data is valid (not calling anything it shouldn't)
require(getSig(_data) == cappedSTO.getInitFunction());
require(address(cappedSTO).call(_data));
require(getSig(_data) == cappedSTO.getInitFunction(), "Provided data is not valid");
require(address(cappedSTO).call(_data), "Un-successfull call");
return address(cappedSTO);
}

Expand Down
Loading

0 comments on commit 71f583d

Please sign in to comment.