MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / deleteLockupsInBatch

Function deleteLockupsInBatch

CLI/commands/transfer_manager.js:2508–2535  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2506}
2507
2508async function deleteLockupsInBatch() {
2509 let csvFilePath = readlineSync.question(`Enter the path for csv data file (${DELETE_LOCKUP_DATA_CSV}): `, {
2510 defaultInput: DELETE_LOCKUP_DATA_CSV
2511 });
2512 let batchSize = readlineSync.question(`Enter the max number of records per transaction or batch size (${gbl.constants.DEFAULT_BATCH_SIZE}): `, {
2513 limit: function (input) {
2514 return parseInt(input) > 0;
2515 },
2516 limitMessage: 'Must be greater than 0',
2517 defaultInput: gbl.constants.DEFAULT_BATCH_SIZE
2518 });
2519 let parsedData = csvParse(csvFilePath);
2520 let validData = parsedData.filter(row => typeof row[0] === 'string');
2521 let invalidRows = parsedData.filter(row => !validData.includes(row));
2522 if (invalidRows.length > 0) {
2523 console.log(chalk.red(`The following lines from csv file are not valid: ${invalidRows.map(r => parsedData.indexOf(r) + 1).join(',')} `));
2524 }
2525 let batches = common.splitIntoBatches(validData, batchSize);
2526 let [lockupNameArray] = common.transposeBatches(batches);
2527 for (let batch = 0; batch < batches.length; batch++) {
2528 console.log(`Batch ${batch + 1} - Attempting to delete the following lockups: \n\n`, lockupNameArray[batch], '\n');
2529 lockupNameArray[batch] = lockupNameArray[batch].map(n => web3.utils.toHex(n));
2530 let action = currentTransferManager.methods.removeLockupTypeMulti(lockupNameArray[batch]);
2531 let receipt = await common.sendTransaction(action);
2532 console.log(chalk.green('Delete multiple lockups transaction was successful.'));
2533 console.log(`${receipt.gasUsed} gas used.Spent: ${web3.utils.fromWei((new web3.utils.BN(receipt.gasUsed)).mul(new web3.utils.BN(defaultGasPrice)))} ETH`);
2534 }
2535}
2536
2537async function addLockupsToInvestorsInBatch() {
2538 let csvFilePath = readlineSync.question(`Enter the path for csv data file (${ADD_LOCKUP_INVESTOR_DATA_CSV}): `, {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected