Add export/import functionality #224

Merged
raucao merged 23 commits from feature/export-import into master 2022-09-02 20:31:28 +00:00
Showing only changes of commit 1521e272f9 - Show all commits

View File

@ -1,3 +1,4 @@
const fs = require('fs');
const Kredits = require('../../lib/kredits'); const Kredits = require('../../lib/kredits');
async function main() { async function main() {
@ -6,21 +7,27 @@ async function main() {
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`); console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
const data = fs.readFileSync("./data/contributors.json"); try {
const contributors = JSON.parse(data); const data = fs.readFileSync("./data/contributors.json");
const contributors = JSON.parse(data);
const ids = Object.keys(contributors)
.map(k => parseInt(k))
.sort(function(a, b){return a-b});
const ids = Object.keys(contributors).map(k => parseInt(k)).sort(); for (const contributorId of ids) {
for (const contributorId of ids) { const contributor = contributors[contributorId.toString()];
const contributor = contributors[contributorId.toString()]; const result = await kredits.Contributor.contract.addContributor(
const result = kredits.Contributor.contract.addContributor({ contributor.account,
account: contributor.account, contributor.hashDigest,
hashDigest: contirbutor.hashDigest, contributor.hashFunction,
hashFunction: contributor.hashFunction, contributor.hashSize,
hashSize: contributr.hashSize, );
}); // await result.wait();
// await result.wait(); console.log(`Added contributor #${contributorId}: ${result.hash}`);
console.log(`Added contributor #${id}: ${result.hash}`); };
}; } catch(e) {
console.log(e);
}
} }
main(); main();