From 886312082b8caba25d85ff70a8c537515643ad84 Mon Sep 17 00:00:00 2001 From: Nick Yeates Date: Fri, 6 Apr 2018 11:57:18 -0400 Subject: [PATCH 01/10] Readme links improved Put them into a list and gave them better names --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aa59b7b8f..7ec7312a4 100644 --- a/README.md +++ b/README.md @@ -170,8 +170,8 @@ http://solidity.readthedocs.io/en/develop/style-guide.html # Links -[Polymath](https://polymath.network) -[Ethereum](https://www.ethereum.org/) -[Solidity](https://solidity.readthedocs.io/en/develop/) -[Truffle](http://truffleframework.com/) -[Testrpc](https://github.com/ethereumjs/testrpc) +- [Polymath Website](https://polymath.network) +- [Ethereum Project](https://www.ethereum.org/) +- [Solidity Docs](https://solidity.readthedocs.io/en/develop/) +- [Truffle Framework](http://truffleframework.com/) +- [Ganache CLI / TestRPC](https://github.com/trufflesuite/ganache-cli) From 4f64db9906d3e5a903f5ce04aa9e0a4dee4c63b0 Mon Sep 17 00:00:00 2001 From: Pablo Ruiz Date: Fri, 6 Apr 2018 13:20:59 -0300 Subject: [PATCH 02/10] Made .sol prettier on GH --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..52031de51 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sol linguist-language=Solidity From 5df61b7ed4a2afead04a39301f9f6f3804bac771 Mon Sep 17 00:00:00 2001 From: Pablo Ruiz Date: Sun, 8 Apr 2018 10:56:15 -0300 Subject: [PATCH 03/10] small typo --- contracts/tokens/SecurityToken.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 7e5a475f0..2c0821362 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -173,7 +173,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { } /** - * @dev allows owner to approve more POLY to one of the modules + * @dev allows owner to approve more POLY to one of the modules */ function changeModuleBudget(uint8 _moduleType, uint8 _moduleIndex, uint256 _budget) public onlyOwner { require(_moduleType != 0); @@ -183,7 +183,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { } /** - * @dev Overladed version of the transfer function + * @dev Overloaded version of the transfer function */ function transfer(address _to, uint256 _value) public returns (bool success) { require(verifyTransfer(msg.sender, _to, _value)); @@ -191,7 +191,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { } /** - * @dev Overladed version of the transferFrom function + * @dev Overloaded version of the transferFrom function */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(verifyTransfer(_from, _to, _value)); From 91149ee1f4b1cb97ab68704f1f9d64945956619d Mon Sep 17 00:00:00 2001 From: satyam Date: Sun, 8 Apr 2018 22:27:58 +0530 Subject: [PATCH 04/10] add test cases for protocol versioning --- CHANGELOG.md | 41 +++- test/security_token_registry.js | 336 ++++++++++++++++++++++++++++++++ 2 files changed, 369 insertions(+), 8 deletions(-) create mode 100644 test/security_token_registry.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 09179828d..fe73d68c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,29 @@ All notable changes to this project will be documented in this file. ## [Unreleased](https://github.com/PolymathNetwork/polymath-core/compare/npm-publish-2...master) -[__0.3.0__](https://www.npmjs.com/package/polymath-core_v2?activeTab=readme) __02-04-18__ +[__0.3.1__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __06-04-18__ + +## Added +* Add `emit` keyword to emit the events. +* Two new variable is added at the time of registeration of ticker. `swarmHash` represents the off-chain data storage location on IPFS and `owner` It reperesent the ethereum address of the owner. +* `LogRegisterTicker` emits two more variable called `_swarmHash` and `_owner`. +* Two events are added in `GeneralPermissionManager` contract to facilitate the notifications for the UI end. + __`LogChangePermission`__ :Emit when permissions to a delegate get changed. + __`LogAddPermission`__: Emit when delegate is added in permission manager contract. +* `getInstructions()` is a public function added into the factories contracts. Use to get the useful instructions about the corresponding factory. +* `_securityTokenRegistry` is more argument is added in __securityTokenV2__ contract. + +## Changed +* All contracts get migrated from solc version 0.4.18 to 0.4.21. +* Now symbols get stored in smart contract in uppercase instead of lowercase. +* Public variable `STRAdress` name in TickerRegistry smart contract changed to `strAddress`. +* Function `permissions()` name in all module factories get changed to `getPermissions()`. +* Function `delegateDetails()` name gets changed to `getDelegateDetails()` in GeneralPermissionManager contract. +* `STVersionProxy_001 & STVersionProxy_002` contract name changed to STVersionProxy001 & STVersionProxy002 respectively. + +*** + +[__0.3.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __02-04-18__ ## Added * Multiple events are added to `ModuleRegistry` contract to facilitate the Logging of the operations. @@ -24,9 +46,9 @@ All notable changes to this project will be documented in this file. * `removeModule` new function added facilitate the removal of the module from the securityToken. It is ownable type function. * `changeModuleBudget` function added to change the budget of the module that already been added. It is ownable type function. -## Changed +## Changed * In early release token symbol in uppercase or in lowercase entertain differently. But for this release both upercase and lowercase symbol name are same. -* Address of the owner of the securityToken is removed from the strucuture of the `SecurityTokenData`. +* Address of the owner of the securityToken is removed from the strucuture of the `SecurityTokenData`. * Mapping `securityTokens` in ISecurityTokenRegistry is now being private instead of public. * `expiryLimit` default value get changed to 7 days instead of the 90 days in TickerRegistry. * __contact__ variable is replaced by the __tokenName__ variable in `SymbolDetails` structure of TickerRegistry. @@ -39,12 +61,12 @@ All notable changes to this project will be documented in this file. * `LogModuleAdded` emit one more variable called ___budget__. * `modules` mapping in the securityToken contract now returns __the array of ModuleData__. -## Removed +## Removed * `admin` varaible is removed from the TickerRegistry contract. *** -[__0.2.0__](https://www.npmjs.com/package/polymath-core_v2?activeTab=readme) __26-03-18__ +[__0.2.0__](https://www.npmjs.com/package/polymath-core?activeTab=readme) __26-03-18__ ## Added * ModuleRegistry contract will provide the list of modules by there types. @@ -53,9 +75,9 @@ All notable changes to this project will be documented in this file. * `SecurityToken` now have the integration with polyToken. At the time of `addModule()` SecurityToken approve the cost of the module to moduleFactory as the spender. * New function `withdrawPoly(uint256 _amount)` is added to withdrawal the unused POLY from the securityToken contract. Called only by the owner of the contract. * `checkPermission(address _delegate, address _module, bytes32 _perm)` function is added to check the permissions on the service providers(delegate). -* `STVersionProxy_001.sol` & `STVersionProxy_002.sol` are the two new contract added. Both of those are the proxy contract use to generate the SecurityToken. Both contract constructor takes two variables address of `transferManagerFactory` address of the +* `STVersionProxy_001.sol` & `STVersionProxy_002.sol` are the two new contract added. Both of those are the proxy contract use to generate the SecurityToken. Both contract constructor takes two variables address of `transferManagerFactory` address of the `permissionManagerFactory`. -* New Module type is added called `PermissionManager`. It has three contracts called GeneralPermissionManagerFactory, GeneralPermissionManager, IPermissionManager. +* New Module type is added called `PermissionManager`. It has three contracts called GeneralPermissionManagerFactory, GeneralPermissionManager, IPermissionManager. * `GeneralPermissionManger` is all about providing the permission to the delegate corresponds to the SecurityToken. Major functionality is added, check, change the permission of the delegate. * Two more functions added for each factory type i.e `getDescription()` & `getTitle()`. * `CappedSTO` is now Configurable by choosing the type of fundraise. Either POLY or ETH. @@ -66,7 +88,7 @@ All notable changes to this project will be documented in this file. * `permissions()` function added in GeneralTransferManager to get all permissions. * `PolyToken.sol` contract is added at contracts/helpers/PolyToken.sol. For now, it has no big use. -## Changed +## Changed * ModuleRegistry only holds the module type of modules only not there names or cost anymore. * No More ModuleReputation struct for counting the reputation of module. Now `reputation` mapping only contains the list of the addresses those used that module factory. * `checkModule()` of ModuleRegistry contract rename to `useModule()` with same function parameters. @@ -91,3 +113,6 @@ All notable changes to this project will be documented in this file. * `SafeMath.sol` contract is replaced by the zeppelin-solidity library contract .   * No more `SecurityTokens` and `symbol` information will be directly part of the SecurityTokenRegistry. Those information will accessed by inheriting the `ISecurityTokenRegistry`. * Remove the Delegable.sol, AclHelpers.sol, DelegablePorting.sol contracts. Now permission manager factory takes their place . * `delegates` mapping removed from the GeneralTransferManager. + + + diff --git a/test/security_token_registry.js b/test/security_token_registry.js new file mode 100644 index 000000000..9aef44759 --- /dev/null +++ b/test/security_token_registry.js @@ -0,0 +1,336 @@ +import latestTime from './helpers/latestTime'; +import { duration, ensureException } from './helpers/utils'; +import takeSnapshot, { increaseTime, revertToSnapshot } from './helpers/time'; + +const CappedSTOFactory = artifacts.require('./CappedSTOFactory.sol'); +const CappedSTO = artifacts.require('./CappedSTO.sol'); +const ModuleRegistry = artifacts.require('./ModuleRegistry.sol'); +const SecurityToken = artifacts.require('./SecurityToken.sol'); +const SecurityTokenRegistry = artifacts.require('./SecurityTokenRegistry.sol'); +const TickerRegistry = artifacts.require('./TickerRegistry.sol'); +const STVersion = artifacts.require('./STVersionProxy001.sol'); +const STVersion002 = artifacts.require('./STVersionProxy002.sol'); +const GeneralPermissionManagerFactory = artifacts.require('./GeneralPermissionManagerFactory.sol'); +const GeneralTransferManagerFactory = artifacts.require('./GeneralTransferManagerFactory.sol'); +const GeneralTransferManager = artifacts.require('./GeneralTransferManager'); +const GeneralPermissionManager = artifacts.require('./GeneralPermissionManager'); +const PolyToken = artifacts.require('./PolyToken.sol'); +const PolyTokenFaucet = artifacts.require('./helpers/contracts/PolyTokenFaucet.sol'); + +const Web3 = require('web3'); +const BigNumber = require('bignumber.js'); +const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) // Hardcoded development port + + +contract('SecurityTokenRegistry', accounts => { + + + // Accounts Variable declaration + let account_polymath; + let account_investor1; + let account_issuer; + let token_owner; + let account_investor2; + let account_fundsReceiver; + let account_delegate; + let account_temp; + + let balanceOfReceiver; + // investor Details + let fromTime = latestTime(); + let toTime = latestTime() + duration.days(100); + + let ID_snap; + const message = "Transaction Should Fail!!"; + + // Contract Instance Declaration + let I_GeneralPermissionManagerFactory; + let I_GeneralTransferManagerFactory; + let I_GeneralPermissionManager; + let I_GeneralTransferManager; + let I_ModuleRegistry; + let I_TickerRegistry; + let I_SecurityTokenRegistry; + let I_CappedSTOFactory; + let I_STVersion; + let I_SecurityToken; + let I_CappedSTO; + let I_PolyToken; + let I_PolyFaucet; + let I_STVersion002; + let I_SecurityToken002 + // SecurityToken Details (Launched ST on the behalf of the issuer) + const swarmHash = "dagwrgwgvwergwrvwrg"; + const name = "Demo Token"; + const symbol = "DET"; + const tokenDetails = "This is equity type of issuance"; + const decimals = 18; + + //Security Token Detials (Version 2) + const swarmHash2 = "dagwrgwgvwergwrvwrg"; + const name2 = "Demo2 Token"; + const symbol2 = "DET2"; + const tokenDetails2 = "This is equity type of issuance"; + + // Module key + const permissionManagerKey = 1; + const transferManagerKey = 2; + const stoKey = 3; + const budget = 0; + + + + before(async() => { + // Accounts setup + account_polymath = accounts[0]; + account_issuer = accounts[1]; + account_investor1 = accounts[9]; + account_investor2 = accounts[6]; + account_fundsReceiver = accounts[4]; + account_delegate = accounts[5]; + account_temp = accounts[8]; + token_owner = account_issuer; + + // ----------- POLYMATH NETWORK Configuration ------------ + + // STEP 1: Deploy the ModuleRegistry + + I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); + + assert.notEqual( + I_ModuleRegistry.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "ModuleRegistry contract was not deployed" + ); + + // STEP 2: Deploy the GeneralTransferManagerFactory + + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + + assert.notEqual( + I_GeneralTransferManagerFactory.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "GeneralTransferManagerFactory contract was not deployed" + ); + + // STEP 3: Deploy the GeneralDelegateManagerFactory + + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + + assert.notEqual( + I_GeneralPermissionManagerFactory.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "GeneralDelegateManagerFactory contract was not deployed" + ); + + // STEP 4: Deploy the CappedSTOFactory + + I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + + assert.notEqual( + I_CappedSTOFactory.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "CappedSTOFactory contract was not deployed" + ); + + // STEP 5: Register the Modules with the ModuleRegistry contract + + // (A) : Register the GeneralTransferManagerFactory + await I_ModuleRegistry.registerModule(I_GeneralTransferManagerFactory.address, { from: account_polymath }); + await I_ModuleRegistry.verifyModule(I_GeneralTransferManagerFactory.address, true, { from: account_polymath }); + + // (B) : Register the GeneralDelegateManagerFactory + await I_ModuleRegistry.registerModule(I_GeneralPermissionManagerFactory.address, { from: account_polymath }); + await I_ModuleRegistry.verifyModule(I_GeneralPermissionManagerFactory.address, true, { from: account_polymath }); + + // (C) : Register the STOFactory + await I_ModuleRegistry.registerModule(I_CappedSTOFactory.address, { from: token_owner }); + + // Step 6: Deploy the TickerRegistry + + I_TickerRegistry = await TickerRegistry.new({ from: account_polymath }); + + assert.notEqual( + I_TickerRegistry.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "TickerRegistry contract was not deployed", + ); + + // Step 7: Deploy the STversionProxy contract + + I_STVersion = await STVersion.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + + assert.notEqual( + I_STVersion.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "STVersion contract was not deployed", + ); + + // Step ANY: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + + // Step 8: Deploy the SecurityTokenRegistry + + I_SecurityTokenRegistry = await SecurityTokenRegistry.new( + I_PolyToken.address, + I_ModuleRegistry.address, + I_TickerRegistry.address, + I_STVersion.address, + { + from: account_polymath + }); + + assert.notEqual( + I_SecurityTokenRegistry.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "SecurityTokenRegistry contract was not deployed", + ); + + // Step 8: Set the STR in TickerRegistry + await I_TickerRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); + await I_ModuleRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); + + // Step 9: Deploy the token Faucet + I_PolyFaucet = await PolyTokenFaucet.new(); + + // Printing all the contract addresses + console.log(`\nPolymath Network Smart Contracts Deployed:\n + ModuleRegistry: ${I_ModuleRegistry.address}\n + GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address}\n + GeneralPermissionManagerFactory: ${I_GeneralPermissionManagerFactory.address}\n + CappedSTOFactory: ${I_CappedSTOFactory.address}\n + TickerRegistry: ${I_TickerRegistry.address}\n + STVersionProxy_001: ${I_STVersion.address}\n + SecurityTokenRegistry: ${I_SecurityTokenRegistry.address}\n + `); + }); + + describe("Generate the SecurityToken", async() => { + + it("Should register the ticker before the generation of the security token", async () => { + let tx = await I_TickerRegistry.registerTicker(token_owner, symbol, name, swarmHash, { from : token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner); + assert.equal(tx.logs[0].args._symbol, symbol); + }); + + it("Should generate the new security token with the same symbol as registered above", async () => { + let tx = await I_SecurityTokenRegistry.generateSecurityToken(name, symbol, decimals, tokenDetails, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + + I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + + const LogAddModule = await I_SecurityToken.allEvents(); + const log = await new Promise(function(resolve, reject) { + LogAddModule.watch(function(error, log){ resolve(log);}); + }); + + // Verify that GeneralPermissionManager module get added successfully or not + assert.equal(log.args._type.toNumber(), permissionManagerKey); + assert.equal( + web3.utils.toAscii(log.args._name) + .replace(/\u0000/g, ''), + "GeneralPermissionManager" + ); + LogAddModule.stopWatching(); + }); + + 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 }); + + assert.notEqual( + I_STVersion002.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "STVersion002 contract was not deployed", + ); + I_SecurityTokenRegistry.setProtocolVersion(I_STVersion002.address, "0.2.0", { from: account_polymath }); + + assert.equal( + web3.utils.toAscii(await I_SecurityTokenRegistry.protocolVersion.call()) + .replace(/\u0000/g, ''), + "0.2.0" + ); + }); + + it("Should register the ticker before the generation of the security token", async () => { + let tx = await I_TickerRegistry.registerTicker(token_owner, symbol2, name2, swarmHash, { from : token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner); + assert.equal(tx.logs[0].args._symbol, symbol2); + }); + + it("Should generate the new security token with version 2", async() => { + let tx = await I_SecurityTokenRegistry.generateSecurityToken(name2, symbol2, decimals, tokenDetails, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[1].args._ticker, symbol2, "SecurityToken doesn't get deployed"); + + I_SecurityToken002 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + + const LogAddModule = await I_SecurityToken002.allEvents(); + const log = await new Promise(function(resolve, reject) { + LogAddModule.watch(function(error, log){ resolve(log);}); + }); + + // Verify that GeneralPermissionManager module get added successfully or not + assert.equal(log.args._type.toNumber(), permissionManagerKey); + assert.equal( + web3.utils.toAscii(log.args._name) + .replace(/\u0000/g, ''), + "GeneralPermissionManager" + ); + LogAddModule.stopWatching(); + }); + + it("Should deploy the st vesrion 3", async() => { + // Step 7: Deploy the STversionProxy contract + + I_STVersion002 = await STVersion002.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + + assert.notEqual( + I_STVersion002.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "STVersion002 contract was not deployed", + ); + I_SecurityTokenRegistry.setProtocolVersion(I_STVersion002.address, "0.3.0", { from: account_polymath }); + + assert.equal( + web3.utils.toAscii(await I_SecurityTokenRegistry.protocolVersion.call()) + .replace(/\u0000/g, ''), + "0.3.0" + ); + }); + + it("Should register the ticker before the generation of the security token", async () => { + let tx = await I_TickerRegistry.registerTicker(token_owner, "DET3", name2, swarmHash, { from : token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner); + assert.equal(tx.logs[0].args._symbol, "DET3"); + }); + + it("Should generate the new security token with version 3", async() => { + let tx = await I_SecurityTokenRegistry.generateSecurityToken(name2, "DET3", decimals, tokenDetails, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[1].args._ticker, "DET3", "SecurityToken doesn't get deployed"); + + I_SecurityToken002 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + + const LogAddModule = await I_SecurityToken002.allEvents(); + const log = await new Promise(function(resolve, reject) { + LogAddModule.watch(function(error, log){ resolve(log);}); + }); + + // Verify that GeneralPermissionManager module get added successfully or not + assert.equal(log.args._type.toNumber(), permissionManagerKey); + assert.equal( + web3.utils.toAscii(log.args._name) + .replace(/\u0000/g, ''), + "GeneralPermissionManager" + ); + LogAddModule.stopWatching(); + }); + + }); +}); \ No newline at end of file From a99a876487f5c15cb3983146dd4749a42e4a1833 Mon Sep 17 00:00:00 2001 From: satyam Date: Mon, 9 Apr 2018 12:51:59 +0530 Subject: [PATCH 05/10] minor fixes in the test-suite --- test/helpers/contracts/TestSTOFactory.sol | 44 ++++++++ test/security_token_registry.js | 117 +++++++++++++++++----- 2 files changed, 138 insertions(+), 23 deletions(-) create mode 100644 test/helpers/contracts/TestSTOFactory.sol diff --git a/test/helpers/contracts/TestSTOFactory.sol b/test/helpers/contracts/TestSTOFactory.sol new file mode 100644 index 000000000..73fd3093e --- /dev/null +++ b/test/helpers/contracts/TestSTOFactory.sol @@ -0,0 +1,44 @@ +pragma solidity ^0.4.21; + +import "../../../contracts/modules/STO/DummySTO.sol"; +import "../../../contracts/interfaces/IModuleFactory.sol"; +import "../../../contracts/interfaces/IModule.sol"; + + +contract TestSTOFactory is IModuleFactory { + + function deploy(bytes _data) external returns(address) { + //polyToken.transferFrom(msg.sender, owner, getCost()); + //Check valid bytes - can only call module init function + DummySTO dummySTO = new DummySTO(msg.sender); + //Checks that _data is valid (not calling anything it shouldn't) + require(getSig(_data) == dummySTO.getInitFunction()); + require(address(dummySTO).call(_data)); + return address(dummySTO); + } + + function getCost() public view returns(uint256) { + return uint256(1000 * 10 ** 18); + } + + function getType() public view returns(uint8) { + return 3; + } + + function getName() public view returns(bytes32) { + return "TestSTO"; + } + + function getDescription() public view returns(string) { + return "Test STO"; + } + + function getTitle() public view returns(string) { + return "Test STO"; + } + + function getInstructions() public view returns(string) { + return "Test STO - you can mint tokens at will"; + } + +} diff --git a/test/security_token_registry.js b/test/security_token_registry.js index 9aef44759..9f3bab6ec 100644 --- a/test/security_token_registry.js +++ b/test/security_token_registry.js @@ -1,9 +1,9 @@ import latestTime from './helpers/latestTime'; import { duration, ensureException } from './helpers/utils'; -import takeSnapshot, { increaseTime, revertToSnapshot } from './helpers/time'; +import { takeSnapshot, increaseTime, revertToSnapshot } from './helpers/time'; -const CappedSTOFactory = artifacts.require('./CappedSTOFactory.sol'); -const CappedSTO = artifacts.require('./CappedSTO.sol'); +const TestSTOFactory = artifacts.require('./test/helpers/contracts/TestSTOFactory.sol'); +const DummySTO = artifacts.require('./DummySTO.sol'); const ModuleRegistry = artifacts.require('./ModuleRegistry.sol'); const SecurityToken = artifacts.require('./SecurityToken.sol'); const SecurityTokenRegistry = artifacts.require('./SecurityTokenRegistry.sol'); @@ -14,7 +14,6 @@ const GeneralPermissionManagerFactory = artifacts.require('./GeneralPermissionMa const GeneralTransferManagerFactory = artifacts.require('./GeneralTransferManagerFactory.sol'); const GeneralTransferManager = artifacts.require('./GeneralTransferManager'); const GeneralPermissionManager = artifacts.require('./GeneralPermissionManager'); -const PolyToken = artifacts.require('./PolyToken.sol'); const PolyTokenFaucet = artifacts.require('./helpers/contracts/PolyTokenFaucet.sol'); const Web3 = require('web3'); @@ -51,14 +50,15 @@ contract('SecurityTokenRegistry', accounts => { let I_ModuleRegistry; let I_TickerRegistry; let I_SecurityTokenRegistry; - let I_CappedSTOFactory; + let I_TestSTOFactory; let I_STVersion; let I_SecurityToken; - let I_CappedSTO; + let I_DummySTO; let I_PolyToken; let I_PolyFaucet; let I_STVersion002; - let I_SecurityToken002 + let I_SecurityToken002; + let I_STVersion003; // SecurityToken Details (Launched ST on the behalf of the issuer) const swarmHash = "dagwrgwgvwergwrvwrg"; const name = "Demo Token"; @@ -78,7 +78,26 @@ contract('SecurityTokenRegistry', accounts => { const stoKey = 3; const budget = 0; - + // Capped STO details + const cap = new BigNumber(10000).times(new BigNumber(10).pow(18)); + const someString = "Hello string"; + const functionSignature = { + name: 'configure', + type: 'function', + inputs: [{ + type: 'uint256', + name: '_startTime' + },{ + type: 'uint256', + name: '_endTime' + },{ + type: 'uint256', + name: '_cap' + },{ + type: 'string', + name: '_someString' + }] + }; before(async() => { // Accounts setup @@ -125,12 +144,12 @@ contract('SecurityTokenRegistry', accounts => { // STEP 4: Deploy the CappedSTOFactory - I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + I_TestSTOFactory = await TestSTOFactory.new({ from: token_owner }); assert.notEqual( - I_CappedSTOFactory.address.valueOf(), + I_TestSTOFactory.address.valueOf(), "0x0000000000000000000000000000000000000000", - "CappedSTOFactory contract was not deployed" + "TestSTOFactory contract was not deployed" ); // STEP 5: Register the Modules with the ModuleRegistry contract @@ -144,7 +163,7 @@ contract('SecurityTokenRegistry', accounts => { await I_ModuleRegistry.verifyModule(I_GeneralPermissionManagerFactory.address, true, { from: account_polymath }); // (C) : Register the STOFactory - await I_ModuleRegistry.registerModule(I_CappedSTOFactory.address, { from: token_owner }); + await I_ModuleRegistry.registerModule(I_TestSTOFactory.address, { from: token_owner }); // Step 6: Deploy the TickerRegistry @@ -166,13 +185,13 @@ contract('SecurityTokenRegistry', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); + // Step 8: Deploy the token Faucet + I_PolyFaucet = await PolyTokenFaucet.new(); - // Step 8: Deploy the SecurityTokenRegistry + // Step 9: Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( - I_PolyToken.address, + I_PolyFaucet.address, I_ModuleRegistry.address, I_TickerRegistry.address, I_STVersion.address, @@ -190,15 +209,14 @@ contract('SecurityTokenRegistry', accounts => { await I_TickerRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); await I_ModuleRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); - // Step 9: Deploy the token Faucet - I_PolyFaucet = await PolyTokenFaucet.new(); + // Printing all the contract addresses console.log(`\nPolymath Network Smart Contracts Deployed:\n ModuleRegistry: ${I_ModuleRegistry.address}\n GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address}\n GeneralPermissionManagerFactory: ${I_GeneralPermissionManagerFactory.address}\n - CappedSTOFactory: ${I_CappedSTOFactory.address}\n + TestSTOFactory: ${I_TestSTOFactory.address}\n TickerRegistry: ${I_TickerRegistry.address}\n STVersionProxy_001: ${I_STVersion.address}\n SecurityTokenRegistry: ${I_SecurityTokenRegistry.address}\n @@ -246,7 +264,7 @@ contract('SecurityTokenRegistry', accounts => { "0x0000000000000000000000000000000000000000", "STVersion002 contract was not deployed", ); - I_SecurityTokenRegistry.setProtocolVersion(I_STVersion002.address, "0.2.0", { from: account_polymath }); + await I_SecurityTokenRegistry.setProtocolVersion(I_STVersion002.address, "0.2.0", { from: account_polymath }); assert.equal( web3.utils.toAscii(await I_SecurityTokenRegistry.protocolVersion.call()) @@ -287,14 +305,14 @@ contract('SecurityTokenRegistry', accounts => { it("Should deploy the st vesrion 3", async() => { // Step 7: Deploy the STversionProxy contract - I_STVersion002 = await STVersion002.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); + I_STVersion003 = await STVersion002.new(I_GeneralTransferManagerFactory.address, I_GeneralPermissionManagerFactory.address, {from : account_polymath }); assert.notEqual( - I_STVersion002.address.valueOf(), + I_STVersion003.address.valueOf(), "0x0000000000000000000000000000000000000000", "STVersion002 contract was not deployed", ); - I_SecurityTokenRegistry.setProtocolVersion(I_STVersion002.address, "0.3.0", { from: account_polymath }); + await I_SecurityTokenRegistry.setProtocolVersion(I_STVersion003.address, "0.3.0", { from: account_polymath }); assert.equal( web3.utils.toAscii(await I_SecurityTokenRegistry.protocolVersion.call()) @@ -332,5 +350,58 @@ contract('SecurityTokenRegistry', accounts => { LogAddModule.stopWatching(); }); + it("Should intialize the auto attached modules", async () => { + let moduleData = await I_SecurityToken.modules(transferManagerKey, 0); + I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]); + + assert.notEqual( + I_GeneralTransferManager.address.valueOf(), + "0x0000000000000000000000000000000000000000", + "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 () => { + let bytesSTO = web3.eth.abi.encodeFunctionCall( + functionSignature, + [ + (latestTime() + duration.seconds(500)), + (latestTime() + duration.days(30)), + cap, + someString, + ]); + + const tx = await I_SecurityToken.addModule( + I_TestSTOFactory.address, + bytesSTO, + (1000 * Math.pow(10, 18)), + (1000 * Math.pow(10, 18)), + false, + { + from: token_owner, + gas: 2500000 + }); + + assert.equal(tx.logs[2].args._type, stoKey, "TestSTO doesn't get deployed"); + assert.equal( + web3.utils.toAscii(tx.logs[2].args._name) + .replace(/\u0000/g, ''), + "TestSTO", + "TestSTOFactory module was not added" + ); + I_DummySTO = DummySTO.at(tx.logs[2].args._module); + }); }); + + + }); \ No newline at end of file From f732bfcc7350cc0c6b54d51eaf1326e5811fea0c Mon Sep 17 00:00:00 2001 From: Sam Mathias Weggersen Date: Mon, 9 Apr 2018 09:33:58 +0200 Subject: [PATCH 06/10] small typo --- contracts/TickerRegistry.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/TickerRegistry.sol b/contracts/TickerRegistry.sol index d445e5f79..217c80426 100644 --- a/contracts/TickerRegistry.sol +++ b/contracts/TickerRegistry.sol @@ -124,7 +124,7 @@ contract TickerRegistry is ITickerRegistry, Ownable, Util { } /** - * @dev To re-intialize the token symbol details if symbol validity expires + * @dev To re-initialize the token symbol details if symbol validity expires * @param _symbol token symbol */ function expiryCheck(string _symbol) internal returns(bool) { From f610519f059057acf01746b6cf6f7d649bfd66a9 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Mon, 9 Apr 2018 11:33:35 +0100 Subject: [PATCH 07/10] Change replaceable to locked --- contracts/tokens/STVersionProxy001.sol | 4 +-- contracts/tokens/STVersionProxy002.sol | 4 +-- contracts/tokens/SecurityToken.sol | 23 +++++++------- demo/ST20Generator.js | 2 +- test/Issuance.js | 42 +++++++++++++------------- test/capped_sto.js | 16 +++++----- test/exchange_transfer_manager.js | 4 +-- test/module_registry.js | 30 +++++++++--------- test/security_token.js | 40 ++++++++++++------------ test/ticker_registry.js | 20 ++++++------ 10 files changed, 92 insertions(+), 93 deletions(-) diff --git a/contracts/tokens/STVersionProxy001.sol b/contracts/tokens/STVersionProxy001.sol index 1f9b50641..b295a3f6d 100644 --- a/contracts/tokens/STVersionProxy001.sol +++ b/contracts/tokens/STVersionProxy001.sol @@ -33,10 +33,10 @@ contract STVersionProxy001 is ISTProxy { ); if (addPermissionManager) { - SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, true); + SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false); } if (addTransferManager) { - SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, true); + SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false); } SecurityToken(newSecurityTokenAddress).transferOwnership(_issuer); diff --git a/contracts/tokens/STVersionProxy002.sol b/contracts/tokens/STVersionProxy002.sol index 3eb0d29cf..2c2bfac64 100644 --- a/contracts/tokens/STVersionProxy002.sol +++ b/contracts/tokens/STVersionProxy002.sol @@ -31,10 +31,10 @@ contract STVersionProxy002 is ISTProxy { ); if (addPermissionManager) { - SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, true); + SecurityToken(newSecurityTokenAddress).addModule(permissionManagerFactory, "", 0, 0, false); } if (addTransferManager) { - SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, true); + SecurityToken(newSecurityTokenAddress).addModule(transferManagerFactory, "", 0, 0, false); } SecurityToken(newSecurityTokenAddress).transferOwnership(_issuer); diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 2c0821362..388867045 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -32,7 +32,6 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { struct ModuleData { bytes32 name; address moduleAddress; - bool replaceable; } address public moduleRegistry; @@ -43,6 +42,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { // Module list should be order agnostic! mapping (uint8 => ModuleData[]) public modules; + mapping (uint8 => bool) public modulesLocked; uint8 public constant MAX_MODULES = 10; @@ -96,9 +96,9 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { bytes _data, uint256 _maxCost, uint256 _budget, - bool _replaceable + bool _locked ) external onlyOwner { - _addModule(_moduleFactory, _data, _maxCost, _budget, _replaceable); + _addModule(_moduleFactory, _data, _maxCost, _budget, _locked); } /** @@ -108,22 +108,20 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { * @param _moduleFactory is the address of the module factory to be added * @param _data is data packed into bytes used to further configure the module (See STO usage) * @param _maxCost max amount of POLY willing to pay to module. (WIP) - * @param _replaceable whether or not the module is supposed to be replaceable + * @param _locked whether or not the module is supposed to be locked */ //You are allowed to add a new moduleType if: // - there is no existing module of that type yet added // - the last member of the module list is replacable - function _addModule(address _moduleFactory, bytes _data, uint256 _maxCost, uint256 _budget, bool _replaceable) internal { + function _addModule(address _moduleFactory, bytes _data, uint256 _maxCost, uint256 _budget, bool _locked) internal { //Check that module exists in registry - will throw otherwise IModuleRegistry(moduleRegistry).useModule(_moduleFactory); IModuleFactory moduleFactory = IModuleFactory(_moduleFactory); require(modules[moduleFactory.getType()].length < MAX_MODULES); uint256 moduleCost = moduleFactory.getCost(); require(moduleCost <= _maxCost); - //Check that this module has not already been set as non-replaceable - if (modules[moduleFactory.getType()].length != 0) { - require(modules[moduleFactory.getType()][modules[moduleFactory.getType()].length - 1].replaceable); - } + //Check that this module has not already been set as locked + require(!modulesLocked[moduleFactory.getType()]); //Approve fee for module require(polyToken.approve(_moduleFactory, moduleCost)); //Creates instance of module from factory @@ -131,7 +129,8 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { //Approve ongoing budget require(polyToken.approve(module, _budget)); //Add to SecurityToken module map - modules[moduleFactory.getType()].push(ModuleData(moduleFactory.getName(), module, _replaceable)); + modules[moduleFactory.getType()].push(ModuleData(moduleFactory.getName(), module)); + modulesLocked[moduleFactory.getType()] = _locked; //Emit log event emit LogModuleAdded(moduleFactory.getType(), moduleFactory.getName(), _moduleFactory, module, moduleCost, _budget, now); } @@ -144,7 +143,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { function removeModule(uint8 _moduleType, uint8 _moduleIndex) external onlyOwner { require(_moduleIndex < modules[_moduleType].length); require(modules[_moduleType][_moduleIndex].moduleAddress != address(0)); - require(modules[_moduleType][_moduleIndex].replaceable); + require(!modulesLocked[_moduleType]); //Take the last member of the list, and replace _moduleIndex with this, then shorten the list by one emit LogModuleRemoved(_moduleType, modules[_moduleType][_moduleIndex].moduleAddress, now); modules[_moduleType][_moduleIndex] = modules[_moduleType][modules[_moduleType].length - 1]; @@ -156,7 +155,7 @@ contract SecurityToken is ISecurityToken, StandardToken, DetailedERC20 { return ( modules[_moduleType][_index].name, modules[_moduleType][_index].moduleAddress, - modules[_moduleType][_index].replaceable + modulesLocked[_moduleType] ); }else { return ("", address(0), false); diff --git a/demo/ST20Generator.js b/demo/ST20Generator.js index 5325a4e27..123c0f1ab 100644 --- a/demo/ST20Generator.js +++ b/demo/ST20Generator.js @@ -462,7 +462,7 @@ async function step_STO_Launch(){ }, [startTime, endTime, web3.utils.toWei(cap, 'ether'), rate,0,0,wallet]); try{ - await securityToken.methods.addModule(cappedSTOFactoryAddress, bytesSTO, 0,0, false).send({ from: Issuer, gas:2500000, gasPrice:DEFAULT_GAS_PRICE}) + await securityToken.methods.addModule(cappedSTOFactoryAddress, bytesSTO, 0,0, true).send({ from: Issuer, gas:2500000, gasPrice:DEFAULT_GAS_PRICE}) .on('transactionHash', function(hash){ console.log(` Your transaction is being processed. Please wait... diff --git a/test/Issuance.js b/test/Issuance.js index 2b83b7b2a..c1dfa88e9 100644 --- a/test/Issuance.js +++ b/test/Issuance.js @@ -40,7 +40,7 @@ contract('SecurityToken', accounts => { // investor Details let fromTime = latestTime(); let toTime = latestTime() + duration.days(15); - + // Contract Instance Declaration let I_GeneralPermissionManagerFactory; let I_GeneralTransferManagerFactory; @@ -239,17 +239,17 @@ contract('SecurityToken', accounts => { it("POLYMATH: Should generate the new security token with the same symbol as registered above", async () => { let tx = await I_SecurityTokenRegistry.generateSecurityToken(name, symbol, decimals, tokenDetails, { from: account_polymath }); - + // Verify the successful generation of the security token assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); - + I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); - + const LogAddModule = await I_SecurityToken.allEvents(); const log = await new Promise(function(resolve, reject) { LogAddModule.watch(function(error, log){ resolve(log);}); }); - + // Verify that GeneralPermissionManager module get added successfully or not assert.equal(log.args._type.toNumber(), permissionManagerKey); assert.equal( @@ -263,16 +263,16 @@ contract('SecurityToken', accounts => { it("POLYMATH: Should intialize the auto attached modules", async () => { let moduleData = await I_SecurityToken.modules(transferManagerKey, 0); I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]); - + assert.notEqual( I_GeneralTransferManager.address.valueOf(), "0x0000000000000000000000000000000000000000", "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", @@ -295,8 +295,8 @@ contract('SecurityToken', accounts => { await I_ModuleRegistry.registerModule(I_CappedSTOFactory.address, { from: account_polymath }); let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [(latestTime() + duration.seconds(5000)), (latestTime() + duration.days(30)), cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); - - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: account_polymath, gas: 2500000 }); + + 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( @@ -327,7 +327,7 @@ contract('SecurityToken', accounts => { await I_GeneralPermissionManager.addPermission(account_delegate, delegateDetails, { from: account_polymath}); // Providing the permission to the delegate await I_GeneralPermissionManager.changePermission(account_delegate, I_GeneralTransferManager.address, TM_Perm, true, { from: account_polymath }); - + assert.isTrue(await I_GeneralPermissionManager.checkPermission(account_delegate, I_GeneralTransferManager.address, TM_Perm)); }); @@ -341,7 +341,7 @@ contract('SecurityToken', accounts => { describe("Operations on the STO", async() => { it("Should Buy the tokens", async() => { balanceOfReceiver = await web3.eth.getBalance(account_fundsReceiver); - + // Jump time await increaseTime(5000); // Fallback transaction @@ -351,16 +351,16 @@ contract('SecurityToken', accounts => { gas: 210000, value: web3.utils.toWei('1', 'ether') }); - + assert.equal( (await I_CappedSTO.fundsRaised.call()) .dividedBy(new BigNumber(10).pow(18)) .toNumber(), 1 ); - + assert.equal(await I_CappedSTO.getNumberInvestors.call(), 1); - + assert.equal( (await I_SecurityToken.balanceOf(account_investor1)) .dividedBy(new BigNumber(10).pow(18)) @@ -368,13 +368,13 @@ contract('SecurityToken', accounts => { 1000 ); }); - + it("Verification of the event Token Purchase", async() => { let TokenPurchase = I_CappedSTO.allEvents(); let log = await new Promise(function(resolve, reject) { TokenPurchase.watch(function(error, log){ resolve(log);}) }); - + assert.equal(log.args.purchaser, account_investor1, "Wrong address of the investor"); assert.equal( (log.args.amount) @@ -405,16 +405,16 @@ contract('SecurityToken', accounts => { gas: 210000, value: web3.utils.toWei('1', 'ether') }); - + assert.equal( (await I_CappedSTO.fundsRaised.call()) .dividedBy(new BigNumber(10).pow(18)) .toNumber(), 2 ); - + assert.equal(await I_CappedSTO.getNumberInvestors.call(), 2); - + assert.equal( (await I_SecurityToken.balanceOf(account_investor2)) .dividedBy(new BigNumber(10).pow(18)) @@ -424,4 +424,4 @@ contract('SecurityToken', accounts => { }) }); }); -}); \ No newline at end of file +}); diff --git a/test/capped_sto.js b/test/capped_sto.js index dd44c3e37..5938dfc69 100644 --- a/test/capped_sto.js +++ b/test/capped_sto.js @@ -288,7 +288,7 @@ contract('CappedSTO', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, 0, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); let errorThrown = false; try { - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 2500000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); } catch(error) { console.log(`Tx Failed because of rate is ${0}. Test Passed Successfully`); errorThrown = true; @@ -301,7 +301,7 @@ contract('CappedSTO', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [ Math.floor(Date.now()/1000 + 100000), Math.floor(Date.now()/1000 + 1000), cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); let errorThrown = false; try { - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 2500000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); } catch(error) { errorThrown = true; console.log(`Tx Failed because of startTime is greater than endTime. Test Passed Successfully`); @@ -314,19 +314,19 @@ contract('CappedSTO', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [ startTime, endTime, 0, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); let errorThrown = false; try { - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 2500000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); } catch(error) { console.log(`Tx Failed because the Cap is equal to ${0}. Test Passed Successfully`); errorThrown = true; ensureException(error); } - assert.ok(errorThrown, message); + assert.ok(errorThrown, message); }); it("Should successfully attach the STO factory with the security token", async () => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 2500000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( @@ -599,7 +599,7 @@ contract('CappedSTO', accounts => { it("POLY: Should successfully attach the STO factory with the security token", async () => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [P_startTime, P_endTime, P_cap, P_rate, P_fundRaiseType, I_PolyFaucet.address, account_fundsReceiver]); - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 2500000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( @@ -784,10 +784,10 @@ contract('CappedSTO', accounts => { ); } catch(error) { console.log(`failed Because STO get expired reached`); - errorThrown = true; + errorThrown = true; ensureException(error); } - assert.ok(errorThrown, message); + assert.ok(errorThrown, message); }); it("Should fundRaised value equal to the raised value in the funds receiver wallet", async() => { diff --git a/test/exchange_transfer_manager.js b/test/exchange_transfer_manager.js index 41c869bd1..53b18a8e2 100644 --- a/test/exchange_transfer_manager.js +++ b/test/exchange_transfer_manager.js @@ -278,7 +278,7 @@ contract('ExchangeTransferManager', accounts => { }); it("Should successfully attach the STO factory with the security token", async () => { - const tx = await I_SecurityToken.addModule(I_DummySTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner }); + const tx = await I_SecurityToken.addModule(I_DummySTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner }); assert.equal(tx.logs[2].args._type.toNumber(), stoKey, "DummySTO doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[2].args._name) @@ -415,7 +415,7 @@ contract('ExchangeTransferManager', accounts => { web3.utils.toWei('1', 'ether') ); }); - + }); }); diff --git a/test/module_registry.js b/test/module_registry.js index 75ec22cdf..07ea3ceaa 100644 --- a/test/module_registry.js +++ b/test/module_registry.js @@ -39,7 +39,7 @@ contract('ModuleRegistry', accounts => { // investor Details let fromTime = latestTime(); let toTime = latestTime() + duration.days(15); - + let ID_snap; let message = "Transaction Should fail!"; // Contract Instance Declaration @@ -119,7 +119,7 @@ contract('ModuleRegistry', accounts => { account_delegate = accounts[5]; account_temp = accounts[8]; token_owner = account_issuer; - + // ----------- POLYMATH NETWORK Configuration ------------ // STEP 1: Deploy the ModuleRegistry @@ -160,7 +160,7 @@ contract('ModuleRegistry', accounts => { }); it("Should successfully deployed the Module Fatories", async () => { - + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); assert.notEqual( @@ -169,7 +169,7 @@ contract('ModuleRegistry', accounts => { "GeneralTransferManagerFactory contract was not deployed" ); - + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); assert.notEqual( @@ -178,7 +178,7 @@ contract('ModuleRegistry', accounts => { "GeneralDelegateManagerFactory contract was not deployed" ); - + I_CappedSTOFactory = await CappedSTOFactory.new({ from: account_polymath }); assert.notEqual( @@ -201,7 +201,7 @@ contract('ModuleRegistry', accounts => { it("Should succssfully registered the module", async() => { let tx = await I_ModuleRegistry.registerModule(I_GeneralTransferManagerFactory.address, { from: account_polymath }); - + assert.equal( tx.logs[0].args._moduleFactory, I_GeneralTransferManagerFactory.address, @@ -211,7 +211,7 @@ contract('ModuleRegistry', accounts => { assert.equal(tx.logs[0].args._owner, account_polymath); tx = await I_ModuleRegistry.registerModule(I_GeneralPermissionManagerFactory.address, { from: account_polymath }); - + assert.equal( tx.logs[0].args._moduleFactory, I_GeneralPermissionManagerFactory.address, @@ -221,7 +221,7 @@ contract('ModuleRegistry', accounts => { assert.equal(tx.logs[0].args._owner, account_polymath); tx = await I_ModuleRegistry.registerModule(I_CappedSTOFactory.address, { from: account_polymath }); - + assert.equal( tx.logs[0].args._moduleFactory, I_CappedSTOFactory.address, @@ -322,7 +322,7 @@ contract('ModuleRegistry', accounts => { "0x0000000000000000000000000000000000000000", "STVersion contract was not deployed", ); - + // Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( @@ -429,7 +429,7 @@ contract('ModuleRegistry', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); let errorThrown = false; try { - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 5000000 }); + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 5000000 }); } catch(error) { errorThrown = true; console.log(`Tx get failed. Because module is un-verified`); @@ -448,7 +448,7 @@ contract('ModuleRegistry', accounts => { ); let tx = await I_ModuleRegistry.registerModule(I_CappedSTOFactory.address, { from: token_owner }); - + assert.equal( tx.logs[0].args._moduleFactory, I_CappedSTOFactory.address, @@ -460,9 +460,9 @@ contract('ModuleRegistry', accounts => { startTime = latestTime() + duration.seconds(5000); endTime = startTime + duration.days(30); let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); - - tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 5000000 }); - + + tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 5000000 }); + assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[2].args._name) @@ -473,4 +473,4 @@ contract('ModuleRegistry', accounts => { }); }); - }); \ No newline at end of file + }); diff --git a/test/security_token.js b/test/security_token.js index 6acba8063..7f3de4428 100644 --- a/test/security_token.js +++ b/test/security_token.js @@ -38,7 +38,7 @@ contract('SecurityToken', accounts => { // investor Details let fromTime = latestTime(); let toTime = latestTime() + duration.days(100); - + let ID_snap; const message = "Transaction Should Fail!!"; @@ -119,7 +119,7 @@ contract('SecurityToken', accounts => { account_delegate = accounts[5]; account_temp = accounts[8]; token_owner = account_issuer; - + // ----------- POLYMATH NETWORK Configuration ------------ // STEP 1: Deploy the ModuleRegistry @@ -289,8 +289,8 @@ contract('SecurityToken', accounts => { startTime = latestTime() + duration.seconds(5000); endTime = startTime + duration.days(30); let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); - - const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, false, { from: token_owner, gas: 5000000 }); + + const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 5000000 }); assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( @@ -308,7 +308,7 @@ contract('SecurityToken', accounts => { let moduleData = await I_SecurityToken.getModule.call(stoKey, 0); assert.equal(web3.utils.toAscii(moduleData[0]).replace(/\u0000/g, ''), "CappedSTO"); assert.equal(moduleData[1], I_CappedSTO.address); - assert.isFalse(moduleData[2]); + assert.isTrue(moduleData[2]); }); it("Should fails in removing the module from the securityToken", async() => { @@ -339,7 +339,7 @@ contract('SecurityToken', accounts => { let key = await takeSnapshot(); let tx = await I_SecurityToken.removeModule(transferManagerKey, 0, { from : token_owner }); assert.equal(tx.logs[0].args._type, transferManagerKey); - assert.equal(tx.logs[0].args._module, I_GeneralTransferManager.address); + assert.equal(tx.logs[0].args._module, I_GeneralTransferManager.address); await revertToSnapshot(key); }); @@ -347,7 +347,7 @@ contract('SecurityToken', accounts => { let moduleData = await I_SecurityToken.getModule.call(transferManagerKey, 0); assert.equal(web3.utils.toAscii(moduleData[0]).replace(/\u0000/g, ''), "GeneralTransferManager"); assert.equal(moduleData[1], I_GeneralTransferManager.address); - assert.isTrue(moduleData[2]); + assert.isFalse(moduleData[2]); }); it("Should change the budget of the module", async() => { @@ -363,7 +363,7 @@ contract('SecurityToken', accounts => { it("Should Buy the tokens", async() => { balanceOfReceiver = await web3.eth.getBalance(account_fundsReceiver); // Add the Investor in to the whitelist - + let tx = await I_GeneralTransferManager.modifyWhitelist( account_investor1, fromTime, @@ -372,9 +372,9 @@ contract('SecurityToken', accounts => { from: account_issuer, gas: 500000 }); - + assert.equal(tx.logs[0].args._investor, account_investor1, "Failed in adding the investor in whitelist"); - + // Jump time await increaseTime(5000); // Fallback transaction @@ -384,16 +384,16 @@ contract('SecurityToken', accounts => { gas: 210000, value: web3.utils.toWei('1', 'ether') }); - + assert.equal( (await I_CappedSTO.fundsRaised.call()) .dividedBy(new BigNumber(10).pow(18)) .toNumber(), 1 ); - + assert.equal(await I_CappedSTO.getNumberInvestors.call(), 1); - + assert.equal( (await I_SecurityToken.balanceOf(account_investor1)) .dividedBy(new BigNumber(10).pow(18)) @@ -412,7 +412,7 @@ contract('SecurityToken', accounts => { ensureException(error); } assert.ok(errorThrown, message); - }); + }); it("Should fail to provide the permission to the delegate to change the transfer bools", async () => { let errorThrown = false; @@ -497,7 +497,7 @@ contract('SecurityToken', accounts => { from: account_issuer, gas: 500000 }); - + assert.equal(tx.logs[0].args._investor, account_investor2, "Failed in adding the investor in whitelist"); await I_SecurityToken.transfer(account_investor2, (10 * Math.pow(10, 18)), { from : account_investor1}); @@ -550,16 +550,16 @@ contract('SecurityToken', accounts => { gas: 210000, value: web3.utils.toWei('1', 'ether') }); - + assert.equal( (await I_CappedSTO.fundsRaised.call()) .dividedBy(new BigNumber(10).pow(18)) .toNumber(), 2 ); - + assert.equal(await I_CappedSTO.getNumberInvestors.call(), 2); - + assert.equal( (await I_SecurityToken.balanceOf(account_investor1)) .dividedBy(new BigNumber(10).pow(18)) @@ -596,10 +596,10 @@ contract('SecurityToken', accounts => { console.log(`non-whitelist investor is not allowed`); errorThrown = true; ensureException(error); - } + } assert.ok(errorThrown, message); }); }); - }); \ No newline at end of file + }); diff --git a/test/ticker_registry.js b/test/ticker_registry.js index 1e1037a67..3584ea18e 100644 --- a/test/ticker_registry.js +++ b/test/ticker_registry.js @@ -31,7 +31,7 @@ contract('TickerRegistry', accounts => { // investor Details let fromTime = latestTime(); let toTime = latestTime() + duration.days(100); - + let ID_snap; const message = "Transaction Should Fail!!"; @@ -70,14 +70,14 @@ contract('TickerRegistry', accounts => { let endTime; const cap = new BigNumber(10000).times(new BigNumber(10).pow(18)); const rate = 1000; - + before(async() => { // Accounts setup account_polymath = accounts[0]; account_issuer = accounts[1]; account_temp = accounts[8]; token_owner = account_issuer; - + // ----------- POLYMATH NETWORK Configuration ------------ // STEP 1: Deploy the ModuleRegistry @@ -176,7 +176,7 @@ contract('TickerRegistry', accounts => { }); describe("Test cases for the TickerRegistry public variable", async () => { - + it("verify the securityTokenRegistry address", async() => { let str = await I_TickerRegistry.strAddress.call(); assert.equal(str, I_SecurityTokenRegistry.address); @@ -189,7 +189,7 @@ contract('TickerRegistry', accounts => { }); describe("Test cases for the registerTicker function", async() => { - + it("Should fail in regestering the ticker due to the symbol length is 0", async() => { let errorThrown = false; try { @@ -242,7 +242,7 @@ contract('TickerRegistry', accounts => { }); describe("test cases for the expiry limit", async() => { - + it("Should fail to set the expiry limit because msg.sender is not owner", async() => { let errorThrown = false; try { @@ -254,7 +254,7 @@ contract('TickerRegistry', accounts => { } assert.ok(errorThrown, message); }); - + it("Should successfully set the expiry limit", async() => { await I_TickerRegistry.changeExpiryLimit(duration.days(10), {from: account_polymath}); assert.equal( @@ -278,7 +278,7 @@ contract('TickerRegistry', accounts => { }); describe("Test cases for the setTokenRegistry", async() => { - + it("Should fail to set the TokenRegistry", async() => { let errorThrown = false; try { @@ -303,7 +303,7 @@ contract('TickerRegistry', accounts => { .replace(/\u0000/g, ''), swarmHash ); - assert.equal(tx[4], false); + assert.equal(tx[4], false); }); }); @@ -321,4 +321,4 @@ contract('TickerRegistry', accounts => { assert.ok(errorThrown, message); }); }); -}); \ No newline at end of file +}); From 6194df6c3aa02ecee9c6674e1450cd1e53c3ed1f Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Mon, 9 Apr 2018 12:07:28 +0100 Subject: [PATCH 08/10] Add PolyToken to ModuleFactory constructor --- contracts/interfaces/IModuleFactory.sol | 4 +++ .../GeneralPermissionManagerFactory.sol | 8 +++++- contracts/modules/STO/CappedSTOFactory.sol | 8 +++++- contracts/modules/STO/DummySTOFactory.sol | 9 ++++++- .../ExchangeTransferManagerFactory.sol | 8 +++++- .../GeneralTransferManagerFactory.sol | 8 +++++- migrations/2_deploy_contracts.js | 8 +++--- test/Issuance.js | 21 ++++++++------- test/capped_sto.js | 24 ++++++++--------- test/exchange_transfer_manager.js | 26 +++++++++---------- test/module_registry.js | 20 +++++++------- test/security_token.js | 19 +++++++------- test/ticker_registry.js | 10 +++---- 13 files changed, 104 insertions(+), 69 deletions(-) diff --git a/contracts/interfaces/IModuleFactory.sol b/contracts/interfaces/IModuleFactory.sol index 46da5663e..e9ef7fa4b 100644 --- a/contracts/interfaces/IModuleFactory.sol +++ b/contracts/interfaces/IModuleFactory.sol @@ -9,6 +9,10 @@ contract IModuleFactory is Ownable { ERC20 public polyToken; + function IModuleFactory(address _polyAddress) public { + polyToken = ERC20(_polyAddress); + } + //Should create an instance of the Module, or throw function deploy(bytes _data) external returns(address); diff --git a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol index 46d9dcfae..558c78e7f 100644 --- a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol +++ b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol"; contract GeneralPermissionManagerFactory is IModuleFactory { + function GeneralPermissionManagerFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + function deploy(bytes /* _data */) external returns(address) { - //polyToken.transferFrom(msg.sender, owner, getCost()); + polyToken.transferFrom(msg.sender, owner, getCost()); return address(new GeneralPermissionManager(msg.sender)); } diff --git a/contracts/modules/STO/CappedSTOFactory.sol b/contracts/modules/STO/CappedSTOFactory.sol index 0491a9e91..ded1f51b3 100644 --- a/contracts/modules/STO/CappedSTOFactory.sol +++ b/contracts/modules/STO/CappedSTOFactory.sol @@ -7,8 +7,14 @@ import "../../interfaces/IModule.sol"; contract CappedSTOFactory is IModuleFactory { + function CappedSTOFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + function deploy(bytes _data) external returns(address) { - //polyToken.transferFrom(msg.sender, owner, getCost()); + polyToken.transferFrom(msg.sender, owner, getCost()); //Check valid bytes - can only call module init function CappedSTO cappedSTO = new CappedSTO(msg.sender); //Checks that _data is valid (not calling anything it shouldn't) diff --git a/contracts/modules/STO/DummySTOFactory.sol b/contracts/modules/STO/DummySTOFactory.sol index 07bf93223..dc66ecc98 100644 --- a/contracts/modules/STO/DummySTOFactory.sol +++ b/contracts/modules/STO/DummySTOFactory.sol @@ -7,8 +7,15 @@ import "../../interfaces/IModule.sol"; contract DummySTOFactory is IModuleFactory { + function DummySTOFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + + function deploy(bytes _data) external returns(address) { - //polyToken.transferFrom(msg.sender, owner, getCost()); + polyToken.transferFrom(msg.sender, owner, getCost()); //Check valid bytes - can only call module init function DummySTO dummySTO = new DummySTO(msg.sender); //Checks that _data is valid (not calling anything it shouldn't) diff --git a/contracts/modules/TransferManager/ExchangeTransferManagerFactory.sol b/contracts/modules/TransferManager/ExchangeTransferManagerFactory.sol index 09d0a2103..dd28dd9f9 100644 --- a/contracts/modules/TransferManager/ExchangeTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/ExchangeTransferManagerFactory.sol @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol"; contract ExchangeTransferManagerFactory is IModuleFactory { + function ExchangeTransferManagerFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + function deploy(bytes _data) external returns(address) { - //polyToken.transferFrom(msg.sender, owner, getCost()); + polyToken.transferFrom(msg.sender, owner, getCost()); ExchangeTransferManager exchangeTransferManager = new ExchangeTransferManager(msg.sender); require(getSig(_data) == exchangeTransferManager.getInitFunction()); require(address(exchangeTransferManager).call(_data)); diff --git a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol index d8f1427e4..f6623f9bd 100644 --- a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol @@ -6,8 +6,14 @@ import "../../interfaces/IModuleFactory.sol"; contract GeneralTransferManagerFactory is IModuleFactory { + function GeneralTransferManagerFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + function deploy(bytes /* _data */) external returns(address) { - //polyToken.transferFrom(msg.sender, owner, getCost()); + polyToken.transferFrom(msg.sender, owner, getCost()); return address(new GeneralTransferManager(msg.sender)); } diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 4f65cb357..149f7d675 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -37,10 +37,10 @@ module.exports = async (deployer, network, accounts) => { // A) POLYMATH NETWORK Configuration :: DO THIS ONLY ONCE // 1. Deploy Registry, Transfer Manager, Permission Manager, (temp) PolyToken - await deployer.deploy(ModuleRegistry, {from: PolymathAccount}); - await deployer.deploy(GeneralTransferManagerFactory, {from: PolymathAccount}); - await deployer.deploy(GeneralPermissionManagerFactory, {from: PolymathAccount}); await deployer.deploy(PolyToken, {from: PolymathAccount}); + await deployer.deploy(ModuleRegistry, {from: PolymathAccount}); + await deployer.deploy(GeneralTransferManagerFactory, PolyToken.address, {from: PolymathAccount}); + await deployer.deploy(GeneralPermissionManagerFactory, PolyToken.address, {from: PolymathAccount}); // 2. Register the Transfer Manager module let moduleRegistry = await ModuleRegistry.deployed(); @@ -62,7 +62,7 @@ module.exports = async (deployer, network, accounts) => { await moduleRegistry.setTokenRegistry(SecurityTokenRegistry.address, {from: PolymathAccount}); // B) DEPLOY STO factories and register them with the Registry - await deployer.deploy(CappedSTOFactory, {from: PolymathAccount}); + await deployer.deploy(CappedSTOFactory, PolyToken.address, {from: PolymathAccount}); let cappedSTOFactory = await CappedSTOFactory.deployed(); await moduleRegistry.registerModule(cappedSTOFactory.address, {from: PolymathAccount}); diff --git a/test/Issuance.js b/test/Issuance.js index c1dfa88e9..882f9434b 100644 --- a/test/Issuance.js +++ b/test/Issuance.js @@ -115,6 +115,9 @@ contract('SecurityToken', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -127,7 +130,7 @@ contract('SecurityToken', accounts => { // STEP 2: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -137,7 +140,7 @@ contract('SecurityToken', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -147,7 +150,7 @@ contract('SecurityToken', accounts => { // STEP 4: Deploy the CappedSTOFactory - I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: token_owner }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -188,8 +191,6 @@ contract('SecurityToken', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); // Step 8: Deploy the SecurityTokenRegistry @@ -283,7 +284,7 @@ contract('SecurityToken', accounts => { it("POLYMATH: Should successfully attach the STO factory with the security token", async () => { // STEP 4: Deploy the CappedSTOFactory - I_CappedSTOFactory = await CappedSTOFactory.new({ from: account_polymath }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: account_polymath }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -297,15 +298,15 @@ contract('SecurityToken', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [(latestTime() + duration.seconds(5000)), (latestTime() + duration.days(30)), cap, rate, fundRaiseType, I_PolyToken.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(tx.logs[3].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "CappedSTO", "CappedSTOFactory module was not added" ); - I_CappedSTO = CappedSTO.at(tx.logs[2].args._module); + I_CappedSTO = CappedSTO.at(tx.logs[3].args._module); }); }); diff --git a/test/capped_sto.js b/test/capped_sto.js index 5938dfc69..718765411 100644 --- a/test/capped_sto.js +++ b/test/capped_sto.js @@ -121,6 +121,9 @@ contract('CappedSTO', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -133,7 +136,7 @@ contract('CappedSTO', accounts => { // STEP 2: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -143,7 +146,7 @@ contract('CappedSTO', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -153,7 +156,7 @@ contract('CappedSTO', accounts => { // STEP 4: Deploy the CappedSTOFactory - I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: token_owner }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -194,9 +197,6 @@ contract('CappedSTO', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); - // Step 8: Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( @@ -328,14 +328,14 @@ contract('CappedSTO', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); - assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); + assert.equal(tx.logs[3].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "CappedSTO", "CappedSTOFactory module was not added" ); - I_CappedSTO = CappedSTO.at(tx.logs[2].args._module); + I_CappedSTO = CappedSTO.at(tx.logs[3].args._module); }); }); @@ -601,14 +601,14 @@ contract('CappedSTO', accounts => { const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 2500000 }); - assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); + assert.equal(tx.logs[3].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "CappedSTO", "CappedSTOFactory module was not added" ); - I_CappedSTO = CappedSTO.at(tx.logs[2].args._module); + I_CappedSTO = CappedSTO.at(tx.logs[3].args._module); }); }); diff --git a/test/exchange_transfer_manager.js b/test/exchange_transfer_manager.js index 53b18a8e2..8ec3f0c38 100644 --- a/test/exchange_transfer_manager.js +++ b/test/exchange_transfer_manager.js @@ -101,6 +101,9 @@ contract('ExchangeTransferManager', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -113,7 +116,7 @@ contract('ExchangeTransferManager', accounts => { // STEP 2a: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -123,7 +126,7 @@ contract('ExchangeTransferManager', accounts => { // STEP 2b: Deploy the ExchangeTransferManagerFactory - I_ExchangeTransferManagerFactory = await ExchangeTransferManagerFactory.new({from:account_polymath}); + I_ExchangeTransferManagerFactory = await ExchangeTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_ExchangeTransferManagerFactory.address.valueOf(), @@ -133,7 +136,7 @@ contract('ExchangeTransferManager', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -143,7 +146,7 @@ contract('ExchangeTransferManager', accounts => { // STEP 4: Deploy the DummySTOFactory - I_DummySTOFactory = await DummySTOFactory.new({from:account_polymath}); + I_DummySTOFactory = await DummySTOFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_DummySTOFactory.address.valueOf(), @@ -189,9 +192,6 @@ contract('ExchangeTransferManager', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); - // Step 8: Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( @@ -279,14 +279,14 @@ contract('ExchangeTransferManager', accounts => { it("Should successfully attach the STO factory with the security token", async () => { const tx = await I_SecurityToken.addModule(I_DummySTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner }); - assert.equal(tx.logs[2].args._type.toNumber(), stoKey, "DummySTO doesn't get deployed"); + assert.equal(tx.logs[3].args._type.toNumber(), stoKey, "DummySTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "DummySTO", "DummySTOFactory module was not added" ); - I_DummySTO = DummySTO.at(tx.logs[2].args._module); + I_DummySTO = DummySTO.at(tx.logs[3].args._module); }); }); @@ -346,14 +346,14 @@ contract('ExchangeTransferManager', accounts => { }, [account_exchange]); const tx = await I_SecurityToken.addModule(I_ExchangeTransferManagerFactory.address, bytesExchange, 0, 0, true, { from: token_owner }); - assert.equal(tx.logs[2].args._type.toNumber(), transferManagerKey, "ExchangeTransferManager doesn't get deployed"); + assert.equal(tx.logs[3].args._type.toNumber(), transferManagerKey, "ExchangeTransferManager doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "ExchangeTransferManager", "ExchangeTransferManager module was not added" ); - I_ExchangeTransferManager = ExchangeTransferManager.at(tx.logs[2].args._module); + I_ExchangeTransferManager = ExchangeTransferManager.at(tx.logs[3].args._module); // Add exchange address to General Transfer Manager whitelist diff --git a/test/module_registry.js b/test/module_registry.js index 07ea3ceaa..179dbf14f 100644 --- a/test/module_registry.js +++ b/test/module_registry.js @@ -122,6 +122,9 @@ contract('ModuleRegistry', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -144,9 +147,6 @@ contract('ModuleRegistry', accounts => { // Step 7: Deploy the STversionProxy contract - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); - // Step 9: Deploy the token Faucet I_PolyFaucet = await PolyTokenFaucet.new(); @@ -161,7 +161,7 @@ contract('ModuleRegistry', accounts => { it("Should successfully deployed the Module Fatories", async () => { - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -170,7 +170,7 @@ contract('ModuleRegistry', accounts => { ); - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -179,7 +179,7 @@ contract('ModuleRegistry', accounts => { ); - I_CappedSTOFactory = await CappedSTOFactory.new({ from: account_polymath }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: account_polymath }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -187,7 +187,7 @@ contract('ModuleRegistry', accounts => { "CappedSTOFactory contract was not deployed" ); - I_DummySTOFactory = await DummySTOFactory.new({ from: account_temp }); + I_DummySTOFactory = await DummySTOFactory.new(I_PolyToken.address, { from: account_temp }); assert.notEqual( I_DummySTOFactory.address.valueOf(), @@ -439,7 +439,7 @@ contract('ModuleRegistry', accounts => { }); it("Should successfully add the CappedSTO module. Because module is deployed by the owner of ST", async() => { - I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: token_owner }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -463,9 +463,9 @@ contract('ModuleRegistry', accounts => { tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 5000000 }); - assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); + assert.equal(tx.logs[3].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "CappedSTO", "CappedSTOFactory module was not added" diff --git a/test/security_token.js b/test/security_token.js index 7f3de4428..2ce0b9ae4 100644 --- a/test/security_token.js +++ b/test/security_token.js @@ -122,6 +122,9 @@ contract('SecurityToken', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -134,7 +137,7 @@ contract('SecurityToken', accounts => { // STEP 2: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -144,7 +147,7 @@ contract('SecurityToken', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -154,7 +157,7 @@ contract('SecurityToken', accounts => { // STEP 4: Deploy the CappedSTOFactory - I_CappedSTOFactory = await CappedSTOFactory.new({ from: token_owner }); + I_CappedSTOFactory = await CappedSTOFactory.new(I_PolyToken.address, { from: token_owner }); assert.notEqual( I_CappedSTOFactory.address.valueOf(), @@ -195,9 +198,6 @@ contract('SecurityToken', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); - // Step 8: Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( @@ -291,15 +291,14 @@ contract('SecurityToken', accounts => { let bytesSTO = web3.eth.abi.encodeFunctionCall(functionSignature, [startTime, endTime, cap, rate, fundRaiseType, I_PolyToken.address, account_fundsReceiver]); const tx = await I_SecurityToken.addModule(I_CappedSTOFactory.address, bytesSTO, 0, 0, true, { from: token_owner, gas: 5000000 }); - - assert.equal(tx.logs[2].args._type, stoKey, "CappedSTO doesn't get deployed"); + assert.equal(tx.logs[3].args._type, stoKey, "CappedSTO doesn't get deployed"); assert.equal( - web3.utils.toAscii(tx.logs[2].args._name) + web3.utils.toAscii(tx.logs[3].args._name) .replace(/\u0000/g, ''), "CappedSTO", "CappedSTOFactory module was not added" ); - I_CappedSTO = CappedSTO.at(tx.logs[2].args._module); + I_CappedSTO = CappedSTO.at(tx.logs[3].args._module); }); }); diff --git a/test/ticker_registry.js b/test/ticker_registry.js index 3584ea18e..579f45cb2 100644 --- a/test/ticker_registry.js +++ b/test/ticker_registry.js @@ -80,6 +80,9 @@ contract('TickerRegistry', accounts => { // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -92,7 +95,7 @@ contract('TickerRegistry', accounts => { // STEP 2: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -102,7 +105,7 @@ contract('TickerRegistry', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -140,9 +143,6 @@ contract('TickerRegistry', accounts => { "STVersion contract was not deployed", ); - // Step ANY: Deploy the Polytoken Contract - I_PolyToken = await PolyToken.new(); - // Step 8: Deploy the SecurityTokenRegistry I_SecurityTokenRegistry = await SecurityTokenRegistry.new( From 450b0cbbe6b69235739f08b970f9f6e11ae5abaa Mon Sep 17 00:00:00 2001 From: Pablo Ruiz Date: Mon, 9 Apr 2018 08:29:24 -0300 Subject: [PATCH 09/10] updated travis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ec7312a4..aca885df5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/PolymathNetwork/polymath-core.svg?token=rqsL7PsbwLxrskjYAHpq&branch=master)](https://travis-ci.com/PolymathNetwork/polymath-core) +[![Build Status](https://travis-ci.org/PolymathNetwork/polymath-core.svg?branch=master)](https://travis-ci.org/PolymathNetwork/polymath-core) ![Polymath](Polymath.png) From 8537cedd3542337bff6762fc1481c7fcb121cd22 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Mon, 9 Apr 2018 13:30:03 +0100 Subject: [PATCH 10/10] Fix test case --- test/helpers/contracts/TestSTOFactory.sol | 6 +++++ test/security_token_registry.js | 32 +++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/test/helpers/contracts/TestSTOFactory.sol b/test/helpers/contracts/TestSTOFactory.sol index 73fd3093e..c6a269572 100644 --- a/test/helpers/contracts/TestSTOFactory.sol +++ b/test/helpers/contracts/TestSTOFactory.sol @@ -7,6 +7,12 @@ import "../../../contracts/interfaces/IModule.sol"; contract TestSTOFactory is IModuleFactory { + function TestSTOFactory(address _polyAddress) public + IModuleFactory(_polyAddress) + { + + } + function deploy(bytes _data) external returns(address) { //polyToken.transferFrom(msg.sender, owner, getCost()); //Check valid bytes - can only call module init function diff --git a/test/security_token_registry.js b/test/security_token_registry.js index 9f3bab6ec..ee303a9c1 100644 --- a/test/security_token_registry.js +++ b/test/security_token_registry.js @@ -14,6 +14,7 @@ const GeneralPermissionManagerFactory = artifacts.require('./GeneralPermissionMa const GeneralTransferManagerFactory = artifacts.require('./GeneralTransferManagerFactory.sol'); const GeneralTransferManager = artifacts.require('./GeneralTransferManager'); const GeneralPermissionManager = artifacts.require('./GeneralPermissionManager'); +const PolyToken = artifacts.require('./PolyToken.sol'); const PolyTokenFaucet = artifacts.require('./helpers/contracts/PolyTokenFaucet.sol'); const Web3 = require('web3'); @@ -38,7 +39,7 @@ contract('SecurityTokenRegistry', accounts => { // investor Details let fromTime = latestTime(); let toTime = latestTime() + duration.days(100); - + let ID_snap; const message = "Transaction Should Fail!!"; @@ -71,7 +72,7 @@ contract('SecurityTokenRegistry', accounts => { const name2 = "Demo2 Token"; const symbol2 = "DET2"; const tokenDetails2 = "This is equity type of issuance"; - + // Module key const permissionManagerKey = 1; const transferManagerKey = 2; @@ -97,7 +98,7 @@ contract('SecurityTokenRegistry', accounts => { type: 'string', name: '_someString' }] - }; + }; before(async() => { // Accounts setup @@ -109,9 +110,12 @@ contract('SecurityTokenRegistry', accounts => { account_delegate = accounts[5]; account_temp = accounts[8]; token_owner = account_issuer; - + // ----------- POLYMATH NETWORK Configuration ------------ + // Step 0: Deploy the Polytoken Contract + I_PolyToken = await PolyToken.new(); + // STEP 1: Deploy the ModuleRegistry I_ModuleRegistry = await ModuleRegistry.new({from:account_polymath}); @@ -124,7 +128,7 @@ contract('SecurityTokenRegistry', accounts => { // STEP 2: Deploy the GeneralTransferManagerFactory - I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new({from:account_polymath}); + I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralTransferManagerFactory.address.valueOf(), @@ -134,7 +138,7 @@ contract('SecurityTokenRegistry', accounts => { // STEP 3: Deploy the GeneralDelegateManagerFactory - I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new({from:account_polymath}); + I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory.new(I_PolyToken.address, {from:account_polymath}); assert.notEqual( I_GeneralPermissionManagerFactory.address.valueOf(), @@ -144,7 +148,7 @@ contract('SecurityTokenRegistry', accounts => { // STEP 4: Deploy the CappedSTOFactory - I_TestSTOFactory = await TestSTOFactory.new({ from: token_owner }); + I_TestSTOFactory = await TestSTOFactory.new(I_PolyToken.address, { from: token_owner }); assert.notEqual( I_TestSTOFactory.address.valueOf(), @@ -209,7 +213,7 @@ contract('SecurityTokenRegistry', accounts => { await I_TickerRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); await I_ModuleRegistry.setTokenRegistry(I_SecurityTokenRegistry.address, {from: account_polymath}); - + // Printing all the contract addresses console.log(`\nPolymath Network Smart Contracts Deployed:\n @@ -353,16 +357,16 @@ contract('SecurityTokenRegistry', accounts => { it("Should intialize the auto attached modules", async () => { let moduleData = await I_SecurityToken.modules(transferManagerKey, 0); I_GeneralTransferManager = GeneralTransferManager.at(moduleData[1]); - + assert.notEqual( I_GeneralTransferManager.address.valueOf(), "0x0000000000000000000000000000000000000000", "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", @@ -386,9 +390,9 @@ contract('SecurityTokenRegistry', accounts => { (1000 * Math.pow(10, 18)), (1000 * Math.pow(10, 18)), false, - { + { from: token_owner, - gas: 2500000 + gas: 2500000 }); assert.equal(tx.logs[2].args._type, stoKey, "TestSTO doesn't get deployed"); @@ -404,4 +408,4 @@ contract('SecurityTokenRegistry', accounts => { -}); \ No newline at end of file +});