From 013897186537f63c66dda7c226ebfc50a9a028dc Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 30 May 2019 13:02:16 +0530 Subject: [PATCH 1/2] minor improvements --- contracts/SecurityTokenRegistry.sol | 6 ++--- .../interfaces/ISecurityTokenRegistry.sol | 7 ++++++ .../Voting/PLCR/PLCRVotingCheckpoint.sol | 24 +++++++++---------- .../Transparent/WeightedVoteCheckpoint.sol | 24 +++++++++---------- .../Checkpoint/Voting/VotingCheckpoint.sol | 24 +++++++++---------- contracts/modules/STO/Capped/CappedSTO.sol | 3 +-- .../modules/STO/Capped/CappedSTOStorage.sol | 1 + .../modules/STO/USDTiered/USDTieredSTO.sol | 21 ++++++---------- .../STO/USDTiered/USDTieredSTOStorage.sol | 4 +++- .../VRTM/VolumeRestrictionTM.sol | 12 +++++----- contracts/tokens/SecurityToken.sol | 3 ++- test/zc_plcr_voting_checkpoint.js | 4 ++-- test/zd_weighted_vote_checkpoint.js | 4 ++-- 13 files changed, 70 insertions(+), 67 deletions(-) diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index f16baab30..68f99330d 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -315,7 +315,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { // Attempt to charge the reg fee if it is > 0 USD (, uint256 _polyFee) = _takeFee(TICKERREGFEE); string memory ticker = Util.upper(_ticker); - require(_tickerAvailable(ticker), "Ticker reserved"); + require(tickerAvailable(ticker), "Ticker reserved"); // Check whether ticker was previously registered (and expired) address previousOwner = _tickerOwner(ticker); if (previousOwner != address(0)) { @@ -421,11 +421,11 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { } /** - * @notice Internal - Checks if the entered ticker is registered and has not expired + * @notice Checks if the entered ticker is registered and has not expired * @param _ticker is the token ticker * @return bool */ - function _tickerAvailable(string memory _ticker) internal view returns(bool) { + function tickerAvailable(string memory _ticker) public view returns(bool) { if (_tickerOwner(_ticker) != address(0)) { /*solium-disable-next-line security/no-block-members*/ if ((now > getUintValue(Encoder.getKey("registeredTickers_expiryDate", _ticker))) && !_tickerStatus(_ticker)) { diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index 3f8acf8ed..6ddbbb38c 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -232,4 +232,11 @@ interface ISecurityTokenRegistry { */ function owner() external view returns(address); + /** + * @notice Checks if the entered ticker is registered and has not expired + * @param _ticker is the token ticker + * @return bool + */ + function tickerAvailable(string calldata _ticker) external view returns(bool); + } diff --git a/contracts/modules/Checkpoint/Voting/PLCR/PLCRVotingCheckpoint.sol b/contracts/modules/Checkpoint/Voting/PLCR/PLCRVotingCheckpoint.sol index a08677222..b4da1843b 100644 --- a/contracts/modules/Checkpoint/Voting/PLCR/PLCRVotingCheckpoint.sol +++ b/contracts/modules/Checkpoint/Voting/PLCR/PLCRVotingCheckpoint.sol @@ -27,7 +27,7 @@ contract PLCRVotingCheckpoint is PLCRVotingCheckpointStorage, VotingCheckpoint { uint256 _proposedQuorum ); event BallotStatusChanged(uint256 indexed _ballotId, bool _newStatus); - event ChangedBallotExemptedVotersList(uint256 indexed _ballotId, address indexed _voter, bool _change); + event ChangedBallotExemptedVotersList(uint256 indexed _ballotId, address indexed _voter, bool _exempt); constructor(address _securityToken, address _polyAddress) public @@ -172,31 +172,31 @@ contract PLCRVotingCheckpoint is PLCRVotingCheckpointStorage, VotingCheckpoint { * Change the given ballot exempted list * @param _ballotId Given ballot Id * @param _voter Address of the voter - * @param _change Whether it is exempted or not + * @param _exempt Whether it is exempted or not */ - function changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _change) external withPerm(ADMIN) { - _changeBallotExemptedVotersList(_ballotId, _voter, _change); + function changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _exempt) external withPerm(ADMIN) { + _changeBallotExemptedVotersList(_ballotId, _voter, _exempt); } /** * Change the given ballot exempted list (Multi) * @param _ballotId Given ballot Id * @param _voters Address of the voter - * @param _changes Whether it is exempted or not + * @param _exempts Whether it is exempted or not */ - function changeBallotExemptedVotersListMulti(uint256 _ballotId, address[] calldata _voters, bool[] calldata _changes) external withPerm(ADMIN) { - require(_voters.length == _changes.length, "Array length mismatch"); + function changeBallotExemptedVotersListMulti(uint256 _ballotId, address[] calldata _voters, bool[] calldata _exempts) external withPerm(ADMIN) { + require(_voters.length == _exempts.length, "Array length mismatch"); for (uint256 i = 0; i < _voters.length; i++) { - _changeBallotExemptedVotersList(_ballotId, _voters[i], _changes[i]); + _changeBallotExemptedVotersList(_ballotId, _voters[i], _exempts[i]); } } - function _changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _change) internal { + function _changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _exempt) internal { require(_voter != address(0), "Invalid address"); _validBallotId(_ballotId); - require(ballots[_ballotId].exemptedVoters[_voter] != _change, "No change"); - ballots[_ballotId].exemptedVoters[_voter] = _change; - emit ChangedBallotExemptedVotersList(_ballotId, _voter, _change); + require(ballots[_ballotId].exemptedVoters[_voter] != _exempt, "No change"); + ballots[_ballotId].exemptedVoters[_voter] = _exempt; + emit ChangedBallotExemptedVotersList(_ballotId, _voter, _exempt); } /** diff --git a/contracts/modules/Checkpoint/Voting/Transparent/WeightedVoteCheckpoint.sol b/contracts/modules/Checkpoint/Voting/Transparent/WeightedVoteCheckpoint.sol index 04a1b7828..42716a176 100644 --- a/contracts/modules/Checkpoint/Voting/Transparent/WeightedVoteCheckpoint.sol +++ b/contracts/modules/Checkpoint/Voting/Transparent/WeightedVoteCheckpoint.sol @@ -23,7 +23,7 @@ contract WeightedVoteCheckpoint is WeightedVoteCheckpointStorage, VotingCheckpoi ); event VoteCast(address indexed _voter, uint256 _weight, uint256 indexed _ballotId, uint256 indexed _proposalId); event BallotStatusChanged(uint256 indexed _ballotId, bool _isActive); - event ChangedBallotExemptedVotersList(uint256 indexed _ballotId, address indexed _voter, bool _change); + event ChangedBallotExemptedVotersList(uint256 indexed _ballotId, address indexed _voter, bool _exempt); /** * @notice Constructor @@ -124,31 +124,31 @@ contract WeightedVoteCheckpoint is WeightedVoteCheckpointStorage, VotingCheckpoi * Change the given ballot exempted list * @param _ballotId Given ballot Id * @param _voter Address of the voter - * @param _change Whether it is exempted or not + * @param _exempt Whether it is exempted or not */ - function changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _change) external withPerm(ADMIN) { - _changeBallotExemptedVotersList(_ballotId, _voter, _change); + function changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _exempt) external withPerm(ADMIN) { + _changeBallotExemptedVotersList(_ballotId, _voter, _exempt); } /** * Change the given ballot exempted list (Multi) * @param _ballotId Given ballot Id * @param _voters Address of the voter - * @param _changes Whether it is exempted or not + * @param _exempts Whether it is exempted or not */ - function changeBallotExemptedVotersListMulti(uint256 _ballotId, address[] calldata _voters, bool[] calldata _changes) external withPerm(ADMIN) { - require(_voters.length == _changes.length, "Array length mismatch"); + function changeBallotExemptedVotersListMulti(uint256 _ballotId, address[] calldata _voters, bool[] calldata _exempts) external withPerm(ADMIN) { + require(_voters.length == _exempts.length, "Array length mismatch"); for (uint256 i = 0; i < _voters.length; i++) { - _changeBallotExemptedVotersList(_ballotId, _voters[i], _changes[i]); + _changeBallotExemptedVotersList(_ballotId, _voters[i], _exempts[i]); } } - function _changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _change) internal { + function _changeBallotExemptedVotersList(uint256 _ballotId, address _voter, bool _exempt) internal { require(_voter != address(0), "Invalid address"); _validBallotId(_ballotId); - require(ballots[_ballotId].exemptedVoters[_voter] != _change, "No change"); - ballots[_ballotId].exemptedVoters[_voter] = _change; - emit ChangedBallotExemptedVotersList(_ballotId, _voter, _change); + require(ballots[_ballotId].exemptedVoters[_voter] != _exempt, "No change"); + ballots[_ballotId].exemptedVoters[_voter] = _exempt; + emit ChangedBallotExemptedVotersList(_ballotId, _voter, _exempt); } /** diff --git a/contracts/modules/Checkpoint/Voting/VotingCheckpoint.sol b/contracts/modules/Checkpoint/Voting/VotingCheckpoint.sol index 77ae226ea..1720bf6b9 100644 --- a/contracts/modules/Checkpoint/Voting/VotingCheckpoint.sol +++ b/contracts/modules/Checkpoint/Voting/VotingCheckpoint.sol @@ -7,33 +7,33 @@ import "../../../storage/modules/Checkpoint/Voting/VotingCheckpointStorage.sol"; contract VotingCheckpoint is VotingCheckpointStorage, ICheckpoint, IVoting, Module { - event ChangedDefaultExemptedVotersList(address indexed _voter, bool _change); + event ChangedDefaultExemptedVotersList(address indexed _voter, bool _exempt); /** * Change the global exempted voters list * @param _voter Address of the voter - * @param _change Whether it is exempted or not + * @param _exempt Whether it is exempted or not */ - function changeDefaultExemptedVotersList(address _voter, bool _change) external withPerm(ADMIN) { - _changeDefaultExemptedVotersList(_voter, _change); + function changeDefaultExemptedVotersList(address _voter, bool _exempt) external withPerm(ADMIN) { + _changeDefaultExemptedVotersList(_voter, _exempt); } /** * Change the global exempted voters list * @param _voters Address of the voter - * @param _changes Whether it is exempted or not + * @param _exempts Whether it is exempted or not */ - function changeDefaultExemptedVotersListMulti(address[] calldata _voters, bool[] calldata _changes) external withPerm(ADMIN) { - require(_voters.length == _changes.length, "Array length mismatch"); + function changeDefaultExemptedVotersListMulti(address[] calldata _voters, bool[] calldata _exempts) external withPerm(ADMIN) { + require(_voters.length == _exempts.length, "Array length mismatch"); for (uint256 i = 0; i < _voters.length; i++) { - _changeDefaultExemptedVotersList(_voters[i], _changes[i]); + _changeDefaultExemptedVotersList(_voters[i], _exempts[i]); } } - function _changeDefaultExemptedVotersList(address _voter, bool _change) internal { + function _changeDefaultExemptedVotersList(address _voter, bool _exempt) internal { require(_voter != address(0), "Invalid address"); - require((defaultExemptIndex[_voter] == 0) == _change); - if (_change) { + require((defaultExemptIndex[_voter] == 0) == _exempt); + if (_exempt) { defaultExemptedVoters.push(_voter); defaultExemptIndex[_voter] = defaultExemptedVoters.length; } else { @@ -44,7 +44,7 @@ contract VotingCheckpoint is VotingCheckpointStorage, ICheckpoint, IVoting, Modu delete defaultExemptIndex[_voter]; defaultExemptedVoters.length --; } - emit ChangedDefaultExemptedVotersList(_voter, _change); + emit ChangedDefaultExemptedVotersList(_voter, _exempt); } /** diff --git a/contracts/modules/STO/Capped/CappedSTO.sol b/contracts/modules/STO/Capped/CappedSTO.sol index adc89d5a9..a8a54f84e 100644 --- a/contracts/modules/STO/Capped/CappedSTO.sol +++ b/contracts/modules/STO/Capped/CappedSTO.sol @@ -80,8 +80,7 @@ contract CappedSTO is CappedSTOStorage, STO, ReentrancyGuard { * @notice Function to set allowBeneficialInvestments (allow beneficiary to be different to funder) * @param _allowBeneficialInvestments Boolean to allow or disallow beneficial investments */ - function changeAllowBeneficialInvestments(bool _allowBeneficialInvestments) public { - _onlySecurityTokenOwner(); + function changeAllowBeneficialInvestments(bool _allowBeneficialInvestments) public withPerm(OPERATOR) { require(_allowBeneficialInvestments != allowBeneficialInvestments, "Does not change value"); allowBeneficialInvestments = _allowBeneficialInvestments; emit SetAllowBeneficialInvestments(allowBeneficialInvestments); diff --git a/contracts/modules/STO/Capped/CappedSTOStorage.sol b/contracts/modules/STO/Capped/CappedSTOStorage.sol index 7ddeea403..cd72fc935 100644 --- a/contracts/modules/STO/Capped/CappedSTOStorage.sol +++ b/contracts/modules/STO/Capped/CappedSTOStorage.sol @@ -5,6 +5,7 @@ pragma solidity ^0.5.0; */ contract CappedSTOStorage { + bytes32 constant OPERATOR = "OPERATOR"; // Determine whether users can invest on behalf of a beneficiary bool public allowBeneficialInvestments = false; // How many token units a buyer gets (multiplied by 10^18) per wei / base unit of POLY diff --git a/contracts/modules/STO/USDTiered/USDTieredSTO.sol b/contracts/modules/STO/USDTiered/USDTieredSTO.sol index 67b2fc6f1..a13aa0ce6 100644 --- a/contracts/modules/STO/USDTiered/USDTieredSTO.sol +++ b/contracts/modules/STO/USDTiered/USDTieredSTO.sol @@ -22,7 +22,6 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { event SetAllowBeneficialInvestments(bool _allowed); event SetNonAccreditedLimit(address _investor, uint256 _limit); - event SetAccredited(address _investor, bool _accredited); event TokenPurchase( address indexed _purchaser, address indexed _beneficiary, @@ -126,8 +125,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @dev Modifies fund raise types * @param _fundRaiseTypes Array of fund raise types to allow */ - function modifyFunding(FundRaiseType[] calldata _fundRaiseTypes) external { - _onlySecurityTokenOwner(); + function modifyFunding(FundRaiseType[] calldata _fundRaiseTypes) external withPerm(OPERATOR) { _isSTOStarted(); _setFundRaiseType(_fundRaiseTypes); } @@ -137,8 +135,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @param _nonAccreditedLimitUSD max non accredited invets limit * @param _minimumInvestmentUSD overall minimum investment limit */ - function modifyLimits(uint256 _nonAccreditedLimitUSD, uint256 _minimumInvestmentUSD) external { - _onlySecurityTokenOwner(); + function modifyLimits(uint256 _nonAccreditedLimitUSD, uint256 _minimumInvestmentUSD) external withPerm(OPERATOR) { _isSTOStarted(); _modifyLimits(_nonAccreditedLimitUSD, _minimumInvestmentUSD); } @@ -157,8 +154,8 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { uint256[] calldata _tokensPerTierDiscountPoly ) external + withPerm(OPERATOR) { - _onlySecurityTokenOwner(); _isSTOStarted(); _modifyTiers(_ratePerTier, _ratePerTierDiscountPoly, _tokensPerTierTotal, _tokensPerTierDiscountPoly); } @@ -168,8 +165,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @param _startTime start time of sto * @param _endTime end time of sto */ - function modifyTimes(uint256 _startTime, uint256 _endTime) external { - _onlySecurityTokenOwner(); + function modifyTimes(uint256 _startTime, uint256 _endTime) external withPerm(OPERATOR) { _isSTOStarted(); _modifyTimes(_startTime, _endTime); } @@ -258,8 +254,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @notice Finalizes the STO and mint remaining tokens to treasury address * @notice Treasury wallet address must be whitelisted to successfully finalize */ - function finalize() external { - _onlySecurityTokenOwner(); + function finalize() external withPerm(ADMIN) { require(!isFinalized, "STO is finalized"); isFinalized = true; uint256 tempReturned; @@ -289,8 +284,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @param _investors Array of investor addresses to modify * @param _nonAccreditedLimit Array of uints specifying non-accredited limits */ - function changeNonAccreditedLimit(address[] calldata _investors, uint256[] calldata _nonAccreditedLimit) external { - _onlySecurityTokenOwner(); + function changeNonAccreditedLimit(address[] calldata _investors, uint256[] calldata _nonAccreditedLimit) external withPerm(OPERATOR) { //nonAccreditedLimitUSDOverride require(_investors.length == _nonAccreditedLimit.length, "Length mismatch"); for (uint256 i = 0; i < _investors.length; i++) { @@ -320,8 +314,7 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @notice Function to set allowBeneficialInvestments (allow beneficiary to be different to funder) * @param _allowBeneficialInvestments Boolean to allow or disallow beneficial investments */ - function changeAllowBeneficialInvestments(bool _allowBeneficialInvestments) external { - _onlySecurityTokenOwner(); + function changeAllowBeneficialInvestments(bool _allowBeneficialInvestments) external withPerm(OPERATOR) { require(_allowBeneficialInvestments != allowBeneficialInvestments); allowBeneficialInvestments = _allowBeneficialInvestments; emit SetAllowBeneficialInvestments(allowBeneficialInvestments); diff --git a/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol b/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol index 75a1f6d1c..12f0050d6 100644 --- a/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol +++ b/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol @@ -6,7 +6,9 @@ pragma solidity ^0.5.0; contract USDTieredSTOStorage { bytes32 internal constant INVESTORSKEY = 0xdf3a8dd24acdd05addfc6aeffef7574d2de3f844535ec91e8e0f3e45dba96731; //keccak256(abi.encodePacked("INVESTORS")) - + bytes32 constant ADMIN = "ADMIN"; + bytes32 constant OPERATOR = "OPERATOR"; + ///////////// // Storage // ///////////// diff --git a/contracts/modules/TransferManager/VRTM/VolumeRestrictionTM.sol b/contracts/modules/TransferManager/VRTM/VolumeRestrictionTM.sol index 12bef17d8..d0961c2f7 100644 --- a/contracts/modules/TransferManager/VRTM/VolumeRestrictionTM.sol +++ b/contracts/modules/TransferManager/VRTM/VolumeRestrictionTM.sol @@ -10,7 +10,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { using SafeMath for uint256; // Emit when the token holder is added/removed from the exemption list - event ChangedExemptWalletList(address indexed _wallet, bool _change); + event ChangedExemptWalletList(address indexed _wallet, bool _exempted); // Emit when the new individual restriction is added corresponds to new token holders event AddIndividualRestriction( address indexed _holder, @@ -186,12 +186,12 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { /** * @notice Add/Remove wallet address from the exempt list * @param _wallet Ethereum wallet/contract address that need to be exempted - * @param _change Boolean value used to add (i.e true) or remove (i.e false) from the list + * @param _exempted Boolean value used to add (i.e true) or remove (i.e false) from the list */ - function changeExemptWalletList(address _wallet, bool _change) public withPerm(ADMIN) { + function changeExemptWalletList(address _wallet, bool _exempted) public withPerm(ADMIN) { require(_wallet != address(0)); - require((exemptions.exemptIndex[_wallet] == 0) == _change); - if (_change) { + require((exemptions.exemptIndex[_wallet] == 0) == _exempted); + if (_exempted) { exemptions.exemptAddresses.push(_wallet); exemptions.exemptIndex[_wallet] = exemptions.exemptAddresses.length; } else { @@ -200,7 +200,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager { delete exemptions.exemptIndex[_wallet]; exemptions.exemptAddresses.length--; } - emit ChangedExemptWalletList(_wallet, _change); + emit ChangedExemptWalletList(_wallet, _exempted); } /** diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 65ab132d9..55a032bbb 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -42,7 +42,8 @@ contract SecurityToken is ERC20, ReentrancyGuard, SecurityTokenStorage, IERC1594 bytes32 _label, bool _archived ); - + // Emit when Module get upgraded from the securityToken + event ModuleUpgraded(uint8[] _types, address _module); // Emit when the token details get updated event UpdateTokenDetails(string _oldDetails, string _newDetails); // Emit when the token name get updated diff --git a/test/zc_plcr_voting_checkpoint.js b/test/zc_plcr_voting_checkpoint.js index d1bcce29a..e27b0fca7 100644 --- a/test/zc_plcr_voting_checkpoint.js +++ b/test/zc_plcr_voting_checkpoint.js @@ -363,7 +363,7 @@ contract("PLCRVotingCheckpoint", async (accounts) => { let tx = await I_PLCRVotingCheckpoint.changeBallotExemptedVotersList(new BN(0), account_investor1, true, {from: token_owner}); assert.equal((tx.logs[0].args._ballotId).toString(), 0); assert.equal(tx.logs[0].args._voter, account_investor1); - assert.equal(tx.logs[0].args._change, true); + assert.equal(tx.logs[0].args._exempt, true); }); it("\t\t Should fail to add voter in ballot exemption list -- doing the same change again", async() => { @@ -426,7 +426,7 @@ contract("PLCRVotingCheckpoint", async (accounts) => { it("\t\t Should add the voter in to the default exemption list", async() => { let tx = await I_PLCRVotingCheckpoint.changeDefaultExemptedVotersList(account_investor3, true, {from: token_owner}); assert.equal(tx.logs[0].args._voter, account_investor3); - assert.equal(tx.logs[0].args._change, true); + assert.equal(tx.logs[0].args._exempt, true); }); it("\t\t Should fail to add voter in default exemption list -- doing the same change again", async() => { diff --git a/test/zd_weighted_vote_checkpoint.js b/test/zd_weighted_vote_checkpoint.js index ec8b0fa46..aaaac7d48 100644 --- a/test/zd_weighted_vote_checkpoint.js +++ b/test/zd_weighted_vote_checkpoint.js @@ -308,7 +308,7 @@ contract("WeightedVoteCheckpoint", async (accounts) => { let tx = await I_WeightedVoteCheckpoint.changeBallotExemptedVotersList(new BN(0), account_investor2, true, {from: token_owner}); assert.equal((tx.logs[0].args._ballotId).toString(), 0); assert.equal(tx.logs[0].args._voter, account_investor2); - assert.equal(tx.logs[0].args._change, true); + assert.equal(tx.logs[0].args._exempt, true); }); it("\t\t Should fail to add voter in ballot exemption list -- doing the same change again", async() => { @@ -355,7 +355,7 @@ contract("WeightedVoteCheckpoint", async (accounts) => { it("\t\t Should add the voter in to the default exemption list", async() => { let tx = await I_WeightedVoteCheckpoint.changeDefaultExemptedVotersList(account_investor1, true, {from: token_owner}); assert.equal(tx.logs[0].args._voter, account_investor1); - assert.equal(tx.logs[0].args._change, true); + assert.equal(tx.logs[0].args._exempt, true); }); it("\t\t Should fail to add voter in default exemption list -- doing the same change again", async() => { From 16d568ff947206d742a954baea495e4fbeefac1c Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 13 Jun 2019 10:25:27 +0530 Subject: [PATCH 2/2] permission fixes --- contracts/modules/STO/Capped/CappedSTO.sol | 3 ++- contracts/modules/STO/Capped/CappedSTOStorage.sol | 1 - contracts/modules/STO/USDTiered/USDTieredSTO.sol | 3 +++ contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol | 2 -- test/b_capped_sto.js | 2 +- test/p_usd_tiered_sto.js | 4 ++-- test/q_usd_tiered_sto_sim.js | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/modules/STO/Capped/CappedSTO.sol b/contracts/modules/STO/Capped/CappedSTO.sol index a8a54f84e..5a54e1c38 100644 --- a/contracts/modules/STO/Capped/CappedSTO.sol +++ b/contracts/modules/STO/Capped/CappedSTO.sol @@ -133,7 +133,8 @@ contract CappedSTO is CappedSTOStorage, STO, ReentrancyGuard { * @notice Return the permissions flag that are associated with STO */ function getPermissions() public view returns(bytes32[] memory) { - bytes32[] memory allPermissions = new bytes32[](0); + bytes32[] memory allPermissions = new bytes32[](1); + allPermissions[0] = OPERATOR; return allPermissions; } diff --git a/contracts/modules/STO/Capped/CappedSTOStorage.sol b/contracts/modules/STO/Capped/CappedSTOStorage.sol index cd72fc935..7ddeea403 100644 --- a/contracts/modules/STO/Capped/CappedSTOStorage.sol +++ b/contracts/modules/STO/Capped/CappedSTOStorage.sol @@ -5,7 +5,6 @@ pragma solidity ^0.5.0; */ contract CappedSTOStorage { - bytes32 constant OPERATOR = "OPERATOR"; // Determine whether users can invest on behalf of a beneficiary bool public allowBeneficialInvestments = false; // How many token units a buyer gets (multiplied by 10^18) per wei / base unit of POLY diff --git a/contracts/modules/STO/USDTiered/USDTieredSTO.sol b/contracts/modules/STO/USDTiered/USDTieredSTO.sol index a13aa0ce6..715d4ec4d 100644 --- a/contracts/modules/STO/USDTiered/USDTieredSTO.sol +++ b/contracts/modules/STO/USDTiered/USDTieredSTO.sol @@ -703,6 +703,9 @@ contract USDTieredSTO is USDTieredSTOStorage, STO { * @notice Return the permissions flag that are associated with STO */ function getPermissions() public view returns(bytes32[] memory allPermissions) { + bytes32[] memory allPermissions = new bytes32[](2); + allPermissions[0] = OPERATOR; + allPermissions[1] = ADMIN; return allPermissions; } diff --git a/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol b/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol index 12f0050d6..6b698358a 100644 --- a/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol +++ b/contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol @@ -6,8 +6,6 @@ pragma solidity ^0.5.0; contract USDTieredSTOStorage { bytes32 internal constant INVESTORSKEY = 0xdf3a8dd24acdd05addfc6aeffef7574d2de3f844535ec91e8e0f3e45dba96731; //keccak256(abi.encodePacked("INVESTORS")) - bytes32 constant ADMIN = "ADMIN"; - bytes32 constant OPERATOR = "OPERATOR"; ///////////// // Storage // diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index c3fa37848..31347b4ae 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -997,7 +997,7 @@ contract("CappedSTO", async (accounts) => { it("Should get the listed permissions", async () => { let tx = await I_CappedSTO_Array_POLY[0].getPermissions.call(); - assert.equal(tx.length, 0); + assert.equal(tx.length, 1); }); it("Should get the metrics of the STO", async () => { diff --git a/test/p_usd_tiered_sto.js b/test/p_usd_tiered_sto.js index 9148dfe7a..e38927de2 100644 --- a/test/p_usd_tiered_sto.js +++ b/test/p_usd_tiered_sto.js @@ -390,7 +390,7 @@ contract("USDTieredSTO", async (accounts) => { _tokensPerTierTotal[stoId].length, "Incorrect number of tiers" ); - assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(0), "Incorrect number of permissions"); + assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(2), "Incorrect number of permissions"); }); it("Should attach the paid STO factory -- failed because of no tokens", async () => { @@ -579,7 +579,7 @@ contract("USDTieredSTO", async (accounts) => { _tokensPerTierTotal[stoId].length, "Incorrect number of tiers" ); - assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(0), "Incorrect number of permissions"); + assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(2), "Incorrect number of permissions"); }); it("Should successfully attach the third STO module to the security token", async () => { diff --git a/test/q_usd_tiered_sto_sim.js b/test/q_usd_tiered_sto_sim.js index b19d6cb5c..0d6feb494 100644 --- a/test/q_usd_tiered_sto_sim.js +++ b/test/q_usd_tiered_sto_sim.js @@ -362,7 +362,7 @@ contract("USDTieredSTO Sim", async (accounts) => { _tokensPerTierTotal[stoId].length, "Incorrect number of tiers" ); - assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(0), "Incorrect number of permissions"); + assert.equal((await I_USDTieredSTO_Array[stoId].getPermissions()).length, new BN(2), "Incorrect number of permissions"); }); it("Should successfully prepare the STO", async () => {