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

Commit

Permalink
Fetch Tokens for Balance component #72
Browse files Browse the repository at this point in the history
  • Loading branch information
apanizo committed Oct 30, 2018
1 parent 1b1a71a commit a83c340
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/routes/safe/component/Balances/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
import * as React from 'react'
import { List } from 'immutable'
import classNames from 'classnames/bind'
import { type Token } from '~/routes/tokens/store/model/token'
import CallMade from '@material-ui/icons/CallMade'
import CallReceived from '@material-ui/icons/CallReceived'
import Button from '@material-ui/core/Button'
Expand Down Expand Up @@ -79,6 +81,7 @@ const styles = theme => ({
type Props = {
classes: Object,
granted: boolean,
tokens: List<Token>,
}

type Action = 'Token' | 'Send' | 'Receive'
Expand Down Expand Up @@ -109,7 +112,7 @@ class Balances extends React.Component<Props, State> {
const {
hideZero, showToken, showReceive, showSend,
} = this.state
const { classes, granted } = this.props
const { classes, granted, tokens } = this.props

const columns = generateColumns()
const autoColumns = columns.filter(c => !c.custom)
Expand Down Expand Up @@ -142,7 +145,7 @@ class Balances extends React.Component<Props, State> {
handleClose={this.onHide('Token')}
open={showToken}
>
<Tokens onClose={this.onHide('Token')} />
<Tokens tokens={tokens} onClose={this.onHide('Token')} />
</Modal>
</Col>
</Row>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/safe/component/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Layout extends React.Component<Props, State> {

render() {
const {
safe, provider, network, classes, granted,
safe, provider, network, classes, granted, tokens, activeTokens,
} = this.props
const { value } = this.state

Expand Down Expand Up @@ -122,7 +122,7 @@ class Layout extends React.Component<Props, State> {
</Tabs>
</Row>
<Hairline color="#c8ced4" />
{value === 0 && <Balances granted={granted} />}
{value === 0 && <Balances tokens={tokens} activeTokens={activeTokens} granted={granted} />}
</React.Fragment>
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/routes/safe/container/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const TIMEOUT = process.env.NODE_ENV === 'test' ? 1500 : 15000
class SafeView extends React.PureComponent<Props> {
componentDidMount() {
this.props.fetchSafe(this.props.safeUrl)
this.props.fetchTokens(this.props.safeUrl)
this.intervalId = setInterval(() => {
const { safeUrl, fetchTokens, fetchSafe } = this.props
fetchTokens(safeUrl)
Expand All @@ -41,13 +42,14 @@ class SafeView extends React.PureComponent<Props> {

render() {
const {
safe, provider, activeTokens, granted, userAddress, network,
safe, provider, activeTokens, granted, userAddress, network, tokens,
} = this.props

return (
<Page>
<Layout
activeTokens={activeTokens}
tokens={tokens}
provider={provider}
safe={safe}
userAddress={userAddress}
Expand Down
4 changes: 3 additions & 1 deletion src/routes/safe/container/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { type Safe } from '~/routes/safe/store/model/safe'
import { type Owner } from '~/routes/safe/store/model/owner'
import { type GlobalState } from '~/store'
import { sameAddress } from '~/logic/wallets/ethAddresses'
import { activeTokensSelector } from '~/routes/tokens/store/selectors'
import { activeTokensSelector, tokenListSelector } from '~/routes/tokens/store/selectors'
import { type Token } from '~/routes/tokens/store/model/token'
import { safeParamAddressSelector } from '../store/selectors'

export type SelectorProps = {
safe: SafeSelectorProps,
provider: string,
tokens: List<Token>,
activeTokens: List<Token>,
userAddress: string,
network: string,
Expand Down Expand Up @@ -44,6 +45,7 @@ export const grantedSelector: Selector<GlobalState, RouterProps, boolean> = crea
export default createStructuredSelector({
safe: safeSelector,
provider: providerNameSelector,
tokens: tokenListSelector,
activeTokens: activeTokensSelector,
granted: grantedSelector,
userAddress: userAccountSelector,
Expand Down

0 comments on commit a83c340

Please sign in to comment.