Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3eb609a
add getRestrictedAddresses() function
SatyamSB Jan 8, 2019
418961e
Merge branch 'dev-2.1.0' into getter-voltm
satyamakgec Jan 8, 2019
d85c594
minor fix
SatyamSB Jan 8, 2019
f5992b4
Add restrictions data to getRestrictedAddresses
adamdossa Jan 8, 2019
ea5089a
Remove commented code and better tests
adamdossa Jan 8, 2019
7429d13
modified the getRestrictedAddress() function
SatyamSB Jan 9, 2019
72c1eb7
code cleanup
SatyamSB Jan 9, 2019
f400049
CLI - Show restrictions table
VictorVicente Jan 9, 2019
3638c60
minor fix
SatyamSB Jan 9, 2019
365db81
Merge branch 'getter-voltm' of https://github.com/PolymathNetwork/pol…
SatyamSB Jan 9, 2019
bb4c1fe
CLI - Update method name, updated csv dates
VictorVicente Jan 9, 2019
d1dec2c
Merge branch 'dev-2.1.0' into getter-voltm
VictorVicente Jan 9, 2019
ceb6acf
CLI - Changed names of restrictions
VictorVicente Jan 9, 2019
d2636c0
Minor fix
VictorVicente Jan 9, 2019
60efa3f
CLI - Percentage with decimals fix
VictorVicente Jan 9, 2019
5c27711
CLI - Changed names of restrictions
VictorVicente Jan 9, 2019
6c8a321
Merge branch 'getter-voltm' of https://github.com/PolymathNetwork/pol…
VictorVicente Jan 9, 2019
3689174
add exempt list getter
SatyamSB Jan 9, 2019
4d342f1
Merge branch 'getter-voltm' of https://github.com/PolymathNetwork/pol…
SatyamSB Jan 9, 2019
c0700ea
minor fix
SatyamSB Jan 10, 2019
a2692fc
CLI - Added 'show exempted addresses'
VictorVicente Jan 10, 2019
1b126c2
Small optimisation
adamdossa Jan 10, 2019
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
Empty file removed 0
Empty file.
4 changes: 2 additions & 2 deletions CLI/commands/common/common_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ module.exports = {
},
splitIntoBatches: function (data, batchSize) {
let allBatches = [];
for (let index = 0; index < data.length; index += batchSize) {
allBatches.push(data.slice(index, index + batchSize));
for (let index = 0; index < data.length; index += parseInt(batchSize)) {
allBatches.push(data.slice(index, index + parseInt(batchSize)));
}
return allBatches;
},
Expand Down
444 changes: 253 additions & 191 deletions CLI/commands/transfer_manager.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions CLI/data/Transfer/VRTM/add_custom_restriction_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,1000,8/1/2019,90,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,8/2/2019,30,10/12/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,8/1/2019,15,10/1/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,8/5/2019,90,10/10/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,0.25,8/3/2019,30,10/15/2019,"Percentage"
0x3c65cfe3de848cf38e9d76e9c3e57a2f1140b399,0.1,8/10/2019,15,10/10/2019,"Percentage"
0xabf60de3265b3017db7a1be66fc8b364ec1dbb98,1234,8/20/2019,10,10/22/2019,"Fixed"
0xb841fe5a89da1bbef2d0805fbd7ffcbbb2fca5e3,5678,8/1/2019,2,10/10/2019,"Fixed"
16 changes: 8 additions & 8 deletions CLI/data/Transfer/VRTM/add_daily_restriction_data.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,1000,1/8/2019,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,1/8/2019,10/10/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,1/8/2019,10/10/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,1/8/2019,10/10/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,0.25,1/8/2019,10/10/2019,"Percentage"
0x3c65cfe3de848cf38e9d76e9c3e57a2f1140b399,0.1,1/8/2019,10/10/2019,"Percentage"
0xabf60de3265b3017db7a1be66fc8b364ec1dbb98,1234,1/8/2019,10/10/2019,"Fixed"
0xb841fe5a89da1bbef2d0805fbd7ffcbbb2fca5e3,5678,1/8/2019,10/10/2019,"Fixed"
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,1000,8/1/2019,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,8/2/2019,10/12/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,8/1/2019,10/10/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,8/3/2019,10/1/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,0.25,8/1/2019,10/10/2019,"Percentage"
0x3c65cfe3de848cf38e9d76e9c3e57a2f1140b399,0.1,8/1/2019,10/5/2019,"Percentage"
0xabf60de3265b3017db7a1be66fc8b364ec1dbb98,1234,8/12/2019,10/10/2019,"Fixed"
0xb841fe5a89da1bbef2d0805fbd7ffcbbb2fca5e3,5678,8/1/2019,10/10/2019,"Fixed"
8 changes: 0 additions & 8 deletions CLI/data/Transfer/VRTM/add_restriction_data.csv

This file was deleted.

5 changes: 5 additions & 0 deletions CLI/data/Transfer/VRTM/modify_custom_restriction_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,2000,8/1/2019,90,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,8/2/2019,30,10/10/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,8/1/2019,20,10/10/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,8/1/2019,90,20/10/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,25,8/1/2019,30,10/10/2019,"Fixed"
10 changes: 5 additions & 5 deletions CLI/data/Transfer/VRTM/modify_daily_restriction_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,2000,1/8/2019,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,2/8/2019,10/10/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,1/8/2019,10/10/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,1/8/2019,20/10/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,25,1/8/2019,10/10/2019,"Fixed"
0xee7ae74d964f2be7d72c1b187b38e2ed3615d4d1,2000,8/1/2019,10/10/2019,"Fixed"
0x2f0fd672bf222413cc69dc1f4f1d7e93ad1763a1,2000,8/1/2019,10/10/2019,"Fixed"
0xac297053173b02b02a737d47f7b4a718e5b170ef,500,8/1/2019,10/10/2019,"Fixed"
0x49fc0b78238dab644698a90fa351b4c749e123d2,0.15,8/1/2019,20/10/2019,"Percentage"
0x10223927009b8add0960359dd90d1449415b7ca9,25,8/1/2019,10/10/2019,"Fixed"
5 changes: 0 additions & 5 deletions CLI/data/Transfer/VRTM/modify_restriction_data.csv

This file was deleted.

87 changes: 87 additions & 0 deletions contracts/libraries/VolumeRestrictionLib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
pragma solidity ^0.4.24;

import "./BokkyPooBahsDateTimeLibrary.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../interfaces/ISecurityToken.sol";

library VolumeRestrictionLib {

using SafeMath for uint256;

enum TypeOfPeriod { MultipleDays, OneDay, Both }

struct RestrictedHolder {
// 1 represent true & 0 for false
uint8 seen;
// Type of period will be enum index of TypeOfPeriod enum
uint8 typeOfPeriod;
// Index of the array where the holder address lives
uint128 index;
}

struct RestrictedData {
mapping(address => RestrictedHolder) restrictedHolders;
address[] restrictedAddresses;
}

function _checkLengthOfArray(
address[] _holders,
uint256[] _allowedTokens,
uint256[] _startTimes,
uint256[] _rollingPeriodInDays,
uint256[] _endTimes,
uint256[] _restrictionTypes
)
internal
pure
{
require(
_holders.length == _allowedTokens.length &&
_allowedTokens.length == _startTimes.length &&
_startTimes.length == _rollingPeriodInDays.length &&
_rollingPeriodInDays.length == _endTimes.length &&
_endTimes.length == _restrictionTypes.length,
"Length mismatch"
);
}

function _deleteHolderFromList(RestrictedData storage data, address _holder, uint8 _typeOfPeriod) public {
// Deleting the holder if holder's type of Period is `Both` type otherwise
// it will assign the given type `_typeOfPeriod` to the _holder typeOfPeriod
// `_typeOfPeriod` it always be contrary to the removing restriction
// if removing restriction is individual then typeOfPeriod is TypeOfPeriod.OneDay
// in uint8 its value is 1. if removing restriction is daily individual then typeOfPeriod
// is TypeOfPeriod.MultipleDays in uint8 its value is 0.
if (data.restrictedHolders[_holder].typeOfPeriod != uint8(TypeOfPeriod.Both)) {
uint128 index = data.restrictedHolders[_holder].index;
uint256 _len = data.restrictedAddresses.length;
if (index != _len) {
data.restrictedHolders[data.restrictedAddresses[_len - 1]].index = index;
data.restrictedAddresses[index - 1] = data.restrictedAddresses[_len - 1];
}
delete data.restrictedHolders[_holder];
data.restrictedAddresses.length--;
} else {
data.restrictedHolders[_holder].typeOfPeriod = _typeOfPeriod;
}
}

function _addRestrictionData(RestrictedData storage data, address _holder, uint8 _callFrom, uint256 _endTime) public {
uint128 index = data.restrictedHolders[_holder].index;
if (data.restrictedHolders[_holder].seen == 0) {
data.restrictedAddresses.push(_holder);
index = uint128(data.restrictedAddresses.length);
}
uint8 _type = _getTypeOfPeriod(data.restrictedHolders[_holder].typeOfPeriod, _callFrom, _endTime);
data.restrictedHolders[_holder] = RestrictedHolder(uint8(1), _type, index);
}

function _getTypeOfPeriod(uint8 _currentTypeOfPeriod, uint8 _callFrom, uint256 _endTime) internal pure returns(uint8) {
if (_currentTypeOfPeriod != _callFrom && _endTime != uint256(0))
return uint8(TypeOfPeriod.Both);
else
return _callFrom;
}


}
Loading