()
| 2438 | } |
| 2439 | |
| 2440 | async function addLockupsInBatch() { |
| 2441 | let csvFilePath = readlineSync.question(`Enter the path for csv data file (${ADD_LOCKUP_DATA_CSV}): `, { |
| 2442 | defaultInput: ADD_LOCKUP_DATA_CSV |
| 2443 | }); |
| 2444 | let batchSize = readlineSync.question(`Enter the max number of records per transaction or batch size (${gbl.constants.DEFAULT_BATCH_SIZE}): `, { |
| 2445 | limit: function (input) { |
| 2446 | return parseInt(input) > 0; |
| 2447 | }, |
| 2448 | limitMessage: 'Must be greater than 0', |
| 2449 | defaultInput: gbl.constants.DEFAULT_BATCH_SIZE |
| 2450 | }); |
| 2451 | let parsedData = csvParse(csvFilePath); |
| 2452 | let validData = parsedData.filter( |
| 2453 | row => !isNaN(row[0]) && |
| 2454 | moment.unix(row[1]).isValid() && |
| 2455 | (!isNaN(row[2] && (parseFloat(row[2]) % 1 === 0))) && |
| 2456 | (!isNaN(row[3] && (parseFloat(row[3]) % 1 === 0))) && |
| 2457 | typeof row[4] === 'string'); |
| 2458 | let invalidRows = parsedData.filter(row => !validData.includes(row)); |
| 2459 | if (invalidRows.length > 0) { |
| 2460 | console.log(chalk.red(`The following lines from csv file are not valid: ${invalidRows.map(r => parsedData.indexOf(r) + 1).join(',')} `)); |
| 2461 | } |
| 2462 | let batches = common.splitIntoBatches(validData, batchSize); |
| 2463 | let [amountArray, startTimeArray, lockUpPeriodArray, releaseFrequencyArray, lockupNameArray] = common.transposeBatches(batches); |
| 2464 | for (let batch = 0; batch < batches.length; batch++) { |
| 2465 | console.log(`Batch ${batch + 1} - Attempting to add the following lockups: \n\n`, lockupNameArray[batch], '\n'); |
| 2466 | lockupNameArray[batch] = lockupNameArray[batch].map(n => web3.utils.toHex(n)); |
| 2467 | let action = currentTransferManager.methods.addNewLockUpTypeMulti(amountArray[batch], startTimeArray[batch], lockUpPeriodArray[batch], releaseFrequencyArray[batch], lockupNameArray[batch]); |
| 2468 | let receipt = await common.sendTransaction(action); |
| 2469 | console.log(chalk.green('Add multiple lockups transaction was successful.')); |
| 2470 | console.log(`${receipt.gasUsed} gas used.Spent: ${web3.utils.fromWei((new web3.utils.BN(receipt.gasUsed)).mul(new web3.utils.BN(defaultGasPrice)))} ETH`); |
| 2471 | } |
| 2472 | } |
| 2473 | |
| 2474 | async function modifyLockupsInBatch() { |
| 2475 | let csvFilePath = readlineSync.question(`Enter the path for csv data file (${MODIFY_LOCKUP_DATA_CSV}): `, { |
no outgoing calls
no test coverage detected