From 47beac499f0b542a8e596a8b82ceb14cc82a1edf Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 18 Oct 2018 14:28:33 -0400 Subject: [PATCH] enable searching contracts --- embark-ui/src/components/Account.js | 2 +- embark-ui/src/components/Blocks.js | 2 +- embark-ui/src/components/Layout.js | 5 ++++- embark-ui/src/components/Transaction.js | 2 +- embark-ui/src/components/Transactions.js | 2 +- embark-ui/src/components/search.css | 2 +- embark-ui/src/containers/GasStationContainer.js | 2 +- embark-ui/src/sagas/searchSaga.js | 15 +++++++++++++-- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/embark-ui/src/components/Account.js b/embark-ui/src/components/Account.js index 4180d0ee..3cfed110 100644 --- a/embark-ui/src/components/Account.js +++ b/embark-ui/src/components/Account.js @@ -13,7 +13,7 @@ const Account = ({account}) => ( Account {account.address} -
+
diff --git a/embark-ui/src/components/Blocks.js b/embark-ui/src/components/Blocks.js index 093be9a8..355906c7 100644 --- a/embark-ui/src/components/Blocks.js +++ b/embark-ui/src/components/Blocks.js @@ -10,7 +10,7 @@ const Blocks = ({blocks}) => (

Blocks

{blocks.map(block => ( - + Block {block.number} diff --git a/embark-ui/src/components/Layout.js b/embark-ui/src/components/Layout.js index b47033be..fd16b21d 100644 --- a/embark-ui/src/components/Layout.js +++ b/embark-ui/src/components/Layout.js @@ -10,7 +10,6 @@ import {LIGHT_THEME, DARK_THEME} from '../constants'; import FontAwesome from 'react-fontawesome'; import { - AppAside, AppFooter, AppHeader, AppSidebar, @@ -79,6 +78,10 @@ class Layout extends React.Component { return true; } + if (nextProps.searchResult.className) { + this.props.history.push(`/embark/contracts/${nextProps.searchResult.className}/overview`); + return false; + } if (nextProps.searchResult.address) { this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`); return false; diff --git a/embark-ui/src/components/Transaction.js b/embark-ui/src/components/Transaction.js index a6505259..b7859586 100644 --- a/embark-ui/src/components/Transaction.js +++ b/embark-ui/src/components/Transaction.js @@ -14,7 +14,7 @@ const Transaction = ({transaction}) => ( Transaction {transaction.hash} -
+
{transaction.blockNumber}} /> diff --git a/embark-ui/src/components/Transactions.js b/embark-ui/src/components/Transactions.js index ce2ad3e5..030a23f0 100644 --- a/embark-ui/src/components/Transactions.js +++ b/embark-ui/src/components/Transactions.js @@ -10,7 +10,7 @@ const Transactions = ({transactions}) => (

Transactions

{transactions.map(transaction => ( - + Transaction {transaction.hash} diff --git a/embark-ui/src/components/search.css b/embark-ui/src/components/search.css index 13fc764d..c216a915 100644 --- a/embark-ui/src/components/search.css +++ b/embark-ui/src/components/search.css @@ -3,7 +3,7 @@ border-bottom-right-radius: 0; outline: none; box-shadow: none; - width: 330px; + width: 245px; border: 1px solid #c8ced3; border-right: 0; } diff --git a/embark-ui/src/containers/GasStationContainer.js b/embark-ui/src/containers/GasStationContainer.js index 4fded5d8..e195f010 100644 --- a/embark-ui/src/containers/GasStationContainer.js +++ b/embark-ui/src/containers/GasStationContainer.js @@ -19,7 +19,7 @@ class GasStationContainer extends Component { } render() { - return ( )}/>; diff --git a/embark-ui/src/sagas/searchSaga.js b/embark-ui/src/sagas/searchSaga.js index 5ba0e89f..e3c1c0df 100644 --- a/embark-ui/src/sagas/searchSaga.js +++ b/embark-ui/src/sagas/searchSaga.js @@ -1,6 +1,6 @@ import {put, select} from "redux-saga/effects"; -import {getAccounts, getBlocks, getTransactions} from "../reducers/selectors"; -import {fetchAccounts, fetchBlocks, fetchTransactions} from "./index"; +import {getAccounts, getBlocks, getTransactions, getContracts} from "../reducers/selectors"; +import {fetchAccounts, fetchBlocks, fetchTransactions, fetchContracts} from "./index"; export function *searchExplorer(entity, payload) { let result; @@ -17,6 +17,17 @@ export function *searchExplorer(entity, payload) { 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 yield fetchBlocks({limit: SEARCH_LIMIT}); const blocks = yield select(getBlocks);