Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (tickerDetails[1] == 0) {
console.log(chalk.yellow(`${ticker} is not registered.`));
} else {
console.log(`-- Current Ticker details --`);
console.log(` Owner: ${tickerDetails[0]}`);
console.log(` Token name: ${tickerDetails[3]}\n`);
}
let name = readlineSync.question(`Enter the token name: `);
let owner = readlineSync.question(`Enter the token owner: `, {
limit: function(input) {
return web3.utils.isAddress(input);
},
limitMessage: "Must be a valid address"
});
let tokenDetails = readlineSync.question(`Enter the token details: `);
let deployedAt = readlineSync.questionInt(`Enter the Unix Epoch timestamp at which security token was deployed: `);
let modifySTAction = currentContract.methods.modifySecurityToken(name, ticker, owner, stAddress, tokenDetails, deployedAt);
await common.sendTransaction(modifySTAction, {factor: 1.5});
console.log(chalk.green(`Security Token has been updated successfully`));
break;
case 'Change Expiry Limit':
let currentExpiryLimit = await currentContract.methods.getExpiryLimit().call();
console.log(chalk.yellow(`Current expiry limit is ${Math.floor(parseInt(currentExpiryLimit)/60/60/24)} days`));
let newExpiryLimit = global.constants.DURATION.days(readlineSync.questionInt('Enter a new value in days for expiry limit: '));
let changeExpiryLimitAction = currentContract.methods.changeExpiryLimit(newExpiryLimit);
let changeExpiryLimitReceipt = await common.sendTransaction(changeExpiryLimitAction, {});
let changeExpiryLimitEvent = common.getEventFromLogs(currentContract._jsonInterface, changeExpiryLimitReceipt.logs, 'ChangeExpiryLimit');
console.log(chalk.green(`Expiry limit was changed successfully. New limit is ${Math.floor(parseInt(changeExpiryLimitEvent._newExpiry)/60/60/24)} days\n`));
break;
case 'Change registration fee':
let currentRegFee = web3.utils.fromWei(await currentContract.methods.getTickerRegistrationFee().call());
console.log(chalk.yellow(`\nCurrent ticker registration fee is ${currentRegFee} POLY`));
limit: function (input) {
return input === '' || input.split(",").every(a => web3.utils.isAddress(a));
},
limitMessage: `All addresses must be valid`
});
if (investorsToShow === '') {
let whitelistData = await currentTransferManager.methods.getAllInvestorsData().call();
showWhitelistTable(whitelistData[0], whitelistData[1], whitelistData[2], whitelistData[3], whitelistData[4]);
} else {
let investorsArray = investorsToShow.split(',');
let whitelistData = await currentTransferManager.methods.getInvestorsData(investorsArray).call();
showWhitelistTable(investorsArray, whitelistData[0], whitelistData[1], whitelistData[2], whitelistData[3]);
}
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 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');
console.log(chalk.green(`Default times have been updated successfully!`));
break;
case 'Modify whitelist':
let investor = readlineSync.question('Enter the address to whitelist: ', {
limit: function (input) {
return web3.utils.isAddress(input);
},
limitMessage: "Must be a valid address"
});
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 });
}
options.push('Delete investors from all blacklists', 'Operate with multiple blacklists');
let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: "RETURN" });
let optionSelected = index !== -1 ? options[index] : 'RETURN';
console.log('Selected:', optionSelected, '\n');
switch (optionSelected) {
case 'Add new blacklist':
let name = readlineSync.question(`Enter the name of the blacklist type: `, {
limit: function (input) {
return input !== "";
},
limitMessage: `Invalid blacklist name`
});
let minuteFromNow = Math.floor(Date.now() / 1000) + 60;
let startTime = readlineSync.questionInt(`Enter the start date (Unix Epoch time) of the blacklist type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow });
let oneDayFromStartTime = startTime + 24 * 60 * 60;
let endTime = readlineSync.questionInt(`Enter the end date (Unix Epoch time) of the blacklist type (1 day from start time = ${oneDayFromStartTime}): `, { defaultInput: oneDayFromStartTime });
let repeatPeriodTime = readlineSync.questionInt(`Enter the repeat period (days) of the blacklist type, 0 to disable (90 days): `, { defaultInput: 90 });
if (readlineSync.keyInYNStrict(`Do you want to add an investor to this blacklist type? `)) {
let investor = readlineSync.question(`Enter the address of the investor: `, {
limit: function (input) {
return web3.utils.isAddress(input);
},
limitMessage: `Must be a valid address`
});
let addInvestorToNewBlacklistAction = currentTransferManager.methods.addInvestorToNewBlacklist(
startTime,
endTime,
web3.utils.toHex(name),
repeatPeriodTime,
investor
async function queryModifyWhiteList(currentTransferManager) {
let investor = input.readAddress('Enter the address to whitelist: ');
let now = Math.floor(Date.now() / 1000);
let canSendAfter = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the sale lockup period ends and the investor can freely transfer his tokens (now = ${now}): `, { defaultInput: now });
let canReceiveAfter = readlineSync.questionInt(`Enter the time (Unix Epoch time) when the purchase lockup period ends and the investor can freely receive 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 modifyWhitelistAction = currentTransferManager.methods.modifyKYCData(investor, canSendAfter, canReceiveAfter, expiryTime);
let modifyWhitelistReceipt = await sendTransaction(modifyWhitelistAction);
let moduleVersion = await getModuleVersion(currentTransferManager);
if (moduleVersion != '1.0.0') {
let modifyWhitelistEvent = getEventFromLogs(currentTransferManager._jsonInterface, modifyWhitelistReceipt.logs, 'ModifyKYCData');
console.log(chalk.green(`${modifyWhitelistEvent._investor} has been whitelisted sucessfully!`));
} else {
console.log(chalk.green(`${investor} has been whitelisted sucessfully!`));
}
}
async function createDividends(dividend, checkpointId) {
await addDividendsModule();
let time = Math.floor(Date.now()/1000);
let maturityTime = readlineSync.questionInt('Enter the dividend maturity time from which dividend can be paid (Unix Epoch time)\n(Now = ' + time + ' ): ', {defaultInput: time});
let defaultTime = time + duration.minutes(10);
let expiryTime = readlineSync.questionInt('Enter the dividend expiry time (Unix Epoch time)\n(10 minutes from now = ' + defaultTime + ' ): ', {defaultInput: defaultTime});
let createDividendAction;
if (dividendsType == 'POLY') {
let approveAction = polyToken.methods.approve(currentDividendsModule._address, web3.utils.toWei(dividend));
await common.sendTransaction(Issuer, approveAction, defaultGasPrice);
if (checkpointId > 0) {
createDividendAction = currentDividendsModule.methods.createDividendWithCheckpoint(maturityTime, expiryTime, polyToken._address, web3.utils.toWei(dividend), checkpointId);
} else {
createDividendAction = currentDividendsModule.methods.createDividend(maturityTime, expiryTime, polyToken._address, web3.utils.toWei(dividend));
}
let receipt = await common.sendTransaction(Issuer, createDividendAction, defaultGasPrice);
let event = common.getEventFromLogs(currentDividendsModule._jsonInterface, receipt.logs, 'ERC20DividendDeposited');
console.log(`
Dividend ${event._dividendIndex} deposited`
"Modify properties",
"Show investors",
"Add investors",
"Remove investor",
"Delete this blacklist type"
];
let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'RETURN' });
let optionSelected = index !== -1 ? options[index] : 'RETURN';
console.log('Selected:', optionSelected, '\n');
switch (optionSelected) {
case 'Modify properties':
let minuteFromNow = Math.floor(Date.now() / 1000) + 60;
let startTime = readlineSync.questionInt(`Enter the start date (Unix Epoch time) of the blacklist type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow });
let oneDayFromStartTime = startTime + 24 * 60 * 60;
let endTime = readlineSync.questionInt(`Enter the end date (Unix Epoch time) of the blacklist type (1 day from start time = ${oneDayFromStartTime}): `, { defaultInput: oneDayFromStartTime });
let repeatPeriodTime = readlineSync.questionInt(`Enter the repeat period (days) of the blacklist type, 0 to disable (90 days): `, { defaultInput: 90 });
let modifyBlacklistTypeAction = currentTransferManager.methods.modifyBlacklistType(
startTime,
endTime,
blacklistName,
repeatPeriodTime
);
let modifyBlacklistTypeReceipt = await common.sendTransaction(modifyBlacklistTypeAction);
let modifyBlacklistTypeEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyBlacklistTypeReceipt.logs, 'ModifyBlacklistType');
console.log(chalk.green(`${web3.utils.hexToUtf8(modifyBlacklistTypeEvent._blacklistName)} blacklist type has been modified successfully!`));
break;
case 'Show investors':
if (investors.length > 0) {
console.log("************ List of investors ************");
investors.map(i => console.log(i));
} else {
let options = [
"Modify properties",
"Show investors",
"Add investors",
"Remove investor",
"Delete this blacklist type"
];
let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'RETURN' });
let optionSelected = index !== -1 ? options[index] : 'RETURN';
console.log('Selected:', optionSelected, '\n');
switch (optionSelected) {
case 'Modify properties':
let minuteFromNow = Math.floor(Date.now() / 1000) + 60;
let startTime = readlineSync.questionInt(`Enter the start date (Unix Epoch time) of the blacklist type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow });
let oneDayFromStartTime = startTime + 24 * 60 * 60;
let endTime = readlineSync.questionInt(`Enter the end date (Unix Epoch time) of the blacklist type (1 day from start time = ${oneDayFromStartTime}): `, { defaultInput: oneDayFromStartTime });
let repeatPeriodTime = readlineSync.questionInt(`Enter the repeat period (days) of the blacklist type, 0 to disable (90 days): `, { defaultInput: 90 });
let modifyBlacklistTypeAction = currentTransferManager.methods.modifyBlacklistType(
startTime,
endTime,
blacklistName,
repeatPeriodTime
);
let modifyBlacklistTypeReceipt = await common.sendTransaction(modifyBlacklistTypeAction);
let modifyBlacklistTypeEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyBlacklistTypeReceipt.logs, 'ModifyBlacklistType');
console.log(chalk.green(`${web3.utils.hexToUtf8(modifyBlacklistTypeEvent._blacklistName)} blacklist type has been modified successfully!`));
break;
case 'Show investors':
if (investors.length > 0) {
console.log("************ List of investors ************");
async function createDividendWithCheckpoint(ethDividend, checkpointId) {
await addDividendsModule();
let time = (await web3.eth.getBlock('latest')).timestamp;
let defaultTime = time + duration.minutes(10);
let expiryTime = readlineSync.questionInt('Enter the dividend expiry time (Unix Epoch time)\n(10 minutes from now = ' + defaultTime + ' ): ', {defaultInput: defaultTime});
let dividendStatus = await etherDividendCheckpoint.methods.getDividendIndex(checkpointId).call({from: Issuer});
if (dividendStatus.length != 1) {
//Send eth dividends
let createDividendWithCheckpointAction = etherDividendCheckpoint.methods.createDividendWithCheckpoint(time, expiryTime, checkpointId);
let GAS = await common.estimateGas(createDividendWithCheckpointAction, Issuer, 1.2, web3.utils.toWei(ethDividend,"ether"));
await createDividendWithCheckpointAction.send({ from: Issuer, value: web3.utils.toWei(ethDividend,"ether"), gas: GAS, gasPrice: defaultGasPrice })
.on('transactionHash', function(hash){
console.log(`
Your transaction is being processed. Please wait...
TxHash: ${hash}\n`
);
})
.on('receipt', function(receipt){
console.log(`
Congratulations! Dividend is created successfully.
async function createDividends(ethDividend){
await addDividendsModule();
let time = (await web3.eth.getBlock('latest')).timestamp;
let defaultTime = time + duration.minutes(10);
let expiryTime = readlineSync.questionInt('Enter the dividend expiry time (Unix Epoch time)\n(10 minutes from now = ' + defaultTime + ' ): ', {defaultInput: defaultTime});
//Send eth dividends
let createDividendAction = etherDividendCheckpoint.methods.createDividend(time, expiryTime);
GAS = await common.estimateGas(createDividendAction, Issuer, 1.2, web3.utils.toWei(ethDividend,"ether"));
await createDividendAction.send({ from: Issuer, value: web3.utils.toWei(ethDividend,"ether"), gas: GAS, gasPrice: defaultGasPrice })
.on('transactionHash', function(hash){
console.log(`
Your transaction is being processed. Please wait...
TxHash: ${hash}\n`
);
})
.on('receipt', function(receipt){
console.log(`
${receipt.events}
TxHash: ${receipt.transactionHash}\n`
);
let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: "RETURN" });
let optionSelected = index !== -1 ? options[index] : 'RETURN';
console.log('Selected:', optionSelected, '\n');
switch (optionSelected) {
case 'Add new blacklist':
let name = readlineSync.question(`Enter the name of the blacklist type: `, {
limit: function (input) {
return input !== "";
},
limitMessage: `Invalid blacklist name`
});
let minuteFromNow = Math.floor(Date.now() / 1000) + 60;
let startTime = readlineSync.questionInt(`Enter the start date (Unix Epoch time) of the blacklist type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow });
let oneDayFromStartTime = startTime + 24 * 60 * 60;
let endTime = readlineSync.questionInt(`Enter the end date (Unix Epoch time) of the blacklist type (1 day from start time = ${oneDayFromStartTime}): `, { defaultInput: oneDayFromStartTime });
let repeatPeriodTime = readlineSync.questionInt(`Enter the repeat period (days) of the blacklist type, 0 to disable (90 days): `, { defaultInput: 90 });
if (readlineSync.keyInYNStrict(`Do you want to add an investor to this blacklist type? `)) {
let investor = readlineSync.question(`Enter the address of the investor: `, {
limit: function (input) {
return web3.utils.isAddress(input);
},
limitMessage: `Must be a valid address`
});
let addInvestorToNewBlacklistAction = currentTransferManager.methods.addInvestorToNewBlacklist(
startTime,
endTime,
web3.utils.toHex(name),
repeatPeriodTime,
investor
);
let addInvestorToNewBlacklistReceipt = await common.sendTransaction(addInvestorToNewBlacklistAction);
let addNewBlacklistEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addInvestorToNewBlacklistReceipt.logs, 'AddBlacklistType');