Skip to content

Commit 1f85d8b

Browse files
authored
Merge pull request #563 from PolymathNetwork/permission-cleanup
Permission cleanup
2 parents ea1bdf0 + 0a6381f commit 1f85d8b

37 files changed

+245
-220
lines changed

contracts/modules/Checkpoint/DividendCheckpoint.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
7979
* @notice Creates a checkpoint on the security token
8080
* @return Checkpoint ID
8181
*/
82-
function createCheckpoint() public withPerm(CHECKPOINT) returns(uint256) {
82+
function createCheckpoint() public withPerm(OPERATOR) returns(uint256) {
8383
return ISecurityToken(securityToken).createCheckpoint();
8484
}
8585

8686
/**
8787
* @notice Function to clear and set list of excluded addresses used for future dividends
8888
* @param _excluded Addresses of investors
8989
*/
90-
function setDefaultExcluded(address[] memory _excluded) public withPerm(MANAGE) {
90+
function setDefaultExcluded(address[] memory _excluded) public withPerm(ADMIN) {
9191
require(_excluded.length <= EXCLUDED_ADDRESS_LIMIT, "Too many excluded addresses");
9292
for (uint256 j = 0; j < _excluded.length; j++) {
9393
require(_excluded[j] != address(0), "Invalid address");
@@ -105,7 +105,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
105105
* @param _investors Addresses of investors
106106
* @param _withholding Withholding tax for individual investors (multiplied by 10**16)
107107
*/
108-
function setWithholding(address[] memory _investors, uint256[] memory _withholding) public withPerm(MANAGE) {
108+
function setWithholding(address[] memory _investors, uint256[] memory _withholding) public withPerm(ADMIN) {
109109
require(_investors.length == _withholding.length, "Mismatched input lengths");
110110
/*solium-disable-next-line security/no-block-members*/
111111
emit SetWithholding(_investors, _withholding);
@@ -120,7 +120,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
120120
* @param _investors Addresses of investor
121121
* @param _withholding Withholding tax for all investors (multiplied by 10**16)
122122
*/
123-
function setWithholdingFixed(address[] memory _investors, uint256 _withholding) public withPerm(MANAGE) {
123+
function setWithholdingFixed(address[] memory _investors, uint256 _withholding) public withPerm(ADMIN) {
124124
require(_withholding <= 10 ** 18, "Incorrect withholding tax");
125125
/*solium-disable-next-line security/no-block-members*/
126126
emit SetWithholdingFixed(_investors, _withholding);
@@ -139,7 +139,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
139139
address payable[] memory _payees
140140
)
141141
public
142-
withPerm(DISTRIBUTE)
142+
withPerm(OPERATOR)
143143
validDividendIndex(_dividendIndex)
144144
{
145145
Dividend storage dividend = dividends[_dividendIndex];
@@ -161,7 +161,7 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
161161
uint256 _start,
162162
uint256 _iterations
163163
) public
164-
withPerm(DISTRIBUTE)
164+
withPerm(OPERATOR)
165165
validDividendIndex(_dividendIndex)
166166
{
167167
Dividend storage dividend = dividends[_dividendIndex];
@@ -391,8 +391,8 @@ contract DividendCheckpoint is DividendCheckpointStorage, ICheckpoint, Module {
391391
*/
392392
function getPermissions() public view returns(bytes32[] memory) {
393393
bytes32[] memory allPermissions = new bytes32[](2);
394-
allPermissions[0] = DISTRIBUTE;
395-
allPermissions[1] = MANAGE;
394+
allPermissions[0] = ADMIN;
395+
allPermissions[1] = OPERATOR;
396396
return allPermissions;
397397
}
398398

contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
5656
bytes32 _name
5757
)
5858
external
59-
withPerm(MANAGE)
59+
withPerm(ADMIN)
6060
{
6161
createDividendWithExclusions(_maturity, _expiry, _token, _amount, excluded, _name);
6262
}
@@ -79,7 +79,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
7979
bytes32 _name
8080
)
8181
external
82-
withPerm(MANAGE)
82+
withPerm(ADMIN)
8383
{
8484
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, excluded, _name);
8585
}
@@ -102,7 +102,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
102102
bytes32 _name
103103
)
104104
public
105-
withPerm(MANAGE)
105+
withPerm(ADMIN)
106106
{
107107
uint256 checkpointId = ISecurityToken(securityToken).createCheckpoint();
108108
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, checkpointId, _excluded, _name);
@@ -128,7 +128,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
128128
bytes32 _name
129129
)
130130
public
131-
withPerm(MANAGE)
131+
withPerm(ADMIN)
132132
{
133133
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _token, _amount, _checkpointId, _excluded, _name);
134134
}
@@ -251,7 +251,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
251251
* @notice Issuer can reclaim remaining unclaimed dividend amounts, for expired dividends
252252
* @param _dividendIndex Dividend to reclaim
253253
*/
254-
function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) {
254+
function reclaimDividend(uint256 _dividendIndex) external withPerm(OPERATOR) {
255255
require(_dividendIndex < dividends.length, "Invalid dividend");
256256
/*solium-disable-next-line security/no-block-members*/
257257
require(now >= dividends[_dividendIndex].expiry, "Dividend expiry in future");
@@ -267,7 +267,7 @@ contract ERC20DividendCheckpoint is ERC20DividendCheckpointStorage, DividendChec
267267
* @notice Allows issuer to withdraw withheld tax
268268
* @param _dividendIndex Dividend to withdraw from
269269
*/
270-
function withdrawWithholding(uint256 _dividendIndex) external withPerm(MANAGE) {
270+
function withdrawWithholding(uint256 _dividendIndex) external withPerm(OPERATOR) {
271271
require(_dividendIndex < dividends.length, "Invalid dividend");
272272
Dividend storage dividend = dividends[_dividendIndex];
273273
uint256 remainingWithheld = dividend.totalWithheld.sub(dividend.totalWithheldWithdrawn);

contracts/modules/Checkpoint/EtherDividendCheckpoint.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
3939
* @param _expiry Time until dividend can no longer be paid, and can be reclaimed by issuer
4040
* @param _name Name/title for identification
4141
*/
42-
function createDividend(uint256 _maturity, uint256 _expiry, bytes32 _name) external payable withPerm(MANAGE) {
42+
function createDividend(uint256 _maturity, uint256 _expiry, bytes32 _name) external payable withPerm(ADMIN) {
4343
createDividendWithExclusions(_maturity, _expiry, excluded, _name);
4444
}
4545

@@ -58,7 +58,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
5858
)
5959
external
6060
payable
61-
withPerm(MANAGE)
61+
withPerm(ADMIN)
6262
{
6363
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _checkpointId, excluded, _name);
6464
}
@@ -78,7 +78,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
7878
)
7979
public
8080
payable
81-
withPerm(MANAGE)
81+
withPerm(ADMIN)
8282
{
8383
uint256 checkpointId = ISecurityToken(securityToken).createCheckpoint();
8484
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, checkpointId, _excluded, _name);
@@ -101,7 +101,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
101101
)
102102
public
103103
payable
104-
withPerm(MANAGE)
104+
withPerm(ADMIN)
105105
{
106106
_createDividendWithCheckpointAndExclusions(_maturity, _expiry, _checkpointId, _excluded, _name);
107107
}
@@ -190,7 +190,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
190190
* @notice Issuer can reclaim remaining unclaimed dividend amounts, for expired dividends
191191
* @param _dividendIndex Dividend to reclaim
192192
*/
193-
function reclaimDividend(uint256 _dividendIndex) external withPerm(MANAGE) {
193+
function reclaimDividend(uint256 _dividendIndex) external withPerm(OPERATOR) {
194194
require(_dividendIndex < dividends.length, "Incorrect dividend index");
195195
/*solium-disable-next-line security/no-block-members*/
196196
require(now >= dividends[_dividendIndex].expiry, "Dividend expiry is in the future");
@@ -206,7 +206,7 @@ contract EtherDividendCheckpoint is DividendCheckpoint {
206206
* @notice Allows issuer to withdraw withheld tax
207207
* @param _dividendIndex Dividend to withdraw from
208208
*/
209-
function withdrawWithholding(uint256 _dividendIndex) external withPerm(MANAGE) {
209+
function withdrawWithholding(uint256 _dividendIndex) external withPerm(OPERATOR) {
210210
require(_dividendIndex < dividends.length, "Incorrect dividend index");
211211
Dividend storage dividend = dividends[_dividendIndex];
212212
uint256 remainingWithheld = dividend.totalWithheld.sub(dividend.totalWithheldWithdrawn);

contracts/modules/Experimental/TransferManager/BlacklistTransferManager.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol";
99
contract BlacklistTransferManager is TransferManager {
1010
using SafeMath for uint256;
1111

12-
bytes32 public constant ADMIN = "ADMIN";
13-
1412
struct BlacklistsDetails {
1513
uint256 startTime;
1614
uint256 endTime;

contracts/modules/Experimental/TransferManager/KYCTransferManager.sol

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ contract KYCTransferManager is TransferManager {
1313

1414
bytes32 public constant KYC_NUMBER = "KYC_NUMBER"; //We will standardize what key to use for what.
1515

16-
bytes32 public constant KYC_PROVIDER = "KYC_PROVIDER";
17-
1816
bytes32 public constant KYC_ARRAY = "KYC_ARRAY";
1917

2018
/**
@@ -50,7 +48,7 @@ contract KYCTransferManager is TransferManager {
5048
return (Result.NA, bytes32(0));
5149
}
5250

53-
function modifyKYC( address _investor, bool _kycStatus) public withPerm(KYC_PROVIDER) {
51+
function modifyKYC( address _investor, bool _kycStatus) public withPerm(ADMIN) {
5452
_modifyKYC(_investor, _kycStatus);
5553
}
5654

@@ -75,15 +73,6 @@ contract KYCTransferManager is TransferManager {
7573
//I am maintaining the array to showcase how it can be done in cases where it might be needed.
7674
}
7775

78-
/**
79-
* @notice Return the permissions flag that are associated with general trnasfer manager
80-
*/
81-
function getPermissions() public view returns(bytes32[] memory) {
82-
bytes32[] memory allPermissions = new bytes32[](1);
83-
allPermissions[0] = KYC_PROVIDER;
84-
return allPermissions;
85-
}
86-
8776
function getKYCAddresses() public view returns(address[] memory) {
8877
IDataStore dataStore = IDataStore(ISecurityToken(securityToken).dataStore());
8978
return dataStore.getAddressArray(KYC_ARRAY);
@@ -100,6 +89,16 @@ contract KYCTransferManager is TransferManager {
10089
return bytes32(keccak256(abi.encodePacked(KYC_NUMBER, _identity)));
10190
}
10291

92+
/**
93+
* @notice Return the permissions flag that are associated with this module
94+
* @return bytes32 array
95+
*/
96+
function getPermissions() public view returns(bytes32[] memory) {
97+
bytes32[] memory allPermissions = new bytes32[](1);
98+
allPermissions[0] = ADMIN;
99+
return allPermissions;
100+
}
101+
103102
/**
104103
* @notice return the amount of tokens for a given user as per the partition
105104
*/

contracts/modules/Experimental/TransferManager/LockUpTransferManager.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ contract LockUpTransferManager is TransferManager {
88

99
using SafeMath for uint256;
1010

11-
// permission definition
12-
bytes32 public constant ADMIN = "ADMIN";
13-
1411
// a per-user lockup
1512
struct LockUp {
1613
uint256 lockupAmount; // Amount to be locked

contracts/modules/Experimental/TransferManager/SignedTransferManager.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ contract SignedTransferManager is TransferManager {
1111
using SafeMath for uint256;
1212
using ECDSA for bytes32;
1313

14-
bytes32 constant public ADMIN = "ADMIN";
15-
1614
//Keeps track of if the signature has been used or invalidated
1715
//mapping(bytes => bool) invalidSignatures;
1816
bytes32 constant public INVALID_SIG = "INVALIDSIG";

contracts/modules/Experimental/Wallet/VestingEscrowWallet.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import "./IWallet.sol";
1010
contract VestingEscrowWallet is VestingEscrowWalletStorage, IWallet {
1111
using SafeMath for uint256;
1212

13-
bytes32 public constant ADMIN = "ADMIN";
14-
1513
// States used to represent the status of the schedule
1614
enum State {CREATED, STARTED, COMPLETED}
1715

@@ -103,7 +101,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, IWallet {
103101
* @notice Sends unassigned tokens to the treasury wallet
104102
* @param _amount Amount of tokens that should be send to the treasury wallet
105103
*/
106-
function sendToTreasury(uint256 _amount) external withPerm(ADMIN) {
104+
function sendToTreasury(uint256 _amount) external withPerm(OPERATOR) {
107105
require(_amount > 0, "Amount cannot be zero");
108106
require(_amount <= unassignedTokens, "Amount is greater than unassigned tokens");
109107
uint256 amount = unassignedTokens;
@@ -116,7 +114,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, IWallet {
116114
* @notice Pushes available tokens to the beneficiary's address
117115
* @param _beneficiary Address of the beneficiary who will receive tokens
118116
*/
119-
function pushAvailableTokens(address _beneficiary) public withPerm(ADMIN) {
117+
function pushAvailableTokens(address _beneficiary) public withPerm(OPERATOR) {
120118
_sendTokens(_beneficiary);
121119
}
122120

@@ -420,7 +418,7 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, IWallet {
420418
* @param _fromIndex Start index of array of beneficiary's addresses
421419
* @param _toIndex End index of array of beneficiary's addresses
422420
*/
423-
function pushAvailableTokensMulti(uint256 _fromIndex, uint256 _toIndex) external withPerm(ADMIN) {
421+
function pushAvailableTokensMulti(uint256 _fromIndex, uint256 _toIndex) external withPerm(OPERATOR) {
424422
require(_toIndex <= beneficiaries.length - 1, "Array out of bound");
425423
for (uint256 i = _fromIndex; i <= _toIndex; i++) {
426424
if (schedules[beneficiaries[i]].length !=0)
@@ -557,8 +555,9 @@ contract VestingEscrowWallet is VestingEscrowWalletStorage, IWallet {
557555
* @notice Return the permissions flag that are associated with VestingEscrowWallet
558556
*/
559557
function getPermissions() public view returns(bytes32[] memory) {
560-
bytes32[] memory allPermissions = new bytes32[](1);
558+
bytes32[] memory allPermissions = new bytes32[](2);
561559
allPermissions[0] = ADMIN;
560+
allPermissions[1] = OPERATOR;
562561
return allPermissions;
563562
}
564563

contracts/modules/Module.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ contract Module is IModule, ModuleStorage {
2121
ModuleStorage(_securityToken, _polyAddress)
2222
{
2323
}
24-
24+
2525
//Allows owner, factory or permissioned delegate
2626
modifier withPerm(bytes32 _perm) {
2727
bool isOwner = msg.sender == Ownable(securityToken).owner();
@@ -61,6 +61,9 @@ contract Module is IModule, ModuleStorage {
6161
return true;
6262
}
6363

64+
/**
65+
* @notice used to return the data store address of securityToken
66+
*/
6467
function getDataStore() public view returns(address) {
6568
return ISecurityToken(securityToken).dataStore();
6669
}

contracts/modules/PermissionManager/GeneralPermissionManager.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio
4646
* @param _delegate Ethereum address of the delegate
4747
* @param _details Details about the delegate i.e `Belongs to financial firm`
4848
*/
49-
function addDelegate(address _delegate, bytes32 _details) external withPerm(CHANGE_PERMISSION) {
49+
function addDelegate(address _delegate, bytes32 _details) external withPerm(ADMIN) {
5050
require(_delegate != address(0), "Invalid address");
5151
require(_details != bytes32(0), "0 value not allowed");
5252
require(delegateDetails[_delegate] == bytes32(0), "Already present");
@@ -60,7 +60,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio
6060
* @notice Used to delete a delegate
6161
* @param _delegate Ethereum address of the delegate
6262
*/
63-
function deleteDelegate(address _delegate) external withPerm(CHANGE_PERMISSION) {
63+
function deleteDelegate(address _delegate) external withPerm(ADMIN) {
6464
require(delegateDetails[_delegate] != bytes32(0), "delegate does not exist");
6565
for (uint256 i = 0; i < allDelegates.length; i++) {
6666
if (allDelegates[i] == _delegate) {
@@ -92,7 +92,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio
9292
* @param _valid Bool flag use to switch on/off the permission
9393
* @return bool
9494
*/
95-
function changePermission(address _delegate, address _module, bytes32 _perm, bool _valid) public withPerm(CHANGE_PERMISSION) {
95+
function changePermission(address _delegate, address _module, bytes32 _perm, bool _valid) public withPerm(ADMIN) {
9696
require(_delegate != address(0), "invalid address");
9797
_changePermission(_delegate, _module, _perm, _valid);
9898
}
@@ -112,7 +112,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio
112112
bool[] calldata _valids
113113
)
114114
external
115-
withPerm(CHANGE_PERMISSION)
115+
withPerm(ADMIN)
116116
{
117117
require(_delegate != address(0), "invalid address");
118118
require(_modules.length > 0, "0 length is not allowed");
@@ -225,7 +225,7 @@ contract GeneralPermissionManager is GeneralPermissionManagerStorage, IPermissio
225225
*/
226226
function getPermissions() public view returns(bytes32[] memory) {
227227
bytes32[] memory allPermissions = new bytes32[](1);
228-
allPermissions[0] = CHANGE_PERMISSION;
228+
allPermissions[0] = ADMIN;
229229
return allPermissions;
230230
}
231231

0 commit comments

Comments
 (0)