Compare commits

..

1 Commits

Author SHA1 Message Date
a7c497da6a Return IPFS hash in addContribution() response
Needed in kredits-web. Useful for clients to identify contributions
before knowing their assigned ID.
2019-09-10 12:18:35 +02:00
43 changed files with 140904 additions and 21576 deletions

View File

@@ -1,4 +0,0 @@
template: |
## Changes
$CHANGES

View File

@@ -22,16 +22,11 @@ install:
before_script:
- npm run devchain &
- sleep 10
script:
- npm run lint:wrapper
- npm run lint:contract-tests
# FIXME Fix tests
# - npm run test:token
# - npm run test:contributor
# - npm run test:contribution
# - npm run test:proposal
- npm run test
branches:
only:

View File

@@ -63,26 +63,21 @@ if you want to increase the block time to 10 seconds you can add
$ npm run devchain
$ ipfs daemon
2. Compile contracts
(compiled contracts will be in `/build`)
$ npm run compile-contracts
3. Deploy each app to the devchain
2. Deploy each app to the devchain
(make sure you've run `npm install` for every app - see installation)
$ npm run deploy:apps
4. Deploy a new KreditsKit and create a new DAO with the latest app versions
3. Deploy a new KreditsKit and create a new DAO with the latest app versions
$ npm run deploy:kit
$ npm run deploy:dao
5. Execute seeds to create demo contributors, contributions, etc. (optional)
4. Execute seeds to create demo contributors, contributions, etc. (optional)
$ npm run seeds
**Step 2-5 is also summarized in `npm run bootstrap`**
**Step 2-4 is also summarized in `npm run bootstrap`**
If you want to reset your local setup:
@@ -170,14 +165,8 @@ Deploys a new KreditsKit that allows to create a new DAO
or
$ npm run deploy:kit
#### Kredits configuration options:
Configuration options can be set in an environment specific `kredits` object in the `arapp.json` or using a CLI parameter.
* daoFactory: Ethereum address of the used DAO Factory. On public networks we use [official aragon factories](https://github.com/aragon/deployments/tree/master/environments/)
* apmDomain: the ENS domain of the aragonPM (normally `open.aragonpm.eth`)
(please also see the [arapp.json related configuration options](https://hack.aragon.org/docs/cli-global-confg#the-arappjson-file))
`ENS` address is required as environment variable.
`DAO_FACTORY` can optionally be set as environment variable. (see aragon)
### new-dao.js

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,13 @@
"version": "1.0.0",
"description": "",
"dependencies": {
"@aragon/os": "^4.4.0"
"@aragon/os": "^4.2.0",
"@aragon/cli": "^5.9.6"
},
"devDependencies": {
"@aragon/test-helpers": "^2.1.0",
"eth-gas-reporter": "^0.2.17",
"ganache-cli": "^6.9.1",
"@aragon/test-helpers": "^2.0.0",
"eth-gas-reporter": "^0.2.0",
"ganache-cli": "^6.4.3",
"solidity-coverage": "^0.5.11"
},
"scripts": {
@@ -25,7 +26,7 @@
"publish:minor": "aragon apm publish minor",
"publish:major": "aragon apm publish major",
"versions": "aragon apm versions",
"test": "truffle test"
"test": "aragon contracts test"
},
"keywords": []
}

8145
apps/contribution/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,13 +3,14 @@
"version": "1.0.0",
"description": "",
"dependencies": {
"@aragon/os": "^4.4.0"
"@aragon/os": "^4.2.0",
"@aragon/cli": "^5.9.6"
},
"devDependencies": {
"@aragon/test-helpers": "^2.1.0",
"eth-gas-reporter": "^0.2.17",
"ganache-cli": "^6.9.1",
"solidity-coverage": "^0.5.11"
"eth-gas-reporter": "^0.2.0",
"ganache-cli": "^6.4.3",
"solidity-coverage": "^0.5.11",
"@aragon/test-helpers": "^2.0.0"
},
"scripts": {
"start": "npm run start:aragon:ipfs",
@@ -25,7 +26,7 @@
"publish:minor": "aragon apm publish minor",
"publish:major": "aragon apm publish major",
"versions": "aragon apm versions",
"test": "truffle test"
"test": "aragon contracts test"
},
"keywords": []
}

View File

@@ -21,8 +21,8 @@ contract('Contributor app', (accounts) => {
aclBase = await getContract('ACL').new();
daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, ZERO_ADDR);
r = await daoFactory.newDAO(root);
dao = await getContract('Kernel').at(r.logs.filter(l => l.event == 'DeployDAO')[0].args.dao);
acl = await getContract('ACL').at(await dao.acl());
dao = getContract('Kernel').at(r.logs.filter(l => l.event == 'DeployDAO')[0].args.dao);
acl = getContract('ACL').at(await dao.acl());
//create dao mamnager permission for coin owner
await acl.createPermission(
@@ -63,7 +63,7 @@ contract('Contributor app', (accounts) => {
root,
{ from: root }
);
});
describe("Owner default permissions", async () => {
@@ -71,7 +71,7 @@ contract('Contributor app', (accounts) => {
let manageContributorPermission = await acl.hasPermission(root, contributor.address, await contributor.MANAGE_CONTRIBUTORS_ROLE());
// eslint-disable-next-line no-undef
assert.equal(manageContributorPermission, true);
});
});
});
describe("Add contributor", async () => {

8145
apps/contributor/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,13 @@
"version": "1.0.0",
"description": "",
"dependencies": {
"@aragon/os": "^4.4.0"
"@aragon/os": "^4.2.0",
"@aragon/cli": "^5.9.6"
},
"devDependencies": {
"@aragon/test-helpers": "^2.1.0",
"eth-gas-reporter": "^0.2.17",
"ganache-cli": "^6.9.1",
"@aragon/test-helpers": "^2.0.0",
"eth-gas-reporter": "^0.2.0",
"ganache-cli": "^6.4.3",
"solidity-coverage": "^0.5.11"
},
"scripts": {
@@ -25,7 +26,7 @@
"publish:minor": "aragon apm publish minor",
"publish:major": "aragon apm publish major",
"versions": "aragon apm versions",
"test": "truffle test"
"test": "aragon contracts test"
},
"keywords": []
}

8145
apps/proposal/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,13 @@
"version": "1.0.0",
"description": "",
"dependencies": {
"@aragon/os": "^4.4.0"
"@aragon/os": "^4.2.0",
"@aragon/cli": "^5.9.6"
},
"devDependencies": {
"@aragon/test-helpers": "^2.1.0",
"eth-gas-reporter": "^0.2.17",
"ganache-cli": "^6.9.1",
"@aragon/test-helpers": "^2.0.0",
"eth-gas-reporter": "^0.2.0",
"ganache-cli": "^6.4.3",
"solidity-coverage": "^0.5.11"
},
"scripts": {
@@ -25,7 +26,7 @@
"publish:minor": "aragon apm publish minor",
"publish:major": "aragon apm publish major",
"versions": "aragon apm versions",
"test": "truffle test"
"test": "aragon contracts test"
},
"keywords": []
}

View File

@@ -21,8 +21,8 @@ contract('Token app', (accounts) => {
aclBase = await getContract('ACL').new();
daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, ZERO_ADDR);
r = await daoFactory.newDAO(root);
dao = await getContract('Kernel').at(r.logs.filter(l => l.event == 'DeployDAO')[0].args.dao);
acl = await getContract('ACL').at(await dao.acl());
dao = getContract('Kernel').at(r.logs.filter(l => l.event == 'DeployDAO')[0].args.dao);
acl = getContract('ACL').at(await dao.acl());
//create dao mamnager permission for coin owner
await acl.createPermission(
@@ -63,7 +63,7 @@ contract('Token app', (accounts) => {
root,
{ from: root }
);
});
describe("Owner default space permissions", async () => {
@@ -71,7 +71,7 @@ contract('Token app', (accounts) => {
let tokenIssuerPermission = await acl.hasPermission(root, token.address, await token.MINT_TOKEN_ROLE());
// eslint-disable-next-line no-undef
assert.equal(tokenIssuerPermission, true);
});
});
});
describe("Token issuing", async () => {

8145
apps/token/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -34,6 +34,7 @@
"environments": {
"development": {
"network": "development",
"apm": "open.aragonpm.eth",
"registry": "0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1",
"appName": "dummy.open.aragonpm.eth"
},
@@ -41,10 +42,9 @@
"network": "rinkeby",
"registry": "0x98Df287B6C145399Aaa709692c8D308357bC085D",
"wsRPC": "wss://rinkeby.eth.aragon.network/ws",
"daoFactory": "0x2298d27a9b847c681d2b2c2828ab9d79013f5f1d",
"appName": "dummy.open.aragonpm.eth",
"kredits": {
"daoFactory": "0x2298d27a9b847c681d2b2c2828ab9d79013f5f1d"
}
"apm": "open.aragonpm.eth"
},
"kovan": {
"network": "kovan",
@@ -52,7 +52,8 @@
},
"default": {
"network": "development",
"appName": "dummy.aragonpm.eth"
"appName": "dummy.aragonpm.eth",
"apm": "open.aragonpm.eth"
}
},
"path": "contracts/misc/DummyApp.sol"

View File

@@ -5,7 +5,7 @@ class Acl extends Base {
hasPermission (fromAddress, contractAddress, roleID, params = null) {
let roleHash = EthersUtils.keccak256(EthersUtils.toUtf8Bytes(roleID));
return this.hasPermission(
return this.functions.hasPermission(
fromAddress,
contractAddress,
roleHash,

View File

@@ -1,13 +1,10 @@
const deprecate = require('../utils/deprecate');
class Base {
constructor (contract) {
this.contract = contract;
}
get functions () {
deprecate('The property `functions` is deprecated. contract functions are now directly defined on the ethers contract object. https://github.com/ethers-io/ethers.js/issues/920#issuecomment-650836642');
return this.contract;
return this.contract.functions;
}
get address () {

View File

@@ -4,33 +4,33 @@ const deprecate = require('../utils/deprecate');
class Contribution extends Record {
get count () {
return this.contract.contributionsCount();
return this.functions.contributionsCount();
}
getById (id) {
return this.contract.getContribution(id)
return this.functions.getContribution(id)
.then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
});
}
getData (id) {
return this.contract.getContribution(id);
return this.functions.getContribution(id);
}
getByContributorId (contributorId) {
return this.contract.getContributorAddressById(contributorId)
return this.functions.getContributorAddressById(contributorId)
.then(address => this.getByContributorAddress(address));
}
getByContributorAddress (address) {
return this.contract.balanceOf(address)
return this.functions.balanceOf(address)
.then(async (balance) => {
const count = balance.toNumber();
const contributions = [];
for (let index = 0; index < count; index++) {
const id = await this.contract.tokenOfOwnerByIndex(address, index);
const id = await this.functions.tokenOfOwnerByIndex(address, index);
const contribution = await this.getById(id);
contributions.push(contribution);
}
@@ -58,7 +58,10 @@ class Contribution extends Record {
ipfsHashAttr.hashSize,
];
return this.contract.add(...contribution, callOptions);
return this.functions.add(...contribution, callOptions).then(res => {
res.ipfsHash = this.ipfs.encodeHash(ipfsHashAttr);
return res;
});
});
}

View File

@@ -4,20 +4,19 @@ const formatKredits = require('../utils/format-kredits');
class Contributor extends Record {
get count () {
return this.contract.contributorsCount();
return this.functions.contributorsCount();
}
getById (id) {
return this.contract.getContributorById(id)
.then(contractData => {
let data = {...contractData};
return this.functions.getContributorById(id)
.then(data => {
data.balanceInt = formatKredits(data.balance);
return this.ipfs.catAndMerge(data, ContributorSerializer.deserialize);
});
}
getData (id) {
return this.contract.getContributorById(id);
return this.functions.getContributorById(id);
}
filterByAccount (search) {
@@ -62,7 +61,7 @@ class Contributor extends Record {
ipfsHashAttr.hashSize,
];
return this.contract.addContributor(...contributor, callOptions);
return this.functions.addContributor(...contributor, callOptions);
});
}
@@ -79,7 +78,7 @@ class Contributor extends Record {
return this.ipfs
.add(jsonStr)
.then(ipfsHashAttr => {
return this.contract.updateContributorProfileHash(
return this.functions.updateContributorProfileHash(
contributorId,
ipfsHashAttr.hashDigest,
ipfsHashAttr.hashFunction,

View File

@@ -11,9 +11,9 @@ class Kernel extends Base {
getApp (appName) {
if (appName === 'Acl') {
return this.contract.acl();
return this.functions.acl();
}
return this.contract.getApp(KERNEL_APP_ADDR_NAMESPACE, this.appNamehash(appName));
return this.functions.getApp(KERNEL_APP_ADDR_NAMESPACE, this.appNamehash(appName));
}
appNamehash (appName) {

View File

@@ -4,11 +4,11 @@ const deprecate = require('../utils/deprecate');
class Proposal extends Record {
get count () {
return this.contract.proposalsCount();
return this.functions.proposalsCount();
}
getById (id) {
return this.contract.getProposal(id)
return this.functions.getProposal(id)
.then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
});
@@ -33,7 +33,7 @@ class Proposal extends Record {
ipfsHashAttr.hashSize,
];
return this.contract.addProposal(...proposal, callOptions);
return this.functions.addProposal(...proposal, callOptions);
});
}

View File

@@ -30,11 +30,11 @@ class KreditsKit {
appIdFor (contractName) {
// see appIds in KreditsKit.sol for more details
const knownContracts = ['Contribution', 'Contributor', 'Proposal', 'Token'];
return this.contract.appIds(knownContracts.indexOf(contractName));
return this.contract.functions.appIds(knownContracts.indexOf(contractName));
}
newDAO (options = {}) {
return this.contract.newInstance(options).then(transaction => {
return this.contract.functions.newInstance(options).then(transaction => {
return transaction.wait().then(result => {
const deployEvent = result.events.find(e => e.event === 'DeployInstance');
return {

View File

@@ -28,7 +28,7 @@ class Contributor {
github_username,
gitea_username,
wiki_username,
zoom_display_name,
accounts,
} = this;
let data = {
@@ -36,7 +36,7 @@ class Contributor {
'@type': 'Contributor',
kind,
name,
accounts: [],
accounts: accounts || [],
};
if (url) {
@@ -68,13 +68,6 @@ class Contributor {
});
}
if (zoom_display_name) {
data.accounts.push({
'site': 'zoom.us',
'username': zoom_display_name,
});
}
// Write it pretty to ipfs
return JSON.stringify(data, null, 2);
}
@@ -104,11 +97,10 @@ class Contributor {
accounts,
} = JSON.parse(serialized.toString('utf8'));
let github_username, github_uid, gitea_username, wiki_username, zoom_display_name;
let github_username, github_uid, gitea_username, wiki_username;
let github = accounts.find(a => a.site === 'github.com');
let gitea = accounts.find(a => a.site === 'gitea.kosmos.org');
let wiki = accounts.find(a => a.site === 'wiki.kosmos.org');
let zoom = accounts.find(a => a.site === 'zoom.us');
if (github) {
(({ username: github_username, uid: github_uid} = github));
@@ -119,9 +111,6 @@ class Contributor {
if (wiki) {
(({ username: wiki_username } = wiki));
}
if (zoom) {
(({ username: zoom_display_name } = zoom));
}
return {
name,
@@ -132,7 +121,6 @@ class Contributor {
github_username,
gitea_username,
wiki_username,
zoom_display_name,
ipfsData: serialized,
};
}

View File

@@ -11,8 +11,7 @@ class IPFS {
this._ipfsAPI = ipfsClient(config);
}
catAndMerge (contractData, deserialize) {
let data = {...contractData}; // data from ethers.js is not extensible. this copy the attributes in a new object
catAndMerge (data, deserialize) {
// if no hash details are found simply return the data; nothing to merge
if (!data.hashSize || data.hashSize === 0) {
return data;
@@ -37,7 +36,7 @@ class IPFS {
cat (hashData) {
let ipfsHash = hashData; // default - if it is a string
if (Object.prototype.hasOwnProperty.call(hashData, 'hashSize')) {
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
}
if (this._config['gatewayUrl']) {
@@ -49,7 +48,7 @@ class IPFS {
pin (hashData) {
let ipfsHash = hashData; // default - if it is a string
if (Object.prototype.hasOwnProperty.call(hashData, 'hashSize')) {
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
}
return this._ipfsAPI.pin.add(multihashes.toB58String(ipfsHash));

6126
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "kredits-contracts",
"version": "6.0.0",
"version": "5.4.0",
"description": "Ethereum contracts and npm wrapper for Kredits",
"main": "./lib/kredits.js",
"directories": {
@@ -15,9 +15,9 @@
"compile-contracts": "truffle compile --all",
"bootstrap": "npm run reset:hard && npm run seeds",
"reset": "npm run deploy:kit && npm run deploy:dao",
"reset:hard": "npm run compile-contracts && npm run deploy:apps && npm run reset",
"deploy:kit": "truffle exec scripts/deploy-kit.js",
"deploy:dao": "truffle exec scripts/new-dao.js",
"reset:hard": "npm run deploy:apps && npm run reset",
"deploy:kit": "aragon contracts exec scripts/deploy-kit.js",
"deploy:dao": "aragon contracts exec scripts/new-dao.js",
"deploy:apps": "./scripts/every-app.sh \"aragon apm publish major --propagate-content=false --build=false --prepublish=false --skip-confirmation\"",
"devchain": "aragon devchain --port 7545",
"dao:address": "truffle exec scripts/current-address.js",
@@ -43,26 +43,23 @@
"homepage": "https://github.com/67P/truffle-kredits#readme",
"devDependencies": {
"@aragon/kits-base": "^1.0.0",
"@aragon/os": "^4.4.0",
"@aragon/os": "^4.2.0",
"async-each-series": "^1.1.0",
"cli-table": "^0.3.1",
"eslint": "^7.1.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eth-provider": "^0.2.5",
"homedir": "^0.6.0",
"eslint": "^5.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",
"promptly": "^3.0.3",
"solc": "^0.6.8",
"solhint": "^2.3.1",
"truffle-hdwallet-provider": "^1.0.17",
"truffle-hdwallet-provider-privkey": "^0.3.0",
"yargs": "^15.0.0"
"solc": "^0.4.26",
"solhint": "^2.1.0",
"yargs": "^12.0.0"
},
"dependencies": {
"ethers": "^5.0.2",
"ipfs-http-client": "^41.0.1",
"kosmos-schemas": "^2.2.1",
"ethers": "^4.0.29",
"ipfs-http-client": "^30.1.3",
"kosmos-schemas": "^2.1.0",
"node-fetch": "^2.6.0",
"tv4": "^1.3.0"
},

View File

@@ -19,10 +19,10 @@ module.exports = async function(callback) {
let contributorAccount;
if (contributor.length < 5) {
contributorId = contributor;
contributorAccount = await kredits.Contributor.contract.getContributorAddressById(contributor);
contributorAccount = await kredits.Contributor.functions.getContributorAddressById(contributor);
} else {
contributorAccount = contributor;
contributorId = await kredits.Contributor.contract.getContributorIdByAddress(contributor);
contributorId = await kredits.Contributor.functions.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.add(contributionAttributes, { gasLimit: 300000 })
kredits.Contribution.addContribution(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.contract.getContributorAddressById(contributor);
contributorAccount = await kredits.Contributor.functions.getContributorAddressById(contributor);
} else {
contributorAccount = contributor;
contributorId = await kredits.Contributor.contract.getContributorIdByAddress(contributor);
contributorId = await kredits.Contributor.functions.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.contract.claim(c.id, { gasLimit: 500000 }).then(tx => {
return kredits.Contribution.functions.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.contract[method]) {
if (!contractWrapper[method] && !contractWrapper.functions[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.contract[method];
func = contractWrapper.functions[method];
}
func.apply(contractWrapper, args).then((result) => {
console.log("\nResult:");

View File

@@ -1,12 +1,9 @@
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;
const networkId = await getNetworkId(web3)
console.log('# All known DAO addresses');
Object.keys(knownDAOAddresses).forEach((networkId) => {

View File

@@ -3,33 +3,23 @@ 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 namehash = require('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')
const arapp = require('../arapp.json')
const environment = argv['network'] || argv['environment'] || 'development'
const apm = arapp.environments[environment].apm
const ensAddr = arapp.environments[environment].registry || process.env.ENS
const daoFactoryAddress = arapp.environments[environment].daoFactory || process.env.DAO_FACTORY
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;
const networkId = await getNetworkId(web3)
console.log(`Deploying to networkId: ${networkId}`)
if (!ensAddr) {

View File

@@ -1,5 +1,6 @@
const argv = require('yargs').argv;
const ethers = require('ethers');
const getNetworkId = require('./networkid.js');
const Kredits = require('../../lib/kredits');
const arapp = require('../../arapp.json');
@@ -9,7 +10,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);
const signer = provider.getSigner();
let signer = provider.getSigner();
// checking if siner supports signing transactions
signer.getAddress().then(_ => {
new Kredits(provider, signer, { apm }).init().then(kredits => {

View File

@@ -0,0 +1,17 @@
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,14 +1,12 @@
const fs = require('fs');
const ethers = require('ethers');
const getNetworkId = require('./networkid.js');
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 networkId = await getNetworkId(web3);
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.contract.totalKreditsEarned(false);
let totalKreditsEarnedConfirmed = await kredits.Contribution.contract.totalKreditsEarned(true);
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);

View File

@@ -3,15 +3,13 @@ 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 provider = new ethers.providers.Web3Provider(web3.currentProvider);
const signer = provider.getSigner();
const network = await provider.getNetwork();
const networkId = network.chainId;
const networkId = await getNetworkId(web3)
console.log(`Deploying to networkId: ${networkId}`)
let kitAddresseFile = path.join(addressesPath, 'KreditsKit.json');
@@ -22,6 +20,9 @@ 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.contract[method];
func = contractWrapper.functions[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.contract.veto(contributionId, { gasLimit: 300000 })
kredits.Contribution.functions.veto(contributionId, { gasLimit: 300000 })
.then(result => {
console.log("\n\nResult:");
console.log(result);

8836
yarn.lock Normal file

File diff suppressed because it is too large Load Diff