Compare commits

..

1 Commits

Author SHA1 Message Date
eecb129bd5 Try to run bootstrap on travis
This basically tests the whole setup process
2019-08-09 18:54:52 +02:00
22 changed files with 46050 additions and 14578 deletions

View File

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

View File

@@ -15,26 +15,21 @@ cache:
- apps/token/node_modules - apps/token/node_modules
- apps/vault/node_modules - apps/vault/node_modules
env:
- TASK=lint:wrapper
- TASK=lint:contract-tests
- TASK=test:token
- TASK=test:contributor
- TASK=test:contribution
- TASK=test:proposal
install: install:
- npm install -g @aragon/cli - npm install -g @aragon/cli
- npm install -g truffle - npm install -g truffle
- npm install - npm install
before_script: before_script:
- npm run devchain > /dev/null & - npm run devchain &
- sleep 5 - ipfs daemon --offline &
script: script:
- travis_wait 60 npm run $TASK - npm run lint:wrapper
- npm run lint:contract-tests
- npm run test
- npm run bootstrap
branches: branches:
only: only:
- master - master

View File

@@ -38,7 +38,7 @@ Aragon CLI and Truffle need to be installed on your sytem as well:
For local development it is recommended to use For local development it is recommended to use
[ganache](http://truffleframework.com/ganache/) to run a local development [ganache](http://truffleframework.com/ganache/) to run a local development
chain. When using the ganache simulator, no full Ethereum node is required. chain. Using the ganache simulator no full Ethereum node is required.
We use the default aragon-cli devchain command to configure and run a local We use the default aragon-cli devchain command to configure and run a local
development ganache. development ganache.
@@ -52,10 +52,6 @@ To clear/reset the chain use (e.g. if you run out of funds on your devchain)
We default to port 7545 for development to not get in conflict with the default We default to port 7545 for development to not get in conflict with the default
Ethereum RPC port. Ethereum RPC port.
You can also set certain ganache options to configure the devchain, for example
if you want to increase the block time to 10 seconds you can add
`--block-time=10`.
### Bootstrap ### Bootstrap
1. Run an Ethereum node and ipfs 1. Run an Ethereum node and ipfs

View File

@@ -0,0 +1,912 @@
{
"roles": [
{
"name": "Add contributions",
"id": "ADD_CONTRIBUTION_ROLE",
"params": [],
"bytes": "0x493d28cd0d82bcb20db66e4f6390a00122ef772717e282b436ba3240af18bfb1"
},
{
"name": "Manage token contract",
"id": "MANAGE_TOKEN_CONTRACT_ROLE",
"params": [],
"bytes": "0xdd275187bc43df45ce7b34f6716e572716c69ad44e5e496175008950f032854b"
},
{
"name": "Veto contributions",
"id": "VETO_CONTRIBUTION_ROLE",
"params": [],
"bytes": "0x495a36de1ed34d5c1b9f8704e7d8bc8badb027221b09c79691d430bc54c4c88f"
}
],
"environments": {
"default": {
"network": "development",
"appName": "kredits-contribution.open.aragonpm.eth"
}
},
"path": "contracts/Contribution.sol",
"appName": "kredits-contribution.open.aragonpm.eth",
"appId": "0x09f5274cba299b46c5be722ef672d10eef7a2ef980b612aef529d74fb9da7643",
"abi": [
{
"constant": true,
"inputs": [],
"name": "hasInitialized",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ADD_CONTRIBUTION_ROLE",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_script",
"type": "bytes"
}
],
"name": "getEVMScriptExecutor",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getRecoveryVault",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "contributionsCount",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "token",
"type": "address"
}
],
"name": "allowRecoverability",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "appId",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getInitializationBlock",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "KERNEL_APP_ADDR_NAMESPACE",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_token",
"type": "address"
}
],
"name": "transferToVault",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_sender",
"type": "address"
},
{
"name": "_role",
"type": "bytes32"
},
{
"name": "_params",
"type": "uint256[]"
}
],
"name": "canPerform",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getEVMScriptRegistry",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint32"
}
],
"name": "contributionOwner",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint32"
}
],
"name": "contributions",
"outputs": [
{
"name": "contributorId",
"type": "uint32"
},
{
"name": "amount",
"type": "uint32"
},
{
"name": "claimed",
"type": "bool"
},
{
"name": "hashDigest",
"type": "bytes32"
},
{
"name": "hashFunction",
"type": "uint8"
},
{
"name": "hashSize",
"type": "uint8"
},
{
"name": "tokenMetadataURL",
"type": "string"
},
{
"name": "confirmedAtBlock",
"type": "uint256"
},
{
"name": "vetoed",
"type": "bool"
},
{
"name": "exists",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint32"
},
{
"name": "",
"type": "uint256"
}
],
"name": "ownedContributions",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "kernel",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "blocksToWait",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isPetrified",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "appIds",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "VETO_CONTRIBUTION_ROLE",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "id",
"type": "uint32"
},
{
"indexed": true,
"name": "contributorId",
"type": "uint32"
},
{
"indexed": false,
"name": "amount",
"type": "uint32"
}
],
"name": "ContributionAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "id",
"type": "uint32"
},
{
"indexed": true,
"name": "contributorId",
"type": "uint32"
},
{
"indexed": false,
"name": "amount",
"type": "uint32"
}
],
"name": "ContributionClaimed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "id",
"type": "uint32"
},
{
"indexed": false,
"name": "vetoedByAccount",
"type": "address"
}
],
"name": "ContributionVetoed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "executor",
"type": "address"
},
{
"indexed": false,
"name": "script",
"type": "bytes"
},
{
"indexed": false,
"name": "input",
"type": "bytes"
},
{
"indexed": false,
"name": "returnData",
"type": "bytes"
}
],
"name": "ScriptResult",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "vault",
"type": "address"
},
{
"indexed": true,
"name": "token",
"type": "address"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "RecoverToVault",
"type": "event"
},
{
"constant": false,
"inputs": [
{
"name": "_appIds",
"type": "bytes32[4]"
}
],
"name": "initialize",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getTokenContract",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getContributorContract",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributorAccount",
"type": "address"
}
],
"name": "getContributorIdByAddress",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributorId",
"type": "uint32"
}
],
"name": "getContributorAddressById",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "ownerOf",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "owner",
"type": "address"
},
{
"name": "index",
"type": "uint32"
}
],
"name": "tokenOfOwnerByIndex",
"outputs": [
{
"name": "",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "tokenMetadata",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "confirmedOnly",
"type": "bool"
}
],
"name": "totalKreditsEarned",
"outputs": [
{
"name": "amount",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributorId",
"type": "uint32"
},
{
"name": "confirmedOnly",
"type": "bool"
}
],
"name": "totalKreditsEarnedByContributor",
"outputs": [
{
"name": "amount",
"type": "uint32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "getContribution",
"outputs": [
{
"name": "id",
"type": "uint32"
},
{
"name": "contributorId",
"type": "uint32"
},
{
"name": "amount",
"type": "uint32"
},
{
"name": "claimed",
"type": "bool"
},
{
"name": "hashDigest",
"type": "bytes32"
},
{
"name": "hashFunction",
"type": "uint8"
},
{
"name": "hashSize",
"type": "uint8"
},
{
"name": "confirmedAtBlock",
"type": "uint256"
},
{
"name": "exists",
"type": "bool"
},
{
"name": "vetoed",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "amount",
"type": "uint32"
},
{
"name": "contributorId",
"type": "uint32"
},
{
"name": "hashDigest",
"type": "bytes32"
},
{
"name": "hashFunction",
"type": "uint8"
},
{
"name": "hashSize",
"type": "uint8"
}
],
"name": "add",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "veto",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "claim",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "contributionId",
"type": "uint32"
}
],
"name": "exists",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"deployment": {
"contractName": "Contribution",
"compiledAt": "2019-06-13T12:39:07.659Z",
"compiler": {
"name": "solc",
"version": "0.4.24+commit.e67f0147.Emscripten.clang",
"optimizer": {
"enabled": false
}
},
"flattenedCode": "./code.sol",
"transactionHash": "0x073057bb616243e415823fa9a8c8cc096b573fbd0bbf11c2f59bb75a84291689"
},
"functions": [
{
"sig": "mintFor(address,uint256,uint32)",
"roles": [],
"notice": null
},
{
"sig": "initialize(bytes32[4])",
"roles": [],
"notice": null
},
{
"sig": "add(uint32,uint32,bytes32,uint8,uint8)",
"roles": [
"ADD_CONTRIBUTION_ROLE"
],
"notice": null
},
{
"sig": "veto(uint32)",
"roles": [
"VETO_CONTRIBUTION_ROLE"
],
"notice": null
},
{
"sig": "claim(uint32)",
"roles": [],
"notice": null
}
]
}

1252
apps/contribution/code.sol Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -152,8 +152,6 @@ contract Contribution is AragonApp {
function add(uint32 amount, uint32 contributorId, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize) public isInitialized auth(ADD_CONTRIBUTION_ROLE) { function add(uint32 amount, uint32 contributorId, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize) public isInitialized auth(ADD_CONTRIBUTION_ROLE) {
//require(canPerform(msg.sender, ADD_CONTRIBUTION_ROLE, new uint32[](0)), 'nope'); //require(canPerform(msg.sender, ADD_CONTRIBUTION_ROLE, new uint32[](0)), 'nope');
require(amount > 0, "INVALID_AMOUNT");
uint32 contributionId = contributionsCount + 1; uint32 contributionId = contributionsCount + 1;
ContributionData storage c = contributions[contributionId]; ContributionData storage c = contributions[contributionId];
c.exists = true; c.exists = true;

View File

@@ -1,18 +0,0 @@
pragma solidity ^0.4.24;
import "@aragon/os/contracts/acl/ACL.sol";
import "@aragon/os/contracts/kernel/Kernel.sol";
import "@aragon/os/contracts/factory/DAOFactory.sol";
import "../../../contributor/contracts/Contributor.sol";
import "../../../token/contracts/Token.sol";
// You might think this file is a bit odd, but let me explain.
// We only use for now those imported contracts in our tests, which
// means Truffle will not compile them for us, because they are from
// an external dependency.
// solium-disable-next-line no-empty-blocks
contract Spoof {
// ...
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
// const Contribution = artifacts.require('Contribution.sol');
contract('Contribution', (_accounts) => {
it('should be tested');
});

View File

@@ -1,332 +0,0 @@
const namehash = require('ethers').utils.namehash;
// eslint-disable-next-line no-undef
const Contribution = artifacts.require("Contribution.sol");
// eslint-disable-next-line no-undef
const Contributor = artifacts.require("Contributor.sol");
// eslint-disable-next-line no-undef
const Token = artifacts.require("Token.sol");
// eslint-disable-next-line no-undef
const getContract = name => artifacts.require(name);
const { assertRevert } = require('@aragon/test-helpers/assertThrow');
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
const timeTravel = function(time){
return new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
web3.currentProvider.sendAsync({
jsonrpc: "2.0",
method: "evm_increaseTime",
params: [time], //86400 is num seconds in day
id: new Date().getSeconds(),
}, (err, result) => {
if(err) {
return reject(err);
}
return resolve(result);
});
});
};
const mineBlock = function() {
return new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
web3.currentProvider.sendAsync({
jsonrpc: "2.0",
method: "evm_mine",
params: [],
id: new Date().getSeconds(),
}, (err, result) => {
if(err){ return reject(err); }
return resolve(result);
});
});
};
const getBlockNumber = function() {
return new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
web3.eth.getBlockNumber(async (err, res) => {
if (err || !res) return reject(err);
resolve(res);
});
});
};
contract('Contribution app', (accounts) => {
// eslint-disable-next-line no-undef
let kernelBase, aclBase, daoFactory, r, dao, acl, contribution, token, contributor;
const root = accounts[0];
const member1 = accounts[1];
const blocksToWait = 40320;
// eslint-disable-next-line no-undef
before(async () => {
kernelBase = await getContract('Kernel').new(true); // petrify immediately
aclBase = await getContract('ACL').new();
daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, ZERO_ADDR);
r = await daoFactory.newDAO(root);
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(
root,
dao.address,
await dao.APP_MANAGER_ROLE(),
root,
{ from: root }
);
//apps id
let appsId = [];
appsId[0] = namehash("kredits-contribution");
appsId[1] = namehash("kredits-contributor");
appsId[2] = namehash("kredits-proposal");
appsId[3] = namehash("kredits-token");
//get new app instance from DAO
let receipt = await dao.newAppInstance(
appsId[0],
(await Contribution.new()).address,
0x0,
false,
{ from: root }
);
contribution = Contribution.at(
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
);
receipt = await dao.newAppInstance(
appsId[3],
(await Token.new()).address,
0x0,
false,
{ from: root }
);
token = Token.at(
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
);
receipt = await dao.newAppInstance(
appsId[1],
(await Contributor.new()).address,
0x0,
false,
{ from: root }
);
contributor = Contributor.at(
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
);
//init app
await contribution.initialize(appsId);
await acl.createPermission(
root,
contribution.address,
await contribution.ADD_CONTRIBUTION_ROLE(),
root,
{ from: root }
);
await acl.createPermission(
root,
contribution.address,
await contribution.VETO_CONTRIBUTION_ROLE(),
root,
{ from: root }
);
//init token (app)
await token.initialize(appsId);
//create token mint permission for coin owner
await acl.createPermission(
contribution.address,
token.address,
await token.MINT_TOKEN_ROLE(),
root,
{ from: root }
);
//init contributor app
await contributor.initialize(root, appsId);
await acl.createPermission(
root,
contributor.address,
await contributor.MANAGE_CONTRIBUTORS_ROLE(),
root,
{ from: root }
);
});
describe("Owner default space permissions", async () => {
it('check owner can add contribution', async () => {
let addContributionPermission = await acl.hasPermission(root, contribution.address, await contribution.ADD_CONTRIBUTION_ROLE());
// eslint-disable-next-line no-undef
assert.equal(addContributionPermission, true);
});
it('check owner can veto contribution', async () => {
let vetoContributionPermission = await acl.hasPermission(root, contribution.address, await contribution.VETO_CONTRIBUTION_ROLE());
// eslint-disable-next-line no-undef
assert.equal(vetoContributionPermission, true);
});
it('check contribution app can mint token', async () => {
let mintTokenPermission = await acl.hasPermission(contribution.address, token.address, await token.MINT_TOKEN_ROLE());
// eslint-disable-next-line no-undef
assert.equal(mintTokenPermission, true);
});
});
describe("Add contribution", async () => {
// contributor detials
let account, contributorHashDigest, contributorHashFunction, contributorHashSize;
// contribution details
let amount, contributorId, hashDigest, hashFunction, hashSize;
// eslint-disable-next-line no-undef
before(async () => {
// Add contributor from Contributor app
account = root;
contributorHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
contributorHashFunction = 0;
contributorHashSize = 0;
await contributor.addContributor(account, contributorHashDigest, contributorHashFunction, contributorHashSize);
// eslint-disable-next-line no-undef
assert.equal(await contributor.addressExists(account), true);
amount = 100;
contributorId = await contributor.getContributorIdByAddress(root);
hashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
hashFunction = 1;
hashSize = 1;
});
it("should revert when add contribution from address that does not have permission", async () => {
return assertRevert(async () => {
await contribution.add(amount, contributorId, hashDigest, hashFunction, hashSize, {from: member1});
'sender does not have permission';
});
});
it("should revert when add contribution with amount equal to zero", async () => {
return assertRevert(async () => {
await contribution.add(0, contributorId, hashDigest, hashFunction, hashSize, {from: root});
'amount equal to zero';
});
});
it("should add contribution", async () => {
let contributionCountBefore = await contribution.contributionsCount();
await contribution.add(amount, contributorId, hashDigest, hashFunction, hashSize, {from: root});
let contributionCountAfter = await contribution.contributionsCount();
// eslint-disable-next-line no-undef
assert.equal(contributionCountAfter.toNumber()-contributionCountBefore.toNumber(), 1, "contributions counter incremented");
let contributionObject = await contribution.getContribution(contributionCountAfter.toNumber());
// eslint-disable-next-line no-undef
assert.equal(contributionObject[1].toNumber(), contributorId.toNumber(), "contribution added belong to contributor id");
let isExist = await contribution.exists(contributionCountAfter.toNumber());
// eslint-disable-next-line no-undef
assert.equal(isExist, true, "contribution exist");
});
});
describe("Veto contribution", async () => {
it("should revert when veto from address that does not have permission", async () => {
const contributionId = await contribution.contributionsCount();
return assertRevert(async () => {
await contribution.veto(contributionId.toNumber(), {from: member1});
'sender does not have permission to veto';
});
});
it("should revert when veto contribution that does not exist", async () => {
const contributionId = await contribution.contributionsCount();
return assertRevert(async () => {
await contribution.veto(contributionId.toNumber()+1, {from: root});
'contribution not found';
});
});
it("veto contribution", async () => {
const contributionId = await contribution.contributionsCount();
if(contributionId < 10) {
return assertRevert(async () => {
await contribution.veto(contributionId.toNumber(), {from: root});
'can not veto first 10 contribution';
});
}
else {
await contribution.veto(contributionId.toNumber(), {from: root});
let contributionObject = await contribution.getContribution(contributionId.toNumber());
// eslint-disable-next-line no-undef
assert(contributionObject[9], true);
}
});
});
describe("Claim contribution", async () => {
let contributionId;
// eslint-disable-next-line no-undef
before(async () =>{
//add contribution
let amount = 200;
let contributorId = await contributor.getContributorIdByAddress(root);
let contributionHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
let contributionHashFunction = 1;
let contributionHashSize = 1;
await contribution.add(amount, contributorId.toNumber(), contributionHashDigest, contributionHashFunction, contributionHashSize, {from: root});
contributionId = await contribution.contributionsCount();
});
it("should revert when claim contribution that does not exist", async () => {
return assertRevert(async () => {
await contribution.claim(contributionId.toNumber()+1, {from: root});
'contribution not found';
});
});
it("should revert when claim contribution before confirmation block", async () => {
if(contributionId > 10) {
return assertRevert(async () => {
await contribution.claim(contributionId.toNumber(), {from: root});
'contribution not confirmed yet';
});
}
});
it("claim contribution", async () => {
let contributionObject = await contribution.getContribution(contributionId.toNumber());
let confirmationBlock = contributionObject[7];
let chainBlockNumberBefore = await getBlockNumber();
if(contributionId > 10) {
await timeTravel(blocksToWait);
await mineBlock();
let chainBlockNumberAfter = await getBlockNumber();
// eslint-disable-next-line no-undef
assert.equal(chainBlockNumberAfter.toNumber()-chainBlockNumberBefore.toNumber(), confirmationBlock.toNumber());
}
//Claim contribution
await contribution.claim(contributionId, {from: root});
contributionObject = await contribution.getContribution(contributionId.toNumber());
// eslint-disable-next-line no-undef
assert(contributionObject[3], true);
});
it("should revert when claim already claimed contribution", async () => {
return assertRevert(async () => {
await contribution.claim(contributionId.toNumber(), {from: root});
'contribution already claimed';
});
});
});
});

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

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

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

8145
apps/token/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -34,9 +34,7 @@
"environments": { "environments": {
"development": { "development": {
"network": "development", "network": "development",
"apm": { "apm": "open.aragonpm.eth",
"open.aragonpm.eth"
},
"registry": "0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1", "registry": "0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1",
"appName": "dummy.open.aragonpm.eth" "appName": "dummy.open.aragonpm.eth"
}, },
@@ -46,9 +44,7 @@
"wsRPC": "wss://rinkeby.eth.aragon.network/ws", "wsRPC": "wss://rinkeby.eth.aragon.network/ws",
"daoFactory": "0x2298d27a9b847c681d2b2c2828ab9d79013f5f1d", "daoFactory": "0x2298d27a9b847c681d2b2c2828ab9d79013f5f1d",
"appName": "dummy.open.aragonpm.eth", "appName": "dummy.open.aragonpm.eth",
"apm": { "apm": "open.aragonpm.eth"
"open.aragonpm.eth"
}
}, },
"kovan": { "kovan": {
"network": "kovan", "network": "kovan",
@@ -57,9 +53,7 @@
"default": { "default": {
"network": "development", "network": "development",
"appName": "dummy.aragonpm.eth", "appName": "dummy.aragonpm.eth",
"apm": { "apm": "open.aragonpm.eth"
"open.aragonpm.eth"
}
} }
}, },
"path": "contracts/misc/DummyApp.sol" "path": "contracts/misc/DummyApp.sol"

View File

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

891
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,6 @@
"devDependencies": { "devDependencies": {
"@aragon/kits-base": "^1.0.0", "@aragon/kits-base": "^1.0.0",
"@aragon/os": "^4.2.0", "@aragon/os": "^4.2.0",
"@aragon/test-helpers": "^2.0.0",
"async-each-series": "^1.1.0", "async-each-series": "^1.1.0",
"cli-table": "^0.3.1", "cli-table": "^0.3.1",
"eslint": "^5.16.0", "eslint": "^5.16.0",

8836
yarn.lock Normal file

File diff suppressed because it is too large Load Diff