Cleanup scripts
This commit is contained in:
parent
63e8ce1e3f
commit
dd70bf77d5
@ -1,56 +0,0 @@
|
||||
const promptly = require('promptly');
|
||||
const { inspect } = require('util');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await initKredits(web3);
|
||||
} catch(e) {
|
||||
callback(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Using Proposal at: ${kredits.Proposal.contract.address}`);
|
||||
|
||||
let contributor = await promptly.prompt('Contributor (address or id): ');
|
||||
let contributorId;
|
||||
let contributorAccount;
|
||||
if (contributor.length < 5) {
|
||||
contributorId = contributor;
|
||||
contributorAccount = await kredits.Contributor.contract.getContributorAddressById(contributor);
|
||||
} else {
|
||||
contributorAccount = contributor;
|
||||
contributorId = await kredits.Contributor.contract.getContributorIdByAddress(contributor);
|
||||
}
|
||||
console.log(`Creating a proposal for contributor ID #${contributorId} account: ${contributorAccount}`);
|
||||
|
||||
[ dateNow, timeNow ] = (new Date()).toISOString().split('T');
|
||||
|
||||
let contributionAttributes = {
|
||||
contributorId,
|
||||
date: dateNow,
|
||||
time: timeNow,
|
||||
amount: await promptly.prompt('Amount: '),
|
||||
description: await promptly.prompt('Description: '),
|
||||
kind: await promptly.prompt('Kind: ', { default: 'dev' }),
|
||||
url: await promptly.prompt('URL: ', { default: '' })
|
||||
}
|
||||
|
||||
const contributorData = await kredits.Contributor.getById(contributorId);
|
||||
contributionAttributes.contributorIpfsHash = contributorData.ipfsHash;
|
||||
|
||||
console.log("\nAdding proposal:");
|
||||
console.log(contributionAttributes);
|
||||
|
||||
kredits.Proposal.addProposal(contributionAttributes, { gasLimit: 300000 })
|
||||
.then((result) => {
|
||||
console.log("\n\nResult:");
|
||||
console.log(result);
|
||||
callback();
|
||||
}).catch((error) => {
|
||||
console.log('Failed to create proposal');
|
||||
callback(inspect(error));
|
||||
});
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
const promptly = require('promptly');
|
||||
const Table = require('cli-table');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await initKredits(web3);
|
||||
} catch(e) {
|
||||
callback(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||
|
||||
let recipient = await promptly.prompt('Contributor ID: ');
|
||||
recipient = parseInt(recipient);
|
||||
|
||||
const table = new Table({
|
||||
head: ['ID', 'Description', 'Amount', 'Claim Transaction'],
|
||||
});
|
||||
|
||||
try {
|
||||
let blockNumber = await kredits.provider.getBlockNumber();
|
||||
let contributions = await kredits.Contribution.all({page: {size: 200}});
|
||||
|
||||
console.log(`Current block number: ${blockNumber}`);
|
||||
let claimPromises = contributions.map(async (c) => {
|
||||
const confirmed = c.confirmedAtBlock <= blockNumber;
|
||||
|
||||
if (c.contributorId === recipient && confirmed && !c.vetoed && !c.claimed) {
|
||||
console.log(`Claiming contribution ID=${c.id}`);
|
||||
return kredits.Contribution.contract.claim(c.id, { gasLimit: 500000 }).then(tx => {
|
||||
table.push([
|
||||
c.id.toString(),
|
||||
`${c.description}`,
|
||||
c.amount.toString(),
|
||||
tx.hash,
|
||||
]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(claimPromises).then(_ => {
|
||||
console.log(table.toString());
|
||||
callback();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
callback();
|
||||
}
|
||||
};
|
@ -1,61 +0,0 @@
|
||||
const REPL = require('repl');
|
||||
const promptly = require('promptly');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
initKredits(web3).then(async function(kredits) {
|
||||
let contractName = await promptly.prompt('Contract Name: ');
|
||||
const contractWrapper = kredits[contractName];
|
||||
|
||||
let method;
|
||||
method = await promptly.prompt('Function (? for available functions): ');
|
||||
while (method === '?') {
|
||||
console.log(`Contract functions: ${JSON.stringify(Object.keys(contractWrapper.functions))}`);
|
||||
console.log(`\nWrapper functions: ${JSON.stringify(Object.getOwnPropertyNames(Object.getPrototypeOf(contractWrapper)))}`);
|
||||
console.log("\n");
|
||||
|
||||
method = await promptly.prompt('Function: ');
|
||||
}
|
||||
if (!contractWrapper[method] && !contractWrapper.contract[method]) {
|
||||
callback(new Error(`Method ${method} is not defined on ${contractName}`));
|
||||
return;
|
||||
}
|
||||
let argumentInput = await promptly.prompt('Arguments (comma separated): ', { default: '' });
|
||||
let args = [];
|
||||
if (argumentInput !== '') {
|
||||
args = argumentInput.split(',').map(a => a.trim());
|
||||
}
|
||||
console.log(`Using ${contractName} at ${contractWrapper.contract.address}`);
|
||||
console.log(`Calling ${method} with ${JSON.stringify(args)}`);
|
||||
|
||||
let func;
|
||||
if (contractWrapper[method]) {
|
||||
func = contractWrapper[method];
|
||||
} else {
|
||||
func = contractWrapper.contract[method];
|
||||
}
|
||||
func.apply(contractWrapper, args).then((result) => {
|
||||
console.log("\nResult:");
|
||||
console.log(result);
|
||||
|
||||
console.log("\nStartig a REPL. (type .exit to exit)");
|
||||
console.log(`defined variables: result, ${contractName}, kredis`);
|
||||
let r = REPL.start();
|
||||
r.context.result = result;
|
||||
r.context[contractName] = contractWrapper;
|
||||
r.context.kredits = kredits;
|
||||
|
||||
r.on('exit', () => {
|
||||
console.log('Bye');
|
||||
callback();
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log("Call failed. Probably the contract raised an error?\n");
|
||||
console.log("...");
|
||||
callback(error);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
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 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) => {
|
||||
console.log(` Network ID: ${networkId} => ${knownDAOAddresses[networkId]}`);
|
||||
});
|
||||
console.log('# All known KreditsKit addresses');
|
||||
Object.keys(knownKreditsKitAddresses).forEach((networkId) => {
|
||||
console.log(` Network ID: ${networkId} => ${knownKreditsKitAddresses[networkId]}`);
|
||||
});
|
||||
console.log('-----------------');
|
||||
|
||||
console.log(`# Current network ID: ${networkId}`);
|
||||
|
||||
let currentDAOAddress = knownDAOAddresses[networkId];
|
||||
let currentKreditsKitAddress = knownKreditsKitAddresses[networkId];
|
||||
|
||||
console.log(`# Current KreditsKit address: ${currentKreditsKitAddress}`);
|
||||
console.log(`# Current DAO address: ${currentDAOAddress}`);
|
||||
|
||||
callback();
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
rootDir=`pwd`
|
||||
|
||||
echo "## Kredits app bootstrap"
|
||||
echo ""
|
||||
echo "Setting up each aragon app in ./apps"
|
||||
echo "a new app version will be deployed"
|
||||
echo "----"
|
||||
|
||||
./scripts/every-app.sh "npm install"
|
||||
./scripts/every-app.sh "aragon apm publish major"
|
||||
|
||||
echo "Done, new versions of all apps deployed"
|
@ -1,69 +0,0 @@
|
||||
const deployDAOFactory = require('@aragon/os/scripts/deploy-daofactory.js')
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const argv = require('yargs').argv
|
||||
const ethers = require('ethers');
|
||||
const namehash = ethers.utils.namehash;
|
||||
|
||||
const fileInject = require('./helpers/file_inject.js')
|
||||
|
||||
const DAOFactory = artifacts.require('DAOFactory')
|
||||
const KreditsKit = artifacts.require('KreditsKit')
|
||||
|
||||
const arapp = require('../arapp.json')
|
||||
const environment = argv['network'] || argv['environment'] || 'development'
|
||||
|
||||
const kreditsArappConfig = arapp.environments[environment].kredits || {}
|
||||
|
||||
// typically we use the open.aragonpm.eth aragonpm.
|
||||
const apm = kreditsArappConfig.apmDomain || argv['apmDomain'] || 'open.aragonpm.eth'
|
||||
|
||||
// daoFactory is environment specific.
|
||||
// See https://github.com/aragon/deployments/tree/master/environments/ for the official daoFactory
|
||||
// Locally we deploy our own daoFactory and no daoFactory is required (`daoFactoryAddress` is null).
|
||||
const daoFactoryAddress = kreditsArappConfig.daoFactory || argv['daoFactory']
|
||||
|
||||
const ensAddr = arapp.environments[environment].registry || argv['ensAddress']
|
||||
|
||||
module.exports = async function(callback) {
|
||||
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) {
|
||||
callback(new Error("ENS address not found in environment variable ENS"))
|
||||
}
|
||||
console.log(`Using ENS at: ${ensAddr}`);
|
||||
|
||||
let daoFactory
|
||||
if (daoFactoryAddress) {
|
||||
daoFactory = DAOFactory.at(daoFactoryAddress)
|
||||
} else {
|
||||
daoFactory = (await deployDAOFactory(null, { artifacts, verbose: false })).daoFactory
|
||||
}
|
||||
console.log(`Using DAOFactory at: ${daoFactory.address}`)
|
||||
|
||||
const apps = fs.readdirSync('./apps', { withFileTypes: true })
|
||||
.filter(e => e.isDirectory())
|
||||
.map(e => e.name);
|
||||
console.log(`Found apps: [${apps}].${apm}`)
|
||||
let appIds = {}
|
||||
apps.sort().forEach((app) => {
|
||||
let [first, ...rest] = app;
|
||||
let contractName = `${first.toUpperCase()}${rest.join('')}`
|
||||
appIds[contractName] = namehash(`kredits-${app}.${apm}`)
|
||||
})
|
||||
|
||||
KreditsKit.new(daoFactory.address, ensAddr, Object.values(appIds)).then((kreditsKit) => {
|
||||
console.log(`Deployed KreditsKit at: ${kreditsKit.address}`);
|
||||
|
||||
fileInject(path.join(__dirname, '..', 'lib/addresses/KreditsKit.json'), networkId, kreditsKit.address);
|
||||
|
||||
callback();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
callback(e);
|
||||
})
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
rootDir=`pwd`
|
||||
|
||||
for dir in ./apps/*/; do
|
||||
set -x
|
||||
cd $dir
|
||||
eval $1
|
||||
cd $rootDir
|
||||
set +x
|
||||
done
|
||||
|
@ -1,10 +1,12 @@
|
||||
const promptly = require('promptly');
|
||||
const EthDater = require('ethereum-block-by-date');
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try { kredits = await initKredits(web3); } catch(e) { callback(e); return; }
|
||||
const { ethers } = require("hardhat");
|
||||
const Kredits = require('../lib/kredits');
|
||||
|
||||
async function main() {
|
||||
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||
await kredits.init();
|
||||
|
||||
const dater = new EthDater(kredits.provider);
|
||||
const dateStr = await promptly.prompt('Specify a date and time (e.g. 2021-05-07T14:00:40Z): ');
|
||||
@ -15,5 +17,6 @@ The closest block is #${blockData.block}:
|
||||
https://rinkeby.etherscan.io/block/${blockData.block}
|
||||
`);
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,29 +0,0 @@
|
||||
const argv = require('yargs').argv;
|
||||
const ethers = require('ethers');
|
||||
const Kredits = require('../../lib/kredits');
|
||||
|
||||
const arapp = require('../../arapp.json');
|
||||
const environment = argv['network'] || argv['environment'] || 'development';
|
||||
const apm = arapp.environments[environment].apm;
|
||||
|
||||
module.exports = async function(web3) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
|
||||
const signer = provider.getSigner();
|
||||
// checking if siner supports signing transactions
|
||||
signer.getAddress().then(_ => {
|
||||
new Kredits(provider, signer, { apm }).init().then(kredits => {
|
||||
resolve(kredits);
|
||||
}).catch(e => {
|
||||
reject(e);
|
||||
});
|
||||
}).catch(e => {
|
||||
console.log(`Signer account not available; readonly connection (${e.message}`);
|
||||
new Kredits(provider, null, { apm }).init().then(kredits => {
|
||||
resolve(kredits);
|
||||
}).catch(e => {
|
||||
reject(e);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
const fs = require('fs');
|
||||
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 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];
|
||||
daoAddresses[networkId] = localDaoAddress;
|
||||
delete daoAddresses[oldNetworkId];
|
||||
fs.writeFileSync(daoAddressPath, JSON.stringify(daoAddresses, null, 2));
|
||||
console.log('Updated local network ID for DAO address');
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
callback();
|
||||
};
|
@ -1,16 +1,12 @@
|
||||
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) {
|
||||
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 Contribution at: ${kredits.Contribution.contract.address}`);
|
||||
|
||||
@ -18,59 +14,55 @@ module.exports = async function(callback) {
|
||||
head: ['ID', 'Name', 'Kredits']
|
||||
})
|
||||
|
||||
try {
|
||||
let currentBlockNumber = await kredits.provider.getBlockNumber();
|
||||
console.log(`Current block number: ${currentBlockNumber}`);
|
||||
let currentBlockNumber = await kredits.provider.getBlockNumber();
|
||||
console.log(`Current block number: ${currentBlockNumber}`);
|
||||
|
||||
let confirmedBeforeBlock = await promptly.prompt('Before block: ');
|
||||
let confirmedAfterBlock = await promptly.prompt('After block: ');
|
||||
let confirmedBeforeBlock = await promptly.prompt('Before block: ');
|
||||
let confirmedAfterBlock = await promptly.prompt('After block: ');
|
||||
|
||||
let tokens = {};
|
||||
let contributors = await kredits.Contributor.all();
|
||||
contributors.forEach(c => {
|
||||
tokens[c.id] = { amount: 0, contributor: c };
|
||||
});
|
||||
let tokens = {};
|
||||
let contributors = await kredits.Contributor.all();
|
||||
contributors.forEach(c => {
|
||||
tokens[c.id] = { amount: 0, contributor: c };
|
||||
});
|
||||
|
||||
let contributionId = await kredits.Contribution.contract.contributionsCount();
|
||||
let nextContribution = true;
|
||||
let contributionId = await kredits.Contribution.contract.contributionsCount();
|
||||
let nextContribution = true;
|
||||
|
||||
while (nextContribution) {
|
||||
console.log(`Getting contribution: ${contributionId}`);
|
||||
let contribution = await kredits.Contribution.getById(contributionId);
|
||||
contributionId = contributionId - 1;
|
||||
while (nextContribution) {
|
||||
console.log(`Getting contribution: ${contributionId}`);
|
||||
let contribution = await kredits.Contribution.getById(contributionId);
|
||||
contributionId = contributionId - 1;
|
||||
|
||||
// if no conribution is found
|
||||
if (!contribution.exists) {
|
||||
nextContribution = false;
|
||||
break;
|
||||
}
|
||||
// check if the contribution is older
|
||||
// in that case we assume all other contributions now are older
|
||||
if (contribution.confirmedAtBlock < confirmedAfterBlock) {
|
||||
nextContribution = false;
|
||||
}
|
||||
|
||||
// if the contribution is within the range count it
|
||||
if (!contribution.vetoed && contribution.confirmedAtBlock < confirmedBeforeBlock && contribution.confirmedAtBlock > confirmedAfterBlock) {
|
||||
// init
|
||||
tokens[contribution.contributorId].amount = tokens[contribution.contributorId].amount + contribution.amount;
|
||||
}
|
||||
// if no conribution is found
|
||||
if (!contribution.exists) {
|
||||
nextContribution = false;
|
||||
break;
|
||||
}
|
||||
// check if the contribution is older
|
||||
// in that case we assume all other contributions now are older
|
||||
if (contribution.confirmedAtBlock < confirmedAfterBlock) {
|
||||
nextContribution = false;
|
||||
}
|
||||
|
||||
Object.keys(tokens).forEach((contributorId) => {
|
||||
table.push([
|
||||
contributorId,
|
||||
`${tokens[contributorId].contributor.name}`,
|
||||
`${tokens[contributorId].amount}`
|
||||
]);
|
||||
});
|
||||
|
||||
const total = Object.keys(tokens).map(cid => { return tokens[cid].amount}).reduce((a,b) => { return a+b }, 0);
|
||||
console.log(`Total confirmed Kredits: ${total} between block ${confirmedAfterBlock} and ${confirmedBeforeBlock}`);
|
||||
console.log(table.toString());
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
// if the contribution is within the range count it
|
||||
if (!contribution.vetoed && contribution.confirmedAtBlock < confirmedBeforeBlock && contribution.confirmedAtBlock > confirmedAfterBlock) {
|
||||
// init
|
||||
tokens[contribution.contributorId].amount = tokens[contribution.contributorId].amount + contribution.amount;
|
||||
}
|
||||
}
|
||||
|
||||
callback();
|
||||
Object.keys(tokens).forEach((contributorId) => {
|
||||
table.push([
|
||||
contributorId,
|
||||
`${tokens[contributorId].contributor.name}`,
|
||||
`${tokens[contributorId].amount}`
|
||||
]);
|
||||
});
|
||||
|
||||
const total = Object.keys(tokens).map(cid => { return tokens[cid].amount}).reduce((a,b) => { return a+b }, 0);
|
||||
console.log(`Total confirmed Kredits: ${total} between block ${confirmedAfterBlock} and ${confirmedBeforeBlock}`);
|
||||
console.log(table.toString());
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,35 +0,0 @@
|
||||
const promptly = require('promptly');
|
||||
const Table = require('cli-table');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await initKredits(web3);
|
||||
} catch(e) {
|
||||
callback(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Using Proposal at: ${kredits.Proposal.contract.address}`);
|
||||
|
||||
const table = new Table({
|
||||
head: ['ID', 'Contributor ID', 'Amount', 'Votes', 'Executed?', 'Description']
|
||||
})
|
||||
|
||||
let proposals = await kredits.Proposal.all()
|
||||
|
||||
proposals.forEach((p) => {
|
||||
table.push([
|
||||
p.id.toString(),
|
||||
p.contributorId.toString(),
|
||||
p.amount.toString(),
|
||||
`${p.votesCount.toString()}/${p.votesNeeded.toString()}`,
|
||||
p.executed,
|
||||
`${p.description}`
|
||||
])
|
||||
})
|
||||
console.log(table.toString())
|
||||
callback()
|
||||
}
|
@ -1,16 +1,12 @@
|
||||
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) {
|
||||
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 Reimbursement at: ${kredits.Reimbursement.contract.address}`);
|
||||
|
||||
@ -18,35 +14,31 @@ module.exports = async function(callback) {
|
||||
head: ['ID', 'Amount', 'Token', 'recipientId', 'Confirmed?', 'Vetoed?', 'IPFS', 'Expenses']
|
||||
})
|
||||
|
||||
try {
|
||||
let blockNumber = await kredits.provider.getBlockNumber();
|
||||
let reimbursements = await kredits.Reimbursement.all({page: {size: 1000}});
|
||||
let blockNumber = await kredits.provider.getBlockNumber();
|
||||
let reimbursements = await kredits.Reimbursement.all({page: {size: 1000}});
|
||||
|
||||
let kreditsSum = 0;
|
||||
console.log(`Current block number: ${blockNumber}`);
|
||||
reimbursements.forEach(r => {
|
||||
const confirmed = r.confirmedAtBlock <= blockNumber;
|
||||
let kreditsSum = 0;
|
||||
console.log(`Current block number: ${blockNumber}`);
|
||||
reimbursements.forEach(r => {
|
||||
const confirmed = r.confirmedAtBlock <= blockNumber;
|
||||
|
||||
table.push([
|
||||
r.id.toString(),
|
||||
r.amount.toString(),
|
||||
`${r.token}`,
|
||||
`${r.recipientId}`,
|
||||
`${confirmed}`,
|
||||
`${r.vetoed}`,
|
||||
`${r.ipfsHash}`,
|
||||
`${r.expenses.length}`
|
||||
]);
|
||||
});
|
||||
table.push([
|
||||
r.id.toString(),
|
||||
r.amount.toString(),
|
||||
`${r.token}`,
|
||||
`${r.recipientId}`,
|
||||
`${confirmed}`,
|
||||
`${r.vetoed}`,
|
||||
`${r.ipfsHash}`,
|
||||
`${r.expenses.length}`
|
||||
]);
|
||||
});
|
||||
|
||||
console.log(table.toString());
|
||||
console.log(table.toString());
|
||||
|
||||
let totalAmountUnconfirmed = await kredits.Reimbursement.functions.totalAmount(false);
|
||||
let totalAmountConfirmed = await kredits.Reimbursement.functions.totalAmount(true);
|
||||
console.log(`Total: ${totalAmountConfirmed} (confirmed) | ${totalAmountUnconfirmed} (including unconfirmed)`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
callback();
|
||||
let totalAmountUnconfirmed = await kredits.Reimbursement.functions.totalAmount(false);
|
||||
let totalAmountConfirmed = await kredits.Reimbursement.functions.totalAmount(true);
|
||||
console.log(`Total: ${totalAmountConfirmed} (confirmed) | ${totalAmountUnconfirmed} (including unconfirmed)`);
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,39 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ethers = require('ethers');
|
||||
const fileInject = require('./helpers/file_inject.js');
|
||||
const KreditsKit = require('../lib/kreditskit');
|
||||
|
||||
const addressesPath = path.join(__dirname, '..', 'lib/addresses');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
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');
|
||||
let kitAddresses = JSON.parse(fs.readFileSync(kitAddresseFile));
|
||||
let kreditsKitAddress = process.env.KREDITS_KIT || kitAddresses[networkId]
|
||||
if (!kreditsKitAddress) {
|
||||
callback(new Error("KreditsKit address not found in environment variable KREDITS_KIT"))
|
||||
}
|
||||
console.log(`Using KreditsKit at: ${kreditsKitAddress}`);
|
||||
|
||||
let kit = await new KreditsKit(provider, signer).init()
|
||||
|
||||
// TODO: get rid of the hard coded gas limit
|
||||
kit.newDAO({ gasLimit: 10000000 }).then(result => {
|
||||
console.log(result);
|
||||
fileInject(path.join(addressesPath, 'dao.json'), networkId, result.daoAddress)
|
||||
|
||||
console.log(`\n\nCreated new DAO at: ${result.daoAddress}`)
|
||||
|
||||
callback();
|
||||
}).catch((err) => {
|
||||
console.log('failed to create a new DAO')
|
||||
callback(err)
|
||||
})
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
const REPL = require('repl');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
|
||||
function promiseEval (repl) {
|
||||
const currentEval = repl.eval;
|
||||
return function (cmd, context, filename, callback) {
|
||||
currentEval(cmd, context, filename, (err, result) => {
|
||||
if (result && typeof result.then === 'function') {
|
||||
console.log('...waiting for promise to resolve');
|
||||
return result
|
||||
.then(response => callback(null, response))
|
||||
.catch(err => callback(err, null));
|
||||
}
|
||||
return callback(err, result);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await initKredits(web3);
|
||||
} catch(e) {
|
||||
callback(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Defined variables: kredits, web3`);
|
||||
let r = REPL.start();
|
||||
r.context.kredits = kredits;
|
||||
r.context.web3 = web3;
|
||||
r.eval = promiseEval(r);
|
||||
|
||||
r.on('exit', () => {
|
||||
console.log('Bye');
|
||||
callback();
|
||||
});
|
||||
}
|
@ -1,29 +1,22 @@
|
||||
const path = require('path');
|
||||
const each = require('async-each-series');
|
||||
const ethers = require('ethers');
|
||||
|
||||
const initKredits = require('./helpers/init_kredits.js');
|
||||
const seeds = require(path.join(__dirname, '..', '/config/seeds.js'));
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let kredits;
|
||||
try {
|
||||
kredits = await initKredits(web3);
|
||||
} catch(e) {
|
||||
callback(e);
|
||||
return;
|
||||
}
|
||||
const { ethers } = require("hardhat");
|
||||
const Kredits = require('../lib/kredits');
|
||||
|
||||
let fundingAmount = 2;
|
||||
async function main() {
|
||||
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||
await kredits.init();
|
||||
|
||||
let fundingAmount = '2';
|
||||
each(seeds.funds, (address, next) => {
|
||||
console.log(`funding ${address} with 2 ETH`);
|
||||
try {
|
||||
web3.eth.personal.getAccounts().then(accounts => {
|
||||
web3.eth.personal.sendTransaction({
|
||||
to: address,
|
||||
from: accounts[0],
|
||||
value: web3.utils.toWei(new web3.utils.BN(fundingAmount))
|
||||
});
|
||||
hre.ethers.provider.getSigner().sendTransaction({
|
||||
to: address,
|
||||
value: hre.ethers.utils.parseEther(fundingAmount)
|
||||
});
|
||||
} catch(e) {
|
||||
console.log('FAILED:', e);
|
||||
@ -51,3 +44,5 @@ module.exports = async function(callback) {
|
||||
}, () => { console.log("\nDone!") });
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,27 +0,0 @@
|
||||
const promptly = require('promptly');
|
||||
|
||||
module.exports = async function(callback) {
|
||||
let recipient = await promptly.prompt('Recipient address: ');
|
||||
let amount = await promptly.prompt('Amount: ', {default: '1'});
|
||||
amount = parseInt(amount);
|
||||
|
||||
const accounts = await web3.eth.personal.getAccounts();
|
||||
let fromAccount = accounts[0];
|
||||
let fromBalance = await web3.eth.getBalance(fromAccount);
|
||||
let recipientBalance = await web3.eth.getBalance(recipient);
|
||||
|
||||
console.log('--------------');
|
||||
console.log(`sender account balance ${fromAccount}: ${fromBalance}`);
|
||||
console.log(`recipient account balance ${recipient}: ${recipientBalance}`);
|
||||
|
||||
console.log(`\nsending ${amount} ETH from ${accounts[0]} to ${recipient}`);
|
||||
|
||||
let transaction = await web3.eth.sendTransaction({to: recipient, value: web3.utils.toWei(new web3.utils.BN(amount)), from: accounts[0]});
|
||||
|
||||
console.log(`transaction id: ${transaction.transactionHash}`);
|
||||
|
||||
recipientBalance = await web3.eth.getBalance(recipient);
|
||||
console.log(`\nnew recipient account balance ${recipient}: ${recipientBalance}`);
|
||||
|
||||
callback();
|
||||
}
|
@ -1,12 +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}\n`);
|
||||
|
||||
@ -14,19 +14,16 @@ module.exports = async function(callback) {
|
||||
|
||||
console.log(`Recording a veto for contribution #${contributionId}`);
|
||||
|
||||
try {
|
||||
kredits.Contribution.contract.veto(contributionId, { gasLimit: 300000 })
|
||||
.then(result => {
|
||||
console.log("\n\nResult:");
|
||||
console.log(result);
|
||||
callback();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('Failed to veto contribution');
|
||||
callback(inspect(error));
|
||||
});
|
||||
} catch(err) {
|
||||
console.log('Failed to veto contribution');
|
||||
callback(inspect(err));
|
||||
}
|
||||
kredits.Contribution.contract.veto(contributionId, { gasLimit: 300000 })
|
||||
.then(result => {
|
||||
console.log("\n\nResult:");
|
||||
console.log(result);
|
||||
callback();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('Failed to veto contribution');
|
||||
callback(inspect(error));
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
|
Loading…
x
Reference in New Issue
Block a user