merge master

This commit is contained in:
2020-12-01 10:39:01 +01:00
27 changed files with 757 additions and 125 deletions

View File

@@ -19,10 +19,10 @@ module.exports = async function(callback) {
let contributorAccount;
if (contributor.length < 5) {
contributorId = contributor;
contributorAccount = await kredits.Contributor.functions.getContributorAddressById(contributor);
contributorAccount = await kredits.Contributor.contract.getContributorAddressById(contributor);
} else {
contributorAccount = contributor;
contributorId = await kredits.Contributor.functions.getContributorIdByAddress(contributor);
contributorId = await kredits.Contributor.contract.getContributorIdByAddress(contributor);
}
console.log(`Creating a contribution for contributor account ${contributorAccount} ID: ${contributorId}`);
@@ -45,7 +45,7 @@ module.exports = async function(callback) {
console.log("\nAdding contribution:");
console.log(contributionAttributes);
kredits.Contribution.addContribution(contributionAttributes, { gasLimit: 300000 })
kredits.Contribution.add(contributionAttributes, { gasLimit: 300000 })
.then(result => {
console.log("\n\nResult:");
console.log(result);

View File

@@ -19,10 +19,10 @@ module.exports = async function(callback) {
let contributorAccount;
if (contributor.length < 5) {
contributorId = contributor;
contributorAccount = await kredits.Contributor.functions.getContributorAddressById(contributor);
contributorAccount = await kredits.Contributor.contract.getContributorAddressById(contributor);
} else {
contributorAccount = contributor;
contributorId = await kredits.Contributor.functions.getContributorIdByAddress(contributor);
contributorId = await kredits.Contributor.contract.getContributorIdByAddress(contributor);
}
console.log(`Creating a proposal for contributor ID #${contributorId} account: ${contributorAccount}`);

View File

@@ -31,7 +31,7 @@ module.exports = async function(callback) {
if (c.contributorId === recipient && confirmed && !c.vetoed && !c.claimed) {
console.log(`Claiming contribution ID=${c.id}`);
return kredits.Contribution.functions.claim(c.id, { gasLimit: 500000 }).then(tx => {
return kredits.Contribution.contract.claim(c.id, { gasLimit: 500000 }).then(tx => {
table.push([
c.id.toString(),
`${c.description}`,

View File

@@ -17,7 +17,7 @@ module.exports = async function(callback) {
method = await promptly.prompt('Function: ');
}
if (!contractWrapper[method] && !contractWrapper.functions[method]) {
if (!contractWrapper[method] && !contractWrapper.contract[method]) {
callback(new Error(`Method ${method} is not defined on ${contractName}`));
return;
}
@@ -33,7 +33,7 @@ module.exports = async function(callback) {
if (contractWrapper[method]) {
func = contractWrapper[method];
} else {
func = contractWrapper.functions[method];
func = contractWrapper.contract[method];
}
func.apply(contractWrapper, args).then((result) => {
console.log("\nResult:");

View File

@@ -1,9 +1,12 @@
const knownDAOAddresses = require('../lib/addresses/dao.json');
const knownKreditsKitAddresses = require('../lib/addresses/KreditsKit.json');
const getNetworkId = require('./helpers/networkid.js')
const ethers = require('ethers');
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
let network = await provider.getNetwork();
let networkId = network.chainId;
console.log('# All known DAO addresses');
Object.keys(knownDAOAddresses).forEach((networkId) => {

View File

@@ -3,10 +3,10 @@ const deployDAOFactory = require('@aragon/os/scripts/deploy-daofactory.js')
const fs = require('fs');
const path = require('path');
const argv = require('yargs').argv
const namehash = require('ethers').utils.namehash;
const ethers = require('ethers');
const namehash = ethers.utils.namehash;
const fileInject = require('./helpers/file_inject.js')
const getNetworkId = require('./helpers/networkid.js')
const DAOFactory = artifacts.require('DAOFactory')
const KreditsKit = artifacts.require('KreditsKit')
@@ -26,9 +26,10 @@ const daoFactoryAddress = kreditsArappConfig.daoFactory || argv['daoFactory']
const ensAddr = arapp.environments[environment].registry || argv['ensAddress']
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const network = await provider.getNetwork();
const networkId = network.chainId;
console.log(`Deploying to networkId: ${networkId}`)
if (!ensAddr) {

View File

@@ -1,6 +1,5 @@
const argv = require('yargs').argv;
const ethers = require('ethers');
const getNetworkId = require('./networkid.js');
const Kredits = require('../../lib/kredits');
const arapp = require('../../arapp.json');
@@ -10,7 +9,7 @@ const apm = arapp.environments[environment].apm;
module.exports = async function(web3) {
return new Promise((resolve, reject) => {
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
let signer = provider.getSigner();
const signer = provider.getSigner();
// checking if siner supports signing transactions
signer.getAddress().then(_ => {
new Kredits(provider, signer, { apm }).init().then(kredits => {

View File

@@ -1,17 +0,0 @@
module.exports = function(web3) {
return new Promise((resolve, reject) => {
let func;
if (web3.version.getNetwork) {
func = web3.version.getNetwork;
} else {
func = web3.eth.net.getId;
}
func((err, network) => {
if (err) {
reject(err);
} else {
resolve(network);
}
})
})
}

View File

@@ -1,12 +1,14 @@
const fs = require('fs');
const getNetworkId = require('./networkid.js');
const ethers = require('ethers');
module.exports = async function(callback) {
const daoAddressPath = 'lib/addresses/dao.json';
// TODO maybe do the same for KreditsKit address file
try {
const networkId = await getNetworkId(web3);
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const network = await provider.getNetwork();
const networkId = network.chainId;
const daoAddresses = JSON.parse(fs.readFileSync(daoAddressPath));
const oldNetworkId = Math.max(...Object.keys(daoAddresses).map(a => parseInt(a)));
const localDaoAddress = daoAddresses[oldNetworkId];

View File

@@ -41,8 +41,8 @@ module.exports = async function(callback) {
console.log(table.toString());
let totalKreditsEarnedUnConfirmed = await kredits.Contribution.functions.totalKreditsEarned(false);
let totalKreditsEarnedConfirmed = await kredits.Contribution.functions.totalKreditsEarned(true);
let totalKreditsEarnedUnConfirmed = await kredits.Contribution.contract.totalKreditsEarned(false);
let totalKreditsEarnedConfirmed = await kredits.Contribution.contract.totalKreditsEarned(true);
console.log(`Total Kredits: ${totalKreditsEarnedConfirmed} (confirmed) | ${totalKreditsEarnedUnConfirmed} (including unconfirmed)`);
} catch (err) {
console.log(err);

View File

@@ -3,13 +3,15 @@ const path = require('path');
const ethers = require('ethers');
const fileInject = require('./helpers/file_inject.js');
const getNetworkId = require('./helpers/networkid.js');
const KreditsKit = require('../lib/kreditskit');
const addressesPath = path.join(__dirname, '..', 'lib/addresses');
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const signer = provider.getSigner();
const network = await provider.getNetwork();
const networkId = network.chainId;
console.log(`Deploying to networkId: ${networkId}`)
let kitAddresseFile = path.join(addressesPath, 'KreditsKit.json');
@@ -20,9 +22,6 @@ module.exports = async function(callback) {
}
console.log(`Using KreditsKit at: ${kreditsKitAddress}`);
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
let signer = provider.getSigner();
let kit = await new KreditsKit(provider, signer).init()
// TODO: get rid of the hard coded gas limit

View File

@@ -38,7 +38,7 @@ module.exports = async function(callback) {
if (contractWrapper[method]) {
func = contractWrapper[method];
} else {
func = contractWrapper.functions[method];
func = contractWrapper.contract[method];
}
func.apply(contractWrapper, args).then((result) => {
console.log(`[OK] kredits.${contractName}.${method}(${JSON.stringify(args)}) => ${result.hash}`);

View File

@@ -15,7 +15,7 @@ module.exports = async function(callback) {
console.log(`Recording a veto for contribution #${contributionId}`);
try {
kredits.Contribution.functions.veto(contributionId, { gasLimit: 300000 })
kredits.Contribution.contract.veto(contributionId, { gasLimit: 300000 })
.then(result => {
console.log("\n\nResult:");
console.log(result);