From 5e3957e3792e0b0dbf48c36e386440b4c40aed42 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Thu, 27 Sep 2018 14:55:27 +0100 Subject: [PATCH 1/3] Add list of times that checkpoints were created --- contracts/tokens/SecurityToken.sol | 10 ++++++++++ test/c_checkpoints.js | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 86f761854..c122650fe 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -81,6 +81,7 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr mapping (address => Checkpoint[]) public checkpointBalances; Checkpoint[] public checkpointTotalSupply; + uint256[] public checkpointTimes; // Records added modules - module list should be order agnostic! mapping (uint8 => address[]) public modules; @@ -696,10 +697,19 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr function createCheckpoint() external onlyModuleOrOwner(CHECKPOINT_KEY) returns(uint256) { require(currentCheckpointId < 2**256 - 1); currentCheckpointId = currentCheckpointId + 1; + checkpointTimes.push(now); emit LogCheckpointCreated(currentCheckpointId, now); return currentCheckpointId; } + /** + * @notice Gets list of times that checkpoints were created + * @return List of checkpoint times + */ + function getCheckpointTimes() external view returns(uint256[]) { + return checkpointTimes; + } + /** * @notice Queries totalSupply as of a defined checkpoint * @param _checkpointId Checkpoint ID to query diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index 8e3da77ee..df8ae49c6 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -152,8 +152,8 @@ contract('Checkpoints', accounts => { I_SecurityTokenRegistryProxy = await SecurityTokenRegistryProxy.new({from: account_polymath}); let bytesProxy = encodeProxyCall([I_PolymathRegistry.address, I_STFactory.address, initRegFee, initRegFee, I_PolyToken.address, account_polymath]); await I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, {from: account_polymath}); - I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); - + I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); + // Step 10: Deploy the FeatureRegistry I_FeatureRegistry = await FeatureRegistry.new( I_PolymathRegistry.address, @@ -315,6 +315,7 @@ contract('Checkpoints', accounts => { ts.push(totalSupply); console.log("Checkpoint: " + (j + 1) + " Balances: " + JSON.stringify(cps[cps.length - 1]) + " TotalSupply: " + JSON.stringify(totalSupply)); await I_SecurityToken.createCheckpoint({ from: token_owner }); + console.log("Checkpoint Times: " + (await I_SecurityToken.getCheckpointTimes())); let txs = Math.floor(Math.random() * 3); for (let i = 0; i < txs; i++) { let sender; From 4bb9d6e53cd7405eaf590d863b7e3fe864322f41 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Thu, 27 Sep 2018 15:05:38 +0100 Subject: [PATCH 2/3] Add another test case --- test/c_checkpoints.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index df8ae49c6..4100d06c6 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -315,7 +315,9 @@ contract('Checkpoints', accounts => { ts.push(totalSupply); console.log("Checkpoint: " + (j + 1) + " Balances: " + JSON.stringify(cps[cps.length - 1]) + " TotalSupply: " + JSON.stringify(totalSupply)); await I_SecurityToken.createCheckpoint({ from: token_owner }); - console.log("Checkpoint Times: " + (await I_SecurityToken.getCheckpointTimes())); + let checkpointTimes = (await I_SecurityToken.getCheckpointTimes()); + assert.isEqual(checkpointTimes.length, (j + 1)); + console.log("Checkpoint Times: " + checkpointTimes); let txs = Math.floor(Math.random() * 3); for (let i = 0; i < txs; i++) { let sender; From 7c7633714e7c0ef9770ec3249d8a0954eec683ca Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Thu, 27 Sep 2018 15:08:13 +0100 Subject: [PATCH 3/3] fix typo --- test/c_checkpoints.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index 4100d06c6..16fa5945d 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -316,7 +316,7 @@ contract('Checkpoints', accounts => { console.log("Checkpoint: " + (j + 1) + " Balances: " + JSON.stringify(cps[cps.length - 1]) + " TotalSupply: " + JSON.stringify(totalSupply)); await I_SecurityToken.createCheckpoint({ from: token_owner }); let checkpointTimes = (await I_SecurityToken.getCheckpointTimes()); - assert.isEqual(checkpointTimes.length, (j + 1)); + assert.equal(checkpointTimes.length, (j + 1)); console.log("Checkpoint Times: " + checkpointTimes); let txs = Math.floor(Math.random() * 3); for (let i = 0; i < txs; i++) {