Cleanup and readme

simplify bootstrap
This commit is contained in:
bumi 2019-03-24 15:40:46 +01:00
parent 0d9b2d7d58
commit b03095e149
18 changed files with 1287 additions and 16687 deletions

View File

@ -13,11 +13,16 @@ Aragon itself uses the [Truffle framework](http://truffleframework.com/) for som
### Installation ### Installation
All requirements are defined in `package.json`.
$ npm install $ npm install
### Requirements Each of the aragon apps are separate packages:
All requirements are defined in `package.json`. $ cd apps/[app]
$ npm install
or use the bootstrap command (see below)
### Local development chain ### Local development chain
@ -28,15 +33,30 @@ chain. Using the ganache simulator no full Ethereum node is required.
We use the default aragon-cli devchain command to confgure and run a local We use the default aragon-cli devchain command to confgure and run a local
development ganache. development ganache.
`npm run devchain` (or `aragon devchain --port 7545) $ npm run devchain (or aragon devchain --port 7545)
To clear/reset the chain use: To clear/reset the chain use:
`npm run devchain -- --reset` (or `aragon devchain --port 7545 --reset`) $ npm run devchain -- --reset (or aragon devchain --port 7545 --reset)
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.
### Bootstrap
1. Run an Ethereum node and ipfs
$ npm run devchain
$ ipfs daemon
2. Deploy each app to the devchain
$ npm run deploy:apps
3. Deploy a new DAO with the latest app versions
$ npm run deploy:dao
## Contract Deployment ## Contract Deployment
@ -47,12 +67,11 @@ on the Kredits DAO independently.
![](docs/kredits-diagram.png) ![](docs/kredits-diagram.png)
A DAO can be deployed using the `scripts/deploy-kit.js` script or with the A DAO can be deployed using the `scripts/deploy-kit.js` script or with the
`npm run deploy:dao:dev` command. This deploys a new Kredits DAO, installs `npm run deploy:dao` command. This deploys a new Kredits DAO, installs
the latest app versions and sets the required permissions. the latest app versions and sets the required permissions.
See each app in `/apps/*` for details. See each app in `/apps/*` for details.
## ACL / Permissions
## Helper scripts ## Helper scripts
@ -108,6 +127,10 @@ Run seeds defined in `config/seeds.js`.
or or
$ npm run seeds $ npm run seeds
## ACL / Permissions
## Upgradeable contracts ## Upgradeable contracts
We use aragonOS for upgradeablity of the different contracts. We use aragonOS for upgradeablity of the different contracts.

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.4; pragma solidity ^0.4.24;
contract Migrations { contract Migrations {
address public owner; address public owner;
@ -8,15 +8,15 @@ contract Migrations {
if (msg.sender == owner) _; if (msg.sender == owner) _;
} }
function Migrations() { constructor() public {
owner = msg.sender; owner = msg.sender;
} }
function setCompleted(uint completed) restricted { function setCompleted(uint completed) public restricted {
last_completed_migration = completed; last_completed_migration = completed;
} }
function upgrade(address new_address) restricted { function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address); Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration); upgraded.setCompleted(last_completed_migration);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,12 @@
{ {
"name": "app-name", "name": "kredits-contribution",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"dependencies": { "dependencies": {
"@aragon/os": "^4.1.0", "@aragon/os": "^4.1.0",
"@aragon/cli": "^5.5.0" "@aragon/cli": "^5.5.0"
}, },
"devDependencies": { "devDependencies": {},
},
"scripts": { "scripts": {
"start": "npm run start:aragon:ipfs", "start": "npm run start:aragon:ipfs",
"start:aragon:ipfs": "aragon run", "start:aragon:ipfs": "aragon run",

View File

@ -1,63 +1 @@
/** module.exports = require("../../truffle.js");
* https://github.com/aragon/aragonOS/blob/v4.0.0/truffle-config.js
*/
const homedir = require('homedir')
const path = require('path')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const DEFAULT_MNEMONIC = 'explain tackle mirror kit van hammer degree position ginger unfair soup bonus'
const defaultRPC = (network) =>
`https://${network}.infura.io`
const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)
const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}
const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}
// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)
rpc = rpc || defaultRPC(network)
if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}
return new HDWalletProviderPrivkey(keys, rpc)
}
)
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*'
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet')
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby')
}
}
}

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.4; pragma solidity ^0.4.24;
contract Migrations { contract Migrations {
address public owner; address public owner;
@ -8,15 +8,15 @@ contract Migrations {
if (msg.sender == owner) _; if (msg.sender == owner) _;
} }
function Migrations() { constructor() public {
owner = msg.sender; owner = msg.sender;
} }
function setCompleted(uint completed) restricted { function setCompleted(uint completed) public restricted {
last_completed_migration = completed; last_completed_migration = completed;
} }
function upgrade(address new_address) restricted { function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address); Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration); upgraded.setCompleted(last_completed_migration);
} }

View File

@ -1,63 +1 @@
/** module.exports = require("../../truffle.js");
* https://github.com/aragon/aragonOS/blob/v4.0.0/truffle-config.js
*/
const homedir = require('homedir')
const path = require('path')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const DEFAULT_MNEMONIC = 'explain tackle mirror kit van hammer degree position ginger unfair soup bonus'
const defaultRPC = (network) =>
`https://${network}.infura.io`
const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)
const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}
const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}
// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)
rpc = rpc || defaultRPC(network)
if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}
return new HDWalletProviderPrivkey(keys, rpc)
}
)
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*'
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet')
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby')
}
}
}

View File

@ -0,0 +1,23 @@
pragma solidity ^0.4.24;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
constructor() public {
owner = msg.sender;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,7 @@
"@aragon/os": "^4.1.0", "@aragon/os": "^4.1.0",
"@aragon/cli": "^5.5.0" "@aragon/cli": "^5.5.0"
}, },
"devDependencies": { "devDependencies": {},
},
"scripts": { "scripts": {
"start": "npm run start:aragon:ipfs", "start": "npm run start:aragon:ipfs",
"start:aragon:ipfs": "aragon run", "start:aragon:ipfs": "aragon run",

View File

@ -1,63 +1 @@
/** module.exports = require("../../truffle.js");
* https://github.com/aragon/aragonOS/blob/v4.0.0/truffle-config.js
*/
const homedir = require('homedir')
const path = require('path')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const DEFAULT_MNEMONIC = 'explain tackle mirror kit van hammer degree position ginger unfair soup bonus'
const defaultRPC = (network) =>
`https://${network}.infura.io`
const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)
const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}
const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}
// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)
rpc = rpc || defaultRPC(network)
if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}
return new HDWalletProviderPrivkey(keys, rpc)
}
)
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*'
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet')
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby')
}
}
}

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.4; pragma solidity ^0.4.24;
contract Migrations { contract Migrations {
address public owner; address public owner;
@ -8,15 +8,15 @@ contract Migrations {
if (msg.sender == owner) _; if (msg.sender == owner) _;
} }
function Migrations() { constructor() public {
owner = msg.sender; owner = msg.sender;
} }
function setCompleted(uint completed) restricted { function setCompleted(uint completed) public restricted {
last_completed_migration = completed; last_completed_migration = completed;
} }
function upgrade(address new_address) restricted { function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address); Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration); upgraded.setCompleted(last_completed_migration);
} }

View File

@ -6,8 +6,7 @@
"@aragon/os": "^4.1.0", "@aragon/os": "^4.1.0",
"@aragon/cli": "^5.5.0" "@aragon/cli": "^5.5.0"
}, },
"devDependencies": { "devDependencies": {},
},
"scripts": { "scripts": {
"start": "npm run start:aragon:ipfs", "start": "npm run start:aragon:ipfs",
"start:aragon:ipfs": "aragon run", "start:aragon:ipfs": "aragon run",

View File

@ -1,63 +1 @@
/** module.exports = require("../../truffle.js");
* https://github.com/aragon/aragonOS/blob/v4.0.0/truffle-config.js
*/
const homedir = require('homedir')
const path = require('path')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const DEFAULT_MNEMONIC = 'explain tackle mirror kit van hammer degree position ginger unfair soup bonus'
const defaultRPC = (network) =>
`https://${network}.infura.io`
const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)
const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}
const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}
// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)
rpc = rpc || defaultRPC(network)
if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}
return new HDWalletProviderPrivkey(keys, rpc)
}
)
module.exports = {
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*'
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet')
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby')
}
}
}

View File

@ -33,8 +33,8 @@
"appName": "dummy.open.aragonpm.eth", "appName": "dummy.open.aragonpm.eth",
"network": "rinkeby" "network": "rinkeby"
}, },
"rpc": { "development": {
"network": "rpc", "network": "development",
"appName": "dummy.aragonpm.eth" "appName": "dummy.aragonpm.eth"
}, },
"default": { "default": {

22
deploy-apps.sh Executable file
View File

@ -0,0 +1,22 @@
#!/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 "----"
for dir in ./apps/*/; do
set -x
cd $dir
npm install
aragon apm publish major
cd $rootDir
set +x
done
echo "Done, new versions of all apps deployed"

View File

@ -7,12 +7,14 @@
"test": "test" "test": "test"
}, },
"scripts": { "scripts": {
"build-json": "aragon contracts compile --all && node ./scripts/build-json.js", "build-json": "npm run compile-contracts && node ./scripts/build-json.js",
"repl": "truffle exec scripts/repl/js", "repl": "truffle exec scripts/repl/js",
"compile-contracts": "aragon contracts compile --all", "compile-contracts": "aragon contracts compile --all",
"bootstrap": "npm run compile-contracts && npm run deploy-dev && truffle exec scripts/seeds.js", "bootstrap": "npm run reset && truffle exec scripts/seeds.js",
"deploy-dev": "ENS=0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1 aragon contracts exec scripts/deploy-kit.js", "reset": "npm run deploy:apps && npm run deploy:dao",
"devchain": "aragon devchain", "deploy:dao": "npm run compile-contracts && ENS=0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1 aragon contracts exec scripts/deploy-kit.js",
"deploy:apps": "./deploy-apps.sh",
"devchain": "aragon devchain --port 7545",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {

View File

@ -46,14 +46,9 @@ const providerForNetwork = (network) => (
) )
module.exports = { module.exports = {
networks: { networks: {
rpc: {
host: 'localhost',
port: 8545,
network_id: '*'
},
development: { development: {
host: 'localhost', host: 'localhost',
port: 8545, port: 7545,
network_id: '*' network_id: '*'
}, },
mainnet: { mainnet: {
@ -63,6 +58,14 @@ module.exports = {
rinkeby: { rinkeby: {
network_id: 4, network_id: 4,
provider: providerForNetwork('rinkeby') provider: providerForNetwork('rinkeby')
},
kovan: {
network_id: 42,
provider: providerForNetwork('kovan')
},
goerli: {
network_id: 5,
provider: providerForNetwork('goerli')
} }
}, },
compilers: { compilers: {