Skip to content

Commit f8fe939

Browse files
authored
Merge branch 'dev-3.0.0' into internalise_functions_variables
2 parents c40bc10 + c2e6434 commit f8fe939

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

contracts/modules/TransferManager/CTM/CountTransferManager.sol

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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));

test/d_count_transfer_manager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ contract("CountTransferManager", async (accounts) => {
311311
);
312312

313313
await catchRevert(I_SecurityToken.issue(account_investor3, new BN(web3.utils.toWei("3", "ether")), "0x0", { from: token_owner }));
314+
await catchRevert(I_SecurityToken.transfer(account_investor3, new BN(web3.utils.toWei("1", "ether")), { from: account_investor2 }));
315+
let canTransfer = await I_SecurityToken.canTransfer(account_investor3, new BN(web3.utils.toWei("1", "ether")), "0x0", { from: account_investor2 });
316+
assert.equal(canTransfer[0], "0x50"); //Transfer failure.
314317
});
315318

316319
it("Should still be able to add to original token holders", async () => {

0 commit comments

Comments
 (0)