Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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