Build on aragonOS #62

Merged
bumi merged 51 commits from aragonos into master 2019-04-02 19:36:36 +00:00
bumi commented 2019-03-24 08:53:40 +00:00 (Migrated from github.com)

This PR builds on #55 (includes the contribution contract) and refactors the smart contracts to use aragonOS.

Sadly it got a bit of a big refactoring 🤷‍♂️ that also follows the typical directory structure for aragonOS based contracts. Those are called "apps" and organized in independent folders (which could also be independent npm packages)

Advantages

Upgradeablity

This allows use to develop and deploy each contract independently and use the aragon upgrading system to upgrade the DAO/our kredits instance that uses the app.
We don't have to develop our own upgrading proxy and keep our own registry - we can focus on our core contracts/features and less on base infrastructure.

Permission system

Aragon brings a powerful permission system that allows to evaluate the ACL on runtime and thus to more loosly couply our contracts.
For example to only allow contributors to vote: The proposal contract does no longer need to know about contributors it simply defines a permission and role. The permission is then configured in the ACL and can later be easly updated without the requirement to change the contract.

Contracts / Apps

apps/contribution

manages contributions. currently allows to add and claim contributions.
missing: veto of contributions

apps/contributors

manages all contributor profiles

apps/proposals

allows to add and vote on proposals that issue contribtions.

apps/token

the actual ERC20 kredits token.
issued by claiming contributions

Usage of the kredits-contracts wrapper

The usage of the wrapper does not change. It slightly got updated to use the aragon DAO system instead of our own registry.

About AragonOS

It is important to mention that using aragon tools does NOT mean we run within the aragon app/network! So far we only use the tools provided by aragonOS. These are mainly the permission system and the upgradeability of contracts.
We can allow our contracts/apps to be used with other aragon "apps" or even within the aragon UI, but that is not planned right now.

closes #57
closed #52

This PR builds on #55 (includes the contribution contract) and refactors the smart contracts to use aragonOS. Sadly it got a bit of a big refactoring :man_shrugging: that also follows the typical directory structure for aragonOS based contracts. Those are called "apps" and organized in independent folders (which could also be independent npm packages) ## Advantages ### Upgradeablity This allows use to develop and deploy each contract independently and use the aragon upgrading system to upgrade the DAO/our kredits instance that uses the app. We don't have to develop our own upgrading proxy and keep our own registry - we can focus on our core contracts/features and less on base infrastructure. ### Permission system Aragon brings a powerful permission system that allows to evaluate the ACL on runtime and thus to more loosly couply our contracts. For example to only allow contributors to vote: The proposal contract does no longer need to know about contributors it simply defines a permission and role. The permission is then configured in the ACL and can later be easly updated without the requirement to change the contract. ## Contracts / Apps ### `apps/contribution` manages contributions. currently allows to add and claim contributions. missing: veto of contributions ### `apps/contributors` manages all contributor profiles ### `apps/proposals` allows to add and vote on proposals that issue contribtions. ### `apps/token` the actual ERC20 kredits token. issued by claiming contributions ## Usage of the kredits-contracts wrapper The usage of the wrapper does not change. It slightly got updated to use the aragon DAO system instead of our own registry. ## About AragonOS It is important to mention that using aragon tools does NOT mean we run within the aragon app/network! So far we only use the tools provided by aragonOS. These are mainly the permission system and the upgradeability of contracts. We can allow our contracts/apps to be used with other aragon "apps" or even within the aragon UI, but that is not planned right now. ### Links: * https://hack.aragon.org/docs/aragonos-intro.html * https://wiki.kosmos.org/Aragon closes #57 closed #52
fsmanuel (Migrated from github.com) reviewed 2019-03-24 15:01:02 +00:00
fsmanuel (Migrated from github.com) left a comment

That looks pretty awesome to me!

I think we don't need that capitalize helper anymore and we should be consistent with the add methods on the contracts. We sometimes have addContributor, addContribution and sometimes just add...

That looks pretty awesome to me! I think we don't need that `capitalize` helper anymore and we should be consistent with the `add` methods on the contracts. We sometimes have `addContributor`, `addContribution` and sometimes just `add`...
@ -47,1 +57,4 @@
);
});
});
return RSVP.all(addressPromises).then(() => { return this });
fsmanuel (Migrated from github.com) commented 2019-03-24 14:51:27 +00:00

Can be removed

Can be removed
fsmanuel (Migrated from github.com) commented 2019-03-24 14:52:48 +00:00

Do we still need it for backwards compatibility?

Do we still need it for backwards compatibility?
fsmanuel (Migrated from github.com) reviewed 2019-03-24 22:16:51 +00:00
@ -0,0 +18,4 @@
const daoFactoryAddress = arapp.environments[environment].daoFactory || process.env.DAO_FACTORY
module.exports = async function(callback) {
fsmanuel (Migrated from github.com) commented 2019-03-24 22:16:51 +00:00

Are you a javascript pro, now?

Are you a javascript pro, now?
fsmanuel (Migrated from github.com) reviewed 2019-03-24 22:23:02 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-24 22:23:01 +00:00

What about:

const KreditsKit = artifacts.require('KreditsKit')
const kreditsKitFile = 'KreditsKit.json'
// ...
let addresseFile = path.join(addressesPath, kreditsKitFile);
What about: ```js const KreditsKit = artifacts.require('KreditsKit') const kreditsKitFile = 'KreditsKit.json' // ... let addresseFile = path.join(addressesPath, kreditsKitFile); ```
fsmanuel (Migrated from github.com) reviewed 2019-03-24 22:27:22 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-24 22:27:22 +00:00

Haha, make a function to update the addresseFile.

Haha, make a function to update the `addresseFile`.
bumi (Migrated from github.com) reviewed 2019-03-26 23:41:46 +00:00
bumi (Migrated from github.com) commented 2019-03-26 23:41:45 +00:00

not sure, maybe kredits-web is still using it.
even though this PR changes a lot the API of the wrapper is still the same and I tried to minimize changes there.

not sure, maybe kredits-web is still using it. even though this PR changes a lot the API of the wrapper is still the same and I tried to minimize changes there.
bumi (Migrated from github.com) reviewed 2019-03-26 23:43:11 +00:00
@ -0,0 +18,4 @@
const daoFactoryAddress = arapp.environments[environment].daoFactory || process.env.DAO_FACTORY
module.exports = async function(callback) {
bumi (Migrated from github.com) commented 2019-03-26 23:43:10 +00:00

a pro in being desperate :)
those scripts are executed in some truffle context and debugging sometimes is a pain because truffle swallows the errors and traces... so I sometimes threw everything on it :D

a pro in being desperate :) those scripts are executed in some truffle context and debugging sometimes is a pain because truffle swallows the errors and traces... so I sometimes threw everything on it :D
bumi (Migrated from github.com) reviewed 2019-03-26 23:44:31 +00:00
bumi (Migrated from github.com) commented 2019-03-26 23:44:31 +00:00

yep, did that now finally. and added a `helpers' directory...
do you have a good name for that file/function that injects that data based on the networkId?

yep, did that now finally. and added a `helpers' directory... do you have a good name for that file/function that injects that data based on the networkId?
bumi commented 2019-03-27 00:03:06 +00:00 (Migrated from github.com)

I've deployed to rinkeby and the local devchain deployments work for me.
So would be awesome if you could test it and see if you can run it locally on your machine (see readme file)

To deploy to a testnet or mainnet it now actually also supports frame to handle keys, but there is an open PR to make this work with truffle 4 and web3 0.x which we are using.

I've deployed to rinkeby and the local devchain deployments work for me. So would be awesome if you could test it and see if you can run it locally on your machine (see readme file) To deploy to a testnet or mainnet it now actually also supports [frame](https://frame.sh/) to handle keys, but there is an open [PR](https://github.com/floating/ethereum-provider/pull/3) to make this work with truffle 4 and web3 0.x which we are using.
bumi commented 2019-03-27 00:05:24 +00:00 (Migrated from github.com)

it's been quite a lot of hacking and trial and error to get this running and I need to clean up some code, but feedback is welcome.
I feel like this is now finally a working smart contract setup to iterate on... let's see if it really works.

it's been quite a lot of hacking and trial and error to get this running and I need to clean up some code, but feedback is welcome. I feel like this is now finally a working smart contract setup to iterate on... let's see if it really works.
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:06:51 +00:00
@ -0,0 +16,4 @@
// ensure alphabetic order
enum Apps { Contribution, Contributor, Proposal, Token }
bytes32[4] public appIds;
fsmanuel (Migrated from github.com) commented 2019-03-27 11:06:51 +00:00

❤️

❤️
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:10:41 +00:00
@ -0,0 +18,4 @@
const daoFactoryAddress = arapp.environments[environment].daoFactory || process.env.DAO_FACTORY
module.exports = async function(callback) {
fsmanuel (Migrated from github.com) commented 2019-03-27 11:10:41 +00:00

Much better with a normal function!

Much better with a normal function!
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:27:22 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-27 11:27:22 +00:00

I was thinking about updateAddresses but as it also updates IDs I think fileInject works fine.

I was thinking about `updateAddresses` but as it also updates IDs I think `fileInject` works fine.
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:38:31 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-27 11:38:31 +00:00

const networkId = await getNetworkId(web3);

`const networkId = await getNetworkId(web3);`
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:39:07 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-27 11:39:07 +00:00

const networkId = await getNetworkId(web3);

`const networkId = await getNetworkId(web3);`
raucao (Migrated from github.com) reviewed 2019-03-27 11:39:55 +00:00
raucao (Migrated from github.com) commented 2019-03-27 11:39:55 +00:00

Have you tried the new suggestion feature in these comments? It's pretty useful! (And you'll be credited in the commit.)

Have you tried the new suggestion feature in these comments? It's pretty useful! (And you'll be credited in the commit.)
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:40:16 +00:00
@ -10,3 +5,1 @@
const Registry = artifacts.require('./Registry.sol');
Registry.deployed().then(async (registry) => {
const initKredits = require('./helpers/init_kredits.js');
fsmanuel (Migrated from github.com) commented 2019-03-27 11:40:16 +00:00

const networkId = await getNetworkId(web3);

`const networkId = await getNetworkId(web3);`
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:41:16 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-27 11:41:16 +00:00

const networkId = await getNetworkId(web3);

`const networkId = await getNetworkId(web3);`
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:42:06 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-27 11:42:05 +00:00

👍

👍
fsmanuel (Migrated from github.com) reviewed 2019-03-27 11:44:25 +00:00
@ -0,0 +10,4 @@
if (err) {
reject(err);
} else {
resolve(network);
fsmanuel (Migrated from github.com) commented 2019-03-27 11:44:25 +00:00

Do the address files need the networkId as a string? Otherwise I would do the parseInt here.

Do the address files need the `networkId` as a string? Otherwise I would do the `parseInt` here.
bumi (Migrated from github.com) reviewed 2019-03-27 12:26:18 +00:00
@ -0,0 +10,4 @@
if (err) {
reject(err);
} else {
resolve(network);
bumi (Migrated from github.com) commented 2019-03-27 12:26:17 +00:00

yeah... that keeps bothering me also. but I don't know... maybe we sometimes use strings maybe integers.
I think I should go through the whole code once and make sure we use strings everywhere.
but also I am nut sure what web3 or ethers.js return as network id - if that is consistent.

yeah... that keeps bothering me also. but I don't know... maybe we sometimes use strings maybe integers. I think I should go through the whole code once and make sure we use strings everywhere. but also I am nut sure what web3 or ethers.js return as network id - if that is consistent.
fsmanuel commented 2019-03-27 17:19:18 +00:00 (Migrated from github.com)

@bumi luckily we didn't implement the diff ratio factor. You would be doomed: +70,784 −2,006

@bumi luckily we didn't implement the diff ratio factor. You would be doomed: +70,784 −2,006
bumi commented 2019-03-27 19:16:19 +00:00 (Migrated from github.com)

@fsmanuel yeah, I hoped nobody (and especially you) notices it :D

@fsmanuel yeah, I hoped nobody (and especially you) notices it :D
bumi commented 2019-03-27 19:17:10 +00:00 (Migrated from github.com)

and we still should implement that... hopefully after this one is merged.. lol :D

and we still should implement that... hopefully after this one is merged.. lol :D
bumi (Migrated from github.com) reviewed 2019-03-27 21:12:17 +00:00
bumi (Migrated from github.com) commented 2019-03-27 21:12:17 +00:00

I am wondering how I can prevent that those local address details get commited.
Those "14945560" network IDs are devchain IDs.
so far I don't think it is worth to write code for that and maybe simply try to ignore commiting those changes, but if somebody has an idea...?

I am wondering how I can prevent that those local address details get commited. Those "14945560" network IDs are devchain IDs. so far I don't think it is worth to write code for that and maybe simply try to ignore commiting those changes, but if somebody has an idea...?
bumi commented 2019-03-28 10:24:12 +00:00 (Migrated from github.com)

ok, now we should soon merge it because I am adding stuff that really should not be here :/ :D

ok, now we should soon merge it because I am adding stuff that really should not be here :/ :D
fsmanuel (Migrated from github.com) reviewed 2019-03-28 17:16:51 +00:00
fsmanuel (Migrated from github.com) commented 2019-03-28 17:16:51 +00:00

Maybe a git pre commit hook would work. I have never worked with git hooks...

Maybe a git pre commit hook would work. I have never worked with git hooks...
raucao (Migrated from github.com) reviewed 2019-03-28 21:43:54 +00:00
raucao (Migrated from github.com) commented 2019-03-28 21:43:54 +00:00

Yes, I think that could be a good solution. Git hooks are pretty easy to work with actually.

Yes, I think that could be a good solution. Git hooks are pretty easy to work with actually.
bumi (Migrated from github.com) reviewed 2019-03-28 23:03:39 +00:00
bumi (Migrated from github.com) commented 2019-03-28 23:03:39 +00:00

hmm. the issue is locally you need those addresses in the file but in the repo we only need the commonly used ones.
so what would the hook do?

then it probably does not change that often...

hmm. the issue is locally you need those addresses in the file but in the repo we only need the commonly used ones. so what would the hook do? then it probably does not change that often...
bumi commented 2019-03-29 11:37:25 +00:00 (Migrated from github.com)

now frame and potentially also local nodes are supported for deployment and for the helper scripts .
using infura the helper scripts now also have a readonly mode to testnet/mainnet deploys.
e.g. truffle exec scripts/list-proposals.js --network=rinkeby will list all proposals from the rinkeby testnet.

now [frame](https://frame.sh/) and potentially also local nodes are supported for deployment and for the helper scripts . using infura the helper scripts now also have a readonly mode to testnet/mainnet deploys. e.g. `truffle exec scripts/list-proposals.js --network=rinkeby` will list all proposals from the rinkeby testnet.
fsmanuel (Migrated from github.com) reviewed 2019-03-29 14:39:10 +00:00
@ -0,0 +1,48 @@
const promptly = require('promptly');
const initKredits = require('./helpers/init_kredits.js');
fsmanuel (Migrated from github.com) commented 2019-03-29 14:39:10 +00:00

❤️

❤️
fsmanuel (Migrated from github.com) reviewed 2019-03-29 14:43:41 +00:00
@ -62,3 +79,2 @@
// TODO: rename to contributor
return this.contractFor('contributors');
return this.contractFor('Contributor');
}
fsmanuel (Migrated from github.com) commented 2019-03-29 14:43:41 +00:00

You don't need the () see get Contributors()

You don't need the `()` see `get Contributors()`
bumi (Migrated from github.com) reviewed 2019-03-29 17:15:56 +00:00
@ -62,3 +79,2 @@
// TODO: rename to contributor
return this.contractFor('contributors');
return this.contractFor('Contributor');
}
bumi (Migrated from github.com) commented 2019-03-29 17:15:55 +00:00

ah ja... thx.

ah ja... thx.
bumi (Migrated from github.com) reviewed 2019-03-29 17:16:27 +00:00
@ -0,0 +1,48 @@
const promptly = require('promptly');
const initKredits = require('./helpers/init_kredits.js');
bumi (Migrated from github.com) commented 2019-03-29 17:16:27 +00:00

is it actually init_kredits.js or initKredits.js` as file name?

is it actually `init_kredits.js` or initKredits.js` as file name?
bumi commented 2019-03-29 17:17:36 +00:00 (Migrated from github.com)

I've updated ethers.js here now... as ethers.js is also a kredits-web dependency we have to update it there.
I should really wait until we merge this PR....

I've updated ethers.js here now... as ethers.js is also a kredits-web dependency we have to update it there. I should really wait until we merge this PR....
fsmanuel (Migrated from github.com) reviewed 2019-03-30 13:32:31 +00:00
@ -0,0 +1,48 @@
const promptly = require('promptly');
const initKredits = require('./helpers/init_kredits.js');
fsmanuel (Migrated from github.com) commented 2019-03-30 13:32:30 +00:00

I think JS folks use require('./helpers/init-kredits'); You don't need the .js

I think JS folks use `require('./helpers/init-kredits');` You don't need the `.js`
fsmanuel commented 2019-03-30 14:14:59 +00:00 (Migrated from github.com)

Ship it!

Ship it!
raucao commented 2019-04-01 09:26:49 +00:00 (Migrated from github.com)

Went through the instructions and bootstrap etc. worked like a charm!

I think we should merge this asap, and then finish everything with new, smaller PRs from master.

Went through the instructions and bootstrap etc. worked like a charm! I think we should merge this asap, and then finish everything with new, smaller PRs from master.
bumi commented 2019-04-02 07:48:38 +00:00 (Migrated from github.com)

@skddc if the last changes solve the problem of the changing network id then merge it. \o/

@skddc if the last changes solve the problem of the changing network id then merge it. \o/
raucao commented 2019-04-02 19:37:37 +00:00 (Migrated from github.com)

bluesbrothers

![bluesbrothers](https://user-images.githubusercontent.com/842/55430909-8580b600-558f-11e9-9a51-d72f9da6d1e3.gif)
Sign in to join this conversation.
No description provided.