This commit is contained in:
Anthony Laibe 2018-08-06 10:03:52 +01:00 committed by Pascal Precht
parent f98c9b5578
commit 6bc8a6d8c0
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
8 changed files with 31 additions and 42 deletions

View File

@ -4,10 +4,10 @@ import {
} from "tabler-react";
import PropTypes from 'prop-types';
const Account = ({account}) => (
<Page.Content title={`Account ${account.address}`}>
<p>Hello</p>
<p>Balance: {account.balance}</p>
<p>Tx count: {account.transactionCount}</p>
</Page.Content>
);

View File

@ -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}) => (

View File

@ -8,7 +8,6 @@ import {
} from "tabler-react";
import PropTypes from 'prop-types';
const Blocks = ({blocks}) => (
<Page.Content title="Blocks">
<Grid.Row>

View File

@ -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"}
]);
})
}

View File

@ -36,7 +36,7 @@ function mapStateToProps(state, props) {
}
AccountContainer.propTypes = {
router: PropTypes.object,
match: PropTypes.object,
account: PropTypes.object,
fetchAccount: PropTypes.func
};

View File

@ -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 <Loading />;
}
if (block.error) {
return (
<h1>
<i>Error API...</i>
</h1>
);
if (!block) {
return <NoMatch />;
}
return (
<React.Fragment>
<Block blocks={block.data} />
<Transactions transactions={block.data.transactions} />
<Block blocks={block} />
<Transactions transactions={block.transactions} />
</React.Fragment>
);
}
}
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));

View File

@ -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 <Loading />;
}
if (transaction.error) {
return (
<h1>
<i>Error API...</i>
</h1>
);
if (!transaction) {
return <NoMatch />;
}
return (
<React.Fragment>
<Transaction transactions={transaction.data} />
<Transaction transactions={transaction} />
</React.Fragment>
);
}
}
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));

View File

@ -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");