mirror of https://github.com/embarklabs/embark.git
Lint
This commit is contained in:
parent
f98c9b5578
commit
6bc8a6d8c0
|
@ -4,10 +4,10 @@ import {
|
||||||
} from "tabler-react";
|
} from "tabler-react";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
|
||||||
const Account = ({account}) => (
|
const Account = ({account}) => (
|
||||||
<Page.Content title={`Account ${account.address}`}>
|
<Page.Content title={`Account ${account.address}`}>
|
||||||
<p>Hello</p>
|
<p>Balance: {account.balance}</p>
|
||||||
|
<p>Tx count: {account.transactionCount}</p>
|
||||||
</Page.Content>
|
</Page.Content>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
} from "tabler-react";
|
} from "tabler-react";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
|
||||||
const Blocks = ({blocks}) => (
|
const Blocks = ({blocks}) => (
|
||||||
<Page.Content title="Blocks">
|
<Page.Content title="Blocks">
|
||||||
<Grid.Row>
|
<Grid.Row>
|
||||||
|
|
|
@ -30,7 +30,7 @@ const Transactions = ({transactions}) => (
|
||||||
{content: transaction.blockNumber},
|
{content: transaction.blockNumber},
|
||||||
{content: transaction.from},
|
{content: transaction.from},
|
||||||
{content: transaction.to},
|
{content: transaction.to},
|
||||||
{content: transaction.to ? "Contract Call" : "Contract Creation"},
|
{content: transaction.to ? "Contract Call" : "Contract Creation"}
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ function mapStateToProps(state, props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountContainer.propTypes = {
|
AccountContainer.propTypes = {
|
||||||
router: PropTypes.object,
|
match: PropTypes.object,
|
||||||
account: PropTypes.object,
|
account: PropTypes.object,
|
||||||
fetchAccount: PropTypes.func
|
fetchAccount: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,43 +5,38 @@ import {withRouter} from 'react-router-dom';
|
||||||
|
|
||||||
import {fetchBlock} from '../actions';
|
import {fetchBlock} from '../actions';
|
||||||
import Block from '../components/Block';
|
import Block from '../components/Block';
|
||||||
|
import NoMatch from "../components/NoMatch";
|
||||||
import Transactions from '../components/Transactions';
|
import Transactions from '../components/Transactions';
|
||||||
import Loading from '../components/Loading';
|
|
||||||
|
|
||||||
class BlockContainer extends Component {
|
class BlockContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchBlock(this.props.router.match.params.blockNumber);
|
this.props.fetchBlock(this.props.match.params.blockNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {block} = this.props;
|
const {block} = this.props;
|
||||||
if (!block.data) {
|
if (!block) {
|
||||||
return <Loading />;
|
return <NoMatch />;
|
||||||
}
|
|
||||||
|
|
||||||
if (block.error) {
|
|
||||||
return (
|
|
||||||
<h1>
|
|
||||||
<i>Error API...</i>
|
|
||||||
</h1>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Block blocks={block.data} />
|
<Block blocks={block} />
|
||||||
<Transactions transactions={block.data.transactions} />
|
<Transactions transactions={block.transactions} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state, props) {
|
||||||
return {block: state.block};
|
if(state.blocks.data) {
|
||||||
|
return {block: state.blocks.data.find(block => block.number === props.match.params.blockNumber)};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockContainer.propTypes = {
|
BlockContainer.propTypes = {
|
||||||
router: PropTypes.object,
|
match: PropTypes.object,
|
||||||
block: PropTypes.object,
|
block: PropTypes.object,
|
||||||
fetchBlock: PropTypes.func
|
fetchBlock: PropTypes.func
|
||||||
};
|
};
|
||||||
|
@ -51,4 +46,4 @@ export default withRouter(connect(
|
||||||
{
|
{
|
||||||
fetchBlock
|
fetchBlock
|
||||||
}
|
}
|
||||||
))(BlockContainer);
|
)(BlockContainer));
|
||||||
|
|
|
@ -4,42 +4,37 @@ import PropTypes from 'prop-types';
|
||||||
import {withRouter} from 'react-router-dom';
|
import {withRouter} from 'react-router-dom';
|
||||||
|
|
||||||
import {fetchTransaction} from '../actions';
|
import {fetchTransaction} from '../actions';
|
||||||
|
import NoMatch from "../components/NoMatch";
|
||||||
import Transaction from '../components/Transaction';
|
import Transaction from '../components/Transaction';
|
||||||
import Loading from '../components/Loading';
|
|
||||||
|
|
||||||
class TransactionContainer extends Component {
|
class TransactionContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchTransaction(this.props.router.match.params.hash);
|
this.props.fetchTransaction(this.props.match.params.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {transaction} = this.props;
|
const {transaction} = this.props;
|
||||||
if (!transaction.data) {
|
if (!transaction) {
|
||||||
return <Loading />;
|
return <NoMatch />;
|
||||||
}
|
|
||||||
|
|
||||||
if (transaction.error) {
|
|
||||||
return (
|
|
||||||
<h1>
|
|
||||||
<i>Error API...</i>
|
|
||||||
</h1>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Transaction transactions={transaction.data} />
|
<Transaction transactions={transaction} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state, props) {
|
||||||
return {transaction: state.transaction};
|
if(state.transactions.data) {
|
||||||
|
return {transaction: state.transactions.data.find(transaction => transaction.hash === props.match.params.hash)};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionContainer.propTypes = {
|
TransactionContainer.propTypes = {
|
||||||
router: PropTypes.object,
|
match: PropTypes.object,
|
||||||
transaction: PropTypes.object,
|
transaction: PropTypes.object,
|
||||||
fetchTransaction: PropTypes.func
|
fetchTransaction: PropTypes.func
|
||||||
};
|
};
|
||||||
|
@ -49,4 +44,4 @@ export default withRouter(connect(
|
||||||
{
|
{
|
||||||
fetchTransaction
|
fetchTransaction
|
||||||
}
|
}
|
||||||
))(TransactionContainer);
|
)(TransactionContainer));
|
||||||
|
|
Loading…
Reference in New Issue