merge with master
This commit is contained in:
commit
e2b55e1d0f
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
/scripts/
|
12
.travis.yml
12
.travis.yml
@ -7,18 +7,14 @@ sudo: false
|
||||
dist: xenial
|
||||
|
||||
cache:
|
||||
yarn: true
|
||||
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- export PATH=$HOME/.yarn/bin:$PATH
|
||||
npm: true
|
||||
|
||||
install:
|
||||
- yarn install --no-lockfile --non-interactive
|
||||
- npm install
|
||||
|
||||
script:
|
||||
- yarn lint:wrapper
|
||||
- yarn lint:contract-tests
|
||||
- npm run lint:wrapper
|
||||
- npm run lint:contract-tests
|
||||
# - yarn lint:contracts
|
||||
|
||||
branches:
|
||||
|
@ -118,22 +118,22 @@ contract Contribution is AragonApp {
|
||||
// Custom functions
|
||||
//
|
||||
|
||||
function totalKreditsEarned(bool confirmedOnly) public view returns (uint256 count) {
|
||||
function totalKreditsEarned(bool confirmedOnly) public view returns (uint32 amount) {
|
||||
for (uint32 i = 1; i <= contributionsCount; i++) {
|
||||
ContributionData memory c = contributions[i];
|
||||
if (block.number >= c.confirmedAtBlock || !confirmedOnly) {
|
||||
count += c.amount; // should use safemath
|
||||
if (!c.vetoed && (block.number >= c.confirmedAtBlock || !confirmedOnly)) {
|
||||
amount += c.amount; // should use safemath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function totalKreditsEarnedByContributor(uint32 contributorId, bool confirmedOnly) public view returns (uint256 count) {
|
||||
uint256 tokenBalance = ownedContributions[contributorId].length;
|
||||
for (uint256 i = 0; i < tokenBalance; i++) {
|
||||
function totalKreditsEarnedByContributor(uint32 contributorId, bool confirmedOnly) public view returns (uint32 amount) {
|
||||
uint256 tokenCount = ownedContributions[contributorId].length;
|
||||
for (uint256 i = 0; i < tokenCount; i++) {
|
||||
uint32 cId = ownedContributions[contributorId][i];
|
||||
ContributionData memory c = contributions[cId];
|
||||
if (block.number >= c.confirmedAtBlock || !confirmedOnly) {
|
||||
count += c.amount; // should use safemath
|
||||
if (!c.vetoed && (block.number >= c.confirmedAtBlock || !confirmedOnly)) {
|
||||
amount += c.amount; // should use safemath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ interface ITokenBalance {
|
||||
function balanceOf(address contributorAccount) public view returns (uint256);
|
||||
}
|
||||
interface IContributionBalance {
|
||||
function totalKreditsEarnedByContributor(uint32 contributorId, bool confirmedOnly) public view returns (uint256 count);
|
||||
function totalKreditsEarnedByContributor(uint32 contributorId, bool confirmedOnly) public view returns (uint32 amount);
|
||||
function balanceOf(address owner) public view returns (uint256);
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ contract Contributor is AragonApp {
|
||||
return contributors[id];
|
||||
}
|
||||
|
||||
function getContributorById(uint32 _id) public view returns (uint32 id, address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize, bool isCore, uint256 balance, uint256 totalKreditsEarned, uint256 contributionsCount, bool exists ) {
|
||||
function getContributorById(uint32 _id) public view returns (uint32 id, address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize, bool isCore, uint256 balance, uint32 totalKreditsEarned, uint256 contributionsCount, bool exists ) {
|
||||
id = _id;
|
||||
Contributor storage c = contributors[_id];
|
||||
account = c.account;
|
||||
|
@ -7,7 +7,7 @@ const contractCalls = [
|
||||
github_username: 'bumi',
|
||||
github_uid: 318,
|
||||
gitea_username: 'bumi',
|
||||
wiki_username: 'Bumi'
|
||||
wiki_username: 'Bumi',
|
||||
}, { gasLimit: 200000 }]],
|
||||
|
||||
['Contributor', 'add', [{
|
||||
@ -18,7 +18,7 @@ const contractCalls = [
|
||||
github_username: 'skddc',
|
||||
github_uid: 842,
|
||||
gitea_username: 'raucao',
|
||||
wiki_username: 'Basti'
|
||||
wiki_username: 'Basti',
|
||||
}, { gasLimit: 200000 }]],
|
||||
|
||||
['Contributor', 'add', [{
|
||||
@ -28,21 +28,21 @@ const contractCalls = [
|
||||
url: '',
|
||||
github_username: 'fsmanuel',
|
||||
github_uid: 54812,
|
||||
wiki_username: 'Manuel'
|
||||
wiki_username: 'Manuel',
|
||||
}, { gasLimit: 200000 }]],
|
||||
|
||||
['Proposal', 'addProposal', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-09', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-10', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'addProposal', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Hacked on kredits', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-09', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-10', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Ran the seeds', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Hacked on kredits', url: '' }, { gasLimit: 350000 }]],
|
||||
['Proposal', 'vote', [1, { gasLimit: 550000 }]],
|
||||
['Contribution', 'addContribution', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 5000, kind: 'dev', description: '[67P/kredits-contracts] Introduce contribution token', url: '' }, { gasLimit: 350000 }]],
|
||||
['Contribution', 'addContribution', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-web] Reviewed stuff', url: '' }, { gasLimit: 350000 }]],
|
||||
['Contribution', 'claim', [1, { gasLimit: 300000 }]]
|
||||
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 5000, kind: 'dev', description: '[67P/kredits-contracts] Introduce contribution token', url: '' }, { gasLimit: 350000 }]],
|
||||
['Contribution', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-web] Reviewed stuff', url: '' }, { gasLimit: 350000 }]],
|
||||
['Contribution', 'claim', [1, { gasLimit: 300000 }]],
|
||||
];
|
||||
|
||||
const funds = [
|
||||
'0x7e8f313c56f809188313aa274fa67ee58c31515d',
|
||||
'0xa502eb4021f3b9ab62f75b57a94e1cfbf81fd827'
|
||||
'0xa502eb4021f3b9ab62f75b57a94e1cfbf81fd827',
|
||||
];
|
||||
|
||||
module.exports = { contractCalls, funds };
|
||||
|
@ -34,20 +34,20 @@ contract KreditsKit is KitBase {
|
||||
Contributor contributor = Contributor(_installApp(dao, appIds[uint8(Apps.Contributor)]));
|
||||
contributor.initialize(root, appIds);
|
||||
acl.createPermission(root, contributor, contributor.MANAGE_CONTRIBUTORS_ROLE(), this);
|
||||
|
||||
|
||||
Token token = Token(_installApp(dao, appIds[uint8(Apps.Token)]));
|
||||
token.initialize(appIds);
|
||||
|
||||
|
||||
Contribution contribution = Contribution(_installApp(dao, appIds[uint8(Apps.Contribution)]));
|
||||
contribution.initialize(appIds);
|
||||
|
||||
|
||||
Proposal proposal = Proposal(_installApp(dao, appIds[uint8(Apps.Proposal)]));
|
||||
proposal.initialize(appIds);
|
||||
|
||||
acl.createPermission(root, contribution, contribution.ADD_CONTRIBUTION_ROLE(), this);
|
||||
acl.createPermission(root, contribution, contribution.VETO_CONTRIBUTION_ROLE(), this);
|
||||
acl.grantPermission(proposal, contribution, contribution.ADD_CONTRIBUTION_ROLE());
|
||||
|
||||
|
||||
uint256[] memory params = new uint256[](1);
|
||||
params[0] = uint256(203) << 248 | uint256(1) << 240 | uint240(contributor);
|
||||
acl.grantPermissionP(acl.ANY_ENTITY(), contribution, contribution.ADD_CONTRIBUTION_ROLE(), params);
|
||||
@ -57,7 +57,7 @@ contract KreditsKit is KitBase {
|
||||
//acl.setPermissionManager(this, proposal, proposal.VOTE_PROPOSAL_ROLE();
|
||||
acl.createPermission(root, proposal, proposal.VOTE_PROPOSAL_ROLE(), this);
|
||||
acl.grantPermissionP(acl.ANY_ENTITY(), proposal, proposal.VOTE_PROPOSAL_ROLE(), params);
|
||||
|
||||
|
||||
acl.createPermission(root, proposal, proposal.ADD_PROPOSAL_ROLE(), this);
|
||||
//acl.grantPermissionP(address(-1), proposal, proposal.ADD_PROPOSAL_ROLE(), params);
|
||||
acl.grantPermission(acl.ANY_ENTITY(), proposal, proposal.ADD_PROPOSAL_ROLE());
|
||||
@ -67,9 +67,9 @@ contract KreditsKit is KitBase {
|
||||
acl.setPermissionManager(root, contribution, contribution.ADD_CONTRIBUTION_ROLE());
|
||||
acl.setPermissionManager(root, contribution, contribution.VETO_CONTRIBUTION_ROLE());
|
||||
acl.setPermissionManager(root, contributor, contributor.MANAGE_CONTRIBUTORS_ROLE());
|
||||
|
||||
|
||||
acl.createPermission(root, token, token.MINT_TOKEN_ROLE(), this);
|
||||
acl.grantPermission(contribution, token, token.MINT_TOKEN_ROLE());
|
||||
acl.grantPermission(contribution, token, token.MINT_TOKEN_ROLE());
|
||||
acl.setPermissionManager(root, token, token.MINT_TOKEN_ROLE());
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
lib/abis/KreditsKit.json
Normal file
1
lib/abis/KreditsKit.json
Normal file
@ -0,0 +1 @@
|
||||
[{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fac","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"appId","type":"bytes32"}],"name":"latestVersionAppBase","outputs":[{"name":"base","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"appIds","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_fac","type":"address"},{"name":"_ens","type":"address"},{"name":"_appIds","type":"bytes32[4]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"dao","type":"address"}],"name":"DeployInstance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"dao","type":"address"},{"indexed":false,"name":"appProxy","type":"address"},{"indexed":false,"name":"appId","type":"bytes32"}],"name":"InstalledApp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"appProxy","type":"address"},{"indexed":false,"name":"appId","type":"bytes32"}],"name":"InstalledApp","type":"event"},{"constant":false,"inputs":[],"name":"newInstance","outputs":[{"name":"dao","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
|
@ -7,6 +7,10 @@ class Base {
|
||||
return this.contract.functions;
|
||||
}
|
||||
|
||||
get address () {
|
||||
return this.contract.address;
|
||||
}
|
||||
|
||||
get ipfs () {
|
||||
if (!this._ipfsAPI) { throw new Error('IPFS API not configured; please set an ipfs instance'); }
|
||||
return this._ipfsAPI;
|
||||
|
@ -66,6 +66,27 @@ class Kredits {
|
||||
return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init();
|
||||
}
|
||||
|
||||
static for (connectionOptions, kreditsOptions) {
|
||||
let { network, rpcUrl, wallet } = connectionOptions;
|
||||
if (!rpcUrl && network === 'local') { rpcUrl = 'http://localhost:8545'; }
|
||||
let ethProvider, signer;
|
||||
if (rpcUrl) {
|
||||
ethProvider = new ethers.providers.JsonRpcProvider(rpcUrl);
|
||||
} else {
|
||||
ethProvider = new ethers.getDefaultProvider(network);
|
||||
}
|
||||
if (wallet) {
|
||||
signer = wallet.connect(ethProvider);
|
||||
} else if (ethProvider.getSigner) {
|
||||
signer = ethProvider.getSigner();
|
||||
}
|
||||
return new Kredits(ethProvider, signer, kreditsOptions);
|
||||
}
|
||||
|
||||
static availableNetworks () {
|
||||
return Object.keys(DaoAddresses);
|
||||
}
|
||||
|
||||
get Kernel () {
|
||||
let k = this.contractFor('Kernel');
|
||||
// in case we want to use a special apm (e.g. development vs. production)
|
||||
|
49
lib/kreditskit.js
Normal file
49
lib/kreditskit.js
Normal file
@ -0,0 +1,49 @@
|
||||
const ethers = require('ethers');
|
||||
|
||||
const ABI = require('./abis/KreditsKit.json');
|
||||
const Addresses = require('./addresses/KreditsKit.json');
|
||||
|
||||
class KreditsKit {
|
||||
|
||||
constructor (provider, signer, options = {}) {
|
||||
let { address, abi } = options;
|
||||
|
||||
this.provider = provider;
|
||||
this.signer = signer;
|
||||
this.options = options;
|
||||
this.address = address;
|
||||
this.abi = abi || ABI;
|
||||
}
|
||||
|
||||
init () {
|
||||
return this.provider.getNetwork().then((network) => {
|
||||
this.address = this.address || Addresses[network.chainId.toString()];
|
||||
this.contract = new ethers.Contract(
|
||||
this.address,
|
||||
this.abi,
|
||||
(this.signer || this.provider)
|
||||
);
|
||||
return this;
|
||||
});
|
||||
}
|
||||
|
||||
appIdFor (contractName) {
|
||||
// see appIds in KreditsKit.sol for more details
|
||||
const knownContracts = ['Contribution', 'Contributor', 'Proposal', 'Token'];
|
||||
return this.contract.functions.appIds(knownContracts.indexOf(contractName));
|
||||
}
|
||||
|
||||
newDAO (options = {}) {
|
||||
return this.contract.functions.newInstance(options).then(transaction => {
|
||||
return transaction.wait().then(result => {
|
||||
const deployEvent = result.events.find(e => e.event === 'DeployInstance');
|
||||
return {
|
||||
daoAddress: deployEvent.args.dao,
|
||||
transactionHash: transaction.hash,
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = KreditsKit;
|
@ -28,6 +28,7 @@ class Contributor {
|
||||
github_username,
|
||||
gitea_username,
|
||||
wiki_username,
|
||||
accounts,
|
||||
} = this;
|
||||
|
||||
let data = {
|
||||
@ -35,7 +36,7 @@ class Contributor {
|
||||
'@type': 'Contributor',
|
||||
kind,
|
||||
name,
|
||||
'accounts': [],
|
||||
accounts: accounts || [],
|
||||
};
|
||||
|
||||
if (url) {
|
||||
|
38406
package-lock.json
generated
38406
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -27,7 +27,9 @@
|
||||
"test:kit": "aragon contracts test --environment default",
|
||||
"lint:contracts": "solhint \"contracts/**/*.sol\" \"apps/*/contracts/**/*.sol\"",
|
||||
"lint:contract-tests": "eslint apps/*/test",
|
||||
"lint:wrapper": "eslint lib/"
|
||||
"lint:wrapper": "eslint lib/",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"setup-git-hooks": "sh scripts/git-hooks/install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -40,26 +42,27 @@
|
||||
},
|
||||
"homepage": "https://github.com/67P/truffle-kredits#readme",
|
||||
"devDependencies": {
|
||||
"@aragon/cli": "^5.5.0",
|
||||
"@aragon/cli": "^5.9.4",
|
||||
"@aragon/kits-base": "^1.0.0",
|
||||
"@aragon/os": "^4.1.0",
|
||||
"@aragon/os": "^4.2.0",
|
||||
"async-each-series": "^1.1.0",
|
||||
"cli-table": "^0.3.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-import": "^2.17.3",
|
||||
"eslint-plugin-node": "^8.0.1",
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eth-provider": "^0.2.2",
|
||||
"openzeppelin-solidity": "^2.2.0",
|
||||
"promptly": "^3.0.3",
|
||||
"solc": "^0.4.25",
|
||||
"chai": "^4.2.0",
|
||||
"solidity-coverage": "0.5.11",
|
||||
"eth-ens-namehash": "^2.0.8",
|
||||
"solhint": "^2.0.0"
|
||||
"solc": "^0.4.26",
|
||||
"solhint": "^2.1.0",
|
||||
"yargs": "^12.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethers": "^4.0.27",
|
||||
"ipfs-http-client": "^30.1.1",
|
||||
"ethers": "^4.0.29",
|
||||
"ipfs-http-client": "^32.0.1",
|
||||
"kosmos-schemas": "^2.1.0",
|
||||
"tv4": "^1.3.0"
|
||||
},
|
||||
|
53
scripts/claim-contributions.js
Normal file
53
scripts/claim-contributions.js
Normal file
@ -0,0 +1,53 @@
|
||||
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.functions.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();
|
||||
}
|
||||
};
|
2
scripts/git-hooks/install
Normal file
2
scripts/git-hooks/install
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
cp -f scripts/git-hooks/pre-commit .git/hooks
|
17
scripts/git-hooks/pre-commit
Executable file
17
scripts/git-hooks/pre-commit
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run appropriate linter against staged files
|
||||
#
|
||||
if [ $(git diff --name-only --cached lib/ | wc -l) != 0 ]; then
|
||||
./node_modules/.bin/eslint lib/
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# TODO master not linted yet, uncomment this when ready
|
||||
# if [ $(git diff --name-only --cached contracts/ | wc -l) != 0 ]; then
|
||||
# solhint contracts/**/*.sol && apps/*/contracts/**/*.sol
|
||||
# if [ $? != 0 ]; then
|
||||
# exit 1
|
||||
# fi
|
||||
# fi
|
@ -20,8 +20,9 @@ module.exports = async function(callback) {
|
||||
|
||||
try {
|
||||
let blockNumber = await kredits.provider.getBlockNumber();
|
||||
let contributions = await kredits.Contribution.all();
|
||||
let contributions = await kredits.Contribution.all({page: {size: 1000}});
|
||||
|
||||
let kreditsSum = 0;
|
||||
console.log(`Current block number: ${blockNumber}`);
|
||||
contributions.forEach((c) => {
|
||||
const confirmed = c.confirmedAtBlock <= blockNumber;
|
||||
@ -40,8 +41,9 @@ module.exports = async function(callback) {
|
||||
|
||||
console.log(table.toString());
|
||||
|
||||
let totalKreditsEarned = await kredits.Contribution.functions.totalKreditsEarned(true);
|
||||
console.log(`Total confirmed kredits: ${totalKreditsEarned}`);
|
||||
let totalKreditsEarnedUnConfirmed = await kredits.Contribution.functions.totalKreditsEarned(false);
|
||||
let totalKreditsEarnedConfirmed = await kredits.Contribution.functions.totalKreditsEarned(true);
|
||||
console.log(`Total Kredits: ${totalKreditsEarnedConfirmed} (confirmed) | ${totalKreditsEarnedUnConfirmed} (including unconfirmed)`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
const fs = require('fs');
|
||||
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');
|
||||
|
||||
const KreditsKit = artifacts.require('KreditsKit')
|
||||
|
||||
module.exports = async function(callback) {
|
||||
const networkId = await getNetworkId(web3)
|
||||
console.log(`Deploying to networkId: ${networkId}`)
|
||||
@ -20,25 +20,21 @@ module.exports = async function(callback) {
|
||||
}
|
||||
console.log(`Using KreditsKit at: ${kreditsKitAddress}`);
|
||||
|
||||
let kreditsKit = KreditsKit.at(kreditsKitAddress)
|
||||
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
|
||||
let signer = provider.getSigner();
|
||||
|
||||
kreditsKit.newInstance().then((ret) => {
|
||||
console.log(ret.logs);
|
||||
const installedEvents = ret.logs.filter(log => log.event === 'InstalledApp').map(log => log.args)
|
||||
const deployEvents = ret.logs.filter(log => log.event === 'DeployInstance').map(log => log.args)
|
||||
let kit = await new KreditsKit(provider, signer).init()
|
||||
|
||||
if (deployEvents.length > 1) {
|
||||
callback(new Error("More than one DAO was deployed. Something is wrong"))
|
||||
}
|
||||
const daoAddress = deployEvents[0].dao;
|
||||
// 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)
|
||||
|
||||
fileInject(path.join(addressesPath, 'dao.json'), networkId, daoAddress)
|
||||
|
||||
console.log(`\n\nCreated new DAO at: ${daoAddress}`)
|
||||
console.log(`\n\nCreated new DAO at: ${result.daoAddress}`)
|
||||
|
||||
callback();
|
||||
}).catch((err) => {
|
||||
console.log('failed to create a new instance')
|
||||
console.log('failed to create a new DAO')
|
||||
callback(err)
|
||||
})
|
||||
}
|
||||
|
@ -17,13 +17,15 @@ module.exports = async function(callback) {
|
||||
let fundingAmount = 2;
|
||||
each(seeds.funds, (address, next) => {
|
||||
console.log(`funding ${address} with 2 ETH`);
|
||||
web3.eth.sendTransaction({
|
||||
to: address,
|
||||
value: web3.toWei(fundingAmount),
|
||||
from: web3.eth.accounts[0]
|
||||
},
|
||||
(result) => { next(); }
|
||||
)
|
||||
try {
|
||||
web3.eth.sendTransaction({
|
||||
to: address,
|
||||
value: web3.toWei(fundingAmount),
|
||||
from: web3.eth.accounts[0]
|
||||
}, result => next())
|
||||
} catch(e) {
|
||||
console.log('FAILED:', e);
|
||||
}
|
||||
});
|
||||
|
||||
each(seeds.contractCalls, (call, next) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user