diff --git a/embark-ui/src/components/Account.js b/embark-ui/src/components/Account.js index 9193aeea7..548df2c31 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 348d776bd..34f64e37a 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 67329281c..92981ac89 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 3d16815a9..9a295d807 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 e187a8e61..dab3ade9b 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 d0c19c45d..d95477f68 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 dc56074e5..22707b142 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 4e4d57c39..c1f005f9a 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");