Skip to content

Commit f1e986c

Browse files
authored
Merge branch 'dev-2.1.0' into Comment-Fix
2 parents a133f13 + 124311b commit f1e986c

20 files changed

+49
-54
lines changed

contracts/libraries/VolumeRestrictionLib.sol

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,12 @@ pragma solidity ^0.4.24;
33
import "./BokkyPooBahsDateTimeLibrary.sol";
44
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
55
import "../interfaces/ISecurityToken.sol";
6+
import "../storage/VolumeRestrictionTMStorage.sol";
67

78
library VolumeRestrictionLib {
89

910
using SafeMath for uint256;
1011

11-
enum TypeOfPeriod { MultipleDays, OneDay, Both }
12-
13-
struct RestrictedHolder {
14-
// 1 represent true & 0 for false
15-
uint8 seen;
16-
// Type of period will be enum index of TypeOfPeriod enum
17-
uint8 typeOfPeriod;
18-
// Index of the array where the holder address lives
19-
uint128 index;
20-
}
21-
22-
struct RestrictedData {
23-
mapping(address => RestrictedHolder) restrictedHolders;
24-
address[] restrictedAddresses;
25-
}
26-
2712
function _checkLengthOfArray(
2813
address[] _holders,
2914
uint256[] _allowedTokens,
@@ -45,14 +30,14 @@ library VolumeRestrictionLib {
4530
);
4631
}
4732

48-
function _deleteHolderFromList(RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public {
33+
function deleteHolderFromList(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public {
4934
// Deleting the holder if holder's type of Period is `Both` type otherwise
5035
// it will assign the given type `_typeOfPeriod` to the _holder typeOfPeriod
5136
// `_typeOfPeriod` it always be contrary to the removing restriction
5237
// if removing restriction is individual then typeOfPeriod is TypeOfPeriod.OneDay
5338
// in uint8 its value is 1. if removing restriction is daily individual then typeOfPeriod
5439
// is TypeOfPeriod.MultipleDays in uint8 its value is 0.
55-
if (data.restrictedHolders[_holder].typeOfPeriod != uint8(TypeOfPeriod.Both)) {
40+
if (data.restrictedHolders[_holder].typeOfPeriod != uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both)) {
5641
uint128 index = data.restrictedHolders[_holder].index;
5742
uint256 _len = data.restrictedAddresses.length;
5843
if (index != _len) {
@@ -66,22 +51,22 @@ library VolumeRestrictionLib {
6651
}
6752
}
6853

69-
function _addRestrictionData(RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public {
54+
function addRestrictionData(VolumeRestrictionTMStorage.RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public {
7055
uint128 index = data.restrictedHolders[_holder].index;
7156
if (data.restrictedHolders[_holder].seen == 0) {
7257
data.restrictedAddresses.push(_holder);
7358
index = uint128(data.restrictedAddresses.length);
7459
}
7560
uint8 _type = _getTypeOfPeriod(data.restrictedHolders[_holder].typeOfPeriod, _callFrom, _endTime);
76-
data.restrictedHolders[_holder] = RestrictedHolder(uint8(1), _type, index);
61+
data.restrictedHolders[_holder] = VolumeRestrictionTMStorage.RestrictedHolder(uint8(1), _type, index);
7762
}
7863

7964
function _getTypeOfPeriod(uint8 _currentTypeOfPeriod, uint8 _callFrom, uint256 _endTime) internal pure returns(uint8) {
8065
if (_currentTypeOfPeriod != _callFrom && _endTime != uint256(0))
81-
return uint8(TypeOfPeriod.Both);
66+
return uint8(VolumeRestrictionTMStorage.TypeOfPeriod.Both);
8267
else
8368
return _callFrom;
8469
}
85-
8670

87-
}
71+
72+
}

contracts/modules/TransferManager/BlacklistTransferManager.sol renamed to contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "./ITransferManager.sol";
3+
import "../../TransferManager/ITransferManager.sol";
44
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
55

66
/**

contracts/modules/TransferManager/BlacklistTransferManagerFactory.sol renamed to contracts/modules/Experimental/TransferManager/BlacklistTransferManagerFactory.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pragma solidity ^0.4.24;
22

33
import "./BlacklistTransferManager.sol";
4-
import "../ModuleFactory.sol";
5-
import "../../libraries/Util.sol";
4+
import "../../ModuleFactory.sol";
5+
import "../../../libraries/Util.sol";
66

77
/**
88
* @title Factory for deploying BlacklistManager module

contracts/modules/TransferManager/LockUpTransferManager.sol renamed to contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "./ITransferManager.sol";
3+
import "../../TransferManager/ITransferManager.sol";
44
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
55

66
contract LockUpTransferManager is ITransferManager {

contracts/modules/TransferManager/LockUpTransferManagerFactory.sol renamed to contracts/modules/Experimental/TransferManager/LockUpTransferManagerFactory.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../ModuleFactory.sol";
3+
import "../../ModuleFactory.sol";
44
import "./LockUpTransferManager.sol";
55

66
/**

contracts/modules/Wallet/IWallet.sol renamed to contracts/modules/Experimental/Wallet/IWallet.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../Pausable.sol";
4-
import "../Module.sol";
3+
import "../../../Pausable.sol";
4+
import "../../Module.sol";
55

66
/**
77
* @title Interface to be implemented by all Wallet modules

contracts/modules/Wallet/VestingEscrowWallet.sol renamed to contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity ^0.4.24;
22

33
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
4-
import "./VestingEscrowWalletStorage.sol";
4+
import "../../../storage/VestingEscrowWalletStorage.sol";
55
import "./IWallet.sol";
66

77
/**

contracts/modules/Wallet/VestingEscrowWalletFactory.sol renamed to contracts/modules/Experimental/Wallet/VestingEscrowWalletFactory.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../proxy/VestingEscrowWalletProxy.sol";
4-
import "../../interfaces/IBoot.sol";
5-
import "../ModuleFactory.sol";
6-
import "../../libraries/Util.sol";
3+
import "../../../proxy/VestingEscrowWalletProxy.sol";
4+
import "../../../interfaces/IBoot.sol";
5+
import "../../ModuleFactory.sol";
6+
import "../../../libraries/Util.sol";
77

88
/**
99
* @title Factory for deploying VestingEscrowWallet module

contracts/modules/STO/USDTieredSTO.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "../../RegistryUpdater.sol";
77
import "../../libraries/DecimalMath.sol";
88
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
99
import "openzeppelin-solidity/contracts/ReentrancyGuard.sol";
10-
import "./USDTieredSTOStorage.sol";
10+
import "../../storage/USDTieredSTOStorage.sol";
1111

1212
/**
1313
* @title STO module for standard capped crowdsale

contracts/modules/TransferManager/GeneralTransferManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity ^0.4.24;
22

33
import "./ITransferManager.sol";
4-
import "./GeneralTransferManagerStorage.sol";
4+
import "../../storage/GeneralTransferManagerStorage.sol";
55
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
66

77
/**

contracts/modules/TransferManager/VolumeRestrictionTM.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.24;
22

33
import "./ITransferManager.sol";
4-
import "./VolumeRestrictionTMStorage.sol";
54
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
65
import "../../libraries/BokkyPooBahsDateTimeLibrary.sol";
6+
import "../../libraries/VolumeRestrictionLib.sol";
77

88
contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
99

@@ -212,7 +212,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
212212
_endTime,
213213
RestrictionType(_restrictionType)
214214
);
215-
VolumeRestrictionLib._addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.MultipleDays), individualRestriction[_holder].endTime);
215+
VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.MultipleDays), individualRestriction[_holder].endTime);
216216
emit AddIndividualRestriction(
217217
_holder,
218218
_allowedTokens,
@@ -275,7 +275,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
275275
_endTime,
276276
RestrictionType(_restrictionType)
277277
);
278-
VolumeRestrictionLib._addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.OneDay), individualRestriction[_holder].endTime);
278+
VolumeRestrictionLib.addRestrictionData(holderData, _holder, uint8(TypeOfPeriod.OneDay), individualRestriction[_holder].endTime);
279279
emit AddIndividualDailyRestriction(
280280
_holder,
281281
_allowedTokens,
@@ -447,7 +447,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
447447
require(_holder != address(0));
448448
require(individualRestriction[_holder].endTime != 0);
449449
individualRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0));
450-
VolumeRestrictionLib._deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.OneDay));
450+
VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.OneDay));
451451
userToBucket[_holder].lastTradedDayTime = 0;
452452
userToBucket[_holder].sumOfLastPeriod = 0;
453453
userToBucket[_holder].daysCovered = 0;
@@ -477,7 +477,7 @@ contract VolumeRestrictionTM is VolumeRestrictionTMStorage, ITransferManager {
477477
require(_holder != address(0));
478478
require(individualDailyRestriction[_holder].endTime != 0);
479479
individualDailyRestriction[_holder] = VolumeRestriction(0, 0, 0, 0, RestrictionType(0));
480-
VolumeRestrictionLib._deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.MultipleDays));
480+
VolumeRestrictionLib.deleteHolderFromList(holderData, _holder, uint8(TypeOfPeriod.MultipleDays));
481481
userToBucket[_holder].dailyLastTradedDayTime = 0;
482482
emit IndividualDailyRestrictionRemoved(_holder);
483483
}

contracts/proxy/GeneralTransferManagerProxy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../modules/TransferManager/GeneralTransferManagerStorage.sol";
3+
import "../storage/GeneralTransferManagerStorage.sol";
44
import "./OwnedProxy.sol";
55
import "../Pausable.sol";
66
import "../modules/ModuleStorage.sol";

contracts/proxy/USDTieredSTOProxy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../modules/STO/USDTieredSTOStorage.sol";
3+
import "../storage/USDTieredSTOStorage.sol";
44
import "./OwnedProxy.sol";
55
import "../Pausable.sol";
66
import "openzeppelin-solidity/contracts/ReentrancyGuard.sol";

contracts/proxy/VestingEscrowWalletProxy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../modules/Wallet/VestingEscrowWalletStorage.sol";
3+
import "../storage/VestingEscrowWalletStorage.sol";
44
import "./OwnedProxy.sol";
55
import "../Pausable.sol";
66
import "../modules/ModuleStorage.sol";

contracts/proxy/VolumeRestrictionTMProxy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../modules/TransferManager/VolumeRestrictionTMStorage.sol";
3+
import "../storage/VolumeRestrictionTMStorage.sol";
44
import "./OwnedProxy.sol";
55
import "../Pausable.sol";
66
import "../modules/ModuleStorage.sol";

contracts/modules/STO/USDTieredSTOStorage.sol renamed to contracts/storage/USDTieredSTOStorage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../interfaces/IERC20.sol";
3+
import "../interfaces/IERC20.sol";
44

55
/**
66
* @title Contract used to store layout for the USDTieredSTO storage

contracts/modules/TransferManager/VolumeRestrictionTMStorage.sol renamed to contracts/storage/VolumeRestrictionTMStorage.sol

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
pragma solidity ^0.4.24;
22

3-
import "../../libraries/VolumeRestrictionLib.sol";
4-
53
/**
64
* @title Storage layout for VolumeRestrictionTM
75
*/
@@ -11,6 +9,20 @@ contract VolumeRestrictionTMStorage {
119

1210
enum TypeOfPeriod { MultipleDays, OneDay, Both }
1311

12+
struct RestrictedHolder {
13+
// 1 represent true & 0 for false
14+
uint8 seen;
15+
// Type of period will be enum index of TypeOfPeriod enum
16+
uint8 typeOfPeriod;
17+
// Index of the array where the holder address lives
18+
uint128 index;
19+
}
20+
21+
struct RestrictedData {
22+
mapping(address => RestrictedHolder) restrictedHolders;
23+
address[] restrictedAddresses;
24+
}
25+
1426
struct VolumeRestriction {
1527
// If typeOfRestriction is `Percentage` then allowedTokens will be in
1628
// the % (w.r.t to totalSupply) with a multiplier of 10**16 . else it
@@ -43,11 +55,9 @@ contract VolumeRestrictionTMStorage {
4355
mapping(address => BucketDetails) internal userToBucket;
4456
// Storing the information related to default restriction
4557
mapping(address => BucketDetails) internal defaultUserToBucket;
46-
// List of wallets that are exempted from all the restrictions applied by the this contract
47-
/* mapping(address => bool) public exemptList; */
4858
// Restricted data (refernce from the VolumeRestrictionLib library )
49-
VolumeRestrictionLib.RestrictedData holderData;
50-
// Holde exempt index
59+
RestrictedData holderData;
60+
// Hold exempt index
5161
mapping(address => uint256) exemptIndex;
5262
address[] public exemptAddresses;
5363

test/y_volume_restriction_tm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ contract('VolumeRestrictionTransferManager', accounts => {
543543
await I_VolumeRestrictionTM.addIndividualRestrictionMulti(
544544
[account_investor2, account_delegate3, account_investor4],
545545
[web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")],
546-
[latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)],
546+
[0, 0, 0],
547547
[3, 4, 5],
548548
[latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)],
549549
[0,0,0],

0 commit comments

Comments
 (0)