diff --git a/contracts/interfaces/ITransferManager.sol b/contracts/interfaces/ITransferManager.sol index 63d652207..b5c0e1691 100644 --- a/contracts/interfaces/ITransferManager.sol +++ b/contracts/interfaces/ITransferManager.sol @@ -26,10 +26,4 @@ interface ITransferManager { */ function getTokensByPartition(bytes32 _partition, address _tokenHolder, uint256 _additionalBalance) external view returns(uint256); - /** - * @notice return the list of partitions for a tokenHolder - * @param _tokenHolder Whom token amount need to query - */ - function getPartitions(address _tokenHolder) external view returns(bytes32[] memory); - } diff --git a/contracts/modules/TransferManager/TransferManager.sol b/contracts/modules/TransferManager/TransferManager.sol index 45a34a2ad..2ef53c8d5 100644 --- a/contracts/modules/TransferManager/TransferManager.sol +++ b/contracts/modules/TransferManager/TransferManager.sol @@ -35,14 +35,4 @@ contract TransferManager is ITransferManager, Module { return 0; } - /** - * @notice return the amount of tokens for a given user as per the partition - */ - function getPartitions(address /*_tokenHolder*/) external view returns(bytes32[] memory) { - bytes32[] memory result = new bytes32[](2); - result[0] = UNLOCKED; - result[1] = LOCKED; - return result; - } - } diff --git a/contracts/tokens/STGetter.sol b/contracts/tokens/STGetter.sol index 19960f4be..535abb245 100644 --- a/contracts/tokens/STGetter.sol +++ b/contracts/tokens/STGetter.sol @@ -228,63 +228,13 @@ contract STGetter is OZStorage, SecurityTokenStorage { /** * @notice Return all partitions - * @param _tokenHolder Whom balance need to queried * @return List of partitions */ - function partitionsOf(address _tokenHolder) external view returns (bytes32[] memory) { - address[] memory tms = modules[TRANSFER_KEY]; - /* uint256 count; */ - bytes32[] memory partitions; - bytes32[] memory tmPartitions; - // First determine the total number of non-distinct partitions - for (uint256 i = 0; i < tms.length; i++) { - tmPartitions = ITransferManager(tms[i]).getPartitions(_tokenHolder); - for (uint256 j = 0 ; j < tmPartitions.length; j++) { - partitions = _appendPartition(partitions, tmPartitions[j]); - } - } - partitions = _appendPartition(partitions, "DEFAULT"); - /* bytes32[] memory partitions = new bytes32[](count + 1); - count = 0; - for (uint256 i = 0; i < tms.length; i++) { - tmPartitions = ITransferManager(tms[i]).getPartitions(_tokenHolder); - for (uint256 j = 0; j < tmPartitions.length; j++) { - partitions[count + j] = tmPartitions[j]; - } - count += tmPartitions.length; - } - partitions[count] = "DEFAULT"; - uint256[] memory index = new uint256[](count); - count = 0; - for (uint256 i = 0; i < partitions.length; i++) { - for (uint256 j = 0; j < partitions.length; j++) { - if (partitions[i] == partitions[j]) { - index[i] = j; - } - } - } - // Create distinct list - bytes32[] memory result */ - return partitions; - } - - function _appendPartition(bytes32[] memory partitions, bytes32 partition) internal pure returns (bytes32[] memory) { - bool duplicate = false; - for (uint256 i = 0; i < partitions.length; i++) { - if (partition == partitions[i]) { - duplicate = true; - break; - } - } - if (duplicate) { - bytes32[] memory result = new bytes32[](1 + partitions.length); - for (uint256 i = 0; i < partitions.length; i++) { - result[i] = partitions[i]; - } - result[partitions.length] = partition; - return result; - } - return partitions; + function partitionsOf(address /*_tokenHolder*/) external view returns (bytes32[] memory) { + bytes32[] memory result = new bytes32[](2); + result[0] = UNLOCKED; + result[1] = LOCKED; + return result; } /** @@ -307,9 +257,9 @@ contract STGetter is OZStorage, SecurityTokenStorage { */ function getDocument(bytes32 _name) external view returns (string memory, bytes32, uint256) { return ( - _documents[_name].uri, - _documents[_name].docHash, - _documents[_name].lastModified + _documents[_name].uri, + _documents[_name].docHash, + _documents[_name].lastModified ); } diff --git a/test/o_security_token.js b/test/o_security_token.js index 780cee7c4..35d3599cf 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -1735,7 +1735,16 @@ contract("SecurityToken", async (accounts) => { let afterTotalSupply = await I_SecurityToken.totalSupply.call(); assert.equal(web3.utils.fromWei(beforeTotalSupply.sub(afterTotalSupply)), 10); - }) + }); + + it("Should get the partitions of the secuirtyToken", async() => { + let partitions = await I_STGetter.partitionsOf.call(account_investor1); + console.log(`Partitions of the investor 1: ${web3.utils.hexToUtf8(partitions[0])}`); + assert.equal("UNLOCKED", web3.utils.hexToUtf8(partitions[0])); + assert.equal("LOCKED", web3.utils.hexToUtf8(partitions[1])); + partitions = await I_STGetter.partitionsOf.call(account_investor2); + console.log(`Partitions of the investor 2: ${web3.utils.hexToUtf8(partitions[0])}`); + }); }); describe("Test cases for the storage", async() => {