Skip to content

Commit

Permalink
Extra Items (#702)
Browse files Browse the repository at this point in the history
* minor improvements

* permission fixes
  • Loading branch information
satyamakgec authored and adamdossa committed Jun 13, 2019
1 parent 2706d20 commit 9fae133
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 72 deletions.
6 changes: 3 additions & 3 deletions contracts/SecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy {
// Attempt to charge the reg fee if it is > 0 USD
(uint256 usdFee, 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)) {
Expand Down Expand Up @@ -462,11 +462,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)) {
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/ISecurityTokenRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,11 @@ interface ISecurityTokenRegistry {
*/
function owner() external view returns(address ownerAddress);

/**
* @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);

}
24 changes: 12 additions & 12 deletions contracts/modules/Checkpoint/Voting/PLCR/PLCRVotingCheckpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions contracts/modules/Checkpoint/Voting/VotingCheckpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -44,7 +44,7 @@ contract VotingCheckpoint is VotingCheckpointStorage, ICheckpoint, IVoting, Modu
delete defaultExemptIndex[_voter];
defaultExemptedVoters.length --;
}
emit ChangedDefaultExemptedVotersList(_voter, _change);
emit ChangedDefaultExemptedVotersList(_voter, _exempt);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions contracts/modules/STO/Capped/CappedSTO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -134,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;
}

Expand Down
24 changes: 10 additions & 14 deletions contracts/modules/STO/USDTiered/USDTieredSTO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -157,8 +154,8 @@ contract USDTieredSTO is USDTieredSTOStorage, STO {
uint256[] calldata _tokensPerTierDiscountPoly
)
external
withPerm(OPERATOR)
{
_onlySecurityTokenOwner();
_isSTOStarted();
_modifyTiers(_ratePerTier, _ratePerTierDiscountPoly, _tokensPerTierTotal, _tokensPerTierDiscountPoly);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -275,8 +271,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;
Expand Down Expand Up @@ -306,8 +301,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++) {
Expand Down Expand Up @@ -337,8 +331,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);
Expand Down Expand Up @@ -727,6 +720,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;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/STO/USDTiered/USDTieredSTOStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity 0.5.8;
contract USDTieredSTOStorage {

bytes32 internal constant INVESTORSKEY = 0xdf3a8dd24acdd05addfc6aeffef7574d2de3f844535ec91e8e0f3e45dba96731; //keccak256(abi.encodePacked("INVESTORS"))

/////////////
// Storage //
/////////////
Expand Down
12 changes: 6 additions & 6 deletions contracts/modules/TransferManager/VRTM/VolumeRestrictionTM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -200,7 +200,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, TransferManager {
delete exemptions.exemptIndex[_wallet];
exemptions.exemptAddresses.length--;
}
emit ChangedExemptWalletList(_wallet, _change);
emit ChangedExemptWalletList(_wallet, _exempted);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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
Expand Down
2 changes: 1 addition & 1 deletion test/b_capped_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,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 () => {
Expand Down
4 changes: 2 additions & 2 deletions test/p_usd_tiered_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,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 () => {
Expand Down Expand Up @@ -581,7 +581,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 () => {
Expand Down
Loading

0 comments on commit 9fae133

Please sign in to comment.