From 6bc8a6d8c00d43b388a2c1653759472fe0e6e6c0 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Mon, 6 Aug 2018 10:03:52 +0100 Subject: [PATCH] Lint --- embark-ui/src/components/Account.js | 4 +-- embark-ui/src/components/Accounts.js | 2 +- embark-ui/src/components/Blocks.js | 1 - embark-ui/src/components/Transactions.js | 2 +- embark-ui/src/containers/AccountContainer.js | 2 +- embark-ui/src/containers/BlockContainer.js | 31 ++++++++----------- .../src/containers/TransactionContainer.js | 29 +++++++---------- lib/modules/blockchain_connector/index.js | 2 +- 8 files changed, 31 insertions(+), 42 deletions(-) diff --git a/embark-ui/src/components/Account.js b/embark-ui/src/components/Account.js index 9193aeea..548df2c3 100644 --- a/embark-ui/src/components/Account.js +++ b/embark-ui/src/components/Account.js @@ -4,10 +4,10 @@ import { } from "tabler-react"; import PropTypes from 'prop-types'; - const Account = ({account}) => ( -

Hello

+

Balance: {account.balance}

+

Tx count: {account.transactionCount}

); diff --git a/embark-ui/src/components/Accounts.js b/embark-ui/src/components/Accounts.js index 348d776b..34f64e37 100644 --- a/embark-ui/src/components/Accounts.js +++ b/embark-ui/src/components/Accounts.js @@ -5,7 +5,7 @@ import { Card, Table } from "tabler-react"; -import { Link } from 'react-router-dom'; +import {Link} from 'react-router-dom'; import PropTypes from 'prop-types'; const Accounts = ({accounts}) => ( diff --git a/embark-ui/src/components/Blocks.js b/embark-ui/src/components/Blocks.js index 67329281..92981ac8 100644 --- a/embark-ui/src/components/Blocks.js +++ b/embark-ui/src/components/Blocks.js @@ -8,7 +8,6 @@ import { } from "tabler-react"; import PropTypes from 'prop-types'; - const Blocks = ({blocks}) => ( diff --git a/embark-ui/src/components/Transactions.js b/embark-ui/src/components/Transactions.js index 3d16815a..9a295d80 100644 --- a/embark-ui/src/components/Transactions.js +++ b/embark-ui/src/components/Transactions.js @@ -30,7 +30,7 @@ const Transactions = ({transactions}) => ( {content: transaction.blockNumber}, {content: transaction.from}, {content: transaction.to}, - {content: transaction.to ? "Contract Call" : "Contract Creation"}, + {content: transaction.to ? "Contract Call" : "Contract Creation"} ]); }) } diff --git a/embark-ui/src/containers/AccountContainer.js b/embark-ui/src/containers/AccountContainer.js index e187a8e6..dab3ade9 100644 --- a/embark-ui/src/containers/AccountContainer.js +++ b/embark-ui/src/containers/AccountContainer.js @@ -36,7 +36,7 @@ function mapStateToProps(state, props) { } AccountContainer.propTypes = { - router: PropTypes.object, + match: PropTypes.object, account: PropTypes.object, fetchAccount: PropTypes.func }; diff --git a/embark-ui/src/containers/BlockContainer.js b/embark-ui/src/containers/BlockContainer.js index d0c19c45..d95477f6 100644 --- a/embark-ui/src/containers/BlockContainer.js +++ b/embark-ui/src/containers/BlockContainer.js @@ -5,43 +5,38 @@ import {withRouter} from 'react-router-dom'; import {fetchBlock} from '../actions'; import Block from '../components/Block'; +import NoMatch from "../components/NoMatch"; import Transactions from '../components/Transactions'; -import Loading from '../components/Loading'; class BlockContainer extends Component { componentDidMount() { - this.props.fetchBlock(this.props.router.match.params.blockNumber); + this.props.fetchBlock(this.props.match.params.blockNumber); } render() { const {block} = this.props; - if (!block.data) { - return ; - } - - if (block.error) { - return ( -

- Error API... -

- ); + if (!block) { + return ; } return ( - - + + ); } } -function mapStateToProps(state) { - return {block: state.block}; +function mapStateToProps(state, props) { + if(state.blocks.data) { + return {block: state.blocks.data.find(block => block.number === props.match.params.blockNumber)}; + } + return null; } BlockContainer.propTypes = { - router: PropTypes.object, + match: PropTypes.object, block: PropTypes.object, fetchBlock: PropTypes.func }; @@ -51,4 +46,4 @@ export default withRouter(connect( { fetchBlock } -))(BlockContainer); +)(BlockContainer)); diff --git a/embark-ui/src/containers/TransactionContainer.js b/embark-ui/src/containers/TransactionContainer.js index dc56074e..22707b14 100644 --- a/embark-ui/src/containers/TransactionContainer.js +++ b/embark-ui/src/containers/TransactionContainer.js @@ -4,42 +4,37 @@ import PropTypes from 'prop-types'; import {withRouter} from 'react-router-dom'; import {fetchTransaction} from '../actions'; +import NoMatch from "../components/NoMatch"; import Transaction from '../components/Transaction'; -import Loading from '../components/Loading'; class TransactionContainer extends Component { componentDidMount() { - this.props.fetchTransaction(this.props.router.match.params.hash); + this.props.fetchTransaction(this.props.match.params.hash); } render() { const {transaction} = this.props; - if (!transaction.data) { - return ; - } - - if (transaction.error) { - return ( -

- Error API... -

- ); + if (!transaction) { + return ; } return ( - + ); } } -function mapStateToProps(state) { - return {transaction: state.transaction}; +function mapStateToProps(state, props) { + if(state.transactions.data) { + return {transaction: state.transactions.data.find(transaction => transaction.hash === props.match.params.hash)}; + } + return null; } TransactionContainer.propTypes = { - router: PropTypes.object, + match: PropTypes.object, transaction: PropTypes.object, fetchTransaction: PropTypes.func }; @@ -49,4 +44,4 @@ export default withRouter(connect( { fetchTransaction } -))(TransactionContainer); +)(TransactionContainer)); diff --git a/lib/modules/blockchain_connector/index.js b/lib/modules/blockchain_connector/index.js index 4e4d57c3..c1f005f9 100644 --- a/lib/modules/blockchain_connector/index.js +++ b/lib/modules/blockchain_connector/index.js @@ -400,7 +400,7 @@ class BlockchainConnector { let self = this; async.waterfall([ function(next) { - self.getAccountsWithTransactionCount((accounts) =>{ + self.getAccountsWithTransactionCount((accounts) => { let account = accounts.find((a) => a.address === address); if(!account) { next("No account found with this address");