Skip to content

Commit

Permalink
Merge be8ba47 into 141e3fa
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdossa committed Sep 27, 2018
2 parents 141e3fa + be8ba47 commit 46a6f3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/tokens/SecurityToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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;
Expand Down Expand Up @@ -704,10 +705,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 CheckpointCreated(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
Expand Down
3 changes: 3 additions & 0 deletions test/c_checkpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,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 });
let checkpointTimes = (await I_SecurityToken.getCheckpointTimes());
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++) {
let sender;
Expand Down

0 comments on commit 46a6f3a

Please sign in to comment.