Compare commits
7 Commits
addresses/
...
v7.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b63c68cd1c
|
||
| c875e775b6 | |||
|
|
6e0ec8741e
|
||
|
|
a1a68092f6
|
||
| c6168e59e8 | |||
| e810424163 | |||
| f71ff4ce9a |
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"31": {
|
||||
"Contributor": "0x9C66a36fa6296EBb81d8F5D4642B05dF2CE85a8D",
|
||||
"Contribution": "0xa12630a995337e45bDD746B6baedc1Ce2a1DCC9D",
|
||||
"Token": "0x12Eb86338076450f86E5B552556028c7D21eaf1F",
|
||||
"Reimbursement": "0xe2FE7cb00e2f94b8bA0AE526dfbe313f34c66E3C"
|
||||
"Contributor": "0xf1073Dab6e305583F95e451Cba449bB867a6e3Fd",
|
||||
"Contribution": "0x1C531F824e339cD37D75B7F391cB8E42e0E0d4bd",
|
||||
"Token": "0x56F64C3BB45e6a248F4C783f5a1633E53D6A2371",
|
||||
"Reimbursement": "0x9C5fFBFba2570A9b31D60338453C5480Ce74B342"
|
||||
},
|
||||
"1337": {
|
||||
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
||||
|
||||
@@ -69,7 +69,10 @@ class Kredits {
|
||||
if (wallet) {
|
||||
signer = wallet.connect(ethProvider);
|
||||
} else if (ethProvider.getSigner) {
|
||||
signer = ethProvider.getSigner();
|
||||
// Only useful for reading data, not writing. The (unused) address is
|
||||
// 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);
|
||||
}
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "kredits-contracts",
|
||||
"version": "7.0.0-beta.0",
|
||||
"version": "7.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "kredits-contracts",
|
||||
"version": "7.0.0-beta.0",
|
||||
"version": "7.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@kosmos/schemas": "^3.1.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "kredits-contracts",
|
||||
"version": "7.0.0-beta.0",
|
||||
"description": "Ethereum contracts and npm wrapper for Kredits",
|
||||
"name": "@kredits/contracts",
|
||||
"version": "7.0.0",
|
||||
"description": "Smart contracts and JavaScript API for Kredits",
|
||||
"main": "./lib/kredits.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
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();
|
||||
|
||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||
const count = await kredits.Contribution.count;
|
||||
console.log(`Currently ${count} entries`);
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync("./data/contributions.json");
|
||||
@@ -20,42 +20,21 @@ 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
|
||||
);
|
||||
console.log(`Adding contribution #${contributionId}: ${result.hash}`);
|
||||
await result.wait();
|
||||
};
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ async function main() {
|
||||
await kredits.init();
|
||||
|
||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||
|
||||
const count = await kredits.Contributor.count;
|
||||
console.log(`Currently ${count} entries`);
|
||||
try {
|
||||
const data = fs.readFileSync("./data/contributors.json");
|
||||
const contributors = JSON.parse(data);
|
||||
@@ -22,11 +23,11 @@ async function main() {
|
||||
contributor.hashFunction,
|
||||
contributor.hashSize,
|
||||
);
|
||||
// await result.wait();
|
||||
console.log(`Added contributor #${contributorId}: ${result.hash}`);
|
||||
console.log(`Adding contributor #${contributorId}: ${result.hash}`);
|
||||
await result.wait();
|
||||
};
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ async function main() {
|
||||
await kredits.init();
|
||||
|
||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||
const count = await kredits.Contributors.count;
|
||||
console.log(`Currently ${count} entries`);
|
||||
|
||||
const table = new Table({
|
||||
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
|
||||
|
||||
Reference in New Issue
Block a user