enable searching contracts

This commit is contained in:
Jonathan Rainville 2018-10-18 14:28:33 -04:00 committed by Pascal Precht
parent aa742e4a6e
commit 47beac499f
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
8 changed files with 23 additions and 9 deletions

View File

@ -13,7 +13,7 @@ const Account = ({account}) => (
<CardTitleIdenticon id={account.address}>Account {account.address}</CardTitleIdenticon> <CardTitleIdenticon id={account.address}>Account {account.address}</CardTitleIdenticon>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
<dl class="row"> <dl className="row">
<Description label="Balance" value={account.balance} /> <Description label="Balance" value={account.balance} />
<Description label="Transaction count" value={account.transactionCount} /> <Description label="Transaction count" value={account.transactionCount} />
</dl> </dl>

View File

@ -10,7 +10,7 @@ const Blocks = ({blocks}) => (
<Col> <Col>
<h1>Blocks</h1> <h1>Blocks</h1>
{blocks.map(block => ( {blocks.map(block => (
<Card> <Card key={block.number}>
<CardHeader> <CardHeader>
<Link to={`/embark/explorer/blocks/${block.number}`}> <CardTitleIdenticon id={block.hash}>Block {block.number}</CardTitleIdenticon></Link> <Link to={`/embark/explorer/blocks/${block.number}`}> <CardTitleIdenticon id={block.hash}>Block {block.number}</CardTitleIdenticon></Link>
</CardHeader> </CardHeader>

View File

@ -10,7 +10,6 @@ import {LIGHT_THEME, DARK_THEME} from '../constants';
import FontAwesome from 'react-fontawesome'; import FontAwesome from 'react-fontawesome';
import { import {
AppAside,
AppFooter, AppFooter,
AppHeader, AppHeader,
AppSidebar, AppSidebar,
@ -79,6 +78,10 @@ class Layout extends React.Component {
return true; return true;
} }
if (nextProps.searchResult.className) {
this.props.history.push(`/embark/contracts/${nextProps.searchResult.className}/overview`);
return false;
}
if (nextProps.searchResult.address) { if (nextProps.searchResult.address) {
this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`); this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`);
return false; return false;

View File

@ -14,7 +14,7 @@ const Transaction = ({transaction}) => (
<CardTitleIdenticon id={transaction.hash}>Transaction {transaction.hash}</CardTitleIdenticon> <CardTitleIdenticon id={transaction.hash}>Transaction {transaction.hash}</CardTitleIdenticon>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
<dl class="row"> <dl className="row">
<Description label="Block" value={<Link to={`/embark/explorer/blocks/${transaction.blockNumber}`}>{transaction.blockNumber}</Link>} /> <Description label="Block" value={<Link to={`/embark/explorer/blocks/${transaction.blockNumber}`}>{transaction.blockNumber}</Link>} />
<Description label="From" value={transaction.from} /> <Description label="From" value={transaction.from} />
<Description label="To" value={transaction.to} /> <Description label="To" value={transaction.to} />

View File

@ -10,7 +10,7 @@ const Transactions = ({transactions}) => (
<Col> <Col>
<h1>Transactions</h1> <h1>Transactions</h1>
{transactions.map(transaction => ( {transactions.map(transaction => (
<Card> <Card key={transaction.hash}>
<CardHeader> <CardHeader>
<Link to={`/embark/explorer/transactions/${transaction.hash}`}> <Link to={`/embark/explorer/transactions/${transaction.hash}`}>
<CardTitleIdenticon id={transaction.hash}>Transaction {transaction.hash}</CardTitleIdenticon> <CardTitleIdenticon id={transaction.hash}>Transaction {transaction.hash}</CardTitleIdenticon>

View File

@ -3,7 +3,7 @@
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
outline: none; outline: none;
box-shadow: none; box-shadow: none;
width: 330px; width: 245px;
border: 1px solid #c8ced3; border: 1px solid #c8ced3;
border-right: 0; border-right: 0;
} }

View File

@ -19,7 +19,7 @@ class GasStationContainer extends Component {
} }
render() { render() {
return <DataWrapper shouldRender={this.props.gasOracleStats && Object.keys(this.props.gasOracleStats).length && this.props.lastBlock} return <DataWrapper shouldRender={Boolean(this.props.gasOracleStats && Object.keys(this.props.gasOracleStats).length && this.props.lastBlock)}
{...this.props} render={({lastBlock, gasOracleStats}) => ( {...this.props} render={({lastBlock, gasOracleStats}) => (
<GasStation gasOracleStats={gasOracleStats} lastBlock={lastBlock}/> <GasStation gasOracleStats={gasOracleStats} lastBlock={lastBlock}/>
)}/>; )}/>;

View File

@ -1,6 +1,6 @@
import {put, select} from "redux-saga/effects"; import {put, select} from "redux-saga/effects";
import {getAccounts, getBlocks, getTransactions} from "../reducers/selectors"; import {getAccounts, getBlocks, getTransactions, getContracts} from "../reducers/selectors";
import {fetchAccounts, fetchBlocks, fetchTransactions} from "./index"; import {fetchAccounts, fetchBlocks, fetchTransactions, fetchContracts} from "./index";
export function *searchExplorer(entity, payload) { export function *searchExplorer(entity, payload) {
let result; let result;
@ -17,6 +17,17 @@ export function *searchExplorer(entity, payload) {
return yield put(entity.success(result)); return yield put(entity.success(result));
} }
// Contracts
yield fetchContracts({});
const contracts = yield select(getContracts);
result = contracts.find(contract => {
return contract.address === payload.searchValue;
});
if (result) {
return yield put(entity.success(result));
}
// Blocks // Blocks
yield fetchBlocks({limit: SEARCH_LIMIT}); yield fetchBlocks({limit: SEARCH_LIMIT});
const blocks = yield select(getBlocks); const blocks = yield select(getBlocks);