From 9ea8b899f72bede8fe5acf7ec4a64b953e031d00 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Tue, 24 Apr 2018 12:01:09 +0100 Subject: [PATCH] Remove permission manager from default token deployment --- contracts/tokens/STVersionProxy001.sol | 8 +----- contracts/tokens/STVersionProxy002.sol | 8 +----- migrations/2_deploy_contracts.js | 4 +-- test/Issuance.js | 24 +++++++--------- test/capped_sto.js | 31 +++++--------------- test/exchange_transfer_manager.js | 16 +++-------- test/module_registry.js | 16 +++-------- test/security_token.js | 23 ++++++--------- test/security_token_registry.js | 40 +++++++++++--------------- test/ticker_registry.js | 2 +- 10 files changed, 55 insertions(+), 117 deletions(-) diff --git a/contracts/tokens/STVersionProxy001.sol b/contracts/tokens/STVersionProxy001.sol index 014b68902..59c5ffd15 100644 --- a/contracts/tokens/STVersionProxy001.sol +++ b/contracts/tokens/STVersionProxy001.sol @@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol"; contract STVersionProxy001 is ISTProxy { address public transferManagerFactory; - address public permissionManagerFactory; //Shoud be set to false when we have more TransferManager options bool addTransferManager = true; - bool addPermissionManager = true; - constructor (address _transferManagerFactory, address _permissionManagerFactory) public { + constructor (address _transferManagerFactory) public { transferManagerFactory = _transferManagerFactory; - permissionManagerFactory = _permissionManagerFactory; } /** * @dev deploys the token and adds default modules like permission manager and transfer manager. @@ -32,9 +29,6 @@ contract STVersionProxy001 is ISTProxy { msg.sender ); - if (addPermissionManager) { - SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false); - } if (addTransferManager) { SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false); } diff --git a/contracts/tokens/STVersionProxy002.sol b/contracts/tokens/STVersionProxy002.sol index 1d1afbd79..fdd944c8a 100644 --- a/contracts/tokens/STVersionProxy002.sol +++ b/contracts/tokens/STVersionProxy002.sol @@ -8,15 +8,12 @@ import "../interfaces/ISTProxy.sol"; contract STVersionProxy002 is ISTProxy { address public transferManagerFactory; - address public permissionManagerFactory; //Shoud be set to false when we have more TransferManager options bool addTransferManager = true; - bool addPermissionManager = true; - constructor (address _transferManagerFactory, address _permissionManagerFactory) public { + constructor (address _transferManagerFactory) public { transferManagerFactory = _transferManagerFactory; - permissionManagerFactory = _permissionManagerFactory; } function deployToken(string _name, string _symbol, uint8 _decimals, bytes32 _tokenDetails, address _issuer) @@ -30,9 +27,6 @@ contract STVersionProxy002 is ISTProxy { msg.sender ); - if (addPermissionManager) { - SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false); - } if (addTransferManager) { SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false); } diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index e7d47cb71..ae159eed6 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -58,7 +58,7 @@ module.exports = function (deployer, network, accounts) { return moduleRegistry.verifyModule(GeneralPermissionManagerFactory.address, true, {from: PolymathAccount}) }).then(() => { // H) Deploy the STVersionProxy001 Contract which contains the logic of deployment of securityToken. - return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, GeneralPermissionManagerFactory.address, {from: PolymathAccount}) + return deployer.deploy(STVersionProxy001, GeneralTransferManagerFactory.address, {from: PolymathAccount}) }).then(() => { // I) Deploy the TickerRegistry Contract (It is used to store the information about the ticker) return deployer.deploy(TickerRegistry, {from: PolymathAccount}) @@ -92,5 +92,5 @@ module.exports = function (deployer, network, accounts) { }) }) }) -}) +}) } diff --git a/test/Issuance.js b/test/Issuance.js index 8bb22cf2a..2e2f0bbe6 100644 --- a/test/Issuance.js +++ b/test/Issuance.js @@ -20,7 +20,7 @@ const BigNumber = require('bignumber.js'); const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // Hardcoded development port -contract('SecurityToken', accounts => { +contract('Issuance', accounts => { // Accounts Variable declaration @@ -181,7 +181,7 @@ contract('SecurityToken', accounts => { // Step 7: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(), @@ -246,12 +246,12 @@ contract('SecurityToken', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -266,14 +266,6 @@ contract('SecurityToken', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("POLYMATH: Should successfully attach the STO factory with the security token", async () => { @@ -293,7 +285,7 @@ contract('SecurityToken', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [(latestTime() + duration.seconds(5000)), (latestTime() + duration.days(30)), cap, rate, fundRaiseType, I_PolyFaucet.address, account_fundsReceiver]); const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: account_polymath, gas: 2500000 }); - + assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[2].args._name) @@ -319,6 +311,10 @@ contract('SecurityToken', accounts => { }); it("Should add the delegate with permission", async() => { + //First attach a permission manager to the token + await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: account_polymath}); + let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); + I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); // Add permission to the deletgate (A regesteration process) await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_polymath}); // Providing the permission to the delegate diff --git a/test/capped_sto.js b/test/capped_sto.js index 47eaa2a40..33e426373 100644 --- a/test/capped_sto.js +++ b/test/capped_sto.js @@ -64,7 +64,6 @@ contract('CappedSTO', accounts => { const P_decimals = 18; // Module key - const permissionManagerKey = 1; const transferManagerKey = 2; const stoKey = 3; const budget = 0; @@ -187,7 +186,7 @@ contract('CappedSTO', accounts => { // Step 7: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(), @@ -249,12 +248,12 @@ contract('CappedSTO', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -269,14 +268,6 @@ contract('CappedSTO', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("Should fail to launch the STO due to rate is 0", async () => { @@ -561,12 +552,12 @@ contract('CappedSTO', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -581,14 +572,6 @@ contract('CappedSTO', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("POLY: Should successfully attach the STO factory with the security token", async () => { diff --git a/test/exchange_transfer_manager.js b/test/exchange_transfer_manager.js index 720405a54..43e880526 100644 --- a/test/exchange_transfer_manager.js +++ b/test/exchange_transfer_manager.js @@ -184,7 +184,7 @@ contract('ExchangeTransferManager', accounts => { // Step 7: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address); assert.notEqual( I_STVersion.address.valueOf(), @@ -247,12 +247,12 @@ contract('ExchangeTransferManager', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), 1); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), 2); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -267,14 +267,6 @@ contract('ExchangeTransferManager', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(1, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("Should successfully attach the STO factory with the security token", async () => { diff --git a/test/module_registry.js b/test/module_registry.js index 89954860e..c307367ca 100644 --- a/test/module_registry.js +++ b/test/module_registry.js @@ -309,7 +309,7 @@ contract('ModuleRegistry', accounts => { "Failed in verifying the module" ); - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(), @@ -384,12 +384,12 @@ contract('ModuleRegistry', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -404,14 +404,6 @@ contract('ModuleRegistry', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); }); diff --git a/test/security_token.js b/test/security_token.js index d462de234..60cac0924 100644 --- a/test/security_token.js +++ b/test/security_token.js @@ -189,7 +189,7 @@ contract('SecurityToken', accounts => { // Step 7: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(), @@ -251,19 +251,19 @@ contract('SecurityToken', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); it("Should intialize the auto attached modules", async () => { - let moduleData = await I_SecurityToken.modules(transferManagerKey, 0); - I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]); + let moduleData = await I_SecurityToken.modules(transferManagerKey, 0); + I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]); assert.notEqual( I_GeneralTransferManager.address.valueOf(), @@ -271,14 +271,6 @@ contract('SecurityToken', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("Should successfully attach the STO factory with the security token", async () => { @@ -419,6 +411,9 @@ contract('SecurityToken', accounts => { it("Should fail to provide the permission to the delegate to change the transfer bools", async () => { let errorThrown = false; // Add permission to the deletgate (A regesteration process) + await I_SecurityToken.addModule(I_GeneralPermissionManagerFactory.address, "", 0, 0, false, {from: token_owner}); + let moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); + I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); try { await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_temp }); } catch (error) { diff --git a/test/security_token_registry.js b/test/security_token_registry.js index 048dcd547..a46338796 100644 --- a/test/security_token_registry.js +++ b/test/security_token_registry.js @@ -114,7 +114,7 @@ contract('SecurityTokenRegistry', accounts => { // Step 0: Deploy the token Faucet I_PolyFaucet = await PolyTokenFaucet.new(); - + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({ from: account_polymath }); @@ -168,7 +168,7 @@ contract('SecurityTokenRegistry', accounts => { // Step 6: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(), @@ -179,7 +179,7 @@ contract('SecurityTokenRegistry', accounts => { // STEP 8: Deploy the CappedSTOFactory I_TestSTOFactory = await TestSTOFactory.new(I_PolyFaucet.address, { from: token_owner }); - + assert.notEqual( I_TestSTOFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", @@ -245,12 +245,12 @@ contract('SecurityTokenRegistry', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTrasnferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -258,7 +258,7 @@ contract('SecurityTokenRegistry', accounts => { it("Should deploy the st vesrion 2", async() => { // Step 7: Deploy the STversionProxy contract - I_STVersion002 = await STVersion002.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion002 = await STVersion002.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion002.address.valueOf(), @@ -293,12 +293,12 @@ contract('SecurityTokenRegistry', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -306,7 +306,7 @@ contract('SecurityTokenRegistry', accounts => { it("Should deploy the st vesrion 3", async() => { // Step 7: Deploy the STversionProxy contract - I_STVersion003 = await STVersion002.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion003 = await STVersion002.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion003.address.valueOf(), @@ -341,12 +341,12 @@ contract('SecurityTokenRegistry', accounts => { LogAddModule.watch(function(error, log){ resolve(log);}); }); - // Verify that GeneralPermissionManager module get added successfully or not - assert.equal(log.args._type.toNumber(), permissionManagerKey); + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._type.toNumber(), transferManagerKey); assert.equal( web3.utils.toAscii(log.args._name) .replace(/\u0000/g, ''), - "GeneralPermissionManager" + "GeneralTransferManager" ); LogAddModule.stopWatching(); }); @@ -361,14 +361,6 @@ contract('SecurityTokenRegistry', accounts => { "GeneralTransferManager contract was not deployed", ); - moduleData = await I_SecurityToken.modules(permissionManagerKey, 0); - I_GeneralPermissionManager = GeneralPermissionManager.at(moduleData[1]); - - assert.notEqual( - I_GeneralPermissionManager.address.valueOf(), - "0x0000000000000000000000000000000000000000", - "GeneralDelegateManager contract was not deployed", - ); }); it("Should failed in attaching the STO factory with the security token -- because securityToken doesn't have sufficient balance", async () => { @@ -410,7 +402,7 @@ contract('SecurityTokenRegistry', accounts => { cap, someString, ]); - + await I_PolyFaucet.getTokens((1000 * Math.pow(10, 18)), I_SecurityToken.address); const tx = await I_SecurityToken.addModule( @@ -423,7 +415,7 @@ contract('SecurityTokenRegistry', accounts => { from: token_owner, gas: 2500000 }); - + assert.equal(tx.logs[3].args._type, stoKey, "TestSTO doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[3].args._name) diff --git a/test/ticker_registry.js b/test/ticker_registry.js index 67399704c..38f4daa3e 100644 --- a/test/ticker_registry.js +++ b/test/ticker_registry.js @@ -135,7 +135,7 @@ contract('TickerRegistry', accounts => { // Step 7: Deploy the STversionProxy contract - I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, {from : account_polymath }); assert.notEqual( I_STVersion.address.valueOf(),