Compare commits
6 Commits
914d4d9585
...
v7.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0a71ca8f1
|
||
|
|
117918e66f
|
||
| d0d456b357 | |||
| cda84fa2ce | |||
| 97e2db93be | |||
| 17c582f6df |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@kredits/contracts",
|
||||
"version": "7.2.0",
|
||||
"version": "7.3.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@kredits/contracts",
|
||||
"version": "7.2.0",
|
||||
"version": "7.3.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@kosmos/schemas": "^3.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kredits/contracts",
|
||||
"version": "7.2.0",
|
||||
"version": "7.3.0",
|
||||
"description": "Smart contracts and JavaScript API for Kredits",
|
||||
"main": "./lib/kredits.js",
|
||||
"directories": {
|
||||
@@ -22,10 +22,6 @@
|
||||
"lint:contract-tests": "eslint apps/*/test",
|
||||
"lint:wrapper": "eslint lib/",
|
||||
"test": "hardhat test",
|
||||
"test:token": "cd apps/token && npm run test",
|
||||
"test:contributor": "cd apps/contributor && npm run test",
|
||||
"test:contribution": "cd apps/contribution && npm run test",
|
||||
"test:proposal": "cd apps/proposal && npm run test",
|
||||
"setup-git-hooks": "sh scripts/git-hooks/install"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
44
scripts/export/reimbursements.js
Normal file
44
scripts/export/reimbursements.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
const currentBlockHeight = await hre.ethers.provider.getBlockNumber();
|
||||
|
||||
const backup = {};
|
||||
const promises = [];
|
||||
for (let i = 1; i <= count; i++) {
|
||||
promises.push(new Promise((resolve, reject) => {
|
||||
setTimeout(async () => {
|
||||
console.log(`Loading reimbursement #${i}`);
|
||||
await kredits.Reimbursement.contract.get(i).then(contractData => {
|
||||
backup[i] = {
|
||||
recipientId: contractData.recipientId,
|
||||
amount: contractData.amount,
|
||||
token: contractData.token,
|
||||
hashDigest: contractData.hashDigest,
|
||||
hashFunction: contractData.hashFunction,
|
||||
hashSize: contractData.hashSize,
|
||||
confirmedAtBlock: contractData.confirmedAtBlock,
|
||||
confirmed: contractData.confirmedAtBlock <= currentBlockHeight,
|
||||
vetoed: contractData.vetoed,
|
||||
id: contractData.id,
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}, 100 * i);
|
||||
}));
|
||||
}
|
||||
|
||||
await Promise.all(promises).then(() => {
|
||||
fs.writeFileSync("./data/reimbursements.json", JSON.stringify(backup, null, 2));
|
||||
console.log("Exported");
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -13,14 +13,18 @@ async function main() {
|
||||
const data = fs.readFileSync("./data/contributions.json");
|
||||
const contributions = JSON.parse(data);
|
||||
const ids = Object.keys(contributions)
|
||||
.map(k => parseInt(k))
|
||||
.sort(function(a, b){return a-b});
|
||||
.map(k => parseInt(k))
|
||||
.sort(function(a, b) { return a - b });
|
||||
|
||||
const currentBlockHeight = await kredits.provider.getBlockNumber();
|
||||
const confirmationPeriod = 40320 // blocks
|
||||
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
||||
|
||||
const startId = parseInt(process.env.START_AT || "0");
|
||||
for (const contributionId of ids) {
|
||||
if (contributionId < startId) {
|
||||
continue;
|
||||
}
|
||||
const c = contributions[contributionId.toString()];
|
||||
|
||||
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
|
||||
@@ -33,7 +37,7 @@ async function main() {
|
||||
console.log(`Adding contribution #${contributionId}: ${result.hash}`);
|
||||
await result.wait();
|
||||
};
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
Reference in New Issue
Block a user