Compare commits
2 Commits
v7.0.0
...
addresses/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a18d3c5c
|
||
|
|
b3dabb41e1
|
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"31": {
|
"31": {
|
||||||
"Contributor": "0xf1073Dab6e305583F95e451Cba449bB867a6e3Fd",
|
"Contributor": "0x9C66a36fa6296EBb81d8F5D4642B05dF2CE85a8D",
|
||||||
"Contribution": "0x1C531F824e339cD37D75B7F391cB8E42e0E0d4bd",
|
"Contribution": "0xa12630a995337e45bDD746B6baedc1Ce2a1DCC9D",
|
||||||
"Token": "0x56F64C3BB45e6a248F4C783f5a1633E53D6A2371",
|
"Token": "0x12Eb86338076450f86E5B552556028c7D21eaf1F",
|
||||||
"Reimbursement": "0x9C5fFBFba2570A9b31D60338453C5480Ce74B342"
|
"Reimbursement": "0xe2FE7cb00e2f94b8bA0AE526dfbe313f34c66E3C"
|
||||||
},
|
},
|
||||||
"1337": {
|
"1337": {
|
||||||
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ class Kredits {
|
|||||||
if (wallet) {
|
if (wallet) {
|
||||||
signer = wallet.connect(ethProvider);
|
signer = wallet.connect(ethProvider);
|
||||||
} else if (ethProvider.getSigner) {
|
} else if (ethProvider.getSigner) {
|
||||||
// Only useful for reading data, not writing. The (unused) address is
|
signer = ethProvider.getSigner();
|
||||||
// necessary because without an address, ethers.js will try to look up
|
|
||||||
// the provider's account 0, which doesn't work on our public RSK nodes.
|
|
||||||
signer = ethProvider.getSigner('0xfa77675540E550b911a6AABF3805ac17C6641ec1');
|
|
||||||
}
|
}
|
||||||
return new Kredits(ethProvider, signer, kreditsOptions);
|
return new Kredits(ethProvider, signer, kreditsOptions);
|
||||||
}
|
}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "kredits-contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.0",
|
"version": "7.0.0-beta.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "kredits-contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.0",
|
"version": "7.0.0-beta.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kosmos/schemas": "^3.1.0",
|
"@kosmos/schemas": "^3.1.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@kredits/contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.0",
|
"version": "7.0.0-beta.0",
|
||||||
"description": "Smart contracts and JavaScript API for Kredits",
|
"description": "Ethereum contracts and npm wrapper for Kredits",
|
||||||
"main": "./lib/kredits.js",
|
"main": "./lib/kredits.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Kredits = require('../../lib/kredits');
|
const Kredits = require('../../lib/kredits');
|
||||||
|
|
||||||
|
const PARALLEL_TXS = 5;
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
const count = await kredits.Contribution.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync("./data/contributions.json");
|
const data = fs.readFileSync("./data/contributions.json");
|
||||||
@@ -20,21 +20,42 @@ async function main() {
|
|||||||
const confirmationPeriod = 40320 // blocks
|
const confirmationPeriod = 40320 // blocks
|
||||||
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
||||||
|
|
||||||
for (const contributionId of ids) {
|
const txBundlesAmount = Math.ceil(ids.length / PARALLEL_TXS);
|
||||||
const c = contributions[contributionId.toString()];
|
let txBundles = [];
|
||||||
|
|
||||||
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
|
for (let i = 0; i < txBundlesAmount; i++) {
|
||||||
|
txBundles.push(ids.slice((i * PARALLEL_TXS), (i * PARALLEL_TXS) + PARALLEL_TXS));
|
||||||
|
}
|
||||||
|
|
||||||
const result = await kredits.Contribution.contract.add(
|
for (const txBundle of txBundles) {
|
||||||
c.amount, c.contributorId,
|
console.log(`Adding contributions #${txBundle[0]} to #${txBundle[txBundle.length - 1]}`)
|
||||||
c.hashDigest, c.hashFunction, c.hashSize,
|
|
||||||
confirmedAtBlock, c.vetoed
|
let resultPromises = [];
|
||||||
);
|
|
||||||
console.log(`Adding contribution #${contributionId}: ${result.hash}`);
|
for (const contributionId of txBundle) {
|
||||||
await result.wait();
|
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');
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ async function main() {
|
|||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||||
const count = await kredits.Contributor.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync("./data/contributors.json");
|
const data = fs.readFileSync("./data/contributors.json");
|
||||||
const contributors = JSON.parse(data);
|
const contributors = JSON.parse(data);
|
||||||
@@ -23,11 +22,11 @@ async function main() {
|
|||||||
contributor.hashFunction,
|
contributor.hashFunction,
|
||||||
contributor.hashSize,
|
contributor.hashSize,
|
||||||
);
|
);
|
||||||
console.log(`Adding contributor #${contributorId}: ${result.hash}`);
|
// await result.wait();
|
||||||
await result.wait();
|
console.log(`Added contributor #${contributorId}: ${result.hash}`);
|
||||||
};
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ async function main() {
|
|||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||||
const count = await kredits.Contributors.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
|
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
|
||||||
|
|||||||
Reference in New Issue
Block a user