Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Fetching active Tokens and showing them in Balances' Tab #73
Browse files Browse the repository at this point in the history
  • Loading branch information
apanizo committed Nov 5, 2018
1 parent 4e019af commit 24dfd80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
45 changes: 12 additions & 33 deletions src/routes/safe/component/Balances/dataFetcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import { List } from 'immutable'
import { type Token } from '~/routes/tokens/store/model/token'
import { buildOrderFieldFrom, FIXED, type SortRow } from '~/components/Table/sorting'
import { type Column } from '~/components/Table/TableHead'

Expand All @@ -14,39 +15,17 @@ type BalanceData = {

export type BalanceRow = SortRow<BalanceData>

export const getBalanceData = (): Array<BalanceRow> => [
{
[BALANCE_TABLE_ASSET_ID]: 'CVL Journalism',
[BALANCE_TABLE_BALANCE_ID]: '234 CVL',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 234,
},
{
[BALANCE_TABLE_ASSET_ID]: 'ABC Periodico',
[BALANCE_TABLE_BALANCE_ID]: '1.394 ABC',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 1.394,
},
{
[BALANCE_TABLE_ASSET_ID]: 'Ethereum',
[BALANCE_TABLE_BALANCE_ID]: '9.394 ETH',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 9.394,
[FIXED]: true,
},
{
[BALANCE_TABLE_ASSET_ID]: 'Gnosis',
[BALANCE_TABLE_BALANCE_ID]: '0.599 GNO',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 0.559,
},
{
[BALANCE_TABLE_ASSET_ID]: 'OmiseGO',
[BALANCE_TABLE_BALANCE_ID]: '39.922 OMG',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 39.922,
},
{
[BALANCE_TABLE_ASSET_ID]: 'Moe Feo',
[BALANCE_TABLE_BALANCE_ID]: '0 MOE',
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 0,
},
]
export const getBalanceData = (activeTokens: List<Token>): Array<BalanceRow> => {
const rows = activeTokens.map((token: Token) => ({
[BALANCE_TABLE_ASSET_ID]: token.get('name'),
[BALANCE_TABLE_BALANCE_ID]: `${token.get('funds')} ${token.get('symbol')}`,
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: Number(token.get('funds')),
[FIXED]: token.get('symbol') === 'ETH',
}))

return Array.from(rows)
}


export const generateColumns = () => {
const assetRow: Column = {
Expand Down
5 changes: 3 additions & 2 deletions src/routes/safe/component/Balances/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Props = {
classes: Object,
granted: boolean,
tokens: List<Token>,
activeTokens: List<Token>,
safeAddress: string,
}

Expand Down Expand Up @@ -65,7 +66,7 @@ class Balances extends React.Component<Props, State> {
hideZero, showToken, showReceive, showSend,
} = this.state
const {
classes, granted, tokens, safeAddress,
classes, granted, tokens, safeAddress, activeTokens,
} = this.props

const columns = generateColumns()
Expand All @@ -74,7 +75,7 @@ class Balances extends React.Component<Props, State> {
root: classes.root,
}

const filteredData = filterByZero(getBalanceData(), hideZero)
const filteredData = filterByZero(getBalanceData(activeTokens), hideZero)

return (
<React.Fragment>
Expand Down

0 comments on commit 24dfd80

Please sign in to comment.