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 0cb02f681..124d0d297 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)}`); @@ -499,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 }); } @@ -608,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 }); } @@ -629,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 }); } 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/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."); diff --git a/CLI/commands/token_manager.js b/CLI/commands/token_manager.js index e46019abb..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': @@ -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,13 +498,13 @@ 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; 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`)); @@ -519,13 +519,13 @@ 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; 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`)); @@ -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); @@ -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 whould 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 }); diff --git a/CLI/commands/transfer_manager.js b/CLI/commands/transfer_manager.js index a85613bdf..5a5b148ca 100644 --- a/CLI/commands/transfer_manager.js +++ b/CLI/commands/transfer_manager.js @@ -199,8 +199,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'); @@ -380,7 +380,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'); @@ -396,9 +396,9 @@ 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 canBuyFromSTO = readlineSync.keyInYNStrict('Is the investor a restricted investor?'); + 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 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'); @@ -2328,16 +2328,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' ]; @@ -2351,7 +2350,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!`)); @@ -2779,4 +2778,4 @@ module.exports = { currentTransferManager.setProvider(web3.currentProvider); return modifyWhitelistInBatch(_csvFilePath, _batchSize); } -} \ No newline at end of file +} diff --git a/test/y_volume_restriction_tm.js b/test/y_volume_restriction_tm.js index 0a9894032..59b5adaa2 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()} `) @@ -91,7 +91,7 @@ contract('VolumeRestrictionTransferManager', accounts => { async function printRestrictedData(data) { let investors = data[0]; - for (let i = 0 ; i < investors.length; i++) { + for (let i = 0; i < investors.length; i++) { console.log(` Token holder: ${data[0][i]} Start Time: ${data[2][i].toNumber()} @@ -114,7 +114,7 @@ contract('VolumeRestrictionTransferManager', accounts => { return sum; } - before(async() => { + before(async () => { // Accounts setup account_polymath = accounts[0]; account_issuer = accounts[1]; @@ -200,9 +200,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), @@ -211,23 +211,23 @@ 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); @@ -238,17 +238,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, @@ -264,7 +264,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, @@ -280,7 +280,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, @@ -296,7 +296,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, @@ -312,7 +312,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, @@ -328,7 +328,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, @@ -344,7 +344,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, @@ -360,7 +360,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, @@ -376,7 +376,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, @@ -392,7 +392,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, @@ -408,18 +408,18 @@ 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); let data = await I_VolumeRestrictionTM.getRestrictedData.call(); @@ -427,15 +427,15 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[0][0], account_investor1); }); - 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 } @@ -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], [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 } @@ -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")], [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 } @@ -475,15 +475,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 } @@ -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], [latestTime() + duration.days(5), latestTime() + duration.days(6), latestTime() + duration.days(7)], - [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], @@ -515,7 +515,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 } @@ -523,7 +523,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], @@ -539,17 +539,17 @@ 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")], - [0, 0, 0], - [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")], + [0, 0, 0], + [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); @@ -560,7 +560,7 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[0].length, 4); }); - 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], @@ -571,8 +571,8 @@ 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); let data = await I_VolumeRestrictionTM.getRestrictedData.call(); await printRestrictedData(data); @@ -582,13 +582,13 @@ contract('VolumeRestrictionTransferManager', accounts => { } }); - 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], { @@ -600,7 +600,7 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[0].length, 1); }); - 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( @@ -619,16 +619,16 @@ 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); @@ -638,22 +638,22 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[0][0], account_investor1); }); - 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 @@ -664,7 +664,7 @@ contract('VolumeRestrictionTransferManager', accounts => { 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( @@ -675,7 +675,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, @@ -690,7 +690,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, @@ -705,7 +705,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, @@ -720,7 +720,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, @@ -735,17 +735,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); @@ -765,57 +765,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)), @@ -846,15 +846,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 @@ -866,25 +866,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 @@ -907,18 +907,18 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[0][0], account_investor1); }); - 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); @@ -930,7 +930,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())); @@ -941,22 +941,22 @@ 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 dataAdd = await I_VolumeRestrictionTM.getRestrictedData.call(); await printRestrictedData(dataAdd); @@ -967,14 +967,14 @@ contract('VolumeRestrictionTransferManager', accounts => { 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())); @@ -984,7 +984,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, @@ -1016,7 +1016,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); @@ -1024,7 +1024,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())); @@ -1035,11 +1035,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, @@ -1054,16 +1054,16 @@ 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); @@ -1077,20 +1077,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())); @@ -1100,14 +1100,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); @@ -1115,7 +1115,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())); @@ -1125,29 +1125,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())); @@ -1157,7 +1157,7 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(amt, 2.86); }); - it("Should fail to transact tokens more than the allowed in the second rolling period", async() => { + 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++) { @@ -1166,11 +1166,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(); @@ -1178,7 +1178,7 @@ 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); @@ -1186,7 +1186,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())); @@ -1196,7 +1196,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(); @@ -1207,7 +1207,7 @@ 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); @@ -1215,7 +1215,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())); @@ -1225,10 +1225,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); } @@ -1236,9 +1236,9 @@ 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); @@ -1246,7 +1246,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())); @@ -1256,16 +1256,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() => { + describe("Test cases for the Default restrictions", async () => { - it("Should add the investor 4 in the whitelist", async() => { + it("Should add the investor 4 in the whitelist", async () => { await I_GeneralTransferManager.modifyWhitelist( account_investor4, latestTime(), @@ -1278,11 +1278,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, @@ -1304,23 +1304,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); @@ -1330,16 +1330,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, @@ -1365,14 +1365,14 @@ 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); @@ -1380,7 +1380,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())); @@ -1392,7 +1392,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); @@ -1400,7 +1400,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())); @@ -1410,13 +1410,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++) { @@ -1428,7 +1428,7 @@ 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); @@ -1436,7 +1436,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())); @@ -1447,11 +1447,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, @@ -1473,19 +1473,19 @@ 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); @@ -1493,7 +1493,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())); @@ -1504,29 +1504,29 @@ 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 }); console.log(await I_VolumeRestrictionTM.getExemptAddress.call()); 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); }); - it("Should add multiple token holders to exemption list and check the getter value", async() => { + it("Should add multiple token holders to exemption list and check the getter value", async () => { let holders = [account_investor1, account_investor3, account_investor2, account_delegate2]; let change = [true, true, true, true]; for (let i = 0; i < holders.length; i++) { - await I_VolumeRestrictionTM.changeExemptWalletList(holders[i], change[i], {from: token_owner}); + await I_VolumeRestrictionTM.changeExemptWalletList(holders[i], change[i], { from: token_owner }); } let data = await I_VolumeRestrictionTM.getExemptAddress.call(); assert.equal(data.length, 5); @@ -1537,8 +1537,8 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[4], account_delegate2); }); - it("Should unexempt a particular address", async() => { - await I_VolumeRestrictionTM.changeExemptWalletList(account_investor1, false, {from: token_owner}); + it("Should unexempt a particular address", async () => { + await I_VolumeRestrictionTM.changeExemptWalletList(account_investor1, false, { from: token_owner }); let data = await I_VolumeRestrictionTM.getExemptAddress.call(); assert.equal(data.length, 4); assert.equal(data[0], account_investor4); @@ -1547,14 +1547,14 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[3], account_investor2); }); - it("Should fail to unexempt the same address again", async() => { + it("Should fail to unexempt the same address again", async () => { await catchRevert( - I_VolumeRestrictionTM.changeExemptWalletList(account_investor1, false, {from: token_owner}) + I_VolumeRestrictionTM.changeExemptWalletList(account_investor1, false, { from: token_owner }) ); }); - it("Should delete the last element of the exemption list", async() => { - await I_VolumeRestrictionTM.changeExemptWalletList(account_investor2, false, {from: token_owner}); + it("Should delete the last element of the exemption list", async () => { + await I_VolumeRestrictionTM.changeExemptWalletList(account_investor2, false, { from: token_owner }); let data = await I_VolumeRestrictionTM.getExemptAddress.call(); assert.equal(data.length, 3); assert.equal(data[0], account_investor4); @@ -1562,27 +1562,27 @@ contract('VolumeRestrictionTransferManager', accounts => { assert.equal(data[2], account_investor3); }); - it("Should delete multiple investor from the exemption list", async() => { + it("Should delete multiple investor from the exemption list", async () => { let holders = [account_delegate2, account_investor4, account_investor3]; let change = [false, false, false]; for (let i = 0; i < holders.length; i++) { - await I_VolumeRestrictionTM.changeExemptWalletList(holders[i], change[i], {from: token_owner}); + await I_VolumeRestrictionTM.changeExemptWalletList(holders[i], change[i], { from: token_owner }); } let data = await I_VolumeRestrictionTM.getExemptAddress.call(); assert.equal(data.length, 0); }); }); - 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 } @@ -1601,14 +1601,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 } @@ -1629,28 +1629,28 @@ 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");