From dd39b51640793bf035733c4aea6164c64181fcd5 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 8 Jan 2019 17:47:38 -0300 Subject: [PATCH 01/14] 'succesfully' typo --- CLI/commands/permission_manager.js | 52 +- ...kup_volume_restriction_transfer_manager.js | 134 ++--- test/y_volume_restriction_tm.js | 520 +++++++++--------- 3 files changed, 353 insertions(+), 353 deletions(-) diff --git a/CLI/commands/permission_manager.js b/CLI/commands/permission_manager.js index ef3e2ea60..71ee21198 100644 --- a/CLI/commands/permission_manager.js +++ b/CLI/commands/permission_manager.js @@ -32,7 +32,7 @@ async function executeApp() { } }; -async function setup(){ +async function setup() { try { let securityTokenRegistryAddress = await contracts.securityTokenRegistry(); let securityTokenRegistryABI = abis.securityTokenRegistry(); @@ -40,7 +40,7 @@ async function setup(){ securityTokenRegistry.setProvider(web3.currentProvider); } catch (err) { console.log(err) - console.log('\x1b[31m%s\x1b[0m',"There was a problem getting the contracts. Make sure they are deployed to the selected network."); + console.log('\x1b[31m%s\x1b[0m', "There was a problem getting the contracts. Make sure they are deployed to the selected network."); process.exit(0); } } @@ -56,7 +56,7 @@ async function selectST() { await selectST(); } else { let securityTokenABI = abis.securityToken(); - securityToken = new web3.eth.Contract(securityTokenABI,result); + securityToken = new web3.eth.Contract(securityTokenABI, result); } } @@ -85,13 +85,13 @@ async function addPermissionModule() { } async function changePermissionStep() { - console.log('\n\x1b[34m%s\x1b[0m',"Permission Manager - Change Permission"); + console.log('\n\x1b[34m%s\x1b[0m', "Permission Manager - Change Permission"); let selectedDelegate = await selectDelegate(); if (isNewDelegate) { isNewDelegate = false; changePermissionAction(selectedDelegate); } else { - let selectFlow = readlineSync.keyInSelect(['Remove', 'Change permission'], 'Select an option:', {cancel: false}); + let selectFlow = readlineSync.keyInSelect(['Remove', 'Change permission'], 'Select an option:', { cancel: false }); if (selectFlow == 0) { await deleteDelegate(selectedDelegate); console.log("Delegate successfully deleted.") @@ -110,7 +110,7 @@ async function changePermissionAction(selectedDelegate) { async function deleteDelegate(address) { let deleteDelegateAction = generalPermissionManager.methods.deleteDelegate(address); - await common.sendTransaction(deleteDelegateAction, {factor: 2}); + await common.sendTransaction(deleteDelegateAction, { factor: 2 }); } // Helper functions @@ -118,10 +118,10 @@ async function selectDelegate() { let result; let delegates = await getDelegates(); let permissions = await getDelegatesAndPermissions(); - + let options = ['Add new delegate']; - options = options.concat(delegates.map(function(d) { + options = options.concat(delegates.map(function (d) { let perm = renderTable(permissions, d.address); return `Account: ${d.address} @@ -129,7 +129,7 @@ async function selectDelegate() { Permisions: ${perm}` })); - let index = readlineSync.keyInSelect(options, 'Select a delegate:', {cancel: false}); + let index = readlineSync.keyInSelect(options, 'Select a delegate:', { cancel: false }); if (index == 0) { let newDelegate = await addNewDelegate(); result = newDelegate; @@ -142,32 +142,32 @@ async function selectDelegate() { async function selectModule() { let modules = await getModulesWithPermissions(); - let options = modules.map(function(m) { + let options = modules.map(function (m) { return m.name; }); - let index = readlineSync.keyInSelect(options, 'Select a module:', {cancel: false}); + let index = readlineSync.keyInSelect(options, 'Select a module:', { cancel: false }); return modules[index]; } async function selectPermission(permissions) { - let options = permissions.map(function(p) { + let options = permissions.map(function (p) { return p }); - let index = readlineSync.keyInSelect(options, 'Select a permission:', {cancel: false}); + let index = readlineSync.keyInSelect(options, 'Select a permission:', { cancel: false }); return permissions[index]; } function isPermissionValid() { let options = ['Grant permission', 'Revoke permission']; - let index = readlineSync.keyInSelect(options, 'What do you want to do?', {cancel: false}); + let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: false }); return index == 0; } async function changePermission(delegate, moduleAddress, permission, isValid) { let changePermissionAction = generalPermissionManager.methods.changePermission(delegate, moduleAddress, web3.utils.asciiToHex(permission), isValid); - let receipt = await common.sendTransaction(changePermissionAction, {factor: 2}); + let receipt = await common.sendTransaction(changePermissionAction, { factor: 2 }); common.getEventFromLogs(generalPermissionManager._jsonInterface, receipt.logs, 'ChangePermission'); - console.log(`Permission changed succesfully,`); + console.log(`Permission changed successfully!`); } async function getDelegates() { @@ -199,7 +199,7 @@ async function addNewDelegate() { limitMessage: "Must be a valid address" }); let details = readlineSync.question('Enter the delegate details (i.e `Belongs to financial firm`): ', { - limit: function(input) { + limit: function (input) { return input.length > 0; }, limitMessage: "Must be a valid string" @@ -208,7 +208,7 @@ async function addNewDelegate() { let addPermissionAction = generalPermissionManager.methods.addDelegate(newDelegate, web3.utils.asciiToHex(details)); let receipt = await common.sendTransaction(addPermissionAction); let event = common.getEventFromLogs(generalPermissionManager._jsonInterface, receipt.logs, 'AddDelegate'); - console.log(`Delegate added succesfully: ${event._delegate} - ${web3.utils.hexToAscii(event._details)}`); + console.log(`Delegate added successfully: ${event._delegate} - ${web3.utils.hexToAscii(event._details)}`); isNewDelegate = true; return event._delegate; } @@ -216,14 +216,14 @@ async function addNewDelegate() { async function getModulesWithPermissions() { let modules = []; let moduleABI = abis.moduleInterface(); - + for (const type in gbl.constants.MODULES_TYPES) { let modulesAttached = await securityToken.methods.getModulesByType(gbl.constants.MODULES_TYPES[type]).call(); for (const m of modulesAttached) { let contractTemp = new web3.eth.Contract(moduleABI, m); let permissions = await contractTemp.methods.getPermissions().call(); if (permissions.length > 0) { - modules.push({ + modules.push({ name: web3.utils.hexToAscii((await securityToken.methods.getModule(m).call())[0]), address: m, permissions: permissions.map(function (p) { return web3.utils.hexToAscii(p) }) @@ -251,11 +251,11 @@ async function getDelegatesAndPermissions() { for (delegateAddr of allDelegates) { if (result[delegateAddr] == undefined) { result[delegateAddr] = [] - } + } if (result[delegateAddr][moduleName + '-' + module] == undefined) { - result[delegateAddr][moduleName + '-' + module] = [{permission: permissionName}] + result[delegateAddr][moduleName + '-' + module] = [{ permission: permissionName }] } else { - result[delegateAddr][moduleName + '-' + module].push({permission: permissionName}) + result[delegateAddr][moduleName + '-' + module].push({ permission: permissionName }) } } } @@ -283,7 +283,7 @@ function renderTable(permissions, address) { } module.exports = { - executeApp: async function() { - return executeApp(); - } + executeApp: async function () { + return executeApp(); + } } \ No newline at end of file diff --git a/test/w_lockup_volume_restriction_transfer_manager.js b/test/w_lockup_volume_restriction_transfer_manager.js index 358e5b702..9d8a429a9 100644 --- a/test/w_lockup_volume_restriction_transfer_manager.js +++ b/test/w_lockup_volume_restriction_transfer_manager.js @@ -67,7 +67,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { // Initial fee for ticker registry and security token registry const initRegFee = web3.utils.toWei("250"); - before(async() => { + before(async () => { // Accounts setup account_polymath = accounts[0]; account_issuer = accounts[1]; @@ -118,11 +118,11 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { `); }); - describe("Generate the SecurityToken", async() => { + describe("Generate the SecurityToken", async () => { it("Should register the ticker before the generation of the security token", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from : token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, symbol, contact, { from: token_owner }); assert.equal(tx.logs[0].args._owner, token_owner); assert.equal(tx.logs[0].args._ticker, symbol.toUpperCase()); }); @@ -137,27 +137,27 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); - const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({from: _blockNo}), 1); + const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); // Verify that GeneralTransferManager module get added successfully or not assert.equal(log.args._types[0].toNumber(), 2); assert.equal( web3.utils.toAscii(log.args._name) - .replace(/\u0000/g, ''), + .replace(/\u0000/g, ''), "GeneralTransferManager" ); }); it("Should intialize the auto attached modules", async () => { - let moduleData = (await I_SecurityToken.getModulesByType(2))[0]; - I_GeneralTransferManager = GeneralTransferManager.at(moduleData); + let moduleData = (await I_SecurityToken.getModulesByType(2))[0]; + I_GeneralTransferManager = GeneralTransferManager.at(moduleData); }); }); - describe("Buy tokens using on-chain whitelist and test locking them up and attempting to transfer", async() => { + describe("Buy tokens using on-chain whitelist and test locking them up and attempting to transfer", async () => { - it("Should Buy the tokens", async() => { + it("Should Buy the tokens", async () => { // Add the Investor in to the whitelist let tx = await I_GeneralTransferManager.modifyWhitelist( @@ -184,7 +184,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should Buy some more tokens", async() => { + it("Should Buy some more tokens", async () => { // Add the Investor in to the whitelist let tx = await I_GeneralTransferManager.modifyWhitelist( @@ -211,18 +211,18 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { it("Should unsuccessfully attach the VolumeRestrictionTransferManager factory with the security token -- failed because Token is not paid", async () => { await I_PolyToken.getTokens(web3.utils.toWei("500", "ether"), token_owner); await catchRevert( - I_SecurityToken.addModule(P_VolumeRestrictionTransferManagerFactory.address, 0, web3.utils.toWei("500", "ether"), 0, { from: token_owner }) + I_SecurityToken.addModule(P_VolumeRestrictionTransferManagerFactory.address, 0, web3.utils.toWei("500", "ether"), 0, { from: token_owner }) ) }); it("Should successfully attach the VolumeRestrictionTransferManager factory with the security token", async () => { let snapId = await takeSnapshot(); - await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), {from: token_owner}); + await I_PolyToken.transfer(I_SecurityToken.address, web3.utils.toWei("500", "ether"), { from: token_owner }); const tx = await I_SecurityToken.addModule(P_VolumeRestrictionTransferManagerFactory.address, 0, web3.utils.toWei("500", "ether"), 0, { from: token_owner }); assert.equal(tx.logs[3].args._types[0].toNumber(), transferManagerKey, "VolumeRestrictionTransferManagerFactory doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[3].args._name) - .replace(/\u0000/g, ''), + .replace(/\u0000/g, ''), "LockupVolumeRestrictionTM", "VolumeRestrictionTransferManagerFactory module was not added" ); @@ -235,14 +235,14 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { assert.equal(tx.logs[2].args._types[0].toNumber(), transferManagerKey, "VolumeRestrictionTransferManager doesn't get deployed"); assert.equal( web3.utils.toAscii(tx.logs[2].args._name) - .replace(/\u0000/g, ''), + .replace(/\u0000/g, ''), "LockupVolumeRestrictionTM", "VolumeRestrictionTransferManager module was not added" ); I_VolumeRestrictionTransferManager = VolumeRestrictionTransferManager.at(tx.logs[2].args._module); }); - it("Add a new token holder", async() => { + it("Add a new token holder", async () => { let tx = await I_GeneralTransferManager.modifyWhitelist( account_investor3, @@ -266,11 +266,11 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should pause the tranfers at transferManager level", async() => { - let tx = await I_VolumeRestrictionTransferManager.pause({from: token_owner}); + it("Should pause the tranfers at transferManager level", async () => { + let tx = await I_VolumeRestrictionTransferManager.pause({ from: token_owner }); }); - it("Should still be able to transfer between existing token holders up to limit", async() => { + it("Should still be able to transfer between existing token holders up to limit", async () => { // Add the Investor in to the whitelist // Mint some tokens await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('1', 'ether'), { from: account_investor2 }); @@ -281,11 +281,11 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should unpause the tranfers at transferManager level", async() => { - await I_VolumeRestrictionTransferManager.unpause({from: token_owner}); + it("Should unpause the tranfers at transferManager level", async () => { + await I_VolumeRestrictionTransferManager.unpause({ from: token_owner }); }); - it("Should prevent the creation of a lockup with bad parameters where the totalAmount is zero", async() => { + it("Should prevent the creation of a lockup with bad parameters where the totalAmount is zero", async () => { // create a lockup // this will generate an exception because the totalAmount is zero await catchRevert( @@ -293,7 +293,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ) }); - it("Should prevent the creation of a lockup with bad parameters where the releaseFrequencySeconds is zero", async() => { + it("Should prevent the creation of a lockup with bad parameters where the releaseFrequencySeconds is zero", async () => { // create a lockup // this will generate an exception because the releaseFrequencySeconds is zero await catchRevert( @@ -301,7 +301,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should prevent the creation of a lockup with bad parameters where the lockUpPeriodSeconds is zero", async() => { + it("Should prevent the creation of a lockup with bad parameters where the lockUpPeriodSeconds is zero", async () => { // create a lockup // this will generate an exception because the lockUpPeriodSeconds is zero await catchRevert( @@ -310,7 +310,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should prevent the creation of a lockup with bad parameters where the total amount to be released is more granular than allowed by the token", async() => { + it("Should prevent the creation of a lockup with bad parameters where the total amount to be released is more granular than allowed by the token", async () => { // create a lockup // this will generate an exception because we're locking up 5e17 tokens but the granularity is 5e18 tokens await catchRevert( @@ -318,7 +318,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should prevent the creation of a lockup with bad parameters where the lockUpPeriodSeconds is not evenly divisible by releaseFrequencySeconds", async() => { + it("Should prevent the creation of a lockup with bad parameters where the lockUpPeriodSeconds is not evenly divisible by releaseFrequencySeconds", async () => { // balance should be 9000000000000000000 here (9 eth) let balance = await I_SecurityToken.balanceOf(account_investor2) @@ -332,7 +332,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should prevent the creation of a lockup with bad parameters where the total amount being locked up isn't evenly divisible by the number of total periods", async() => { + it("Should prevent the creation of a lockup with bad parameters where the total amount being locked up isn't evenly divisible by the number of total periods", async () => { // create a lockup for a balance of 1 eth // over 16e18 seconds total, with 4e18 periods of 4 seconds each. @@ -342,7 +342,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should prevent the creation of a lockup with bad parameters where the amount to be released per period is too granular for the token", async() => { + it("Should prevent the creation of a lockup with bad parameters where the amount to be released per period is too granular for the token", async () => { // balance should be 9000000000000000000 here (9 eth) let balance = await I_SecurityToken.balanceOf(account_investor2) @@ -356,7 +356,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should prevent the transfer of tokens in a lockup", async() => { + it("Should prevent the transfer of tokens in a lockup", async () => { let balance = await I_SecurityToken.balanceOf(account_investor2) console.log("balance", balance.dividedBy(new BigNumber(1).times(new BigNumber(10).pow(18))).toNumber()); @@ -374,7 +374,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should allow the transfer of tokens in a lockup if a period has passed", async() => { + it("Should allow the transfer of tokens in a lockup if a period has passed", async () => { // wait 4 seconds await increaseTime(duration.seconds(4)); @@ -382,14 +382,14 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('3', 'ether'), { from: account_investor2 }); }); - it("Should prevent the transfer of tokens if the amount is larger than the amount allowed by lockups", async() => { + it("Should prevent the transfer of tokens if the amount is larger than the amount allowed by lockups", async () => { await catchRevert( I_SecurityToken.transfer(account_investor1, web3.utils.toWei('4', 'ether'), { from: account_investor2 }) ); }); - it("Should allow the transfer of more tokens in a lockup if another period has passed", async() => { + it("Should allow the transfer of more tokens in a lockup if another period has passed", async () => { // wait 4 more seconds await increaseTime(4000); @@ -397,7 +397,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { await I_SecurityToken.transfer(account_investor1, web3.utils.toWei('3', 'ether'), { from: account_investor2 }); }); - it("Should allow the transfer of all tokens in a lockup if the entire lockup has passed", async() => { + it("Should allow the transfer of all tokens in a lockup if the entire lockup has passed", async () => { let balance = await I_SecurityToken.balanceOf(account_investor2) @@ -407,7 +407,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { await I_SecurityToken.transfer(account_investor1, balance, { from: account_investor2 }); }); - it("Should prevent the transfer of tokens in an edited lockup", async() => { + it("Should prevent the transfer of tokens in an edited lockup", async () => { // balance here should be 12000000000000000000 (12e18 or 12 eth) @@ -453,7 +453,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should succesfully modify the lockup - fail because array index out of bound", async() => { + it("Should successfully modify the lockup - fail because array index out of bound", async () => { // balance here should be 12000000000000000000 (12e18 or 12 eth) let balance = await I_SecurityToken.balanceOf(account_investor1); await catchRevert( @@ -461,13 +461,13 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }) - it("Should succesfully get the lockup - fail because array index out of bound", async() => { + it("Should successfully get the lockup - fail because array index out of bound", async () => { await catchRevert( I_VolumeRestrictionTransferManager.getLockUp(account_investor1, 9) ); }) - it("Should be possible to remove a lockup -- couldn't transfer because of lock up", async() => { + it("Should be possible to remove a lockup -- couldn't transfer because of lock up", async () => { let acct1Balance = await I_SecurityToken.balanceOf(account_investor1) @@ -482,7 +482,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { // remove the lockup await I_VolumeRestrictionTransferManager.removeLockUp(account_investor1, 0, { from: token_owner }); - lockUpCount = await I_VolumeRestrictionTransferManager.getLockUpsLength(account_investor1); + lockUpCount = await I_VolumeRestrictionTransferManager.getLockUpsLength(account_investor1); assert.equal(lockUpCount, 0) let acct2BalanceBefore = await I_SecurityToken.balanceOf(account_investor2) @@ -492,13 +492,13 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { assert.equal(acct2BalanceAfter.sub(acct2BalanceBefore).toString(), acct1Balance.toString()) }); - it("Should try to remove the lockup --failed because of index is out of bounds", async() => { + it("Should try to remove the lockup --failed because of index is out of bounds", async () => { await catchRevert( I_VolumeRestrictionTransferManager.removeLockUp(account_investor2, 7, { from: token_owner }) ); }) - it("Should be possible to create multiple lockups at once", async() => { + it("Should be possible to create multiple lockups at once", async () => { let balancesBefore = {} @@ -571,22 +571,22 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should revert if the parameters are bad when creating multiple lockups", async() => { + it("Should revert if the parameters are bad when creating multiple lockups", async () => { await catchRevert( // pass in the wrong number of params. txn should revert - I_VolumeRestrictionTransferManager.addLockUpMulti( - [account_investor2, account_investor3], - [16, 8], - [2], // this array should have 2 elements but it has 1, which should cause a revert - [0, 0], - [web3.utils.toWei('1', 'ether'), web3.utils.toWei('1', 'ether')], - { from: token_owner } - ) + I_VolumeRestrictionTransferManager.addLockUpMulti( + [account_investor2, account_investor3], + [16, 8], + [2], // this array should have 2 elements but it has 1, which should cause a revert + [0, 0], + [web3.utils.toWei('1', 'ether'), web3.utils.toWei('1', 'ether')], + { from: token_owner } + ) ); }); - it("Should be possible to create a lockup with a specific start time in the future", async() => { + it("Should be possible to create a lockup with a specific start time in the future", async () => { // remove all lockups for account 2 let lockUpsLength = await I_VolumeRestrictionTransferManager.getLockUpsLength(account_investor2); @@ -613,7 +613,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should be possible to edit a lockup with a specific start time in the future", async() => { + it("Should be possible to edit a lockup with a specific start time in the future", async () => { // edit the lockup let now = latestTime(); @@ -697,7 +697,7 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { ); }); - it("Should be possible to stack lockups", async() => { + it("Should be possible to stack lockups", async () => { // should be 17000000000000000000 let balance = await I_SecurityToken.balanceOf(account_investor1) @@ -763,13 +763,13 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - it("Should get configuration function signature", async() => { + it("Should get configuration function signature", async () => { let sig = await I_VolumeRestrictionTransferManager.getInitFunction.call(); assert.equal(web3.utils.hexToNumber(sig), 0); }); - it("Should get the permission", async() => { + it("Should get the permission", async () => { let perm = await I_VolumeRestrictionTransferManager.getPermissions.call(); assert.equal(perm.length, 1); // console.log(web3.utils.toAscii(perm[0]).replace(/\u0000/g, '')) @@ -778,28 +778,28 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { }); - describe("VolumeRestriction Transfer Manager Factory test cases", async() => { + describe("VolumeRestriction Transfer Manager Factory test cases", async () => { - it("Should get the exact details of the factory", async() => { - assert.equal(await I_VolumeRestrictionTransferManagerFactory.getSetupCost.call(),0); - assert.equal((await I_VolumeRestrictionTransferManagerFactory.getTypes.call())[0],2); + it("Should get the exact details of the factory", async () => { + assert.equal(await I_VolumeRestrictionTransferManagerFactory.getSetupCost.call(), 0); + assert.equal((await I_VolumeRestrictionTransferManagerFactory.getTypes.call())[0], 2); assert.equal(web3.utils.toAscii(await I_VolumeRestrictionTransferManagerFactory.getName.call()) - .replace(/\u0000/g, ''), - "LockupVolumeRestrictionTM", - "Wrong Module added"); + .replace(/\u0000/g, ''), + "LockupVolumeRestrictionTM", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTransferManagerFactory.description.call(), - "Manage transfers using lock ups over time", - "Wrong Module added"); + "Manage transfers using lock ups over time", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTransferManagerFactory.title.call(), - "Lockup Volume Restriction Transfer Manager", - "Wrong Module added"); + "Lockup Volume Restriction Transfer Manager", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTransferManagerFactory.getInstructions.call(), - "Allows an issuer to set lockup periods for user addresses, with funds distributed over time. Init function takes no parameters.", - "Wrong Module added"); + "Allows an issuer to set lockup periods for user addresses, with funds distributed over time. Init function takes no parameters.", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTransferManagerFactory.version.call(), "1.0.0"); }); - it("Should get the tags of the factory", async() => { + it("Should get the tags of the factory", async () => { let tags = await I_VolumeRestrictionTransferManagerFactory.getTags.call(); assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ''), "Volume"); }); diff --git a/test/y_volume_restriction_tm.js b/test/y_volume_restriction_tm.js index 1075a64e4..217d89919 100644 --- a/test/y_volume_restriction_tm.js +++ b/test/y_volume_restriction_tm.js @@ -1,6 +1,6 @@ import latestTime from './helpers/latestTime'; -import {signData} from './helpers/signData'; -import { pk } from './helpers/testprivateKey'; +import { signData } from './helpers/signData'; +import { pk } from './helpers/testprivateKey'; import { duration, promisifyLogWatch, latestBlock } from './helpers/utils'; import { takeSnapshot, increaseTime, revertToSnapshot } from './helpers/time'; import { catchRevert } from "./helpers/exceptions"; @@ -83,7 +83,7 @@ contract('VolumeRestrictionTransferManager', accounts => { Days Covered: ${data[2].toNumber()} Latest timestamp daily: ${data[3].toNumber()} Individual Total Trade on latestTimestamp : ${(await I_VolumeRestrictionTM.getTotalTradedByUser.call(account, data[0])) - .dividedBy(new BigNumber(10).pow(18)).toNumber()} + .dividedBy(new BigNumber(10).pow(18)).toNumber()} Individual Total Trade on daily latestTimestamp : ${(await I_VolumeRestrictionTM.getTotalTradedByUser.call(account, data[3])) .dividedBy(new BigNumber(10).pow(18)).toNumber()} `) @@ -100,7 +100,7 @@ contract('VolumeRestrictionTransferManager', accounts => { return sum; } - before(async() => { + before(async () => { // Accounts setup account_polymath = accounts[0]; account_issuer = accounts[1]; @@ -186,9 +186,9 @@ contract('VolumeRestrictionTransferManager', accounts => { }); }); - describe("Attach the VRTM", async() => { - it("Deploy the VRTM and attach with the ST", async()=> { - let tx = await I_SecurityToken.addModule(I_VolumeRestrictionTMFactory.address, 0, 0, 0, {from: token_owner }); + describe("Attach the VRTM", async () => { + it("Deploy the VRTM and attach with the ST", async () => { + let tx = await I_SecurityToken.addModule(I_VolumeRestrictionTMFactory.address, 0, 0, 0, { from: token_owner }); assert.equal(tx.logs[2].args._moduleFactory, I_VolumeRestrictionTMFactory.address); assert.equal( web3.utils.toUtf8(tx.logs[2].args._name), @@ -197,24 +197,24 @@ contract('VolumeRestrictionTransferManager', accounts => { I_VolumeRestrictionTM = VolumeRestrictionTM.at(tx.logs[2].args._module); }); - it("Transfer some tokens to different account", async() => { + it("Transfer some tokens to different account", async () => { // Add tokens in to the whitelist await I_GeneralTransferManager.modifyWhitelistMulti( - [account_investor1, account_investor2, account_investor3], - [latestTime(), latestTime(), latestTime()], - [latestTime(), latestTime(), latestTime()], - [latestTime() + duration.days(60), latestTime() + duration.days(60), latestTime() + duration.days(60)], - [true, true, true], - { - from: token_owner - } + [account_investor1, account_investor2, account_investor3], + [latestTime(), latestTime(), latestTime()], + [latestTime(), latestTime(), latestTime()], + [latestTime() + duration.days(60), latestTime() + duration.days(60), latestTime() + duration.days(60)], + [true, true, true], + { + from: token_owner + } ); // Mint some tokens and transferred to whitelisted addresses - await I_SecurityToken.mint(account_investor1, web3.utils.toWei("40", "ether"), {from: token_owner}); - await I_SecurityToken.mint(account_investor2, web3.utils.toWei("30", "ether"), {from: token_owner}); - await I_SecurityToken.mint(account_investor3, web3.utils.toWei("30", "ether"), {from: token_owner}); - + await I_SecurityToken.mint(account_investor1, web3.utils.toWei("40", "ether"), { from: token_owner }); + await I_SecurityToken.mint(account_investor2, web3.utils.toWei("30", "ether"), { from: token_owner }); + await I_SecurityToken.mint(account_investor3, web3.utils.toWei("30", "ether"), { from: token_owner }); + // Check the balance of the investors let bal1 = await I_SecurityToken.balanceOf.call(account_investor1); let bal2 = await I_SecurityToken.balanceOf.call(account_investor2); @@ -224,17 +224,17 @@ contract('VolumeRestrictionTransferManager', accounts => { }); - it("Should transfer the tokens freely without any restriction", async() => { + it("Should transfer the tokens freely without any restriction", async () => { await I_SecurityToken.transfer(account_investor3, web3.utils.toWei('5', 'ether'), { from: account_investor1 }); let bal1 = await I_SecurityToken.balanceOf.call(account_investor3); - // Verifying the balances + // Verifying the balances assert.equal(web3.utils.fromWei((bal1.toNumber()).toString()), 35); }); }) - describe("Test for the addIndividualRestriction", async() => { + describe("Test for the addIndividualRestriction", async () => { - it("Should add the restriction -- failed because of bad owner", async() => { + it("Should add the restriction -- failed because of bad owner", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -250,7 +250,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e invalid restriction type", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid restriction type", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -266,7 +266,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e Invalid value of allowed tokens", async() => { + it("Should add the restriction -- failed because of bad parameters i.e Invalid value of allowed tokens", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -282,7 +282,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e Percentage of tokens not within (0,100]", async() => { + it("Should add the restriction -- failed because of bad parameters i.e Percentage of tokens not within (0,100]", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -298,7 +298,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e Percentage of tokens not within (0,100]", async() => { + it("Should add the restriction -- failed because of bad parameters i.e Percentage of tokens not within (0,100]", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -314,7 +314,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e invalid dates", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid dates", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -330,7 +330,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the restriction -- failed because of bad parameters i.e invalid dates", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid dates", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -346,7 +346,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -362,7 +362,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -378,7 +378,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async() => { + it("Should add the restriction -- failed because of bad parameters i.e invalid rolling period", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestriction( account_investor1, @@ -394,32 +394,32 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should add the restriction succesfully", async() => { + it("Should add the restriction successfully", async () => { let tx = await I_VolumeRestrictionTM.addIndividualRestriction( - account_investor1, - web3.utils.toWei("12"), - latestTime() + duration.seconds(2), - 3, - latestTime() + duration.days(5), - 0, - { - from: token_owner - } - ); - + account_investor1, + web3.utils.toWei("12"), + latestTime() + duration.seconds(2), + 3, + latestTime() + duration.days(5), + 0, + { + from: token_owner + } + ); + assert.equal(tx.logs[0].args._holder, account_investor1); assert.equal(tx.logs[0].args._typeOfRestriction, 0); }); - it("Should add the restriction for multiple investor -- failed because of bad owner", async() => { + it("Should add the restriction for multiple investor -- failed because of bad owner", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], [web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")], [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], - [3,4,5], + [3, 4, 5], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], + [0, 0, 0], { from: account_polymath } @@ -427,15 +427,15 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3], [web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")], [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], - [3,4,5], + [3, 4, 5], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], + [0, 0, 0], { from: token_owner } @@ -443,15 +443,15 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], [web3.utils.toWei("12"), web3.utils.toWei("10")], [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], - [3,4,5], + [3, 4, 5], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], + [0, 0, 0], { from: account_polymath } @@ -459,15 +459,15 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], [web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")], [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], - [3,4,5], + [3, 4, 5], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], + [0, 0, 0], { from: token_owner } @@ -475,7 +475,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], @@ -483,7 +483,7 @@ contract('VolumeRestrictionTransferManager', accounts => { [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], [3], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], + [0, 0, 0], { from: token_owner } @@ -491,7 +491,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], @@ -499,7 +499,7 @@ contract('VolumeRestrictionTransferManager', accounts => { [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], [3, 4, 5], [latestTime() + duration.days(5)], - [0,0,0], + [0, 0, 0], { from: token_owner } @@ -507,7 +507,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async() => { + it("Should add the restriction for multiple investor -- failed because of bad parameters i.e length mismatch", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor2, account_delegate3, account_investor4], @@ -523,24 +523,24 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction for multiple investor successfully", async() => { + it("Should add the restriction for multiple investor successfully", async () => { await I_VolumeRestrictionTM.addIndividualRestrictionMulti( - [account_investor2, account_delegate3, account_investor4], - [web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")], - [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], - [3, 4, 5], - [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [0,0,0], - { - from: token_owner - } + [account_investor2, account_delegate3, account_investor4], + [web3.utils.toWei("12"), web3.utils.toWei("10"), web3.utils.toWei("15")], + [latestTime() + duration.seconds(2), latestTime() + duration.seconds(2), latestTime() + duration.seconds(2)], + [3, 4, 5], + [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], + [0, 0, 0], + { + from: token_owner + } ); assert.equal((await I_VolumeRestrictionTM.individualRestriction.call(account_investor2))[2].toNumber(), 3); assert.equal((await I_VolumeRestrictionTM.individualRestriction.call(account_delegate3))[2].toNumber(), 4); assert.equal((await I_VolumeRestrictionTM.individualRestriction.call(account_investor4))[2].toNumber(), 5); }); - it("Should remove the restriction multi -- failed because of address is 0", async() => { + it("Should remove the restriction multi -- failed because of address is 0", async () => { await catchRevert( I_VolumeRestrictionTM.removeIndividualRestrictionMulti( [0, account_delegate3, account_investor4], @@ -551,18 +551,18 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should successfully remove the restriction", async() => { - await I_VolumeRestrictionTM.removeIndividualRestriction(account_investor2, {from: token_owner}); + it("Should successfully remove the restriction", async () => { + await I_VolumeRestrictionTM.removeIndividualRestriction(account_investor2, { from: token_owner }); assert.equal((await I_VolumeRestrictionTM.individualRestriction.call(account_investor2))[3].toNumber(), 0); }); - it("Should remove the restriction -- failed because restriction not present anymore", async() => { + it("Should remove the restriction -- failed because restriction not present anymore", async () => { await catchRevert( - I_VolumeRestrictionTM.removeIndividualRestriction(account_investor2, {from: token_owner}) + I_VolumeRestrictionTM.removeIndividualRestriction(account_investor2, { from: token_owner }) ); }); - it("Should remove the restriction multi", async() => { + it("Should remove the restriction multi", async () => { await I_VolumeRestrictionTM.removeIndividualRestrictionMulti( [account_delegate3, account_investor4], { @@ -571,7 +571,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ) }); - it("Should add the restriction succesfully after the expiry of previous one for investor 1", async() => { + it("Should add the restriction successfully after the expiry of previous one for investor 1", async () => { await increaseTime(duration.days(5.1)); console.log( @@ -590,37 +590,37 @@ contract('VolumeRestrictionTransferManager', accounts => { `); let tx = await I_VolumeRestrictionTM.addIndividualRestriction( - account_investor1, - web3.utils.toWei("12"), - latestTime() + duration.seconds(2), - 3, - latestTime() + duration.days(6), - 0, - { - from: token_owner - } - ); - + account_investor1, + web3.utils.toWei("12"), + latestTime() + duration.seconds(2), + 3, + latestTime() + duration.days(6), + 0, + { + from: token_owner + } + ); + assert.equal(tx.logs[1].args._holder, account_investor1); assert.equal(tx.logs[1].args._typeOfRestriction, 0); }); - it("Should not successfully transact the tokens -- failed because volume is above the limit", async() => { + it("Should not successfully transact the tokens -- failed because volume is above the limit", async () => { await increaseTime(duration.seconds(10)); await catchRevert( - I_SecurityToken.transfer(account_investor3, web3.utils.toWei("13"), { from: account_investor1}) + I_SecurityToken.transfer(account_investor3, web3.utils.toWei("13"), { from: account_investor1 }) ); }); - it("Should succesfully transact the tokens by investor 1 just after the startTime", async() => { + it("Should successfully transact the tokens by investor 1 just after the startTime", async () => { // Check the transfer will be valid or not by calling the verifyTransfer() directly by using _isTransfer = false let result = await I_VolumeRestrictionTM.verifyTransfer.call(account_investor1, account_investor3, web3.utils.toWei('.3'), "0x0", false); assert.equal(result.toNumber(), 1); // Perform the transaction console.log(` - Gas estimation (Individual): ${await I_SecurityToken.transfer.estimateGas(account_investor3, web3.utils.toWei('.3'), {from: account_investor1})}` + Gas estimation (Individual): ${await I_SecurityToken.transfer.estimateGas(account_investor3, web3.utils.toWei('.3'), { from: account_investor1 })}` ); - await I_SecurityToken.transfer(account_investor3, web3.utils.toWei('.3'), {from: account_investor1}); + await I_SecurityToken.transfer(account_investor3, web3.utils.toWei('.3'), { from: account_investor1 }); // Check the balance of the investors let bal1 = await I_SecurityToken.balanceOf.call(account_investor1); // Verifying the balances @@ -628,10 +628,10 @@ contract('VolumeRestrictionTransferManager', accounts => { let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor1); await print(data, account_investor1); - + assert.equal( (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor1, data[0])) - .dividedBy(new BigNumber(10).pow(18)).toNumber(), + .dividedBy(new BigNumber(10).pow(18)).toNumber(), 0.3 ); assert.equal( @@ -642,7 +642,7 @@ contract('VolumeRestrictionTransferManager', accounts => { tempArray.push(0.3); }); - it("Should fail to add the individual daily restriction -- Bad msg.sender", async() => { + it("Should fail to add the individual daily restriction -- Bad msg.sender", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor3, @@ -657,7 +657,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should fail to add the individual daily restriction -- Bad params value", async() => { + it("Should fail to add the individual daily restriction -- Bad params value", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor3, @@ -672,7 +672,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should fail to add the individual daily restriction -- Bad params value", async() => { + it("Should fail to add the individual daily restriction -- Bad params value", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor3, @@ -687,7 +687,7 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should fail to add the individual daily restriction -- Bad params value", async() => { + it("Should fail to add the individual daily restriction -- Bad params value", async () => { await catchRevert( I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor3, @@ -702,17 +702,17 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }) - it("Should add the individual daily restriction for investor 3", async() => { + it("Should add the individual daily restriction for investor 3", async () => { let tx = await I_VolumeRestrictionTM.addIndividualDailyRestriction( - account_investor3, - web3.utils.toWei("6"), - latestTime() + duration.seconds(1), - latestTime() + duration.days(4), - 0, - { - from: token_owner - } - ); + account_investor3, + web3.utils.toWei("6"), + latestTime() + duration.seconds(1), + latestTime() + duration.days(4), + 0, + { + from: token_owner + } + ); assert.equal(tx.logs[0].args._holder, account_investor3); assert.equal(tx.logs[0].args._typeOfRestriction, 0); @@ -728,57 +728,57 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should transfer the tokens within the individual daily restriction limits", async() => { + it("Should transfer the tokens within the individual daily restriction limits", async () => { // transfer 2 tokens as per the limit await increaseTime(5); // increase 5 seconds to layoff the time gap let startTime = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); console.log(` - Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), {from: account_investor3})} + Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), { from: account_investor3 })} `) - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor3 }); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + await increaseTime(duration.minutes(15)); console.log(` - Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("4"), {from: account_investor3})} + Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("4"), { from: account_investor3 })} `) // transfer the 4 tokens which is under the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), { from: account_investor3 }); let newData = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(newData, account_investor3); assert.equal(newData[3].toNumber(), data[3].toNumber()); assert.equal(data[3].toNumber(), startTime); assert.equal((await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[3])) - .dividedBy(new BigNumber(10).pow(18)).toNumber(), 6); + .dividedBy(new BigNumber(10).pow(18)).toNumber(), 6); }); - it("Should fail to transfer more tokens --because of the above limit", async() => { + it("Should fail to transfer more tokens --because of the above limit", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei(".1"), {from: account_investor3}) - ); + I_SecurityToken.transfer(account_investor2, web3.utils.toWei(".1"), { from: account_investor3 }) + ); }); - it("Should try to send after the one day completion", async() => { + it("Should try to send after the one day completion", async () => { // increase the EVM time by one day await increaseTime(duration.days(1)); let startTime = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); console.log(` - Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), {from: account_investor3})} + Gas Estimation for the Individual daily tx - ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), { from: account_investor3 })} `) - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor3 }); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); assert.equal(data[3].toNumber(), startTime + duration.days(1)); assert.equal((await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[3])) - .dividedBy(new BigNumber(10).pow(18)).toNumber(), 2); + .dividedBy(new BigNumber(10).pow(18)).toNumber(), 2); }); - it("Should add the daily restriction on the investor 1", async() => { + it("Should add the daily restriction on the investor 1", async () => { let tx = await I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor1, new BigNumber(5).times(new BigNumber(10).pow(16)), @@ -804,15 +804,15 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should transfer tokens on the 2nd day by investor1 (Individual + Individual daily)", async() => { + it("Should transfer tokens on the 2nd day by investor1 (Individual + Individual daily)", async () => { let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor1))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor1))[2].toNumber(); console.log(` - Gas estimation (Individual + Individual daily): ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), {from: account_investor1})}` + Gas estimation (Individual + Individual daily): ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("2"), { from: account_investor1 })}` ); - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor1}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor1 }); // Check the balance of the investors let bal1 = await I_SecurityToken.balanceOf.call(account_investor1); // Verifying the balances @@ -824,25 +824,25 @@ contract('VolumeRestrictionTransferManager', accounts => { // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor1, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); assert.equal(data[1].dividedBy(new BigNumber(10).pow(18)).toNumber(), await calculateSum(rollingPeriod, tempArray)); assert.equal(data[2].toNumber(), 1); assert.equal(data[3].toNumber(), - (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor1))[1].toNumber()); + (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor1))[1].toNumber()); assert.equal(amt, 2); }); - it("Should fail to transfer by investor 1 -- because voilating the individual daily", async() => { + it("Should fail to transfer by investor 1 -- because voilating the individual daily", async () => { // transfer 4 tokens -- voilate the daily restriction await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), {from: account_investor1}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), { from: account_investor1 }) ); }); - it("Should add the individual restriction to investor 3", async() => { + it("Should add the individual restriction to investor 3", async () => { let tx = await I_VolumeRestrictionTM.addIndividualRestriction( account_investor3, new BigNumber(15.36).times(new BigNumber(10).pow(16)), // 15.36 tokens as totalsupply is 1000 @@ -854,23 +854,23 @@ contract('VolumeRestrictionTransferManager', accounts => { from: token_owner } ); - + assert.equal(tx.logs[0].args._holder, account_investor3); assert.equal(tx.logs[0].args._typeOfRestriction, 1); }); - it("Should transfer the token by the investor 3 with in the (Individual + Individual daily limit)", async() => { + it("Should transfer the token by the investor 3 with in the (Individual + Individual daily limit)", async () => { await increaseTime(4); // Allowed 4 tokens to transfer let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); let startTimeDaily = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); console.log(` - Gas estimation (Individual + Individual daily): ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("4"), {from: account_investor3})}` + Gas estimation (Individual + Individual daily): ${await I_SecurityToken.transfer.estimateGas(account_investor2, web3.utils.toWei("4"), { from: account_investor3 })}` ); // Check the balance of the investors let bal1 = await I_SecurityToken.balanceOf.call(account_investor3); - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), { from: account_investor3 }); tempArray3.push(4); // Check the balance of the investors let bal2 = await I_SecurityToken.balanceOf.call(account_investor3); @@ -882,7 +882,7 @@ contract('VolumeRestrictionTransferManager', accounts => { // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -893,35 +893,35 @@ contract('VolumeRestrictionTransferManager', accounts => { }); - it("Should fail during transferring more tokens by investor3 -- Voilating the daily Limit", async() => { + it("Should fail during transferring more tokens by investor3 -- Voilating the daily Limit", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1"), { from: account_investor3 }) ); }); - it("Should remove the daily individual limit and transfer more tokens on a same day -- failed because of bad owner", async() => { + it("Should remove the daily individual limit and transfer more tokens on a same day -- failed because of bad owner", async () => { // remove the Individual daily restriction await catchRevert( - I_VolumeRestrictionTM.removeIndividualDailyRestriction(account_investor3, {from: account_investor4}) + I_VolumeRestrictionTM.removeIndividualDailyRestriction(account_investor3, { from: account_investor4 }) ); }) - it("Should remove the daily individual limit and transfer more tokens on a same day", async() => { + it("Should remove the daily individual limit and transfer more tokens on a same day", async () => { // remove the Individual daily restriction - let tx = await I_VolumeRestrictionTM.removeIndividualDailyRestriction(account_investor3, {from: token_owner}); + let tx = await I_VolumeRestrictionTM.removeIndividualDailyRestriction(account_investor3, { from: token_owner }); assert.equal(tx.logs[0].args._holder, account_investor3); let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); // transfer more tokens on the same day - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), {from: account_investor3}); - tempArray3[tempArray3.length -1] += 4; + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("4"), { from: account_investor3 }); + tempArray3[tempArray3.length - 1] += 4; let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -931,7 +931,7 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 8); }); - it("Should add the new Individual daily restriction and transact the tokens", async() => { + it("Should add the new Individual daily restriction and transact the tokens", async () => { // add new restriction let tx = await I_VolumeRestrictionTM.addIndividualDailyRestriction( account_investor3, @@ -963,7 +963,7 @@ contract('VolumeRestrictionTransferManager', accounts => { await increaseTime(duration.days(1.1)); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor3 }); tempArray3.push(2); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); @@ -971,7 +971,7 @@ contract('VolumeRestrictionTransferManager', accounts => { // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -982,11 +982,11 @@ contract('VolumeRestrictionTransferManager', accounts => { // Fail to sell more tokens than the limit await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor3 }) ); }); - it("Should fail to modify the individual daily restriction -- bad owner", async() => { + it("Should fail to modify the individual daily restriction -- bad owner", async () => { await catchRevert( I_VolumeRestrictionTM.modifyIndividualDailyRestriction( account_investor3, @@ -1000,17 +1000,17 @@ contract('VolumeRestrictionTransferManager', accounts => { ) ); }); - - it("Should modify the individual daily restriction", async() => { + + it("Should modify the individual daily restriction", async () => { await I_VolumeRestrictionTM.modifyIndividualDailyRestriction( - account_investor3, - web3.utils.toWei('3'), - 0, - latestTime() + duration.days(5), - 0, - { - from: token_owner - } + account_investor3, + web3.utils.toWei('3'), + 0, + latestTime() + duration.days(5), + 0, + { + from: token_owner + } ); let dataRestriction = await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3); @@ -1024,20 +1024,20 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should allow to sell to transfer more tokens by investor3", async() => { + it("Should allow to sell to transfer more tokens by investor3", async () => { let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); let startTimedaily = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), {from: account_investor3}); - tempArray3[tempArray3.length -1] += 3; + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), { from: account_investor3 }); + tempArray3[tempArray3.length - 1] += 3; let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1047,14 +1047,14 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 5); }); - it("Should allow to transact the tokens on the other day", async() => { + it("Should allow to transact the tokens on the other day", async () => { let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); let startTimedaily = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); await increaseTime(duration.days(1)); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2.36"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2.36"), { from: account_investor3 }); tempArray3.push(2.36); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); @@ -1062,7 +1062,7 @@ contract('VolumeRestrictionTransferManager', accounts => { // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1072,29 +1072,29 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 2.36); }); - it("Should fail to transfer the tokens after completion of the total amount", async() => { + it("Should fail to transfer the tokens after completion of the total amount", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("0.3"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("0.3"), { from: account_investor3 }) ); }) - it("Should sell more tokens on the same day after changing the total supply", async() => { - await I_SecurityToken.mint(account_investor3, web3.utils.toWei("10"), {from: token_owner}); + it("Should sell more tokens on the same day after changing the total supply", async () => { + await I_SecurityToken.mint(account_investor3, web3.utils.toWei("10"), { from: token_owner }); let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); let startTimedaily = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei(".50"), {from: account_investor3}); - tempArray3[tempArray3.length -1] += .50; + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei(".50"), { from: account_investor3 }); + tempArray3[tempArray3.length - 1] += .50; let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1104,8 +1104,8 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 2.86); }); - it("Should fail to transact tokens more than the allowed in the second rolling period", async() => { - await increaseTime(duration.days(4)); + it("Should fail to transact tokens more than the allowed in the second rolling period", async () => { + await increaseTime(duration.days(4)); let i for (i = 0; i < 3; i++) { tempArray3.push(0); @@ -1113,11 +1113,11 @@ contract('VolumeRestrictionTransferManager', accounts => { console.log(`Diff Days: ${(latestTime() - ((await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3))[0]).toNumber()) / 86400}`); let allowedAmount = (tempArray3[0] + 1.1); await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei(allowedAmount.toString()), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei(allowedAmount.toString()), { from: account_investor3 }) ); }) - it("Should successfully to transact tokens in the second rolling period", async() => { + it("Should successfully to transact tokens in the second rolling period", async () => { // Should transact freely tokens daily limit is also ended let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); @@ -1125,15 +1125,15 @@ contract('VolumeRestrictionTransferManager', accounts => { let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); let allowedAmount = (tempArray3[0] + 1); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei(allowedAmount.toString()), {from: account_investor3}); - + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei(allowedAmount.toString()), { from: account_investor3 }); + tempArray3.push(allowedAmount); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1143,7 +1143,7 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, allowedAmount); }); - it("Should sell more tokens on the net day of rolling period", async() => { + it("Should sell more tokens on the net day of rolling period", async () => { await increaseTime(duration.days(3)); let startTime = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[1].toNumber(); @@ -1154,15 +1154,15 @@ contract('VolumeRestrictionTransferManager', accounts => { tempArray3.push(0); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("7"), {from: account_investor3}); - + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("7"), { from: account_investor3 }); + tempArray3.push(7) let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1172,10 +1172,10 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 7); }) - it("Should transfer after the 5 days", async() => { + it("Should transfer after the 5 days", async () => { await increaseTime(duration.days(4.5)); - for (let i = 0; i <3; i++) { + for (let i = 0; i < 3; i++) { tempArray3.push(0); } @@ -1183,17 +1183,17 @@ contract('VolumeRestrictionTransferManager', accounts => { let startTimedaily = (await I_VolumeRestrictionTM.individualDailyRestriction.call(account_investor3))[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.individualRestriction.call(account_investor3))[2].toNumber(); - await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("25"), {from: account_investor2}); + await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("25"), { from: account_investor2 }); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("8"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("8"), { from: account_investor3 }); tempArray3.push(8); let data = await I_VolumeRestrictionTM.getIndividualBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1203,16 +1203,16 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 8); }); - it("Should freely transfer the tokens after one day (completion of individual restriction)", async() => { + it("Should freely transfer the tokens after one day (completion of individual restriction)", async () => { // increase one time await increaseTime(duration.days(2)); - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("17"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("17"), { from: account_investor3 }); }); }); - describe("Test cases for the Default restrictions", async() => { - - it("Should add the investor 4 in the whitelist", async() => { + describe("Test cases for the Default restrictions", async () => { + + it("Should add the investor 4 in the whitelist", async () => { await I_GeneralTransferManager.modifyWhitelist( account_investor4, latestTime(), @@ -1225,11 +1225,11 @@ contract('VolumeRestrictionTransferManager', accounts => { ); }); - it("Should mint some tokens to investor 4", async() => { - await I_SecurityToken.mint(account_investor4, web3.utils.toWei("20"), {from: token_owner}); + it("Should mint some tokens to investor 4", async () => { + await I_SecurityToken.mint(account_investor4, web3.utils.toWei("20"), { from: token_owner }); }); - it("Should add the default daily restriction successfully", async() => { + it("Should add the default daily restriction successfully", async () => { await I_VolumeRestrictionTM.addDefaultDailyRestriction( new BigNumber(2.75).times(new BigNumber(10).pow(16)), 0, @@ -1251,23 +1251,23 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should fail to transfer above the daily limit", async() => { + it("Should fail to transfer above the daily limit", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor3, web3.utils.toWei("5"), {from: account_investor4}) + I_SecurityToken.transfer(account_investor3, web3.utils.toWei("5"), { from: account_investor4 }) ) }) - it("Should transfer the token by investor 4", async() => { + it("Should transfer the token by investor 4", async () => { let startTimedaily = (await I_VolumeRestrictionTM.defaultDailyRestriction.call())[1].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3.57"), {from: account_investor4}); - + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3.57"), { from: account_investor4 }); + let data = await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor4); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor4, data[3].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), 0); @@ -1277,16 +1277,16 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 3.57); }); - it("Should transfer the tokens freely after ending the default daily restriction", async() => { + it("Should transfer the tokens freely after ending the default daily restriction", async () => { await increaseTime(duration.days(3) + 10); //sell tokens upto the limit - let tx = await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("5"), {from: account_investor4}); + let tx = await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("5"), { from: account_investor4 }); assert.equal((tx.logs[0].args.value).toNumber(), web3.utils.toWei("5")); // Transfer the tokens again to investor 3 - await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("40"), {from: account_investor2}); + await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("40"), { from: account_investor2 }); }) - it("Should successfully add the default restriction", async() => { + it("Should successfully add the default restriction", async () => { await I_VolumeRestrictionTM.addDefaultRestriction( web3.utils.toWei("10"), 0, @@ -1312,22 +1312,22 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should transfer tokens on by investor 3 (comes under the Default restriction)", async() => { + it("Should transfer tokens on by investor 3 (comes under the Default restriction)", async () => { await increaseTime(10); tempArray3.length = 0; let startTime = (await I_VolumeRestrictionTM.defaultRestriction.call())[1].toNumber(); let startTimedaily = (await I_VolumeRestrictionTM.defaultDailyRestriction.call())[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.defaultRestriction.call())[2].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("5"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("5"), { from: account_investor3 }); tempArray3.push(5); let data = await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1339,7 +1339,7 @@ contract('VolumeRestrictionTransferManager', accounts => { // Transfer tokens on another day await increaseTime(duration.days(1)); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), { from: account_investor3 }); tempArray3.push(3); data = await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor3); @@ -1347,7 +1347,7 @@ contract('VolumeRestrictionTransferManager', accounts => { // get the trade amount using the timestamp amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1357,13 +1357,13 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 3); }); - it("Should fail to transfer more tokens than the available default limit", async() => { + it("Should fail to transfer more tokens than the available default limit", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), { from: account_investor3 }) ); }); - it("Should able to transfer tokens in the next rolling period", async() => { + it("Should able to transfer tokens in the next rolling period", async () => { await increaseTime(duration.days(4.1)); console.log(`*** Diff days: ${(latestTime() - ((await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor3))[0]).toNumber()) / 86400}`) for (let i = 0; i < 3; i++) { @@ -1375,15 +1375,15 @@ contract('VolumeRestrictionTransferManager', accounts => { let rollingPeriod = (await I_VolumeRestrictionTM.defaultRestriction.call())[2].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("7"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("7"), { from: account_investor3 }); tempArray3.push(7); let data = await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1394,11 +1394,11 @@ contract('VolumeRestrictionTransferManager', accounts => { // Try to transact more on the same day but fail await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("1"), { from: account_investor3 }) ); }); - it("Should add the daily default restriction again", async() => { + it("Should add the daily default restriction again", async () => { await I_VolumeRestrictionTM.addDefaultDailyRestriction( web3.utils.toWei("2"), 0, @@ -1420,27 +1420,27 @@ contract('VolumeRestrictionTransferManager', accounts => { `); }); - it("Should not able to transfer tokens more than the default daily restriction", async() => { + it("Should not able to transfer tokens more than the default daily restriction", async () => { await catchRevert( - I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), {from: account_investor3}) + I_SecurityToken.transfer(account_investor2, web3.utils.toWei("3"), { from: account_investor3 }) ); }); - it("Should able to transfer tokens within the limit of (daily default + default) restriction", async() => { + it("Should able to transfer tokens within the limit of (daily default + default) restriction", async () => { await increaseTime(duration.days(1)); let startTime = (await I_VolumeRestrictionTM.defaultRestriction.call())[1].toNumber(); let startTimedaily = (await I_VolumeRestrictionTM.defaultDailyRestriction.call())[1].toNumber(); let rollingPeriod = (await I_VolumeRestrictionTM.defaultRestriction.call())[2].toNumber(); //sell tokens upto the limit - await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), {from: account_investor3}); + await I_SecurityToken.transfer(account_investor2, web3.utils.toWei("2"), { from: account_investor3 }); tempArray3.push(2); let data = await I_VolumeRestrictionTM.getDefaultBucketDetailsToUser.call(account_investor3); await print(data, account_investor3); - + // get the trade amount using the timestamp let amt = (await I_VolumeRestrictionTM.getTotalTradedByUser.call(account_investor3, data[0].toNumber())) - .dividedBy(new BigNumber(10).pow(18)).toNumber(); + .dividedBy(new BigNumber(10).pow(18)).toNumber(); // Verify the storage changes assert.equal(data[0].toNumber(), startTime + duration.days(data[2].toNumber())); @@ -1451,34 +1451,34 @@ contract('VolumeRestrictionTransferManager', accounts => { }); }) - describe("Test for the exemptlist", async() => { + describe("Test for the exemptlist", async () => { - it("Should add the token holder in the exemption list -- failed because of bad owner", async() => { + it("Should add the token holder in the exemption list -- failed because of bad owner", async () => { await catchRevert( - I_VolumeRestrictionTM.changeExemptWalletList(account_investor4, true, {from: account_polymath}) + I_VolumeRestrictionTM.changeExemptWalletList(account_investor4, true, { from: account_polymath }) ); }); - it("Should add the token holder in the exemption list", async() => { - await I_VolumeRestrictionTM.changeExemptWalletList(account_investor4, true, {from: token_owner}); + it("Should add the token holder in the exemption list", async () => { + await I_VolumeRestrictionTM.changeExemptWalletList(account_investor4, true, { from: token_owner }); let beforeBal = await I_SecurityToken.balanceOf.call(account_investor4); - await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("3"), {from: account_investor4}); + await I_SecurityToken.transfer(account_investor3, web3.utils.toWei("3"), { from: account_investor4 }); let afterBal = await I_SecurityToken.balanceOf.call(account_investor4); let diff = beforeBal.minus(afterBal); assert.equal(web3.utils.fromWei((diff.toNumber()).toString()), 3); }); }); - describe("Test for modify functions", async() => { + describe("Test for modify functions", async () => { - it("Should add the individual restriction for multiple investor", async() => { + it("Should add the individual restriction for multiple investor", async () => { await I_VolumeRestrictionTM.addIndividualRestrictionMulti( [account_investor3, account_delegate3], [web3.utils.toWei("15"), new BigNumber(12.78).times(new BigNumber(10).pow(16))], [latestTime() + duration.days(1), latestTime() + duration.days(2)], [15, 20], [latestTime() + duration.days(40), latestTime() + duration.days(60)], - [0,1], + [0, 1], { from: token_owner } @@ -1497,14 +1497,14 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(indi2[4].toNumber(), 1); }); - it("Should modify the details before the starttime passed", async() => { + it("Should modify the details before the starttime passed", async () => { await I_VolumeRestrictionTM.modifyIndividualRestrictionMulti( [account_investor3, account_delegate3], [new BigNumber(12.78).times(new BigNumber(10).pow(16)), web3.utils.toWei("15")], [latestTime() + duration.days(1), latestTime() + duration.days(2)], [20, 15], [latestTime() + duration.days(40), latestTime() + duration.days(60)], - [1,0], + [1, 0], { from: token_owner } @@ -1525,32 +1525,32 @@ contract('VolumeRestrictionTransferManager', accounts => { }); - describe("VolumeRestriction Transfer Manager Factory test cases", async() => { + describe("VolumeRestriction Transfer Manager Factory test cases", async () => { - it("Should get the exact details of the factory", async() => { - assert.equal(await I_VolumeRestrictionTMFactory.getSetupCost.call(),0); - assert.equal((await I_VolumeRestrictionTMFactory.getTypes.call())[0],2); + it("Should get the exact details of the factory", async () => { + assert.equal(await I_VolumeRestrictionTMFactory.getSetupCost.call(), 0); + assert.equal((await I_VolumeRestrictionTMFactory.getTypes.call())[0], 2); assert.equal(web3.utils.toAscii(await I_VolumeRestrictionTMFactory.getName.call()) - .replace(/\u0000/g, ''), - "VolumeRestrictionTM", - "Wrong Module added"); + .replace(/\u0000/g, ''), + "VolumeRestrictionTM", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTMFactory.description.call(), - "Manage transfers based on the volume of tokens that needs to be transact", - "Wrong Module added"); + "Manage transfers based on the volume of tokens that needs to be transact", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTMFactory.title.call(), - "Volume Restriction Transfer Manager", - "Wrong Module added"); + "Volume Restriction Transfer Manager", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTMFactory.getInstructions.call(), - "Module used to restrict the volume of tokens traded by the token holders", - "Wrong Module added"); + "Module used to restrict the volume of tokens traded by the token holders", + "Wrong Module added"); assert.equal(await I_VolumeRestrictionTMFactory.version.call(), "1.0.0"); }); - it("Should get the tags of the factory", async() => { + it("Should get the tags of the factory", async () => { let tags = await I_VolumeRestrictionTMFactory.getTags.call(); assert.equal(tags.length, 5); assert.equal(web3.utils.toAscii(tags[0]).replace(/\u0000/g, ''), "Maximum Volume"); }); }); - + }); \ No newline at end of file From e8c0cd6471141e29bc0982837ee6b606f7d143a5 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 8 Jan 2019 17:49:23 -0300 Subject: [PATCH 02/14] 'whould' typo --- CLI/commands/token_manager.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CLI/commands/token_manager.js b/CLI/commands/token_manager.js index e46019abb..87de6889e 100644 --- a/CLI/commands/token_manager.js +++ b/CLI/commands/token_manager.js @@ -467,7 +467,7 @@ async function listModuleOptions() { // Modules a actions async function addModule() { let options = ['Permission Manager', 'Transfer Manager', 'Security Token Offering', 'Dividends', 'Burn']; - let index = readlineSync.keyInSelect(options, 'What type of module whould you like to add?', { cancel: 'Return' }); + let index = readlineSync.keyInSelect(options, 'What type of module would you like to add?', { cancel: 'Return' }); switch (options[index]) { case 'Permission Manager': console.log(chalk.red(` @@ -498,7 +498,7 @@ async function addModule() { async function pauseModule(modules) { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module whould you like to pause?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to pause?'); if (index != -1) { console.log("\nSelected:", options[index]); let moduleABI; @@ -519,7 +519,7 @@ async function pauseModule(modules) { async function unpauseModule(modules) { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module whould you like to pause?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to pause?'); if (index != -1) { console.log("\nSelected: ", options[index]); let moduleABI; @@ -551,7 +551,7 @@ async function archiveModule(modules) { async function unarchiveModule(modules) { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module whould you like to unarchive?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to unarchive?'); if (index != -1) { console.log("\nSelected: ", options[index]); let unarchiveModuleAction = securityToken.methods.unarchiveModule(modules[index].address); @@ -562,7 +562,7 @@ async function unarchiveModule(modules) { async function removeModule(modules) { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module whould you like to remove?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to remove?'); if (index != -1) { console.log("\nSelected: ", options[index]); let removeModuleAction = securityToken.methods.removeModule(modules[index].address); @@ -573,7 +573,7 @@ async function removeModule(modules) { async function changeBudget() { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module whould you like to remove?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to remove?'); if (index != -1) { console.log("\nSelected: ", options[index]); let increase = 0 == readlineSync.keyInSelect(['Increase', 'Decrease'], `Do you want to increase or decrease budget?`, { cancel: false }); From 73f0377ceec5ec382734408c592fcbe18099c9a2 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 8 Jan 2019 17:56:28 -0300 Subject: [PATCH 03/14] To pause/unpause TM modules fix --- CLI/commands/token_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/commands/token_manager.js b/CLI/commands/token_manager.js index 87de6889e..17d8fa2c0 100644 --- a/CLI/commands/token_manager.js +++ b/CLI/commands/token_manager.js @@ -504,7 +504,7 @@ async function pauseModule(modules) { let moduleABI; if (modules[index].type == gbl.constants.MODULES_TYPES.STO) { moduleABI = abis.ISTO(); - } else if (modules[index].type == gbl.constants.MODULES_TYPES.STO) { + } else if (modules[index].type == gbl.constants.MODULES_TYPES.TRANSFER) { moduleABI = abis.ITransferManager(); } else { console.log(chalk.red(`Only STO and TM modules can be paused/unpaused`)); @@ -525,7 +525,7 @@ async function unpauseModule(modules) { let moduleABI; if (modules[index].type == gbl.constants.MODULES_TYPES.STO) { moduleABI = abis.ISTO(); - } else if (modules[index].type == gbl.constants.MODULES_TYPES.STO) { + } else if (modules[index].type == gbl.constants.MODULES_TYPES.TRANSFER) { moduleABI = abis.ITransferManager(); } else { console.log(chalk.red(`Only STO and TM modules can be paused/unpaused`)); From 11f6b50fcefb1569089e9a6b2d6a9943e479da4c Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 8 Jan 2019 18:02:04 -0300 Subject: [PATCH 04/14] Change module budget error --- CLI/commands/token_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/commands/token_manager.js b/CLI/commands/token_manager.js index 17d8fa2c0..4b667b54c 100644 --- a/CLI/commands/token_manager.js +++ b/CLI/commands/token_manager.js @@ -571,9 +571,9 @@ async function removeModule(modules) { } } -async function changeBudget() { +async function changeBudget(modules) { let options = modules.map(m => `${m.name} (${m.address})`); - let index = readlineSync.keyInSelect(options, 'Which module would you like to remove?'); + let index = readlineSync.keyInSelect(options, 'Which module would you like to change budget for?'); if (index != -1) { console.log("\nSelected: ", options[index]); let increase = 0 == readlineSync.keyInSelect(['Increase', 'Decrease'], `Do you want to increase or decrease budget?`, { cancel: false }); From c843a9981cde41eb0a51bd3cf3f5d5cf52f959d5 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 10 Jan 2019 12:31:54 -0300 Subject: [PATCH 05/14] Typo --- CLI/commands/transfer_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index 2b76a8f80..c48bb3483 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -369,7 +369,7 @@ async function generalTransferManager() { break; case 'Change the default times used when they are zero': let fromTimeDefault = readlineSync.questionInt(`Enter the default time (Unix Epoch time) used when fromTime is zero: `); - let toTimeDefault = readlineSync.questionInt(`Enter the default time (Unix Epoch time) used when fromTime is zero: `); + let toTimeDefault = readlineSync.questionInt(`Enter the default time (Unix Epoch time) used when toTime is zero: `); let changeDefaultsAction = currentTransferManager.methods.changeDefaults(fromTimeDefault, toTimeDefault); let changeDefaultsReceipt = await common.sendTransaction(changeDefaultsAction); let changeDefaultsEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, changeDefaultsReceipt.logs, 'ChangeDefaults'); From 14a96509cb3c33c32e1763f3687ebec89b9fb371 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 10 Jan 2019 12:33:06 -0300 Subject: [PATCH 06/14] Text improvements --- CLI/commands/transfer_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index c48bb3483..47008eca8 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -193,8 +193,8 @@ async function forcedTransfers() { }, limitMessage: `Amount must be less or equal than ${fromBalance} ${tokenSymbol}`, }); - let data = readlineSync.question('Enter the data to indicate validation: '); - let log = readlineSync.question('Enter the data attached to the transfer by controller to emit in event: '); + let data = '';//readlineSync.question('Enter the data to indicate validation: '); + let log = readlineSync.question('Enter a message to attach to the transfer (i.e. "Private key lost"): '); let forceTransferAction = securityToken.methods.forceTransfer(from, to, web3.utils.toWei(amount), web3.utils.asciiToHex(data), web3.utils.asciiToHex(log)); let forceTransferReceipt = await common.sendTransaction(forceTransferAction, { factor: 1.5 }); let forceTransferEvent = common.getEventFromLogs(securityToken._jsonInterface, forceTransferReceipt.logs, 'ForceTransfer'); From b2551b43214aa9c366be6efc3cf2db2c06cefa6c Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 10 Jan 2019 12:35:36 -0300 Subject: [PATCH 07/14] KYC expiry date modified to one year from now --- CLI/commands/transfer_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index 47008eca8..37e00d788 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -385,8 +385,8 @@ async function generalTransferManager() { let now = Math.floor(Date.now() / 1000); let fromTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the sale lockup period ends and the investor can freely sell his tokens (now = ${now}): `, { defaultInput: now }); let toTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely purchase tokens from others (now = ${now}): `, { defaultInput: now }); - let oneHourFromNow = Math.floor(Date.now() / 1000 + 3600); - let expiryTime = readlineSync.questionInt(`Enter the time till investors KYC will be validated (after that investor need to do re - KYC) (1 hour from now = ${oneHourFromNow}): `, { defaultInput: oneHourFromNow }); + let oneYearFromNow = Math.floor(Date.now() / 1000 + (60 * 60 * 24 * 365)); + let expiryTime = readlineSync.questionInt(`Enter the time till investors KYC will be validated (after that investor need to do re - KYC) (1 year from now = ${oneYearFromNow}): `, { defaultInput: oneYearFromNow }); let canBuyFromSTO = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); let modifyWhitelistAction = currentTransferManager.methods.modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO); let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction); From c1b5c7e988bb4dac36c4cc7c59a033b79e83e5c5 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 10 Jan 2019 15:42:26 -0300 Subject: [PATCH 08/14] Fix for CappedSTO --- CLI/commands/investor_portal.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CLI/commands/investor_portal.js b/CLI/commands/investor_portal.js index 0cb02f681..0bf12342a 100644 --- a/CLI/commands/investor_portal.js +++ b/CLI/commands/investor_portal.js @@ -152,8 +152,6 @@ async function showTokenInfo() { // Show info async function showUserInfo(_user) { - let listOfStableCoins = await currentSTO.methods.getUsdTokens().call(); - console.log(` ******************* User Information ******************** - Address: ${_user}`); @@ -164,6 +162,7 @@ async function showUserInfo(_user) { console.log(` - ETH balance:\t ${web3.utils.fromWei(await web3.eth.getBalance(_user))}`); } if (await currentSTO.methods.fundRaiseTypes(gbl.constants.FUND_RAISE_TYPES.STABLE).call()) { + let listOfStableCoins = await currentSTO.methods.getUsdTokens().call(); let stableSymbolsAndBalance = await processAddressWithBalance(listOfStableCoins); stableSymbolsAndBalance.forEach(stable => { console.log(` - ${stable.symbol} balance:\t ${web3.utils.fromWei(stable.balance)}`); From 5448cb3e3cecce1a7609c92aa020a2a59e1d9d4e Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 15 Jan 2019 12:05:00 -0300 Subject: [PATCH 09/14] Removed default stable coin --- CLI/commands/sto_manager.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/CLI/commands/sto_manager.js b/CLI/commands/sto_manager.js index f581b7339..4a96b1088 100644 --- a/CLI/commands/sto_manager.js +++ b/CLI/commands/sto_manager.js @@ -22,7 +22,6 @@ let tokenSymbol; let securityTokenRegistry; let moduleRegistry; let polyToken; -let usdToken; let securityToken; async function executeApp() { @@ -329,7 +328,7 @@ async function addressesConfigUSDTieredSTO(usdTokenRaise) { let listOfAddress; if (usdTokenRaise) { - addresses.usdToken = readlineSync.question('Enter the address (or multiple addresses separated by commas) of the USD stable coin(s) (' + usdToken.options.address + '): ', { + addresses.usdToken = readlineSync.question('Enter the address (or multiple addresses separated by commas) of the USD stable coin(s): ', { limit: function (input) { listOfAddress = input.split(','); return listOfAddress.every((addr) => { @@ -337,12 +336,7 @@ async function addressesConfigUSDTieredSTO(usdTokenRaise) { }) }, limitMessage: "Must be a valid address", - defaultInput: usdToken.options.address }); - if (addresses.usdToken == "") { - listOfAddress = [usdToken.options.address] - addresses.usdToken = [usdToken.options.address]; - } } else { listOfAddress = [] addresses.usdToken = []; @@ -978,8 +972,6 @@ async function getBalance(from, type) { return await web3.eth.getBalance(from); case gbl.constants.FUND_RAISE_TYPES.POLY: return await polyToken.methods.balanceOf(from).call(); - case gbl.constants.FUND_RAISE_TYPES.STABLE: - return await usdToken.methods.balanceOf(from).call(); } } @@ -1055,11 +1047,6 @@ async function setup() { let polytokenABI = abis.polyToken(); polyToken = new web3.eth.Contract(polytokenABI, polytokenAddress); polyToken.setProvider(web3.currentProvider); - - //TODO: Use proper DAI token here - let usdTokenAddress = await contracts.usdToken(); - usdToken = new web3.eth.Contract(polytokenABI, usdTokenAddress); - usdToken.setProvider(web3.currentProvider); } catch (err) { console.log(err) console.log('\x1b[31m%s\x1b[0m', "There was a problem getting the contracts. Make sure they are deployed to the selected network."); From 47df79159cd73a2a7d6783530a44fd77efb68f6b Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 23 Jan 2019 09:42:20 -0500 Subject: [PATCH 10/14] Lockup typos and fixes --- CLI/commands/transfer_manager.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index 5b621950b..bf05d1141 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -2302,16 +2302,15 @@ async function manageExistingLockups(lockupName) { console.log(`- Currently unlocked: ${web3.utils.fromWei(currentLockup.unlockedAmount)} ${tokenSymbol}`); console.log(`- Start time: ${moment.unix(currentLockup.startTime).format('MMMM Do YYYY, HH:mm:ss')}`); console.log(`- Lockup period: ${currentLockup.lockUpPeriodSeconds} seconds`); - console.log(`- End time: ${moment.unix(currentLockup.endTime).add(parseInt(currentLockup.lockUpPeriodSeconds)).format('MMMM Do YYYY, HH:mm:ss')}`); - console.log(`- Release frequency: ${currentLockup.releaseFrequencySeconds} senconds`); + console.log(`- End time: ${moment.unix(currentLockup.startTime).add(parseInt(currentLockup.lockUpPeriodSeconds), 'seconds').format('MMMM Do YYYY, HH:mm:ss')}`); console.log(`- Release frequency: ${currentLockup.releaseFrequencySeconds} seconds`); console.log(`- Investors: ${investors.length}`); // ------------------ let options = [ 'Modify properties', 'Show investors', - 'Add this lockup to investors', - 'Remove this lockup from investors', + 'Add investors to this lockup', + 'Remove investors from this lockup', 'Delete this lockup type' ]; @@ -2325,7 +2324,7 @@ async function manageExistingLockups(lockupName) { let startTime = readlineSync.questionInt(`Enter the start time (Unix Epoch time) of the lockup type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow }); let lockUpPeriodSeconds = readlineSync.questionInt(`Enter the total period (seconds) of the lockup type (ten minutes = 600): `, { defaultInput: 600 }); let releaseFrequencySeconds = readlineSync.questionInt(`Enter how often to release a tranche of tokens in seconds (one minute = 60): `, { defaultInput: 60 }); - let modifyLockUpTypeAction = currentTransferManager.methods.modifyLockUpType(lockupAmount, startTime, lockUpPeriodSeconds, releaseFrequencySeconds, lockupName); + let modifyLockUpTypeAction = currentTransferManager.methods.modifyLockUpType(web3.utils.toWei(lockupAmount.toString()), startTime, lockUpPeriodSeconds, releaseFrequencySeconds, lockupName); let modifyLockUpTypeReceipt = await common.sendTransaction(modifyLockUpTypeAction); let modifyLockUpTypeEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyLockUpTypeReceipt.logs, 'ModifyLockUpType'); console.log(chalk.green(`${web3.utils.hexToUtf8(modifyLockUpTypeEvent._lockupName)} lockup type has been modified successfully!`)); From 3bea43c4aefdab0de50c348dd753556e7263a710 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 5 Feb 2019 09:22:56 -0300 Subject: [PATCH 11/14] KYC date text improved --- CLI/commands/transfer_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index bf05d1141..d7538b01f 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -397,7 +397,7 @@ async function generalTransferManager() { let fromTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the sale lockup period ends and the investor can freely sell his tokens (now = ${now}): `, { defaultInput: now }); let toTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely purchase tokens from others (now = ${now}): `, { defaultInput: now }); let oneYearFromNow = Math.floor(Date.now() / 1000 + (60 * 60 * 24 * 365)); - let expiryTime = readlineSync.questionInt(`Enter the time till investors KYC will be validated (after that investor need to do re - KYC) (1 year from now = ${oneYearFromNow}): `, { defaultInput: oneYearFromNow }); + let expiryTime = readlineSync.questionInt(`Enter the time until the investors KYC will be valid (after this time expires, the investor must re-do KYC) (1 year from now = ${oneYearFromNow}): `, { defaultInput: oneYearFromNow }); let canBuyFromSTO = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); let modifyWhitelistAction = currentTransferManager.methods.modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO); let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction); From 3ca197a1db716e565053f32173a61b78989df389 Mon Sep 17 00:00:00 2001 From: F O'Brien <42175565+F-OBrien@users.noreply.github.com> Date: Wed, 6 Feb 2019 10:33:05 -0300 Subject: [PATCH 12/14] Update CLI/commands/transfer_manager.js Co-Authored-By: VictorVicente --- CLI/commands/transfer_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index d7538b01f..cc286fcdd 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -398,7 +398,7 @@ async function generalTransferManager() { let toTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely purchase tokens from others (now = ${now}): `, { defaultInput: now }); let oneYearFromNow = Math.floor(Date.now() / 1000 + (60 * 60 * 24 * 365)); let expiryTime = readlineSync.questionInt(`Enter the time until the investors KYC will be valid (after this time expires, the investor must re-do KYC) (1 year from now = ${oneYearFromNow}): `, { defaultInput: oneYearFromNow }); - let canBuyFromSTO = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); + let canBuyFromSTO = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?'); let modifyWhitelistAction = currentTransferManager.methods.modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO); let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction); let modifyWhitelistEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistReceipt.logs, 'ModifyWhitelist'); @@ -2750,4 +2750,4 @@ module.exports = { currentTransferManager.setProvider(web3.currentProvider); return modifyWhitelistInBatch(_csvFilePath, _batchSize); } -} \ No newline at end of file +} From a742e6764d9dc5aab18805defc304f129d10bd74 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 6 Feb 2019 11:17:37 -0300 Subject: [PATCH 13/14] Allowance method fix --- CLI/commands/ST20Generator.js | 8 ++++---- CLI/commands/investor_portal.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CLI/commands/ST20Generator.js b/CLI/commands/ST20Generator.js index 0863c727e..2b9311172 100644 --- a/CLI/commands/ST20Generator.js +++ b/CLI/commands/ST20Generator.js @@ -187,13 +187,13 @@ async function selectTicker() { async function approvePoly(spender, fee) { polyBalance = await polyToken.methods.balanceOf(Issuer.address).call(); - let requiredAmount = web3.utils.toWei(fee.toString(), "ether"); + let requiredAmount = web3.utils.toWei(fee.toString()); if (parseInt(polyBalance) >= parseInt(requiredAmount)) { - let allowance = await polyToken.methods.allowance(spender, Issuer.address).call(); - if (allowance == web3.utils.toWei(fee.toString(), "ether")) { + let allowance = await polyToken.methods.allowance(Issuer.address, spender).call(); + if (parseInt(allowance) >= parseInt(requiredAmount)) { return true; } else { - let approveAction = polyToken.methods.approve(spender, web3.utils.toWei(fee.toString(), "ether")); + let approveAction = polyToken.methods.approve(spender, requiredAmount); await common.sendTransaction(approveAction); } } else { diff --git a/CLI/commands/investor_portal.js b/CLI/commands/investor_portal.js index 0bf12342a..124d0d297 100644 --- a/CLI/commands/investor_portal.js +++ b/CLI/commands/investor_portal.js @@ -498,8 +498,8 @@ async function investCappedSTO(currency, amount) { if (raiseTypes[0] == 'POLY') { let userBalance = await polyBalance(User.address); if (parseInt(userBalance) >= parseInt(cost)) { - let allowance = await polyToken.methods.allowance(STOAddress, User.address).call(); - if (allowance < costWei) { + let allowance = await polyToken.methods.allowance(User.address, STOAddress).call(); + if (parseInt(allowance) < parseInt(costWei)) { let approveAction = polyToken.methods.approve(STOAddress, costWei); await common.sendTransaction(approveAction, { from: User }); } @@ -607,8 +607,8 @@ async function investUsdTieredSTO(currency, amount) { if (raiseType == POLY) { let userBalance = await polyBalance(User.address); if (parseInt(userBalance) >= parseInt(cost)) { - let allowance = await polyToken.methods.allowance(STOAddress, User.address).call(); - if (allowance < costWei) { + let allowance = await polyToken.methods.allowance(User.address, STOAddress).call(); + if (parseInt(allowance) < parseInt(costWei)) { let approveAction = polyToken.methods.approve(STOAddress, costWei); await common.sendTransaction(approveAction, { from: User }); } @@ -628,8 +628,8 @@ async function investUsdTieredSTO(currency, amount) { if (parseInt(stableInfo.balance) >= parseInt(cost)) { let stableCoin = common.connect(abis.erc20(), stableInfo.address); - let allowance = await stableCoin.methods.allowance(STOAddress, User.address).call(); - if (allowance < costWei) { + let allowance = await stableCoin.methods.allowance(User.address, STOAddress).call(); + if (parseInt(allowance) < parseInt(costWei)) { let approveAction = stableCoin.methods.approve(STOAddress, costWei); await common.sendTransaction(approveAction, { from: User }); } From 0973815dbf1283eb897282392aaf27a9964481aa Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 6 Feb 2019 11:30:42 -0300 Subject: [PATCH 14/14] Minor change --- CLI/commands/token_manager.js | 2 +- CLI/commands/transfer_manager.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CLI/commands/token_manager.js b/CLI/commands/token_manager.js index 4b667b54c..8ceb3bb4f 100644 --- a/CLI/commands/token_manager.js +++ b/CLI/commands/token_manager.js @@ -297,7 +297,7 @@ async function mintTokens() { let fromTime = readlineSync.questionInt('Enter the time (Unix Epoch time) when the sale lockup period ends and the investor can freely sell his tokens: '); let toTime = readlineSync.questionInt('Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely purchase tokens from others: '); let expiryTime = readlineSync.questionInt('Enter the time till investors KYC will be validated (after that investor need to do re-KYC): '); - let canBuyFromSTO = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); + let canBuyFromSTO = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?'); await modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO); break; case 'Mint tokens to a single address': diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index e163bf0b5..5a5b148ca 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -398,7 +398,7 @@ async function generalTransferManager() { let toTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely purchase tokens from others (now = ${now}): `, { defaultInput: now }); let oneYearFromNow = Math.floor(Date.now() / 1000 + (60 * 60 * 24 * 365)); let expiryTime = readlineSync.questionInt(`Enter the time until the investors KYC will be valid (after this time expires, the investor must re-do KYC) (1 year from now = ${oneYearFromNow}): `, { defaultInput: oneYearFromNow }); - let canBuyFromSTO = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?'); + let canBuyFromSTO = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?'); let modifyWhitelistAction = currentTransferManager.methods.modifyWhitelist(investor, fromTime, toTime, expiryTime, canBuyFromSTO); let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction); let modifyWhitelistEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistReceipt.logs, 'ModifyWhitelist'); @@ -421,7 +421,7 @@ async function generalTransferManager() { let vSigned = readlineSync.questionInt('Enter v: '); let rSigned = readlineSync.question('Enter r: '); let sSigned = readlineSync.question('Enter s: '); - let canBuyFromSTOSigned = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); + let canBuyFromSTOSigned = readlineSync.keyInYNStrict('Can the investor buy from security token offerings?'); let modifyWhitelistSignedAction = currentTransferManager.methods.modifyWhitelistSigned(investorSigned, fromTimeSigned, toTimeSigned, expiryTimeSigned, canBuyFromSTOSigned); let modifyWhitelistSignedReceipt = await common.sendTransaction(Issuer, modifyWhitelistSignedAction, defaultGasPrice); let modifyWhitelistSignedEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistSignedReceipt.logs, 'ModifyWhitelist');