Skip to content

Commit

Permalink
Fixed rounding bug. Added livepeer icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
William Griffiths committed Apr 6, 2019
1 parent 673cfd6 commit 117a237
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
7 changes: 4 additions & 3 deletions livepeer/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
"parcel-bundler": "^1.12.0"
},
"scripts": {
"build": "npm run sync-assets && npm run build:app && npm run build:script",
"build": "npm run sync-assets && npm run copy-icon && npm run build:app && npm run build:script",
"build:app": "parcel build index.html -d ../dist/ --public-url \".\" --no-cache",
"build:script": "parcel build src/script.js --out-dir ../dist/ --no-cache",
"watch:script": "parcel watch src/script.js --out-dir ../dist/ --no-hmr",
"devserver": "parcel serve index.html -p 8001 --out-dir ../dist/ --no-cache",
"start": "npm run sync-assets && npm run build:script -- --no-minify && npm run devserver",
"sync-assets": "copy-aragon-ui-assets ../dist"
"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/"
}
}
Binary file removed livepeer/app/public/images/icon.png
Binary file not shown.
12 changes: 6 additions & 6 deletions livepeer/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ 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 {fromDecimals} from "./lib/math-utils"
import {BN} from "bn.js"

const TOKEN_DECIMALS = 18;

Expand Down Expand Up @@ -42,12 +43,11 @@ const reducer = state => {
}
}

//TODO: Fix the null check.
const calculateTotalStake = (delegatorInfo) => {
const bondedAmount = fromDecimals(delegatorInfo.bondedAmount.toString(), TOKEN_DECIMALS)
const pendingStake = fromDecimals(delegatorInfo.pendingStake ? delegatorInfo.pendingStake.toString() : "0", TOKEN_DECIMALS)

return Math.max(bondedAmount, pendingStake)
const bondedAmountBn = new BN(delegatorInfo.bondedAmount ? delegatorInfo.bondedAmount : 0)
const pendingStakeBn = new BN(delegatorInfo.pendingStake ? delegatorInfo.pendingStake : 0)
const totalStake = bondedAmountBn.gt(pendingStakeBn) ? bondedAmountBn : pendingStakeBn
return fromDecimals(totalStake.toString(), TOKEN_DECIMALS)
}

ReactDOM.render(
Expand Down
2 changes: 1 addition & 1 deletion livepeer/config-addresses.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// JUST FOR INFORMATIONAL USE, REQUIRES COPYING INTO package.json
// JUST FOR INFORMATIONAL USE, REQUIRES COPYING INTO package.json OR PASSED TO INITIALIZE FUNCTION

LOCAL_CONTROLLER_ADDRESS = "0xC380044d93C1ee5dCbb57ACA6e933280Ba8C7ABe"

Expand Down
17 changes: 17 additions & 0 deletions livepeer/images/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions livepeer/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "Livepeer",
"description": "An application for Aragon",
"icons": [{
"src": "/dist/images/icon.png",
"sizes": "22x22"
"src": "images/icon.svg",
"sizes": "192x192"
}],
"start_url": "/dist/index.html",
"script": "/dist/script.js"
Expand Down
5 changes: 3 additions & 2 deletions livepeer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@aragon/apps-vault": "^4.0.0",
"@aragon/apps-voting": "2.0.0",
"@aragon/os": "^4.0.1",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.6",
"ethereumjs-util": "^6.1.0",
"solidity-bytes-utils": "0.0.6"
Expand All @@ -20,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",
"start:http:template": "npm run start:http -- --template Kit --template-init @ARAGON_ENS 0xC380044d93C1ee5dCbb57ACA6e933280Ba8C7ABe",
"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",
"prepare": "cd app && npm install && cd ..",
"start:app": "cd app && npm start && cd ..",
"test": "aragon contracts test",
Expand Down

0 comments on commit 117a237

Please sign in to comment.