Skip to content

Commit e092196

Browse files
authored
Merge pull request #86 from PolymathNetwork/remove_default_permission_manager
Remove permission manager from default token deployment
2 parents 71f583d + 9ea8b89 commit e092196

File tree

10 files changed

+55
-117
lines changed

10 files changed

+55
-117
lines changed

contracts/tokens/STVersionProxy001.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol";
88
contract STVersionProxy001 is ISTProxy {
99

1010
address public transferManagerFactory;
11-
address public permissionManagerFactory;
1211

1312
//Shoud be set to false when we have more TransferManager options
1413
bool addTransferManager = true;
15-
bool addPermissionManager = true;
1614

17-
constructor (address _transferManagerFactory, address _permissionManagerFactory) public {
15+
constructor (address _transferManagerFactory) public {
1816
transferManagerFactory = _transferManagerFactory;
19-
permissionManagerFactory = _permissionManagerFactory;
2017
}
2118
/**
2219
* @dev deploys the token and adds default modules like permission manager and transfer manager.
@@ -32,9 +29,6 @@ contract STVersionProxy001 is ISTProxy {
3229
msg.sender
3330
);
3431

35-
if (addPermissionManager) {
36-
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
37-
}
3832
if (addTransferManager) {
3933
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
4034
}

contracts/tokens/STVersionProxy002.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol";
88
contract STVersionProxy002 is ISTProxy {
99

1010
address public transferManagerFactory;
11-
address public permissionManagerFactory;
1211

1312
//Shoud be set to false when we have more TransferManager options
1413
bool addTransferManager = true;
15-
bool addPermissionManager = true;
1614

17-
constructor (address _transferManagerFactory, address _permissionManagerFactory) public {
15+
constructor (address _transferManagerFactory) public {
1816
transferManagerFactory = _transferManagerFactory;
19-
permissionManagerFactory = _permissionManagerFactory;
2017
}
2118

2219
function deployToken(string _name, string _symbol, uint8 _decimals, bytes32 _tokenDetails, address _issuer)
@@ -30,9 +27,6 @@ contract STVersionProxy002 is ISTProxy {
3027
msg.sender
3128
);
3229

33-
if (addPermissionManager) {
34-
SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false);
35-
}
3630
if (addTransferManager) {
3731
SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false);
3832
}

migrations/2_deploy_contracts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function (deployer, network, accounts) {
5858
return moduleRegistry.verifyModule(GeneralPermissionManagerFactory.address, true, {from: PolymathAccount})
5959
}).then(() => {
6060
// H) Deploy the STVersionProxy001 Contract which contains the logic of deployment of securityToken.
61-
return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, GeneralPermissionManagerFactory.address, {from: PolymathAccount})
61+
return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, {from: PolymathAccount})
6262
}).then(() => {
6363
// I) Deploy the TickerRegistry Contract (It is used to store the information about the ticker)
6464
return deployer.deploy(TickerRegistry, {from: PolymathAccount})
@@ -92,5 +92,5 @@ module.exports = function (deployer, network, accounts) {
9292
})
9393
})
9494
})
95-
})
95+
})
9696
}

test/Issuance.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const BigNumber = require('bignumber.js');
2020
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // Hardcoded development port
2121

2222

23-
contract('SecurityToken', accounts => {
23+
contract('Issuance', accounts => {
2424

2525

2626
// Accounts Variable declaration
@@ -181,7 +181,7 @@ contract('SecurityToken', accounts => {
181181

182182
// Step 7: Deploy the STversionProxy contract
183183

184-
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
184+
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });
185185

186186
assert.notEqual(
187187
I_STVersion.address.valueOf(),
@@ -246,12 +246,12 @@ contract('SecurityToken', accounts => {
246246
LogAddModule.watch(function(error, log){ resolve(log);});
247247
});
248248

249-
// Verify that GeneralPermissionManager module get added successfully or not
250-
assert.equal(log.args._type.toNumber(), permissionManagerKey);
249+
// Verify that GeneralTransferManager module get added successfully or not
250+
assert.equal(log.args._type.toNumber(), transferManagerKey);
251251
assert.equal(
252252
web3.utils.toAscii(log.args._name)
253253
.replace(/\u0000/g, ''),
254-
"GeneralPermissionManager"
254+
"GeneralTransferManager"
255255
);
256256
LogAddModule.stopWatching();
257257
});
@@ -266,14 +266,6 @@ contract('SecurityToken', accounts => {
266266
"GeneralTransferManager contract was not deployed",
267267
);
268268

269-
moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
270-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
271-
272-
assert.notEqual(
273-
I_GeneralPermissionManager.address.valueOf(),
274-
"0x0000000000000000000000000000000000000000",
275-
"GeneralDelegateManager contract was not deployed",
276-
);
277269
});
278270

279271
it("POLYMATH: Should successfully attach the STO factory with the security token", async () => {
@@ -293,7 +285,7 @@ contract('SecurityToken', accounts => {
293285
let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [(latestTime() + duration.seconds(5000)), (latestTime() + duration.days(30)), cap, rate, fundRaiseType, I_PolyFaucet.address, account_fundsReceiver]);
294286

295287
const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: account_polymath, gas: 2500000 });
296-
288+
297289
assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed");
298290
assert.equal(
299291
web3.utils.toAscii(tx.logs[2].args._name)
@@ -319,6 +311,10 @@ contract('SecurityToken', accounts => {
319311
});
320312

321313
it("Should add the delegate with permission", async() => {
314+
//First attach a permission manager to the token
315+
await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: account_polymath});
316+
let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
317+
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
322318
// Add permission to the deletgate (A regesteration process)
323319
await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_polymath});
324320
// Providing the permission to the delegate

test/capped_sto.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ contract('CappedSTO', accounts => {
6464
const P_decimals = 18;
6565

6666
// Module key
67-
const permissionManagerKey = 1;
6867
const transferManagerKey = 2;
6968
const stoKey = 3;
7069
const budget = 0;
@@ -187,7 +186,7 @@ contract('CappedSTO', accounts => {
187186

188187
// Step 7: Deploy the STversionProxy contract
189188

190-
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
189+
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });
191190

192191
assert.notEqual(
193192
I_STVersion.address.valueOf(),
@@ -249,12 +248,12 @@ contract('CappedSTO', accounts => {
249248
LogAddModule.watch(function(error, log){ resolve(log);});
250249
});
251250

252-
// Verify that GeneralPermissionManager module get added successfully or not
253-
assert.equal(log.args._type.toNumber(), permissionManagerKey);
251+
// Verify that GeneralTransferManager module get added successfully or not
252+
assert.equal(log.args._type.toNumber(), transferManagerKey);
254253
assert.equal(
255254
web3.utils.toAscii(log.args._name)
256255
.replace(/\u0000/g, ''),
257-
"GeneralPermissionManager"
256+
"GeneralTransferManager"
258257
);
259258
LogAddModule.stopWatching();
260259
});
@@ -269,14 +268,6 @@ contract('CappedSTO', accounts => {
269268
"GeneralTransferManager contract was not deployed",
270269
);
271270

272-
moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
273-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
274-
275-
assert.notEqual(
276-
I_GeneralPermissionManager.address.valueOf(),
277-
"0x0000000000000000000000000000000000000000",
278-
"GeneralDelegateManager contract was not deployed",
279-
);
280271
});
281272

282273
it("Should fail to launch the STO due to rate is 0", async () => {
@@ -561,12 +552,12 @@ contract('CappedSTO', accounts => {
561552
LogAddModule.watch(function(error, log){ resolve(log);});
562553
});
563554

564-
// Verify that GeneralPermissionManager module get added successfully or not
565-
assert.equal(log.args._type.toNumber(), permissionManagerKey);
555+
// Verify that GeneralTransferManager module get added successfully or not
556+
assert.equal(log.args._type.toNumber(), transferManagerKey);
566557
assert.equal(
567558
web3.utils.toAscii(log.args._name)
568559
.replace(/\u0000/g, ''),
569-
"GeneralPermissionManager"
560+
"GeneralTransferManager"
570561
);
571562
LogAddModule.stopWatching();
572563
});
@@ -581,14 +572,6 @@ contract('CappedSTO', accounts => {
581572
"GeneralTransferManager contract was not deployed",
582573
);
583574

584-
moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
585-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
586-
587-
assert.notEqual(
588-
I_GeneralPermissionManager.address.valueOf(),
589-
"0x0000000000000000000000000000000000000000",
590-
"GeneralDelegateManager contract was not deployed",
591-
);
592575
});
593576

594577
it("POLY: Should successfully attach the STO factory with the security token", async () => {

test/exchange_transfer_manager.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ contract('ExchangeTransferManager', accounts => {
184184

185185
// Step 7: Deploy the STversionProxy contract
186186

187-
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address);
187+
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address);
188188

189189
assert.notEqual(
190190
I_STVersion.address.valueOf(),
@@ -247,12 +247,12 @@ contract('ExchangeTransferManager', accounts => {
247247
LogAddModule.watch(function(error, log){ resolve(log);});
248248
});
249249

250-
// Verify that GeneralPermissionManager module get added successfully or not
251-
assert.equal(log.args._type.toNumber(), 1);
250+
// Verify that GeneralTransferManager module get added successfully or not
251+
assert.equal(log.args._type.toNumber(), 2);
252252
assert.equal(
253253
web3.utils.toAscii(log.args._name)
254254
.replace(/\u0000/g, ''),
255-
"GeneralPermissionManager"
255+
"GeneralTransferManager"
256256
);
257257
LogAddModule.stopWatching();
258258
});
@@ -267,14 +267,6 @@ contract('ExchangeTransferManager', accounts => {
267267
"GeneralTransferManager contract was not deployed",
268268
);
269269

270-
moduleData = await I_SecurityToken.modules(1, 0);
271-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
272-
273-
assert.notEqual(
274-
I_GeneralPermissionManager.address.valueOf(),
275-
"0x0000000000000000000000000000000000000000",
276-
"GeneralDelegateManager contract was not deployed",
277-
);
278270
});
279271

280272
it("Should successfully attach the STO factory with the security token", async () => {

test/module_registry.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ contract('ModuleRegistry', accounts => {
309309
"Failed in verifying the module"
310310
);
311311

312-
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
312+
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });
313313

314314
assert.notEqual(
315315
I_STVersion.address.valueOf(),
@@ -384,12 +384,12 @@ contract('ModuleRegistry', accounts => {
384384
LogAddModule.watch(function(error, log){ resolve(log);});
385385
});
386386

387-
// Verify that GeneralPermissionManager module get added successfully or not
388-
assert.equal(log.args._type.toNumber(), permissionManagerKey);
387+
// Verify that GeneralTransferManager module get added successfully or not
388+
assert.equal(log.args._type.toNumber(), transferManagerKey);
389389
assert.equal(
390390
web3.utils.toAscii(log.args._name)
391391
.replace(/\u0000/g, ''),
392-
"GeneralPermissionManager"
392+
"GeneralTransferManager"
393393
);
394394
LogAddModule.stopWatching();
395395
});
@@ -404,14 +404,6 @@ contract('ModuleRegistry', accounts => {
404404
"GeneralTransferManager contract was not deployed",
405405
);
406406

407-
moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
408-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
409-
410-
assert.notEqual(
411-
I_GeneralPermissionManager.address.valueOf(),
412-
"0x0000000000000000000000000000000000000000",
413-
"GeneralDelegateManager contract was not deployed",
414-
);
415407
});
416408
});
417409

test/security_token.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ contract('SecurityToken', accounts => {
189189

190190
// Step 7: Deploy the STversionProxy contract
191191

192-
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath });
192+
I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath });
193193

194194
assert.notEqual(
195195
I_STVersion.address.valueOf(),
@@ -251,34 +251,26 @@ contract('SecurityToken', accounts => {
251251
LogAddModule.watch(function(error, log){ resolve(log);});
252252
});
253253

254-
// Verify that GeneralPermissionManager module get added successfully or not
255-
assert.equal(log.args._type.toNumber(), permissionManagerKey);
254+
// Verify that GeneralTransferManager module get added successfully or not
255+
assert.equal(log.args._type.toNumber(), transferManagerKey);
256256
assert.equal(
257257
web3.utils.toAscii(log.args._name)
258258
.replace(/\u0000/g, ''),
259-
"GeneralPermissionManager"
259+
"GeneralTransferManager"
260260
);
261261
LogAddModule.stopWatching();
262262
});
263263

264264
it("Should intialize the auto attached modules", async () => {
265-
let moduleData = await I_SecurityToken.modules(transferManagerKey, 0);
266-
I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]);
265+
let moduleData = await I_SecurityToken.modules(transferManagerKey, 0);
266+
I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]);
267267

268268
assert.notEqual(
269269
I_GeneralTransferManager.address.valueOf(),
270270
"0x0000000000000000000000000000000000000000",
271271
"GeneralTransferManager contract was not deployed",
272272
);
273273

274-
moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
275-
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
276-
277-
assert.notEqual(
278-
I_GeneralPermissionManager.address.valueOf(),
279-
"0x0000000000000000000000000000000000000000",
280-
"GeneralDelegateManager contract was not deployed",
281-
);
282274
});
283275

284276
it("Should successfully attach the STO factory with the security token", async () => {
@@ -419,6 +411,9 @@ contract('SecurityToken', accounts => {
419411
it("Should fail to provide the permission to the delegate to change the transfer bools", async () => {
420412
let errorThrown = false;
421413
// Add permission to the deletgate (A regesteration process)
414+
await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: token_owner});
415+
let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0);
416+
I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]);
422417
try {
423418
await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_temp });
424419
} catch (error) {

0 commit comments

Comments
 (0)