Move contracts to root level for hardhart usage

byebye aragon apps
This commit is contained in:
2021-06-08 15:45:23 +02:00
parent 1425c3664a
commit a626409221
19 changed files with 12793 additions and 4158 deletions

View File

@@ -1,16 +1,12 @@
const promptly = require('promptly');
const { inspect } = require('util');
const initKredits = require('./helpers/init_kredits.js');
const { ethers } = require("hardhat");
const Kredits = require('../lib/kredits');
module.exports = async function(callback) {
let kredits;
try {
kredits = await initKredits(web3);
} catch(e) {
callback(e);
return;
}
async function main() {
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
await kredits.init();
console.log(`Using Contributions at: ${kredits.Contribution.contract.address}`);
@@ -49,10 +45,11 @@ module.exports = async function(callback) {
.then(result => {
console.log("\n\nResult:");
console.log(result);
callback();
})
.catch(error => {
console.log('Failed to create contribution');
callback(inspect(error));
console.log(error);
});
}
main();

View File

@@ -1,6 +1,7 @@
const promptly = require('promptly');
const initKredits = require('./helpers/init_kredits.js');
const { ethers } = require("hardhat");
const Kredits = require('../lib/kredits');
async function prompt(message, options) {
if (!options) {
@@ -8,15 +9,9 @@ async function prompt(message, options) {
}
return await promptly.prompt(message, options);
}
module.exports = async function(callback) {
let kredits;
try {
kredits = await initKredits(web3);
} catch(e) {
callback(e);
return;
}
async function main() {
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
await kredits.init();
console.log(`Using contributors at: ${kredits.Contributor.contract.address}`);
@@ -36,9 +31,10 @@ module.exports = async function(callback) {
kredits.Contributor.add(contributorAttributes, { gasLimit: 350000 }).then((result) => {
console.log("\n\nResult:");
console.log(result);
callback();
}).catch((error) => {
console.log('Failed to create contributor');
callback(error);
console.log(error);
});
}
main();

53
scripts/create-proxy.js Normal file
View File

@@ -0,0 +1,53 @@
const { ethers, upgrades } = require("hardhat");
const path = require('path');
const fileInject = require('./helpers/file_inject.js');
async function main() {
const network = await hre.ethers.provider.getNetwork();
const networkId = network.chainId;
console.log(`Deploying to network #${networkId}`);
const Contributor = await ethers.getContractFactory("Contributor");
const Contribution = await ethers.getContractFactory("Contribution");
const Token = await ethers.getContractFactory("Token");
const Reimbursement = await ethers.getContractFactory("Reimbursement");
const contributor = await upgrades.deployProxy(Contributor, []);
await contributor.deployed();
console.log("Contributor deployed to:", contributor.address);
const blocksToWait = 40320; // 7 days; 15 seconds block time
const contribution = await upgrades.deployProxy(Contribution, [blocksToWait]);
await contribution.deployed();
console.log("Contribution deployed to:", contribution.address);
const token = await upgrades.deployProxy(Token, []);
await token.deployed();
console.log("Token deployed to:", token.address);
const reimbursement = await upgrades.deployProxy(Reimbursement, []);
await reimbursement.deployed();
console.log("Reimbursement deployed to:", reimbursement.address);
await contributor.setTokenContract(token.address);
await contributor.setContributionContract(contribution.address);
await contribution.setTokenContract(token.address);
await contribution.setContributorContract(contributor.address);
const c = await contributor.contributionContract();
console.log(c);
const addresses = {
Contributor: contributor.address,
Contribution: contribution.address,
Token: token.address,
Reimbursement: reimbursement.address
};
const libPath = path.join(__dirname, '..', 'lib');
fileInject(path.join(libPath, 'addresses.json'), networkId, addresses);
}
main();

View File

@@ -1,16 +1,13 @@
const promptly = require('promptly');
const Table = require('cli-table');
const initKredits = require('./helpers/init_kredits.js');
const { ethers } = require("hardhat");
const Kredits = require('../lib/kredits');
module.exports = async function(callback) {
async function main() {
let kredits;
try {
kredits = await initKredits(web3);
} catch(e) {
callback(e);
return;
}
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
await kredits.init();
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
@@ -47,6 +44,6 @@ module.exports = async function(callback) {
} catch (err) {
console.log(err);
}
callback();
}
main();

View File

@@ -1,17 +1,13 @@
const promptly = require('promptly');
const Table = require('cli-table');
const ethers = require('ethers');
const initKredits = require('./helpers/init_kredits.js');
const { ethers } = require("hardhat");
const Kredits = require('../lib/kredits');
module.exports = async function(callback) {
async function main() {
let kredits;
try {
kredits = await initKredits(web3);
} catch(e) {
callback(e);
return;
}
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
await kredits.init();
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
@@ -19,27 +15,22 @@ module.exports = async function(callback) {
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
})
try {
const contributors = await kredits.Contributor.all()
const contributors = await kredits.Contributor.all()
contributors.forEach((c) => {
table.push([
c.id.toString(),
c.account,
`${c.name}`,
c.isCore,
c.balanceInt.toString(),
c.totalKreditsEarned.toString(),
c.contributionsCount.toString(),
c.ipfsHash
])
})
contributors.forEach((c) => {
table.push([
c.id.toString(),
c.account,
`${c.name}`,
c.isCore,
c.balanceInt.toString(),
c.totalKreditsEarned.toString(),
c.contributionsCount.toString(),
c.ipfsHash
])
});
console.log(table.toString())
} catch(e) {
callback(e);
return;
}
callback()
console.log(table.toString());
}
main();