Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentage tm admin permission #379

Merged
merged 7 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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() => {
kostind marked this conversation as resolved.
Show resolved Hide resolved
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