From 16d568ff947206d742a954baea495e4fbeefac1c Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 13 Jun 2019 10:25:27 +0530 Subject: [PATCH] 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 () => {