Add reimbursement import
This commit is contained in:
parent
08df896ace
commit
55c6e252cf
36
scripts/import/reimbursements.js
Normal file
36
scripts/import/reimbursements.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const Kredits = require('../../lib/kredits');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
|
await kredits.init();
|
||||||
|
|
||||||
|
console.log(`Using Reimbursement at: ${kredits.Reimbursement.contract.address}`);
|
||||||
|
const count = await kredits.Reimbursement.count;
|
||||||
|
console.log(`Currently ${count} entries`);
|
||||||
|
try {
|
||||||
|
const data = fs.readFileSync("./data/reimbursements.json");
|
||||||
|
const reimbursements = JSON.parse(data);
|
||||||
|
const ids = Object.keys(reimbursements)
|
||||||
|
.map(k => parseInt(k))
|
||||||
|
.sort(function(a, b) { return a - b });
|
||||||
|
|
||||||
|
for (const reimbursementId of ids) {
|
||||||
|
const reimbursement = reimbursements[reimbursementId.toString()];
|
||||||
|
const result = await kredits.Reimbursement.contract.add(
|
||||||
|
reimbursement.amount,
|
||||||
|
reimbursement.token,
|
||||||
|
reimbursement.recipientId,
|
||||||
|
reimbursement.hashDigest,
|
||||||
|
reimbursement.hashFunction,
|
||||||
|
reimbursement.hashSize,
|
||||||
|
);
|
||||||
|
console.log(`Adding reimbursement #${reimbursementId}: ${result.hash}`);
|
||||||
|
await result.wait();
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
Loading…
x
Reference in New Issue
Block a user