Skip to content

Commit

Permalink
Percentage tm admin permission (#379)
Browse files Browse the repository at this point in the history
* Make `changeHolderPercentage` in PercentageTM a permissioned

* Add delegate l_percentage_transfer_manager.js

* Remove redundant getters: fixed review comments

* Update test/l_percentage_transfer_manager.js
  • Loading branch information
kostind authored and pabloruiz55 committed Oct 25, 2018
1 parent 56db11e commit 035fbb3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CLI/commands/common/permissions_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function getPermissionList() {
modifyWhitelist: "WHITELIST",
modifyWhitelistMulti: "WHITELIST",
setAllowPrimaryIssuance: "ADMIN",
changeHolderPercentage: "ONLY_OWNER"
changeHolderPercentage: "ADMIN"
},
LockupVolumeRestrictionTM: {
addLockup: "ADMIN",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contract PercentageTransferManager is ITransferManager {
* @notice sets the maximum percentage that an individual token holder can hold
* @param _maxHolderPercentage is the new maximum percentage (multiplied by 10**16)
*/
function changeHolderPercentage(uint256 _maxHolderPercentage) public onlyOwner {
function changeHolderPercentage(uint256 _maxHolderPercentage) public withPerm(ADMIN) {
emit ModifyHolderPercentage(maxHolderPercentage, _maxHolderPercentage);
maxHolderPercentage = _maxHolderPercentage;
}
Expand Down
3 changes: 1 addition & 2 deletions docs/permissions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@
</tr>
<tr>
<td> setAllowPrimaryIssuance() </td>
<td> withPerm(ADMIN) </td>
<td rowspan=2> withPerm(ADMIN) </td>
</tr>
<tr>
<td> changeHolderPercentage() </td>
<td> onlyOwner() </td>
</tr>
<tr>
<td rowspan=4> LockupVolumeRestrictionTM</td>
Expand Down
39 changes: 38 additions & 1 deletion test/l_percentage_transfer_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract("PercentageTransferManager", accounts => {
let account_investor2;
let account_investor3;
let account_investor4;
let account_delegate;

// investor Details
let fromTime = latestTime();
Expand Down Expand Up @@ -57,6 +58,7 @@ contract("PercentageTransferManager", accounts => {
const tokenDetails = "This is equity type of issuance";
const decimals = 18;
const contact = "team@polymath.network";
const delegateDetails = "Hello I am legit delegate";

// Module key
const delegateManagerKey = 1;
Expand Down Expand Up @@ -92,6 +94,7 @@ contract("PercentageTransferManager", accounts => {
account_investor1 = accounts[7];
account_investor2 = accounts[8];
account_investor3 = accounts[9];
account_delegate = accounts[6];

let instances = await setUpPolymathNetwork(account_polymath, token_owner);

Expand Down Expand Up @@ -166,6 +169,18 @@ contract("PercentageTransferManager", accounts => {
let moduleData = (await I_SecurityToken.getModulesByType(2))[0];
I_GeneralTransferManager = GeneralTransferManager.at(moduleData);
});

it("Should successfully attach the General permission manager factory with the security token", async () => {
const tx = await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "0x", 0, 0, { from: token_owner });
assert.equal(tx.logs[2].args._types[0].toNumber(), delegateManagerKey, "General Permission Manager doesn't get deployed");
assert.equal(
web3.utils.toAscii(tx.logs[2].args._name).replace(/\u0000/g, ""),
"GeneralPermissionManager",
"GeneralPermissionManagerFactory module was not added"
);
I_GeneralPermissionManager = GeneralPermissionManager.at(tx.logs[2].args._module);
});

});

describe("Buy tokens using on-chain whitelist", async () => {
Expand Down Expand Up @@ -333,10 +348,32 @@ contract("PercentageTransferManager", accounts => {
)
});

it("Should not be able to modify holder percentage to 100 - Unauthorized msg.sender", async () => {
await catchRevert(
I_PercentageTransferManager.changeHolderPercentage(100 * 10 ** 16, { from: account_delegate })
)
});

it("Should successfully add the delegate", async() => {
let tx = await I_GeneralPermissionManager.addDelegate(account_delegate, delegateDetails, { from: token_owner});
assert.equal(tx.logs[0].args._delegate, account_delegate);
});

it("Should provide the permission", async() => {
let tx = await I_GeneralPermissionManager.changePermission(
account_delegate,
I_PercentageTransferManager.address,
"ADMIN",
true,
{from: token_owner}
);
assert.equal(tx.logs[0].args._delegate, account_delegate);
});

it("Modify holder percentage to 100", async () => {
// Add the Investor in to the whitelist
// Mint some tokens
await I_PercentageTransferManager.changeHolderPercentage(100 * 10 ** 16, { from: token_owner });
await I_PercentageTransferManager.changeHolderPercentage(100 * 10 ** 16, { from: account_delegate });

assert.equal((await I_PercentageTransferManager.maxHolderPercentage()).toNumber(), 100 * 10 ** 16);
});
Expand Down

0 comments on commit 035fbb3

Please sign in to comment.