Compare commits

..

3 Commits

Author SHA1 Message Date
hueso
dce54761a6 make KS undivisible
Some checks failed
continuous-integration/drone/push Build is failing
2022-09-01 22:18:22 -03:00
Râu Cao
62af06c3f8 Use ethers from correct parent object 2022-09-01 22:18:22 -03:00
Râu Cao
b5c0dd5ae0 Add script for importing contributions 2022-09-01 22:18:22 -03:00
4 changed files with 13 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,10 +1,4 @@
{
"31": {
"Contributor": "0x9C66a36fa6296EBb81d8F5D4642B05dF2CE85a8D",
"Contribution": "0xa12630a995337e45bDD746B6baedc1Ce2a1DCC9D",
"Token": "0x12Eb86338076450f86E5B552556028c7D21eaf1F",
"Reimbursement": "0xe2FE7cb00e2f94b8bA0AE526dfbe313f34c66E3C"
},
"1337": {
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",

View File

@@ -1,8 +1,6 @@
const fs = require('fs');
const Kredits = require('../../lib/kredits');
const PARALLEL_TXS = 5;
async function main() {
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
await kredits.init();
@@ -20,40 +18,19 @@ async function main() {
const confirmationPeriod = 40320 // blocks
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
const txBundlesAmount = Math.ceil(ids.length / PARALLEL_TXS);
let txBundles = [];
for (const contributionId of ids) {
const c = contributions[contributionId.toString()];
for (let i = 0; i < txBundlesAmount; i++) {
txBundles.push(ids.slice((i * PARALLEL_TXS), (i * PARALLEL_TXS) + PARALLEL_TXS));
}
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
for (const txBundle of txBundles) {
console.log(`Adding contributions #${txBundle[0]} to #${txBundle[txBundle.length - 1]}`)
let resultPromises = [];
for (const contributionId of txBundle) {
const c = contributions[contributionId.toString()];
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
const result = await kredits.Contribution.contract.add(
c.amount, c.contributorId,
c.hashDigest, c.hashFunction, c.hashSize,
confirmedAtBlock, c.vetoed
);
resultPromises.push(result.wait());
console.log(`Added contribution #${contributionId}: ${result.hash}`);
}
console.log(`Waiting for confirmations...`);
await Promise.all(resultPromises);
console.log('Transactions confirmed');
}
const result = await kredits.Contribution.contract.add(
c.amount, c.contributorId,
c.hashDigest, c.hashFunction, c.hashSize,
confirmedAtBlock, c.vetoed
);
// await result.wait();
console.log(`Added contribution #${contributionId}: ${result.hash}`);
};
} catch(e) {
console.log(e);
}

View File

@@ -95,7 +95,7 @@ describe("Contributor contract", async function () {
expect(c['balance']).to.equal(0);
await Contributor.connect(addr1).withdraw();
c = await Contributor.getContributorById(2);
expect(c['balance']).to.equal(6500);
expect(c['balance'].toString()).to.equal("6500000000000000000000");
expect(c['kreditsWithdrawn']).to.equal(6500);
});