Compare commits

..

7 Commits

Author SHA1 Message Date
Râu Cao
b63c68cd1c 7.0.0
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-02 18:07:46 +01:00
c875e775b6 Merge pull request 'Improve import scripts, update testnet addresses' (#231) from deploy-rsk into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #231
2022-11-02 16:57:06 +00:00
Râu Cao
6e0ec8741e Use a dummy address for the read-only signer
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Necessary for ethers not to fail with public RSK nodes
2022-11-01 15:03:58 +01:00
Râu Cao
a1a68092f6 Change npm module name(space), improve description
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2022-10-31 12:27:24 +01:00
c6168e59e8 Updated adresses
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
on those addresses the import for contributors and contributions was completed
2022-10-27 18:52:57 +02:00
e810424163 My latest deploy addresses
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-10-23 16:31:14 +02:00
f71ff4ce9a minor import script improvements
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
waiting for transactions and logging earlier for better debugging
2022-10-23 16:03:37 +02:00
7 changed files with 34 additions and 49 deletions

View File

@@ -1,9 +1,9 @@
{
"31": {
"Contributor": "0x9C66a36fa6296EBb81d8F5D4642B05dF2CE85a8D",
"Contribution": "0xa12630a995337e45bDD746B6baedc1Ce2a1DCC9D",
"Token": "0x12Eb86338076450f86E5B552556028c7D21eaf1F",
"Reimbursement": "0xe2FE7cb00e2f94b8bA0AE526dfbe313f34c66E3C"
"Contributor": "0xf1073Dab6e305583F95e451Cba449bB867a6e3Fd",
"Contribution": "0x1C531F824e339cD37D75B7F391cB8E42e0E0d4bd",
"Token": "0x56F64C3BB45e6a248F4C783f5a1633E53D6A2371",
"Reimbursement": "0x9C5fFBFba2570A9b31D60338453C5480Ce74B342"
},
"1337": {
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",

View File

@@ -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
View File

@@ -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",

View File

@@ -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"

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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']