Skip to content

Commit

Permalink
Merge 41b9d5e into 2a92ce6
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazia committed May 10, 2019
2 parents 2a92ce6 + 41b9d5e commit 949d2bb
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 27 deletions.
3 changes: 2 additions & 1 deletion apps/dot-voting/app/components/VoteRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class VoteRow extends React.Component {
this.props.onSelectVote(this.props.vote.voteId)
}

handleExecuteVote = () => {
handleExecuteVote = e => {
this.props.app.executeVote(this.props.vote.voteId)
e.stopPropagation()
}
render() {
const { showMore } = this.state
Expand Down
4 changes: 2 additions & 2 deletions apps/projects/app/components/Content/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ class Settings extends React.Component {
// flatten expLevels
const expLevelsDesc = expLevels.map(l => fromUtf8(l.name))
// uint-ify EXP levels
let expLevelsMul = expLevels.map(l => toHex(l.mul * 10.0 ** 2))
let expLevelsMul = expLevels.map(l => toHex(l.mul * 100))
this.props.app.changeBountySettings(
expLevelsMul,
expLevelsDesc,
toHex(baseRate),
toHex(baseRate * 100),
toHex(bountyDeadline),
this.props.tokens[bountyCurrency].addr,
bountyAllocator
Expand Down
2 changes: 1 addition & 1 deletion apps/projects/app/components/Shared/FilterBar/FilterBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const StyledFilterBar = styled.div`
height: 40px;
align-items: center;
border-radius: 3px;
z-index: 3;
> * {
background: ${theme.contentBackground};
}
Expand All @@ -295,7 +296,6 @@ const StyledFilterBar = styled.div`
}
> :nth-last-child(2) {
flex: 1 1 auto;
z-index: 3;
}
> :last-child {
> * {
Expand Down
3 changes: 3 additions & 0 deletions apps/projects/app/store/eventTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* INITIALIZE STORE */
export const INITIALIZE_STORE = 'INITIALIZE_STORE'

/* INITIALIZE VAULT */
export const INITIALIZE_VAULT = 'INITIALIZE_VAULT'

/* GITHUB EVENTS */
export const REQUESTING_GITHUB_TOKEN = 'Requesting_GitHub_Token'
export const REQUESTED_GITHUB_TOKEN_SUCCESS = 'Requesting_GitHub_Token_Success'
Expand Down
5 changes: 5 additions & 0 deletions apps/projects/app/store/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
REQUESTED_GITHUB_TOKEN_FAILURE,
REQUESTED_GITHUB_DISCONNECT,
INITIALIZE_STORE,
INITIALIZE_VAULT,
REPO_ADDED,
REPO_REMOVED,
BOUNTY_ADDED,
Expand All @@ -21,6 +22,7 @@ import { INITIAL_STATE } from './'

import {
initializeGraphQLClient,
initializeTokens,
syncRepos,
loadReposFromQueue,
loadIssueData,
Expand All @@ -45,6 +47,9 @@ export const handleEvent = async (state, action, vaultAddress, vaultContract) =>
}
return nextState
}
case INITIALIZE_VAULT: {
return nextState = await initializeTokens(state, vaultContract)
}
case REQUESTING_GITHUB_TOKEN: {
return state
}
Expand Down
5 changes: 3 additions & 2 deletions apps/projects/app/store/helpers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const loadSettings = () => {
export const syncSettings = async state => {
try {
const settings = await loadSettings()
const { expLevels, expMultipliers } = settings
const { expLevels, expMultipliers, baseRate } = settings

const expLvls = expLevels.map(
// Float-ify exp levels
(expLevel, i) => ({ mul: expMultipliers[i] / 100.0, name: toUtf8(expLevel) })
)
const baseRateDecimal = baseRate / 100.0

state.bountySettings = { ...settings, expLvls }
state.bountySettings = { ...settings, baseRate: baseRateDecimal, expLvls }
return state
} catch (err) {
console.error('[Projects script] syncSettings settings failed:', err)
Expand Down
52 changes: 33 additions & 19 deletions apps/projects/app/store/helpers/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,20 @@ import { app } from '../app'
import tokenSymbolAbi from '../../abi/token-symbol.json'
import tokenDecimalsAbi from '../../abi/token-decimal.json'

const tokenAbi = [].concat(tokenDecimalsAbi, tokenSymbolAbi)

const loadTokenBalance = (tokenAddress, vaultContract) => {
return vaultContract.balance(tokenAddress).toPromise()
}
const ETHER_TOKEN_FAKE_ADDRESS = '0x0000000000000000000000000000000000000000'

const loadToken = async (tokenAddress, vaultContract) => {
const tokenContract = app.external(tokenAddress, tokenAbi)

const [ balance, decimals, symbol ] = await Promise.all([
loadTokenBalance(tokenAddress, vaultContract),
tokenContract.decimals().toPromise(),
tokenContract.symbol().toPromise(),
])
const tokenAbi = [].concat(tokenDecimalsAbi, tokenSymbolAbi)

return ({
addr: tokenAddress,
symbol: symbol,
decimals: decimals,
balance: balance,
})
export const initializeTokens = async (state, vaultContract) => {
const nextState = {
...state,
tokens: [{
addr: ETHER_TOKEN_FAKE_ADDRESS,
symbol: 'ETH',
decimals: '18',
}]
}
return await syncTokens(nextState, { token: ETHER_TOKEN_FAKE_ADDRESS }, vaultContract)
}

export const syncTokens = async (state, { token }, vaultContract) => {
Expand All @@ -49,3 +42,24 @@ export const syncTokens = async (state, { token }, vaultContract) => {
return state
}
}

const loadTokenBalance = (tokenAddress, vaultContract) => {
return vaultContract.balance(tokenAddress).toPromise()
}

const loadToken = async (tokenAddress, vaultContract) => {
const tokenContract = app.external(tokenAddress, tokenAbi)

const [ balance, decimals, symbol ] = await Promise.all([
loadTokenBalance(tokenAddress, vaultContract),
tokenContract.decimals().toPromise(),
tokenContract.symbol().toPromise(),
])

return ({
addr: tokenAddress,
symbol: symbol,
decimals: decimals,
balance: balance,
})
}
3 changes: 2 additions & 1 deletion apps/projects/app/store/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { pluck } from 'rxjs/operators'

import vaultAbi from '../../../shared/json-abis/vault'
import { app, handleEvent } from './'
import { INITIALIZE_STORE } from './eventTypes'
import { INITIALIZE_STORE, INITIALIZE_VAULT } from './eventTypes'

const github = () => {
return app.rpc
Expand All @@ -31,6 +31,7 @@ export const initStore = (vaultAddress, network) => {
[
// Always initialize the store with our own home-made event
of({ event: INITIALIZE_STORE }),
of({ event: INITIALIZE_VAULT }),
github(),
// handle vault events
vaultContract.events(),
Expand Down
2 changes: 1 addition & 1 deletion apps/projects/contracts/Projects.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ contract Projects is IsContract, AragonApp {
_addExperienceLevel(500, bytes32("Advanced"));

_changeBountySettings(
1, // baseRate
100, // baseRate
336, // bountyDeadline
_defaultToken, // bountyCurrency
_bountiesAddr // bountyAllocator
Expand Down

0 comments on commit 949d2bb

Please sign in to comment.