Skip to content

Commit

Permalink
Add Solidity linguist language. Update readme. Renamed some stuff and…
Browse files Browse the repository at this point in the history
… extracted some stuff.
  • Loading branch information
willjgriff committed Apr 7, 2019
1 parent eceb418 commit af6f744
Show file tree
Hide file tree
Showing 46 changed files with 66 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
test
*/package-lock.json
livepeer/app/package-lock.json
*/package-lock.json
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
# Livepeer Delegator Aragon App
An example installation can be found here: https://rinkeby.aragon.org/#/livepeerdelegator.aragonid.eth/0x4a7335f3ecb43b685526c1b39043bf696c78c641

Livepeer Delegator Aragon app for managing Livepeer Delegation actions.

This project uses the Aragon Agent app (Agent.sol) for storing LPT and interacting with Livepeer contracts.
This project uses a modified version of the Aragon Agent app (Agent.sol) for storing LPT and interacting with Livepeer contracts.

Initial development includes functions for Livepeer interaction as a typical bonder/delegator. These include the ability to call the functions: approve, bond, claimEarnings, unbond, rebond and withdrawStake.

Further investigation may be made into creating a Livepeer Transcoder app, some discussion here: https://github.com/livepeer/research/issues/13

## Project contents
### aragon-livepeer-experiment
Initial experimental Solidity tests between the Aragon Agent.sol and the Livepeer BondingManager.sol. See the test file if interested.
#### aragon-livepeer-experiment
Initial Solidity tests to experiment with the interaction between the Aragon Agent.sol and the Livepeer BondingManager.sol. See the test file if interested.

### livepeer-protocol
The full livepeer contract deployment for testing locally. Modified to compile with the current version of Truffle v5.0.6. Includes 2 extra truffle scripts:
#### livepeer-protocol
The full livepeer contract deployment for testing locally. Modified to compile with the current version of Truffle v5.0.6. Includes extra truffle scripts:
- `initialiseFirstRound.js` for preparing the BondingManager to be bonded too after initial deployment.
- `skipRoundAndInitialise.js` for skipping a specified number of Livepeer rounds, required for speeding up the protocol for testing.
- `rewardWithLpt.js` for declaring account[0] as a transcoder, doing the necessary setup and calling reward.

### livepeer
The Livepeer Delegator Aragon app uses a modified version of Agent.sol to workaround limitations with the aragonAPI. Uses the Aragon `react-kit` template. Currently includes basic functions including approve, bond, unbond, claimEarnings, withdrawStake and transfer.
#### livepeer-delegator
The Livepeer Delegator Aragon app. It uses a modified version of Agent.sol to workaround limitations with the aragonAPI, see the `LivepeerDelegator.sol` for more info. It was also initially based on the Aragon `react-kit` template. The template code has almost entirely been replaced.

## Aragon DAO Rinkeby Installation Instructions
## Installation Instructions
### Installing to a deployed Aragon DAO

Experimental versions of the Livepeer Aragon app are available on Rinkeby through the aragonPM.
Experimental versions of the Livepeer Aragon app have been published to Rinkeby using the aragonPM.
Using the aragonCLI with access to Rinkeby through the staging environment you can install the current version of this app into an existing Aragon DAO on Rinkeby.

1. To install the aragonCLI:
```sh
npm install -g @aragon/cli
```

2. To get access to a staging environment you can download this project and `cd` into `/livepeer` then set the network endpoint and accounts as specified here: https://hack.aragon.org/docs/guides-faq#set-a-private-key.
2. To get access to a staging environment you can download this project and `cd` into `/livepeer-delegator` then set the network endpoint and accounts as specified here: https://hack.aragon.org/docs/guides-faq#set-a-private-key.


Once setup, to see info about the app, including permission roles, contract functions available and current version:
To see info about the published app:
```sh
aragon apm info livepeer.open.aragonpm.eth --environment staging
```

To install the Livepeer Aragon app into an existing Aragon DAO:
To install the Livepeer Delegator Aragon app into an existing Aragon DAO:
```sh
dao install <DAO Address> livepeer.open.aragonpm.eth --set-permissions open --environment staging --app-init-args 0x37dC71366Ec655093b9930bc816E16e6b587F968
```
Note the success of this call could be dependant on the permissions set in the DAO. Ensure the account connected can action the Manage Apps permission either directly or through a forwarder eg the Voting app. See Permissions -> Kernal in the UI to check.
Note the success of this call could be dependant on the permissions set in the DAO. Ensure the account connected can action the `Manage Apps` permission either directly or through a forwarder eg the Voting app. See Permissions -> Kernal in the UI to check.

If set without `--set-permissions open` then create a permission for the app to appear with:
If installed without `--set-permissions open` then create a permission for the app to appear in the DAO with:
```sh
dao acl create <DAO Address> <App Proxy Address> APPROVE_ROLE <Entity> <Manager> --environment staging
```
Expand All @@ -60,16 +63,16 @@ After app installation the permissions can be modified through the UI or through
- WITHDRAW_STAKE_ROLE
- TRANSFER_ROLE

Depending on your set up, they may require parameter permissions to be set to restrict access to certain functions. A preliminary script for modifying parameter permissions can be found at `/livepeer/scripts/grantPermissionWithParameters.js`
Depending on your DAO's set up and intended usage, some permissions may require parameters to be set to restrict/allow access to certain functions. A preliminary script for modifying parameter permissions can be found at `/livepeer-delegator/scripts/grantPermissionWithParameters.js`
## Local Deployment Installation Instructions
### Creating and installing to a Local Deployment
1. Install dependencies:
```
npm install -g truffle
npm install -g @aragon/cli
npm install (In /livepeer directory)
npm install (In /livepeer-delegator directory)
npm install (In /livepeer-protocol directory)
```
Expand All @@ -85,16 +88,14 @@ Depending on your set up, they may require parameter permissions to be set to re
truffle exec scripts/livepeerAragonApp/initialiseFirstRound.js
```
4. Copy the Livepeer Controller address, found during the Livepeer deployment after `truffle migrate`, to the package.json relevant script.

5. Compile with the local version of truffle, execute in the `/livepeer` directory (this is necessary as the Aragon CLI truffle config doesn't optimize compilation):
4. Compile with the local version of truffle, execute in the `/livepeer-delegator` directory (this is necessary as the Aragon CLI truffle config doesn't optimize Solidity compilation and the contract will not deploy unless optimized):
```sh
truffle compile --all
```

6. Deploy the Aragon Dao and Livepeer app, execute in the `/livepeer` directory:
5. Deploy the Aragon Dao and Livepeer app, execute in the `/livepeer-delegator` directory (find the Livepeer Controller address after the `truffle migrate` in the `livepeer-protocol` directory):
```sh
aragon run
aragon run --app-init-args <Livepeer Controller Address>
```

To test the bonded amount increases as expected after reward is executed, bond to the main account in your local chain (if using `aragon devchain` it will likely be `0xb4124cEB3451635DAcedd11767f004d8a28c6eE7`) and execute this in the `/livepeer-protocol` directory:
Expand Down
3 changes: 2 additions & 1 deletion livepeer/.gitignore → livepeer-delegator/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
build
.cache
dist
ipfs.cmd
ipfs.cmd
*/package-lock.json
File renamed without changes.
2 changes: 1 addition & 1 deletion livepeer/README.md → livepeer-delegator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ To deploy from a different account, you can:

## Licensing

Note that the [Kit contract](contracts/Kit.sol) has a special requirement on licensing because it includes contract dependencies that are licensed as `GPL-3.0-or-later`. This is the only file in your project that is required to be licensed this way, and you are free to choose a different license for the rest of the project.
Note that the [Kit contract](contracts/Template.sol) has a special requirement on licensing because it includes contract dependencies that are licensed as `GPL-3.0-or-later`. This is the only file in your project that is required to be licensed this way, and you are free to choose a different license for the rest of the project.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"devserver": "parcel serve index.html -p 8001 --out-dir ../dist/ --no-cache",
"start": "npm run sync-assets && npm run copy-icon && npm run build:script -- --no-minify && npm run devserver",
"sync-assets": "copy-aragon-ui-assets ../dist",
"copy-icon": "mkdir -p ../dist/images && cp ../images/icon.svg ../dist/images/"
"copy-icon": "mkdir -p ../dist/images && cp ../images/icon.svg ../dist/images/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function App() {

return (
<Main>
<AppContainer title="Livepeer">
<AppContainer title="Livepeer Delegator">

<BondBalanceApprovalContainer>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import '@babel/polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import {AragonApi} from '@aragon/api-react'
import {fromDecimals} from "./lib/math-utils"
import {BN} from "bn.js"
import {fromDecimals} from "./lib/math-utils";
import {BN} from "../../node_modules/bn.js/lib/bn";

const TOKEN_DECIMALS = 18;

Expand Down Expand Up @@ -50,9 +45,4 @@ const calculateTotalStake = (delegatorInfo) => {
return fromDecimals(totalStake.toString(), TOKEN_DECIMALS)
}

ReactDOM.render(
<AragonApi reducer={reducer}>
<App />
</AragonApi>,
document.getElementById('root')
)
export default reducer
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions livepeer-delegator/app/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '@babel/polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import {AragonApi} from '@aragon/api-react'
import reducer from './app-state-reducer'

ReactDOM.render(
<AragonApi reducer={reducer}>
<App />
</AragonApi>,
document.getElementById('root')
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let livepeerAppAddress = "0x0000000000000000000000000000000000000000"
//TODO: Add withdraw fees function.
//TODO: Rearrange UI, make actions appear in slide in menu.
//TODO: More disabling of buttons/error handling when functions can't be called.
//TODO: Add menu hamburger to smaller view.

const initialState = async (state) => {
return {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import "@aragon/os/contracts/common/IForwarder.sol";

import "./Vault.sol";

/**
* Modified from v1.0.1 so execute and forward are internal functions, callable by a child contract.
*/
contract Agent is IERC165, ERC1271Bytes, IForwarder, IsContract, Vault {
bytes32 public constant EXECUTE_ROLE = keccak256("EXECUTE_ROLE");
bytes32 public constant RUN_SCRIPT_ROLE = keccak256("RUN_SCRIPT_ROLE");
Expand Down Expand Up @@ -117,10 +120,8 @@ contract Agent is IERC165, ERC1271Bytes, IForwarder, IsContract, Vault {
function _forward(bytes _evmScript)
internal
{
bytes memory input = "";
// no input
address[] memory blacklist = new address[](0);
// no addr blacklist, can interact with anything
bytes memory input = ""; // no input
address[] memory blacklist = new address[](0); // no addr blacklist, can interact with anything
runScript(_evmScript, input, blacklist);
// We don't need to emit an event here as EVMScriptRunner will emit ScriptResult if successful
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import "@aragon/apps-shared-minime/contracts/MiniMeToken.sol";

import "./LivepeerDelegator.sol";

contract KitBase is APMNamehash {
contract TemplateBase is APMNamehash {
ENS public ens;
DAOFactory public fac;

event DeployInstance(address dao);
event InstalledApp(address appProxy, bytes32 appId);

function KitBase(DAOFactory _fac, ENS _ens) {
function TemplateBase(DAOFactory _fac, ENS _ens) {
ens = _ens;

// If no factory is passed, get it from on-chain bare-kit
// If no factory is passed, get it from on-chain bare-template
if (address(_fac) == address(0)) {
bytes32 bareKit = apmNamehash("bare-kit");
fac = KitBase(latestVersionAppBase(bareKit)).fac();
fac = TemplateBase(latestVersionAppBase(bareKit)).fac();
} else {
fac = _fac;
}
Expand All @@ -49,14 +49,14 @@ contract KitBase is APMNamehash {
}
}

contract Kit is KitBase {
contract Template is TemplateBase {
MiniMeTokenFactory tokenFactory;
address livepeerController;

uint64 constant PCT = 10 ** 16;
address constant ANY_ENTITY = address(-1);

function Kit(ENS ens, address _livepeerController) KitBase(DAOFactory(0), ens) {
function Template(ENS ens, address _livepeerController) TemplateBase(DAOFactory(0), ens) {
tokenFactory = new MiniMeTokenFactory();
livepeerController = _livepeerController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import "@aragon/os/contracts/common/DepositableStorage.sol";
import "@aragon/os/contracts/common/EtherTokenConstant.sol";
import "@aragon/os/contracts/lib/token/ERC20.sol";

/**
* Modified to remove deposit function (hoisted into a child contract),
* converted transfer to internal for access by child contract
* and removed the initialize function.
*/
contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");

Expand Down
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Livepeer",
"name": "Livepeer Delegator",
"description": "An application for Aragon",
"icons": [{
"src": "images/icon.svg",
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions livepeer/package.json → livepeer-delegator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"start": "npm run start:ipfs",
"start:ipfs": "aragon run",
"start:http": "aragon run --http localhost:8001 --http-served-from ./dist",
"start:ipfs:template": "npm run start:ipfs -- --template Kit --template-init @ARAGON_ENS 0xCbA25B52D863216e3Ef99AdF6ce69bcbCd6ff35C",
"start:http:template": "npm run start:http -- --template Kit --template-init @ARAGON_ENS 0xCbA25B52D863216e3Ef99AdF6ce69bcbCd6ff35C",
"start:ipfs:template": "npm run start:ipfs -- --template Template --template-init @ARAGON_ENS 0xCbA25B52D863216e3Ef99AdF6ce69bcbCd6ff35C",
"start:http:template": "npm run start:http -- --template Template --template-init @ARAGON_ENS 0xCbA25B52D863216e3Ef99AdF6ce69bcbCd6ff35C",
"prepare": "cd app && npm install && cd ..",
"start:app": "cd app && npm start && cd ..",
"test": "aragon contracts test",
Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions livepeer/app/abi/bondingManager-bond.json

This file was deleted.

23 changes: 0 additions & 23 deletions livepeer/app/abi/livepeerToken-approve.json

This file was deleted.

5 changes: 0 additions & 5 deletions livepeer/test/app.js

This file was deleted.

0 comments on commit af6f744

Please sign in to comment.