export scripts without truffle dependency
This commit is contained in:
parent
1cfeaec70b
commit
f17af2d0ae
@ -1,53 +1,49 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const initKredits = require('../helpers/init_kredits.js');
|
const ethers = require('ethers');
|
||||||
|
const Kredits = require('../../lib/kredits');
|
||||||
|
const provider = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/eth_rinkeby');
|
||||||
|
|
||||||
module.exports = async function(callback) {
|
const arapp = require('../../arapp.json');
|
||||||
let kredits;
|
const apm = arapp.environments['rinkeby'].apm;
|
||||||
try {
|
|
||||||
kredits = await initKredits(web3);
|
async function main() {
|
||||||
} catch(e) {
|
const kredits = await new Kredits(provider, null, { apm });
|
||||||
callback(e);
|
//kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
return;
|
await kredits.init();
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
|
|
||||||
try {
|
const count = await kredits.Contribution.count;
|
||||||
const count = await kredits.Contribution.count;
|
const currentBlockHeight = await provider.getBlockNumber();
|
||||||
const currentBlockHeight = await kredits.provider.getBlockNumber();
|
|
||||||
|
|
||||||
const backup = {};
|
const backup = {};
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let i = 1; i <= count; i++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
console.log(`Loading contribution #${i}`);
|
console.log(`Loading contribution #${i}`);
|
||||||
await kredits.Contribution.contract.getContribution(i).then(contractData => {
|
await kredits.Contribution.contract.getContribution(i).then(contractData => {
|
||||||
backup[i] = {
|
backup[i] = {
|
||||||
amount: contractData.amount,
|
amount: contractData.amount,
|
||||||
contributorId: contractData.contributorId,
|
contributorId: contractData.contributorId,
|
||||||
hashDigest: contractData.hashDigest,
|
hashDigest: contractData.hashDigest,
|
||||||
hashFunction: contractData.hashFunction,
|
hashFunction: contractData.hashFunction,
|
||||||
hashSize: contractData.hashSize,
|
hashSize: contractData.hashSize,
|
||||||
confirmedAtBlock: contractData.confirmedAtBlock,
|
confirmedAtBlock: contractData.confirmedAtBlock,
|
||||||
confirmed: contractData.confirmedAtBlock <= currentBlockHeight,
|
confirmed: contractData.confirmedAtBlock <= currentBlockHeight,
|
||||||
vetoed: contractData.vetoed,
|
vetoed: contractData.vetoed,
|
||||||
id: contractData.id,
|
id: contractData.id,
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}, 100 * i);
|
}, 100 * i);
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises).then(() => {
|
|
||||||
fs.writeFileSync("./data/contributions.json", JSON.stringify(backup, null, 2));
|
|
||||||
console.log("Exported");
|
|
||||||
});
|
|
||||||
} catch(e) {
|
|
||||||
callback(e);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
await Promise.all(promises).then(() => {
|
||||||
|
fs.writeFileSync("./data/contributions.json", JSON.stringify(backup, null, 2));
|
||||||
|
console.log("Exported");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
@ -1,48 +1,44 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const initKredits = require('../helpers/init_kredits.js');
|
const ethers = require('ethers');
|
||||||
|
const Kredits = require('../../lib/kredits');
|
||||||
|
const provider = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/eth_rinkeby');
|
||||||
|
|
||||||
module.exports = async function(callback) {
|
const arapp = require('../../arapp.json');
|
||||||
let kredits;
|
const apm = arapp.environments['rinkeby'].apm;
|
||||||
try {
|
|
||||||
kredits = await initKredits(web3);
|
async function main() {
|
||||||
} catch(e) {
|
const kredits = await new Kredits(provider, null, { apm });
|
||||||
callback(e);
|
//kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
return;
|
await kredits.init();
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||||
|
|
||||||
try {
|
const count = await kredits.Contributor.count;
|
||||||
const count = await kredits.Contributor.count;
|
|
||||||
|
|
||||||
const backup = {};
|
const backup = {};
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let i = 1; i <= count; i++) {
|
for (let i = 1; i <= count; i++) {
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
console.log(`Loading contributor #${i}`);
|
console.log(`Loading contributor #${i}`);
|
||||||
await kredits.Contributor.contract.getContributorById(i).then(contractData => {
|
await kredits.Contributor.contract.getContributorById(i).then(contractData => {
|
||||||
backup[i] = {
|
backup[i] = {
|
||||||
account: contractData.account,
|
account: contractData.account,
|
||||||
hashDigest: contractData.hashDigest,
|
hashDigest: contractData.hashDigest,
|
||||||
hashFunction: contractData.hashFunction,
|
hashFunction: contractData.hashFunction,
|
||||||
hashSize: contractData.hashSize,
|
hashSize: contractData.hashSize,
|
||||||
id: contractData.id,
|
id: contractData.id,
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}, 100 * i);
|
}, 100 * i);
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises).then(() => {
|
|
||||||
fs.writeFileSync("./data/contributors.json", JSON.stringify(backup, null, 2));
|
|
||||||
console.log("Exported");
|
|
||||||
});
|
|
||||||
} catch(e) {
|
|
||||||
callback(e);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
await Promise.all(promises).then(() => {
|
||||||
|
fs.writeFileSync("./data/contributors.json", JSON.stringify(backup, null, 2));
|
||||||
|
console.log("Exported");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user