Skip to content

Commit c339f52

Browse files
authored
Merge pull request #523 from dev1644/moved-_adjustTotalSupplyCheckpoints-inside-of-createCheckpoint-#520
Moved adjust total supply checkpoints inside of create checkpoint #520
2 parents 49f6a10 + d3ebb61 commit c339f52

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

contracts/tokens/SecurityToken.sol

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
7676
// Map each investor to a series of checkpoints
7777
mapping(address => TokenLib.Checkpoint[]) checkpointBalances;
7878

79-
// List of checkpoints that relate to total supply
80-
TokenLib.Checkpoint[] checkpointTotalSupply;
79+
// Mapping of checkpoints that relate to total supply
80+
mapping (uint256 => uint256) checkpointTotalSupply;
8181

8282
// Times at which each checkpoint was created
8383
uint256[] checkpointTimes;
@@ -458,13 +458,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
458458
emit FreezeTransfers(false, now);
459459
}
460460

461-
/**
462-
* @notice Internal - adjusts totalSupply at checkpoint after minting or burning tokens
463-
*/
464-
function _adjustTotalSupplyCheckpoints() internal {
465-
TokenLib.adjustCheckpoints(checkpointTotalSupply, totalSupply(), currentCheckpointId);
466-
}
467-
468461
/**
469462
* @notice Internal - adjusts token holder balance at checkpoint after a token transfer
470463
* @param _investor address of the token holder affected
@@ -648,7 +641,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
648641
returns(bool success)
649642
{
650643
require(_updateTransfer(address(0), _investor, _value, _data), "Transfer invalid");
651-
_adjustTotalSupplyCheckpoints();
652644
_mint(_investor, _value);
653645
emit Minted(_investor, _value);
654646
return true;
@@ -692,7 +684,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
692684

693685
function _checkAndBurn(address _from, uint256 _value, bytes memory _data) internal returns(bool) {
694686
bool verified = _updateTransfer(_from, address(0), _value, _data);
695-
_adjustTotalSupplyCheckpoints();
696687
_burn(_from, _value);
697688
emit Burnt(_from, _value);
698689
return verified;
@@ -709,7 +700,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
709700

710701
function _checkAndBurnFrom(address _from, uint256 _value, bytes memory _data) internal returns(bool) {
711702
bool verified = _updateTransfer(_from, address(0), _value, _data);
712-
_adjustTotalSupplyCheckpoints();
713703
_burnFrom(_from, _value);
714704
emit Burnt(_from, _value);
715705
return verified;
@@ -735,6 +725,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
735725
/*solium-disable-next-line security/no-block-members*/
736726
checkpointTimes.push(now);
737727
/*solium-disable-next-line security/no-block-members*/
728+
checkpointTotalSupply[currentCheckpointId] = totalSupply();
738729
emit CheckpointCreated(currentCheckpointId, now);
739730
return currentCheckpointId;
740731
}
@@ -754,7 +745,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater
754745
*/
755746
function totalSupplyAt(uint256 _checkpointId) external view returns(uint256) {
756747
require(_checkpointId <= currentCheckpointId);
757-
return TokenLib.getValueAt(checkpointTotalSupply, _checkpointId, totalSupply());
748+
return checkpointTotalSupply[_checkpointId];
758749
}
759750

760751
/**

0 commit comments

Comments
 (0)