@@ -33,12 +33,16 @@ contract CountTransferManager is CountTransferManagerStorage, TransferManager {
3333 external
3434 returns (Result)
3535 {
36- (Result success , ) = _verifyTransfer (_from, _to, _amount);
36+ (Result success , ) = _verifyTransfer (_from, _to, _amount, securityToken. holderCount () );
3737 return success;
3838 }
3939
4040 /**
4141 * @notice Used to verify the transfer transaction and prevent a transfer if it passes the allowed amount of token holders
42+ * @dev module.verifyTransfer is called by SecToken.canTransfer and does not receive the updated holderCount therefore
43+ * verifyTransfer has to manually account for pot. tokenholder changes (by mimicking TokenLib.adjustInvestorCount).
44+ * module.executeTransfer is called by SecToken.transfer|issue|others and receives an updated holderCount
45+ * as sectoken calls TokenLib.adjustInvestorCount before executeTransfer.
4246 * @param _from Address of the sender
4347 * @param _to Address of the receiver
4448 * @param _amount Amount to send
@@ -53,20 +57,33 @@ contract CountTransferManager is CountTransferManagerStorage, TransferManager {
5357 view
5458 returns (Result, bytes32 )
5559 {
56- return _verifyTransfer (_from, _to, _amount);
60+ uint256 holderCount = securityToken.holderCount ();
61+ if (_amount != 0 && _from != _to) {
62+ // Check whether receiver is a new token holder
63+ if (_to != address (0 ) && securityToken.balanceOf (_to) == 0 ) {
64+ holderCount++ ;
65+ }
66+ // Check whether sender is moving all of their tokens
67+ if (_amount == securityToken.balanceOf (_from)) {
68+ holderCount-- ;
69+ }
70+ }
71+
72+ return _verifyTransfer (_from, _to, _amount, holderCount);
5773 }
5874
5975 function _verifyTransfer (
6076 address _from ,
6177 address _to ,
62- uint256 _amount
78+ uint256 _amount ,
79+ uint256 _holderCount
6380 )
6481 internal
6582 view
6683 returns (Result, bytes32 )
6784 {
6885 if (! paused) {
69- if (maxHolderCount < securityToken. holderCount () ) {
86+ if (maxHolderCount < _holderCount ) {
7087 // Allow transfers to existing maxHolders
7188 if (securityToken.balanceOf (_to) != 0 || securityToken.balanceOf (_from) == _amount) {
7289 return (Result.NA, bytes32 (0 ));
0 commit comments