-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakeAllTransactions.js
27 lines (23 loc) · 1.03 KB
/
MakeAllTransactions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import parseCsvFile from './parseCsvFile.js';
import processCsvRow from './processCsvRow.js';
// Define an async function to process the next row in the CSV file
const MakeAllTransactions = async (filename, api, frequency, currentRowIndex) => {
try {
// Read the contents of the CSV file if we haven't already done so
if (!MakeAllTransactions.rows) {
MakeAllTransactions.rows = await parseCsvFile(filename);
}
// Get the current row from the CSV file and process it using the Polkadot JS API
const row = MakeAllTransactions.rows[currentRowIndex];
const rowsLen = MakeAllTransactions.rows.length;
if (row) {
currentRowIndex++;
await processCsvRow(row, currentRowIndex, api, rowsLen);
}
} catch (error) {
console.error(`Error processing CSV row: ${error}`);
}
// Call this function again after the specified frequency
setTimeout(() => MakeAllTransactions(filename, api, frequency, currentRowIndex), frequency);
};
export default MakeAllTransactions;