diff --git a/CHANGELOG.md b/CHANGELOG.md index 9343860b9..f4bea021f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. * Replaced `updatePolyTokenAddress()` function with `updateFromRegistry()` in `SecurityTokenRegistry`. * Migrate all the getters of `SecurityTokenRegsitry.sol` to `STRGetter.sol` contract. * Removed `_polyToken` parameter from `initialize` function in `SecurityTokenRegistry`. +* Return SecurityToken version in the `getSecurityTokenData()` function. ## GeneralTransferManager * `modifyWhitelist()` function renamed to `modifyKYCData()`. diff --git a/contracts/STRGetter.sol b/contracts/STRGetter.sol index 85c2988bb..86a889657 100644 --- a/contracts/STRGetter.sol +++ b/contracts/STRGetter.sol @@ -1,6 +1,7 @@ pragma solidity ^0.5.0; import "./storage/EternalStorage.sol"; +import "./interfaces/ISecurityToken.sol"; import "./libraries/Util.sol"; import "./libraries/Encoder.sol"; import "./interfaces/IOwnable.sol"; @@ -199,13 +200,15 @@ contract STRGetter is EternalStorage { * @return address is the issuer of the security Token. * @return string is the details of the security token. * @return uint256 is the timestamp at which security Token was deployed. + * @return version of the securityToken */ - function getSecurityTokenData(address _securityToken) external view returns (string memory, address, string memory, uint256) { + function getSecurityTokenData(address _securityToken) external view returns (string memory, address, string memory, uint256, uint8[] memory) { return ( getStringValue(Encoder.getKey("securityTokens_ticker", _securityToken)), IOwnable(_securityToken).owner(), getStringValue(Encoder.getKey("securityTokens_tokenDetails", _securityToken)), - getUintValue(Encoder.getKey("securityTokens_deployedAt", _securityToken)) + getUintValue(Encoder.getKey("securityTokens_deployedAt", _securityToken)), + ISecurityToken(_securityToken).getVersion() ); } diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index 13733beb9..ce5486860 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -79,9 +79,10 @@ interface ISecurityTokenRegistry { * @return string Symbol of the Security Token. * @return address Address of the issuer of Security Token. * @return string Details of the Token. - * @return uint256 Timestamp at which Security Token get launched on Polymath platform. + * @return uint256 Timestamp at which Security Token get launched on Polymath platform + * @return version of the securityToken */ - function getSecurityTokenData(address _securityToken) external view returns(string memory, address, string memory, uint256); + function getSecurityTokenData(address _securityToken) external view returns(string memory, address, string memory, uint256, uint8[] memory); /** * @notice Get the current STFactory Address diff --git a/contracts/libraries/VolumeRestrictionLib.sol b/contracts/libraries/VolumeRestrictionLib.sol index 589256de1..9d30711b4 100644 --- a/contracts/libraries/VolumeRestrictionLib.sol +++ b/contracts/libraries/VolumeRestrictionLib.sol @@ -1,5 +1,6 @@ pragma solidity ^0.5.0; +import "../interfaces/IDataStore.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; import "../storage/modules/TransferManager/VolumeRestrictionTMStorage.sol"; @@ -7,6 +8,12 @@ library VolumeRestrictionLib { using SafeMath for uint256; + uint256 internal constant ONE = uint256(1); + uint8 internal constant INDEX = uint8(2); + bytes32 internal constant INVESTORFLAGS = "INVESTORFLAGS"; + bytes32 internal constant INVESTORSKEY = 0xdf3a8dd24acdd05addfc6aeffef7574d2de3f844535ec91e8e0f3e45dba96731; //keccak256(abi.encodePacked("INVESTORS")) + bytes32 internal constant WHITELIST = "WHITELIST"; + function _checkLengthOfArray( address[] memory _holders, uint256[] memory _allowedTokens, @@ -28,60 +35,89 @@ library VolumeRestrictionLib { ); } - function deleteHolderFromList(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public { + function deleteHolderFromList( + mapping(address => uint8) storage holderToRestrictionType, + address _holder, + address _dataStore, + uint8 _typeOfPeriod + ) + public + { // Deleting the holder if holder's type of Period is `Both` type otherwise // it will assign the given type `_typeOfPeriod` to the _holder typeOfPeriod // `_typeOfPeriod` it always be contrary to the removing restriction // if removing restriction is individual then typeOfPeriod is TypeOfPeriod.OneDay // in uint8 its value is 1. if removing restriction is daily individual then typeOfPeriod // is TypeOfPeriod.MultipleDays in uint8 its value is 0. - if (data.restrictedHolders[_holder].typeOfPeriod != uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) { - uint128 index = data.restrictedHolders[_holder].index; - uint256 _len = data.restrictedAddresses.length; - if (index != _len) { - data.restrictedHolders[data.restrictedAddresses[_len - 1]].index = index; - data.restrictedAddresses[index - 1] = data.restrictedAddresses[_len - 1]; - } - delete data.restrictedHolders[_holder]; - data.restrictedAddresses.length--; + if (holderToRestrictionType[_holder] != uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) { + IDataStore dataStore = IDataStore(_dataStore); + uint256 flags = dataStore.getUint256(_getKey(INVESTORFLAGS, _holder)); + flags = flags & ~(ONE << INDEX); + dataStore.setUint256(_getKey(INVESTORFLAGS, _holder), flags); } else { - data.restrictedHolders[_holder].typeOfPeriod = _typeOfPeriod; + holderToRestrictionType[_holder] = _typeOfPeriod; } } - function addRestrictionData(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public { - uint128 index = data.restrictedHolders[_holder].index; - if (data.restrictedHolders[_holder].seen == 0) { - data.restrictedAddresses.push(_holder); - index = uint128(data.restrictedAddresses.length); + function addRestrictionData( + mapping(address => uint8) storage holderToRestrictionType, + address _holder, + uint8 _callFrom, + uint256 _endTime, + address _dataStore + ) + public + { + IDataStore dataStore = IDataStore(_dataStore); + + uint256 flags = dataStore.getUint256(_getKey(INVESTORFLAGS, _holder)); + if (!_isExistingInvestor(_holder, dataStore)) { + dataStore.insertAddress(INVESTORSKEY, _holder); + //KYC data can not be present if added is false and hence we can set packed KYC as uint256(1) to set added as true + dataStore.setUint256(_getKey(WHITELIST, _holder), uint256(1)); } - uint8 _type = _getTypeOfPeriod(data.restrictedHolders[_holder].typeOfPeriod, _callFrom, _endTime); - data.restrictedHolders[_holder] = VolumeRestrictionTMStorage.RestrictedHolder(uint8(1), _type, index); + if (!_isVolRestricted(flags)) { + flags = flags | (ONE << INDEX); + dataStore.setUint256(_getKey(INVESTORFLAGS, _holder), flags); + } + uint8 _type = _getTypeOfPeriod(holderToRestrictionType[_holder], _callFrom, _endTime); + holderToRestrictionType[_holder] = _type; } - function _getTypeOfPeriod(uint8 _currentTypeOfPeriod, uint8 _callFrom, uint256 _endTime) internal pure returns(uint8) { - if (_currentTypeOfPeriod != _callFrom && _endTime != uint256(0)) - return uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both); - else - return _callFrom; - } + /** + * @notice Provide the restriction details of all the restricted addresses + * @return address List of the restricted addresses + * @return uint256 List of the tokens allowed to the restricted addresses corresponds to restricted address + * @return uint256 List of the start time of the restriction corresponds to restricted address + * @return uint256 List of the rolling period in days for a restriction corresponds to restricted address. + * @return uint256 List of the end time of the restriction corresponds to restricted address. + * @return uint8 List of the type of restriction to validate the value of the `allowedTokens` + * of the restriction corresponds to restricted address + */ function getRestrictionData( - VolumeRestrictionTMStorage.RestrictedData storage _holderData, - VolumeRestrictionTMStorage.IndividualRestrictions storage _individualRestrictions - ) public view returns( - address[] memory allAddresses, - uint256[] memory allowedTokens, - uint256[] memory startTime, - uint256[] memory rollingPeriodInDays, - uint256[] memory endTime, - uint8[] memory typeOfRestriction - ) + mapping(address => uint8) storage holderToRestrictionType, + VolumeRestrictionTMStorage.IndividualRestrictions storage _individualRestrictions, + address _dataStore + ) + public + view + returns( + address[] memory allAddresses, + uint256[] memory allowedTokens, + uint256[] memory startTime, + uint256[] memory rollingPeriodInDays, + uint256[] memory endTime, + uint8[] memory typeOfRestriction + ) { - uint256 counter = 0; - uint256 i = 0; - for (i = 0; i < _holderData.restrictedAddresses.length; i++) { - counter = counter + (_holderData.restrictedHolders[_holderData.restrictedAddresses[i]].typeOfPeriod == uint8(2) ? 2 : 1); + address[] memory investors = IDataStore(_dataStore).getAddressArray(INVESTORSKEY); + uint256 counter; + uint256 i; + for (i = 0; i < investors.length; i++) { + if (_isVolRestricted(IDataStore(_dataStore).getUint256(_getKey(INVESTORFLAGS, investors[i])))) { + counter = counter + (holderToRestrictionType[investors[i]] == uint8(2) ? 2 : 1); + } } allAddresses = new address[](counter); allowedTokens = new uint256[](counter); @@ -90,21 +126,23 @@ library VolumeRestrictionLib { endTime = new uint256[](counter); typeOfRestriction = new uint8[](counter); counter = 0; - for (i = 0; i < _holderData.restrictedAddresses.length; i++) { - allAddresses[counter] = _holderData.restrictedAddresses[i]; - if (_holderData.restrictedHolders[_holderData.restrictedAddresses[i]].typeOfPeriod == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.MultipleDays)) { - _setValues(_individualRestrictions.individualRestriction[_holderData.restrictedAddresses[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); - } - else if (_holderData.restrictedHolders[_holderData.restrictedAddresses[i]].typeOfPeriod == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.OneDay)) { - _setValues(_individualRestrictions.individualDailyRestriction[_holderData.restrictedAddresses[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); - } - else if (_holderData.restrictedHolders[_holderData.restrictedAddresses[i]].typeOfPeriod == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) { - _setValues(_individualRestrictions.individualRestriction[_holderData.restrictedAddresses[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); + for (i = 0; i < investors.length; i++) { + if (_isVolRestricted(IDataStore(_dataStore).getUint256(_getKey(INVESTORFLAGS, investors[i])))) { + allAddresses[counter] = investors[i]; + if (holderToRestrictionType[investors[i]] == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.MultipleDays)) { + _setValues(_individualRestrictions.individualRestriction[investors[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); + } + else if (holderToRestrictionType[investors[i]] == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.OneDay)) { + _setValues(_individualRestrictions.individualDailyRestriction[investors[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); + } + else if (holderToRestrictionType[investors[i]] == uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) { + _setValues(_individualRestrictions.individualRestriction[investors[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); + counter++; + allAddresses[counter] = investors[i]; + _setValues(_individualRestrictions.individualDailyRestriction[investors[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); + } counter++; - allAddresses[counter] = _holderData.restrictedAddresses[i]; - _setValues(_individualRestrictions.individualDailyRestriction[_holderData.restrictedAddresses[i]], allowedTokens, startTime, rollingPeriodInDays, endTime, typeOfRestriction, counter); } - counter++; } } @@ -127,4 +165,26 @@ library VolumeRestrictionLib { typeOfRestriction[index] = uint8(restriction.typeOfRestriction); } + function _isVolRestricted(uint256 _flags) internal pure returns(bool) { + uint256 volRestricted = (_flags >> INDEX) & ONE; + return (volRestricted > 0 ? true : false); + } + + function _getTypeOfPeriod(uint8 _currentTypeOfPeriod, uint8 _callFrom, uint256 _endTime) internal pure returns(uint8) { + if (_currentTypeOfPeriod != _callFrom && _endTime != uint256(0)) + return uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both); + else + return _callFrom; + } + + function _isExistingInvestor(address _investor, IDataStore dataStore) internal view returns(bool) { + uint256 data = dataStore.getUint256(_getKey(WHITELIST, _investor)); + //extracts `added` from packed `_whitelistData` + return uint8(data) == 0 ? false : true; + } + + function _getKey(bytes32 _key1, address _key2) internal pure returns(bytes32) { + return bytes32(keccak256(abi.encodePacked(_key1, _key2))); + } + } diff --git a/contracts/modules/Checkpoint/DividendCheckpoint.sol b/contracts/modules/Checkpoint/DividendCheckpoint.sol index f5d6d621d..60640409b 100644 --- a/contracts/modules/Checkpoint/DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/DividendCheckpoint.sol @@ -79,7 +79,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { * @notice Creates a checkpoint on the security token * @return Checkpoint ID */ - function createCheckpoint() public withPerm(CHECKPOINT) returns(uint256) { + function createCheckpoint() public withPerm(OPERATOR) returns(uint256) { return ISecurityToken(securityToken).createCheckpoint(); } @@ -87,7 +87,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { * @notice Function to clear and set list of excluded addresses used for future dividends * @param _excluded Addresses of investors */ - function setDefaultExcluded(address[] memory _excluded) public withPerm(MANAGE) { + function setDefaultExcluded(address[] memory _excluded) public withPerm(ADMIN) { require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many excluded addresses"); for (uint256 j = 0; j < _excluded.length; j++) { require(_excluded[j] != address(0), "Invalid address"); @@ -105,7 +105,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { * @param _investors Addresses of investors * @param _withholding Withholding tax for individual investors (multiplied by 10**16) */ - function setWithholding(address[] memory _investors, uint256[] memory _withholding) public withPerm(MANAGE) { + function setWithholding(address[] memory _investors, uint256[] memory _withholding) public withPerm(ADMIN) { require(_investors.length == _withholding.length, "Mismatched input lengths"); /*solium-disable-next-line security/no-block-members*/ emit SetWithholding(_investors, _withholding); @@ -120,7 +120,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { * @param _investors Addresses of investor * @param _withholding Withholding tax for all investors (multiplied by 10**16) */ - function setWithholdingFixed(address[] memory _investors, uint256 _withholding) public withPerm(MANAGE) { + function setWithholdingFixed(address[] memory _investors, uint256 _withholding) public withPerm(ADMIN) { require(_withholding <= 10 ** 18, "Incorrect withholding tax"); /*solium-disable-next-line security/no-block-members*/ emit SetWithholdingFixed(_investors, _withholding); @@ -139,7 +139,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { address payable[] memory _payees ) public - withPerm(DISTRIBUTE) + withPerm(OPERATOR) { _validDividendIndex(_dividendIndex); Dividend storage dividend = dividends[_dividendIndex]; @@ -161,8 +161,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { uint256 _start, uint256 _iterations ) public - withPerm(DISTRIBUTE) - + withPerm(OPERATOR) { _validDividendIndex(_dividendIndex); Dividend storage dividend = dividends[_dividendIndex]; @@ -393,8 +392,8 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module { */ function getPermissions() public view returns(bytes32[] memory) { bytes32[] memory allPermissions = new bytes32[](2); - allPermissions[0] = DISTRIBUTE; - allPermissions[1] = MANAGE; + allPermissions[0] = ADMIN; + allPermissions[1] = OPERATOR; return allPermissions; } diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol index 68d24c38e..02037e502 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol @@ -56,7 +56,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec bytes32 _name ) external - withPerm(MANAGE) + withPerm(ADMIN) { createDividendWithExclusions(_maturity, _expiry, _token, _amount, excluded, _name); } @@ -79,7 +79,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec bytes32 _name ) external - withPerm(MANAGE) + withPerm(ADMIN) { _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, excluded, _name); } @@ -102,7 +102,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec bytes32 _name ) public - withPerm(MANAGE) + withPerm(ADMIN) { uint256 checkpointId = ISecurityToken(securityToken).createCheckpoint(); _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, checkpointId, _excluded, _name); @@ -128,7 +128,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec bytes32 _name ) public - withPerm(MANAGE) + withPerm(ADMIN) { _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, _excluded, _name); } @@ -251,7 +251,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec * @notice Issuer can reclaim remaining unclaimed dividend amounts, for expired dividends * @param _dividendIndex Dividend to reclaim */ - function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) { + function reclaimDividend(uint256 _dividendIndex) external withPerm(OPERATOR) { require(_dividendIndex < dividends.length, "Invalid dividend"); /*solium-disable-next-line security/no-block-members*/ require(now >= dividends[_dividendIndex].expiry, "Dividend expiry in future"); @@ -267,7 +267,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec * @notice Allows issuer to withdraw withheld tax * @param _dividendIndex Dividend to withdraw from */ - function withdrawWithholding(uint256 _dividendIndex) external withPerm(MANAGE) { + function withdrawWithholding(uint256 _dividendIndex) external withPerm(OPERATOR) { require(_dividendIndex < dividends.length, "Invalid dividend"); Dividend storage dividend = dividends[_dividendIndex]; uint256 remainingWithheld = dividend.totalWithheld.sub(dividend.totalWithheldWithdrawn); diff --git a/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol b/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol index 0c8cae750..ab82a1ee1 100644 --- a/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/EtherDividendCheckpoint.sol @@ -39,7 +39,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { * @param _expiry Time until dividend can no longer be paid, and can be reclaimed by issuer * @param _name Name/title for identification */ - function createDividend(uint256 _maturity, uint256 _expiry, bytes32 _name) external payable withPerm(MANAGE) { + function createDividend(uint256 _maturity, uint256 _expiry, bytes32 _name) external payable withPerm(ADMIN) { createDividendWithExclusions(_maturity, _expiry, excluded, _name); } @@ -58,7 +58,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { ) external payable - withPerm(MANAGE) + withPerm(ADMIN) { _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _checkpointId, excluded, _name); } @@ -78,7 +78,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { ) public payable - withPerm(MANAGE) + withPerm(ADMIN) { uint256 checkpointId = ISecurityToken(securityToken).createCheckpoint(); _createDividendWithCheckpointAndExclusions(_maturity, _expiry, checkpointId, _excluded, _name); @@ -101,7 +101,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { ) public payable - withPerm(MANAGE) + withPerm(ADMIN) { _createDividendWithCheckpointAndExclusions(_maturity, _expiry, _checkpointId, _excluded, _name); } @@ -190,7 +190,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { * @notice Issuer can reclaim remaining unclaimed dividend amounts, for expired dividends * @param _dividendIndex Dividend to reclaim */ - function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) { + function reclaimDividend(uint256 _dividendIndex) external withPerm(OPERATOR) { require(_dividendIndex < dividends.length, "Incorrect dividend index"); /*solium-disable-next-line security/no-block-members*/ require(now >= dividends[_dividendIndex].expiry, "Dividend expiry is in the future"); @@ -206,7 +206,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint { * @notice Allows issuer to withdraw withheld tax * @param _dividendIndex Dividend to withdraw from */ - function withdrawWithholding(uint256 _dividendIndex) external withPerm(MANAGE) { + function withdrawWithholding(uint256 _dividendIndex) external withPerm(OPERATOR) { require(_dividendIndex < dividends.length, "Incorrect dividend index"); Dividend storage dividend = dividends[_dividendIndex]; uint256 remainingWithheld = dividend.totalWithheld.sub(dividend.totalWithheldWithdrawn); diff --git a/contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol b/contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol index 059588a6e..124a5422b 100644 --- a/contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol +++ b/contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol @@ -9,8 +9,6 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol"; contract BlacklistTransferManager is TransferManager { using SafeMath for uint256; - bytes32 public constant ADMIN = "ADMIN"; - struct BlacklistsDetails { uint256 startTime; uint256 endTime; diff --git a/contracts/modules/Experimental/TransferManager/KYCTransferManager.sol b/contracts/modules/Experimental/TransferManager/KYCTransferManager.sol index a2741d346..302de73df 100644 --- a/contracts/modules/Experimental/TransferManager/KYCTransferManager.sol +++ b/contracts/modules/Experimental/TransferManager/KYCTransferManager.sol @@ -13,8 +13,6 @@ contract KYCTransferManager is TransferManager { bytes32 public constant KYC_NUMBER = "KYC_NUMBER"; //We will standardize what key to use for what. - bytes32 public constant KYC_PROVIDER = "KYC_PROVIDER"; - bytes32 public constant KYC_ARRAY = "KYC_ARRAY"; /** @@ -50,7 +48,7 @@ contract KYCTransferManager is TransferManager { return (Result.NA, bytes32(0)); } - function modifyKYC( address _investor, bool _kycStatus) public withPerm(KYC_PROVIDER) { + function modifyKYC( address _investor, bool _kycStatus) public withPerm(ADMIN) { _modifyKYC(_investor, _kycStatus); } @@ -75,15 +73,6 @@ contract KYCTransferManager is TransferManager { //I am maintaining the array to showcase how it can be done in cases where it might be needed. } - /** - * @notice Return the permissions flag that are associated with general trnasfer manager - */ - function getPermissions() public view returns(bytes32[] memory) { - bytes32[] memory allPermissions = new bytes32[](1); - allPermissions[0] = KYC_PROVIDER; - return allPermissions; - } - function getKYCAddresses() public view returns(address[] memory) { IDataStore dataStore = IDataStore(ISecurityToken(securityToken).dataStore()); return dataStore.getAddressArray(KYC_ARRAY); @@ -100,6 +89,16 @@ contract KYCTransferManager is TransferManager { return bytes32(keccak256(abi.encodePacked(KYC_NUMBER, _identity))); } + /** + * @notice Return the permissions flag that are associated with this module + * @return bytes32 array + */ + function getPermissions() public view returns(bytes32[] memory) { + bytes32[] memory allPermissions = new bytes32[](1); + allPermissions[0] = ADMIN; + return allPermissions; + } + /** * @notice return the amount of tokens for a given user as per the partition */ diff --git a/contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol b/contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol index 6620bc0d7..55e530f93 100644 --- a/contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol +++ b/contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol @@ -8,9 +8,6 @@ import "openzeppelin-solidity/contracts/math/Math.sol"; contract LockUpTransferManager is LockUpTransferManagerStorage, TransferManager { using SafeMath for uint256; - // permission definition - bytes32 public constant ADMIN = "ADMIN"; - event AddLockUpToUser( address indexed _userAddress, bytes32 indexed _lockupName diff --git a/contracts/modules/Experimental/TransferManager/SignedTransferManager.sol b/contracts/modules/Experimental/TransferManager/SignedTransferManager.sol index bcf42edb8..2742154fe 100644 --- a/contracts/modules/Experimental/TransferManager/SignedTransferManager.sol +++ b/contracts/modules/Experimental/TransferManager/SignedTransferManager.sol @@ -11,8 +11,6 @@ contract SignedTransferManager is TransferManager { using SafeMath for uint256; using ECDSA for bytes32; - bytes32 constant public ADMIN = "ADMIN"; - //Keeps track of if the signature has been used or invalidated //mapping(bytes => bool) invalidSignatures; bytes32 constant public INVALID_SIG = "INVALIDSIG"; diff --git a/contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol b/contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol index 08e2be621..1e3654bc5 100644 --- a/contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol +++ b/contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol @@ -10,8 +10,6 @@ import "../../../storage/modules/Wallet/VestingEscrowWalletStorage.sol"; contract VestingEscrowWallet is VestingEscrowWalletStorage, Wallet { using SafeMath for uint256; - bytes32 public constant ADMIN = "ADMIN"; - // States used to represent the status of the schedule enum State {CREATED, STARTED, COMPLETED} @@ -104,7 +102,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, Wallet { * @notice Sends unassigned tokens to the treasury wallet * @param _amount Amount of tokens that should be send to the treasury wallet */ - function sendToTreasury(uint256 _amount) external withPerm(ADMIN) { + function sendToTreasury(uint256 _amount) external withPerm(OPERATOR) { require(_amount > 0, "Amount cannot be zero"); require(_amount <= unassignedTokens, "Amount is greater than unassigned tokens"); uint256 amount = unassignedTokens; @@ -117,7 +115,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, Wallet { * @notice Pushes available tokens to the beneficiary's address * @param _beneficiary Address of the beneficiary who will receive tokens */ - function pushAvailableTokens(address _beneficiary) public withPerm(ADMIN) { + function pushAvailableTokens(address _beneficiary) public withPerm(OPERATOR) { _sendTokens(_beneficiary); } @@ -421,7 +419,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, Wallet { * @param _fromIndex Start index of array of beneficiary's addresses * @param _toIndex End index of array of beneficiary's addresses */ - function pushAvailableTokensMulti(uint256 _fromIndex, uint256 _toIndex) external withPerm(ADMIN) { + function pushAvailableTokensMulti(uint256 _fromIndex, uint256 _toIndex) external withPerm(OPERATOR) { require(_toIndex <= beneficiaries.length - 1, "Array out of bound"); for (uint256 i = _fromIndex; i <= _toIndex; i++) { if (schedules[beneficiaries[i]].length !=0) @@ -558,8 +556,9 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, Wallet { * @notice Return the permissions flag that are associated with VestingEscrowWallet */ function getPermissions() public view returns(bytes32[] memory) { - bytes32[] memory allPermissions = new bytes32[](1); + bytes32[] memory allPermissions = new bytes32[](2); allPermissions[0] = ADMIN; + allPermissions[1] = OPERATOR; return allPermissions; } diff --git a/contracts/modules/Module.sol b/contracts/modules/Module.sol index 0df12cfe8..14a4b0f10 100644 --- a/contracts/modules/Module.sol +++ b/contracts/modules/Module.sol @@ -22,7 +22,7 @@ contract Module is IModule, ModuleStorage { ModuleStorage(_securityToken, _polyAddress) { } - + //Allows owner, factory or permissioned delegate modifier withPerm(bytes32 _perm) { bool isOwner = msg.sender == Ownable(securityToken).owner(); @@ -61,6 +61,9 @@ contract Module is IModule, ModuleStorage { return true; } + /** + * @notice used to return the data store address of securityToken + */ function getDataStore() public view returns(address) { return ISecurityToken(securityToken).dataStore(); } diff --git a/contracts/modules/PermissionManager/GeneralPermissionManager.sol b/contracts/modules/PermissionManager/GeneralPermissionManager.sol index 7a37476b3..dff566cb0 100644 --- a/contracts/modules/PermissionManager/GeneralPermissionManager.sol +++ b/contracts/modules/PermissionManager/GeneralPermissionManager.sol @@ -46,7 +46,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio * @param _delegate Ethereum address of the delegate * @param _details Details about the delegate i.e `Belongs to financial firm` */ - function addDelegate(address _delegate, bytes32 _details) external withPerm(CHANGE_PERMISSION) { + function addDelegate(address _delegate, bytes32 _details) external withPerm(ADMIN) { require(_delegate != address(0), "Invalid address"); require(_details != bytes32(0), "0 value not allowed"); require(delegateDetails[_delegate] == bytes32(0), "Already present"); @@ -60,7 +60,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio * @notice Used to delete a delegate * @param _delegate Ethereum address of the delegate */ - function deleteDelegate(address _delegate) external withPerm(CHANGE_PERMISSION) { + function deleteDelegate(address _delegate) external withPerm(ADMIN) { require(delegateDetails[_delegate] != bytes32(0), "delegate does not exist"); for (uint256 i = 0; i < allDelegates.length; i++) { if (allDelegates[i] == _delegate) { @@ -92,7 +92,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio * @param _valid Bool flag use to switch on/off the permission * @return bool */ - function changePermission(address _delegate, address _module, bytes32 _perm, bool _valid) public withPerm(CHANGE_PERMISSION) { + function changePermission(address _delegate, address _module, bytes32 _perm, bool _valid) public withPerm(ADMIN) { require(_delegate != address(0), "invalid address"); _changePermission(_delegate, _module, _perm, _valid); } @@ -112,7 +112,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio bool[] calldata _valids ) external - withPerm(CHANGE_PERMISSION) + withPerm(ADMIN) { require(_delegate != address(0), "invalid address"); require(_modules.length > 0, "0 length is not allowed"); @@ -225,7 +225,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio */ function getPermissions() public view returns(bytes32[] memory) { bytes32[] memory allPermissions = new bytes32[](1); - allPermissions[0] = CHANGE_PERMISSION; + allPermissions[0] = ADMIN; return allPermissions; } diff --git a/contracts/modules/STO/CappedSTO.sol b/contracts/modules/STO/CappedSTO.sol index bd464d101..6e2a70ded 100644 --- a/contracts/modules/STO/CappedSTO.sol +++ b/contracts/modules/STO/CappedSTO.sol @@ -73,7 +73,7 @@ contract CappedSTO is CappedSTOStorage, STO, ReentrancyGuard { * @notice This function returns the signature of configure function */ function getInitFunction() public pure returns(bytes4) { - return bytes4(keccak256("configure(uint256,uint256,uint256,uint256,uint8[],address)")); + return this.configure.selector; } /** diff --git a/contracts/modules/STO/PreSaleSTO.sol b/contracts/modules/STO/PreSaleSTO.sol index 147c85b8d..386d2e937 100644 --- a/contracts/modules/STO/PreSaleSTO.sol +++ b/contracts/modules/STO/PreSaleSTO.sol @@ -33,7 +33,7 @@ contract PreSaleSTO is PreSaleSTOStorage, STO { * @notice This function returns the signature of the configure function */ function getInitFunction() public pure returns(bytes4) { - return bytes4(keccak256("configure(uint256)")); + return this.configure.selector; } /** @@ -55,7 +55,7 @@ contract PreSaleSTO is PreSaleSTOStorage, STO { */ function getPermissions() public view returns(bytes32[] memory) { bytes32[] memory allPermissions = new bytes32[](1); - allPermissions[0] = PRE_SALE_ADMIN; + allPermissions[0] = ADMIN; return allPermissions; } @@ -73,7 +73,7 @@ contract PreSaleSTO is PreSaleSTOStorage, STO { uint256 _polyContributed ) public - withPerm(PRE_SALE_ADMIN) + withPerm(ADMIN) { /*solium-disable-next-line security/no-block-members*/ require(now <= endTime, "Already passed Endtime"); @@ -104,7 +104,7 @@ contract PreSaleSTO is PreSaleSTOStorage, STO { uint256[] memory _polyContributed ) public - withPerm(PRE_SALE_ADMIN) + withPerm(ADMIN) { require(_investors.length == _amounts.length, "Mis-match in length of the arrays"); require(_etherContributed.length == _polyContributed.length, "Mis-match in length of the arrays"); diff --git a/contracts/modules/TransferManager/CountTransferManager.sol b/contracts/modules/TransferManager/CountTransferManager.sol index b4c1cb5d8..c6d254a6e 100644 --- a/contracts/modules/TransferManager/CountTransferManager.sol +++ b/contracts/modules/TransferManager/CountTransferManager.sol @@ -88,7 +88,7 @@ contract CountTransferManager is CountTransferManagerStorage, TransferManager { * @notice This function returns the signature of configure function */ function getInitFunction() public pure returns(bytes4) { - return bytes4(keccak256("configure(uint256)")); + return this.configure.selector; } /** diff --git a/contracts/modules/TransferManager/GeneralTransferManager.sol b/contracts/modules/TransferManager/GeneralTransferManager.sol index f8731d46d..eafdc8ba4 100644 --- a/contracts/modules/TransferManager/GeneralTransferManager.sol +++ b/contracts/modules/TransferManager/GeneralTransferManager.sol @@ -72,7 +72,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage * @param _defaultFromTime default for zero fromTime * @param _defaultToTime default for zero toTime */ - function changeDefaults(uint64 _defaultFromTime, uint64 _defaultToTime) public withPerm(FLAGS) { + function changeDefaults(uint64 _defaultFromTime, uint64 _defaultToTime) public withPerm(ADMIN) { defaults.fromTime = _defaultFromTime; defaults.toTime = _defaultToTime; emit ChangeDefaults(_defaultFromTime, _defaultToTime); @@ -82,7 +82,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage * @notice Used to change the Issuance Address * @param _issuanceAddress new address for the issuance */ - function changeIssuanceAddress(address _issuanceAddress) public withPerm(FLAGS) { + function changeIssuanceAddress(address _issuanceAddress) public withPerm(ADMIN) { issuanceAddress = _issuanceAddress; emit ChangeIssuanceAddress(_issuanceAddress); } @@ -91,7 +91,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage * @notice Used to change the Sigining Address * @param _signingAddress new address for the signing */ - function changeSigningAddress(address _signingAddress) public withPerm(FLAGS) { + function changeSigningAddress(address _signingAddress) public withPerm(ADMIN) { signingAddress = _signingAddress; emit ChangeSigningAddress(_signingAddress); } @@ -102,7 +102,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage false - It refers transfers are restricted for all addresses. * @param _allowAllTransfers flag value */ - function changeAllowAllTransfers(bool _allowAllTransfers) public withPerm(FLAGS) { + function changeAllowAllTransfers(bool _allowAllTransfers) public withPerm(ADMIN) { allowAllTransfers = _allowAllTransfers; emit AllowAllTransfers(_allowAllTransfers); } @@ -113,7 +113,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage false - It refers transfers are restricted for all addresses. * @param _allowAllWhitelistTransfers flag value */ - function changeAllowAllWhitelistTransfers(bool _allowAllWhitelistTransfers) public withPerm(FLAGS) { + function changeAllowAllWhitelistTransfers(bool _allowAllWhitelistTransfers) public withPerm(ADMIN) { allowAllWhitelistTransfers = _allowAllWhitelistTransfers; emit AllowAllWhitelistTransfers(_allowAllWhitelistTransfers); } @@ -124,7 +124,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage false - It refers transfers are restricted for all addresses. * @param _allowAllWhitelistIssuances flag value */ - function changeAllowAllWhitelistIssuances(bool _allowAllWhitelistIssuances) public withPerm(FLAGS) { + function changeAllowAllWhitelistIssuances(bool _allowAllWhitelistIssuances) public withPerm(ADMIN) { allowAllWhitelistIssuances = _allowAllWhitelistIssuances; emit AllowAllWhitelistIssuances(_allowAllWhitelistIssuances); } @@ -135,7 +135,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage false - It deactivate the burning mechanism. * @param _allowAllBurnTransfers flag value */ - function changeAllowAllBurnTransfers(bool _allowAllBurnTransfers) public withPerm(FLAGS) { + function changeAllowAllBurnTransfers(bool _allowAllBurnTransfers) public withPerm(ADMIN) { allowAllBurnTransfers = _allowAllBurnTransfers; emit AllowAllBurnTransfers(_allowAllBurnTransfers); } @@ -238,7 +238,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage uint256 _expiryTime ) public - withPerm(WHITELIST) + withPerm(ADMIN) { _modifyKYCData(_investor, _fromTime, _toTime, _expiryTime); } @@ -268,7 +268,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage uint256[] memory _expiryTime ) public - withPerm(WHITELIST) + withPerm(ADMIN) { require( _investors.length == _fromTime.length && @@ -294,7 +294,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage bool _value ) public - withPerm(WHITELIST) + withPerm(ADMIN) { _modifyInvestorFlag(_investor, _flag, _value); } @@ -330,7 +330,7 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage bool[] memory _value ) public - withPerm(WHITELIST) + withPerm(ADMIN) { require( _investors.length == _flag.length && @@ -534,9 +534,8 @@ contract GeneralTransferManager is GeneralTransferManagerStorage, TransferManage * @notice Return the permissions flag that are associated with general trnasfer manager */ function getPermissions() public view returns(bytes32[] memory) { - bytes32[] memory allPermissions = new bytes32[](2); - allPermissions[0] = WHITELIST; - allPermissions[1] = FLAGS; + bytes32[] memory allPermissions = new bytes32[](1); + allPermissions[0] = ADMIN; return allPermissions; } diff --git a/contracts/modules/TransferManager/ManualApprovalTransferManager.sol b/contracts/modules/TransferManager/ManualApprovalTransferManager.sol index 6501fc9a6..c9a32605e 100644 --- a/contracts/modules/TransferManager/ManualApprovalTransferManager.sol +++ b/contracts/modules/TransferManager/ManualApprovalTransferManager.sol @@ -119,7 +119,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, bytes32 _description ) external - withPerm(TRANSFER_APPROVAL) + withPerm(ADMIN) { _addManualApproval(_from, _to, _allowance, _expiryTime, _description); } @@ -154,7 +154,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, bytes32[] calldata _descriptions ) external - withPerm(TRANSFER_APPROVAL) + withPerm(ADMIN) { _checkInputLengthArray(_from, _to, _allowances, _expiryTimes, _descriptions); for (uint256 i = 0; i < _from.length; i++){ @@ -181,7 +181,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, uint8 _change ) external - withPerm(TRANSFER_APPROVAL) + withPerm(ADMIN) { _modifyManualApproval(_from, _to, _expiryTime, _changedAllowance, _description, _change); } @@ -251,7 +251,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, uint8[] memory _changes ) public - withPerm(TRANSFER_APPROVAL) + withPerm(ADMIN) { _checkInputLengthArray(_from, _to, _changedAllowances, _expiryTimes, _descriptions); require(_changes.length == _changedAllowances.length, "Input length array mismatch"); @@ -265,7 +265,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, * @param _from is the address from which transfers are approved * @param _to is the address to which transfers are approved */ - function revokeManualApproval(address _from, address _to) external withPerm(TRANSFER_APPROVAL) { + function revokeManualApproval(address _from, address _to) external withPerm(ADMIN) { _revokeManualApproval(_from, _to); } @@ -288,7 +288,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, * @param _from is the address array from which transfers are approved * @param _to is the address array to which transfers are approved */ - function revokeManualApprovalMulti(address[] calldata _from, address[] calldata _to) external withPerm(TRANSFER_APPROVAL) { + function revokeManualApprovalMulti(address[] calldata _from, address[] calldata _to) external withPerm(ADMIN) { require(_from.length == _to.length, "Input array length mismatch"); for(uint256 i = 0; i < _from.length; i++){ _revokeManualApproval(_from[i], _to[i]); @@ -424,7 +424,7 @@ contract ManualApprovalTransferManager is ManualApprovalTransferManagerStorage, */ function getPermissions() public view returns(bytes32[] memory) { bytes32[] memory allPermissions = new bytes32[](1); - allPermissions[0] = TRANSFER_APPROVAL; + allPermissions[0] = ADMIN; return allPermissions; } } diff --git a/contracts/modules/TransferManager/PercentageTransferManager.sol b/contracts/modules/TransferManager/PercentageTransferManager.sol index 8217a1b17..f6610d391 100644 --- a/contracts/modules/TransferManager/PercentageTransferManager.sol +++ b/contracts/modules/TransferManager/PercentageTransferManager.sol @@ -96,7 +96,7 @@ contract PercentageTransferManager is PercentageTransferManagerStorage, Transfer * @notice This function returns the signature of configure function */ function getInitFunction() public pure returns(bytes4) { - return bytes4(keccak256("configure(uint256,bool)")); + return this.configure.selector; } /** @@ -113,7 +113,7 @@ contract PercentageTransferManager is PercentageTransferManagerStorage, Transfer * @param _investor is the address to whitelist * @param _valid whether or not the address it to be added or removed from the whitelist */ - function modifyWhitelist(address _investor, bool _valid) public withPerm(WHITELIST) { + function modifyWhitelist(address _investor, bool _valid) public withPerm(ADMIN) { whitelist[_investor] = _valid; /*solium-disable-next-line security/no-block-members*/ emit ModifyWhitelist(_investor, now, msg.sender, _valid); @@ -124,7 +124,7 @@ contract PercentageTransferManager is PercentageTransferManagerStorage, Transfer * @param _investors Array of the addresses to whitelist * @param _valids Array of boolean value to decide whether or not the address it to be added or removed from the whitelist */ - function modifyWhitelistMulti(address[] memory _investors, bool[] memory _valids) public withPerm(WHITELIST) { + function modifyWhitelistMulti(address[] memory _investors, bool[] memory _valids) public withPerm(ADMIN) { require(_investors.length == _valids.length, "Input array length mis-match"); for (uint i = 0; i < _investors.length; i++) { modifyWhitelist(_investors[i], _valids[i]); @@ -154,7 +154,6 @@ contract PercentageTransferManager is PercentageTransferManagerStorage, Transfer */ function getPermissions() public view returns(bytes32[] memory) { bytes32[] memory allPermissions = new bytes32[](2); - allPermissions[0] = WHITELIST; allPermissions[1] = ADMIN; return allPermissions; } diff --git a/contracts/modules/TransferManager/VolumeRestrictionTM.sol b/contracts/modules/TransferManager/VolumeRestrictionTM.sol index c57cc4929..ee2b952f0 100644 --- a/contracts/modules/TransferManager/VolumeRestrictionTM.sol +++ b/contracts/modules/TransferManager/VolumeRestrictionTM.sol @@ -8,9 +8,6 @@ import "./TransferManager.sol"; contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { using SafeMath for uint256; - // permission definition - bytes32 public constant ADMIN = "ADMIN"; - // Emit when the token holder is added/removed from the exemption list event ChangedExemptWalletList(address indexed _wallet, bool _change); // Emit when the new individual restriction is added corresponds to new token holders @@ -245,7 +242,14 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { _endTime, RestrictionType(_restrictionType) ); - VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.MultipleDays), individualRestrictions.individualRestriction[_holder].endTime); + VolumeRestrictionLib + .addRestrictionData( + holderToRestrictionType, + _holder, + uint8(TypeOfPeriod.MultipleDays), + individualRestrictions.individualRestriction[_holder].endTime, + getDataStore() + ); emit AddIndividualRestriction( _holder, _allowedTokens, @@ -292,7 +296,14 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { _endTime, RestrictionType(_restrictionType) ); - VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.OneDay), individualRestrictions.individualRestriction[_holder].endTime); + VolumeRestrictionLib + .addRestrictionData( + holderToRestrictionType, + _holder, + uint8(TypeOfPeriod.OneDay), + individualRestrictions.individualRestriction[_holder].endTime, + getDataStore() + ); emit AddIndividualDailyRestriction( _holder, _allowedTokens, @@ -300,7 +311,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { 1, _endTime, _restrictionType - ); + ); } /** @@ -457,7 +468,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { require(_holder != address(0)); require(individualRestrictions.individualRestriction[_holder].endTime != 0); individualRestrictions.individualRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0)); - VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.OneDay)); + VolumeRestrictionLib.deleteHolderFromList(holderToRestrictionType, _holder, getDataStore(), uint8(TypeOfPeriod.OneDay)); bucketData.userToBucket[_holder].lastTradedDayTime = 0; bucketData.userToBucket[_holder].sumOfLastPeriod = 0; bucketData.userToBucket[_holder].daysCovered = 0; @@ -482,7 +493,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { require(_holder != address(0)); require(individualRestrictions.individualDailyRestriction[_holder].endTime != 0); individualRestrictions.individualDailyRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0)); - VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.MultipleDays)); + VolumeRestrictionLib.deleteHolderFromList(holderToRestrictionType, _holder, getDataStore(), uint8(TypeOfPeriod.MultipleDays)); bucketData.userToBucket[_holder].dailyLastTradedDayTime = 0; emit IndividualDailyRestrictionRemoved(_holder); } @@ -1122,7 +1133,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { uint256[] memory endTime, uint8[] memory typeOfRestriction ) { - return VolumeRestrictionLib.getRestrictionData(holderData, individualRestrictions); + return VolumeRestrictionLib.getRestrictionData(holderToRestrictionType, individualRestrictions, getDataStore()); } /** diff --git a/contracts/modules/TransferManager/VolumeRestrictionTMFactory.sol b/contracts/modules/TransferManager/VolumeRestrictionTMFactory.sol index 7e363688e..30211e416 100644 --- a/contracts/modules/TransferManager/VolumeRestrictionTMFactory.sol +++ b/contracts/modules/TransferManager/VolumeRestrictionTMFactory.sol @@ -40,8 +40,9 @@ contract VolumeRestrictionTMFactory is UpgradableModuleFactory { * @notice Type of the Module factory */ function types() external view returns(uint8[] memory) { - uint8[] memory res = new uint8[](1); + uint8[] memory res = new uint8[](2); res[0] = 2; + res[1] = 6; return res; } diff --git a/contracts/storage/modules/Checkpoint/DividendCheckpointStorage.sol b/contracts/storage/modules/Checkpoint/DividendCheckpointStorage.sol index 27315b16e..7e6c16db3 100644 --- a/contracts/storage/modules/Checkpoint/DividendCheckpointStorage.sol +++ b/contracts/storage/modules/Checkpoint/DividendCheckpointStorage.sol @@ -9,9 +9,8 @@ contract DividendCheckpointStorage { // Address to which reclaimed dividends and withholding tax is sent address payable public wallet; uint256 public EXCLUDED_ADDRESS_LIMIT = 150; - bytes32 public constant DISTRIBUTE = "DISTRIBUTE"; - bytes32 public constant MANAGE = "MANAGE"; - bytes32 public constant CHECKPOINT = "CHECKPOINT"; + bytes32 public constant ADMIN = "ADMIN"; + bytes32 public constant OPERATOR = "OPERATOR"; struct Dividend { uint256 checkpointId; diff --git a/contracts/storage/modules/ModuleStorage.sol b/contracts/storage/modules/ModuleStorage.sol index 720c653fb..88e005dfa 100644 --- a/contracts/storage/modules/ModuleStorage.sol +++ b/contracts/storage/modules/ModuleStorage.sol @@ -12,7 +12,9 @@ contract ModuleStorage { address public securityToken; bytes32 public constant FEE_ADMIN = "FEE_ADMIN"; - + // Permission flag + bytes32 public constant ADMIN = "ADMIN"; + IERC20 public polyToken; /** diff --git a/contracts/storage/modules/PermissionManager/GeneralPermissionManagerStorage.sol b/contracts/storage/modules/PermissionManager/GeneralPermissionManagerStorage.sol index cc50bc871..a0e55021a 100644 --- a/contracts/storage/modules/PermissionManager/GeneralPermissionManagerStorage.sol +++ b/contracts/storage/modules/PermissionManager/GeneralPermissionManagerStorage.sol @@ -12,7 +12,4 @@ contract GeneralPermissionManagerStorage { // Array to track all delegates address[] public allDelegates; - // Permission flag - bytes32 public constant CHANGE_PERMISSION = "CHANGE_PERMISSION"; - } diff --git a/contracts/storage/modules/STO/DummySTOStorage.sol b/contracts/storage/modules/STO/DummySTOStorage.sol index 0979974ec..922a2836f 100644 --- a/contracts/storage/modules/STO/DummySTOStorage.sol +++ b/contracts/storage/modules/STO/DummySTOStorage.sol @@ -5,8 +5,6 @@ pragma solidity ^0.5.0; */ contract DummySTOStorage { - bytes32 public constant ADMIN = "ADMIN"; - uint256 public investorCount; uint256 public cap; diff --git a/contracts/storage/modules/STO/PreSaleSTOStorage.sol b/contracts/storage/modules/STO/PreSaleSTOStorage.sol index 9c8ecc0a6..f1b008259 100644 --- a/contracts/storage/modules/STO/PreSaleSTOStorage.sol +++ b/contracts/storage/modules/STO/PreSaleSTOStorage.sol @@ -5,8 +5,6 @@ pragma solidity ^0.5.0; */ contract PreSaleSTOStorage { - bytes32 public constant PRE_SALE_ADMIN = "PRE_SALE_ADMIN"; - mapping (address => uint256) public investors; } \ No newline at end of file diff --git a/contracts/storage/modules/TransferManager/CountTransferManagerStorage.sol b/contracts/storage/modules/TransferManager/CountTransferManagerStorage.sol index 4a33663b1..bc755d301 100644 --- a/contracts/storage/modules/TransferManager/CountTransferManagerStorage.sol +++ b/contracts/storage/modules/TransferManager/CountTransferManagerStorage.sol @@ -5,8 +5,6 @@ pragma solidity ^0.5.0; */ contract CountTransferManagerStorage { - bytes32 public constant ADMIN = "ADMIN"; - // The maximum number of concurrent token holders uint256 public maxHolderCount; diff --git a/contracts/storage/modules/TransferManager/GeneralTransferManagerStorage.sol b/contracts/storage/modules/TransferManager/GeneralTransferManagerStorage.sol index f246b3675..9a329117a 100644 --- a/contracts/storage/modules/TransferManager/GeneralTransferManagerStorage.sol +++ b/contracts/storage/modules/TransferManager/GeneralTransferManagerStorage.sol @@ -8,7 +8,6 @@ contract GeneralTransferManagerStorage { bytes32 public constant WHITELIST = "WHITELIST"; bytes32 public constant INVESTORSKEY = 0xdf3a8dd24acdd05addfc6aeffef7574d2de3f844535ec91e8e0f3e45dba96731; //keccak256(abi.encodePacked("INVESTORS")) bytes32 public constant INVESTORFLAGS = "INVESTORFLAGS"; - bytes32 public constant FLAGS = "FLAGS"; uint256 internal constant ONE = uint256(1); //Address from which issuances come diff --git a/contracts/storage/modules/TransferManager/ManualApprovalTransferManagerStorage.sol b/contracts/storage/modules/TransferManager/ManualApprovalTransferManagerStorage.sol index 29671ff42..774780105 100644 --- a/contracts/storage/modules/TransferManager/ManualApprovalTransferManagerStorage.sol +++ b/contracts/storage/modules/TransferManager/ManualApprovalTransferManagerStorage.sol @@ -11,8 +11,6 @@ contract ManualApprovalTransferManagerStorage { //Address which can sign whitelist changes address public signingAddress = address(0); - bytes32 public constant TRANSFER_APPROVAL = "TRANSFER_APPROVAL"; - //Manual approval is an allowance (that has been approved) with an expiry time struct ManualApproval { address from; diff --git a/contracts/storage/modules/TransferManager/PercentageTransferManagerStorage.sol b/contracts/storage/modules/TransferManager/PercentageTransferManagerStorage.sol index f2db59690..c5a8c8976 100644 --- a/contracts/storage/modules/TransferManager/PercentageTransferManagerStorage.sol +++ b/contracts/storage/modules/TransferManager/PercentageTransferManagerStorage.sol @@ -5,10 +5,6 @@ pragma solidity ^0.5.0; */ contract PercentageTransferManagerStorage { - // Permission key for modifying the whitelist - bytes32 public constant WHITELIST = "WHITELIST"; - bytes32 public constant ADMIN = "ADMIN"; - // Maximum percentage that any holder can have, multiplied by 10**16 - e.g. 20% is 20 * 10**16 uint256 public maxHolderPercentage; diff --git a/contracts/storage/modules/TransferManager/VolumeRestrictionTMStorage.sol b/contracts/storage/modules/TransferManager/VolumeRestrictionTMStorage.sol index 0c88cbd65..00228124a 100644 --- a/contracts/storage/modules/TransferManager/VolumeRestrictionTMStorage.sol +++ b/contracts/storage/modules/TransferManager/VolumeRestrictionTMStorage.sol @@ -9,22 +9,8 @@ contract VolumeRestrictionTMStorage { enum TypeOfPeriod { MultipleDays, OneDay, Both } - struct RestrictedHolder { - // 1 represent true & 0 for false - uint8 seen; - // Type of period will be enum index of TypeOfPeriod enum - uint8 typeOfPeriod; - // Index of the array where the holder address lives - uint128 index; - } - - struct RestrictedData { - mapping(address => RestrictedHolder) restrictedHolders; - address[] restrictedAddresses; - } - - // Restricted data (refernce from the VolumeRestrictionLib library ) - RestrictedData holderData; + // Store the type of restriction corresponds to token holder address + mapping(address => uint8) holderToRestrictionType; struct VolumeRestriction { // If typeOfRestriction is `Percentage` then allowedTokens will be in diff --git a/contracts/storage/modules/Wallet/VestingEscrowWalletStorage.sol b/contracts/storage/modules/Wallet/VestingEscrowWalletStorage.sol index f3752ad7f..66e0be868 100644 --- a/contracts/storage/modules/Wallet/VestingEscrowWalletStorage.sol +++ b/contracts/storage/modules/Wallet/VestingEscrowWalletStorage.sol @@ -5,6 +5,9 @@ pragma solidity ^0.5.0; */ contract VestingEscrowWalletStorage { + // Permission flag + bytes32 constant OPERATOR = "OPERATOR"; + struct Schedule { // Name of the template bytes32 templateName; diff --git a/docs/investor_flags.md b/docs/investor_flags.md index 9ccf74473..0b8fb9c38 100644 --- a/docs/investor_flags.md +++ b/docs/investor_flags.md @@ -19,5 +19,10 @@