Merge branch 'master' into feature/new-theming-capabilites

* master:
  define hash len as constant in module
  update changelog
  able to search without prefix "0x"
  UPDATE CHANGELOG
  update changelog
  Clear build script
  add block count updater
  add block count to chain show view

# Conflicts:
#	apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex
#	apps/block_scout_web/priv/gettext/default.pot
#	apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
pull/1844/head
Gabriel Rodriguez Alsina 6 years ago
commit 59851dd969
  1. 3
      CHANGELOG.md
  2. 18
      apps/block_scout_web/assets/js/pages/chain.js
  3. 20
      apps/block_scout_web/lib/block_scout_web/chain.ex
  4. 4
      apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex
  5. 69
      apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex
  6. 640
      apps/block_scout_web/priv/gettext/default.pot
  7. 640
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  8. 22
      apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs
  9. 7
      rel/commands/clear_build.sh

@ -2,12 +2,15 @@
### Features
- [#1815](https://github.com/poanetwork/blockscout/pull/1815) - able to search without prefix "0x"
- [#1813](https://github.com/poanetwork/blockscout/pull/1813) - add total blocks counter to the main page
- [#1806](https://github.com/poanetwork/blockscout/pull/1806) - verify contracts with a post request
### Fixes
### Chore
- [#1814](https://github.com/poanetwork/blockscout/pull/1814) - Clear build artefacts script
## 1.3.10-beta

@ -24,7 +24,8 @@ export const initialState = {
transactionsError: false,
transactionsLoading: true,
transactionCount: null,
usdMarketCap: null
usdMarketCap: null,
blockCount: null
}
export const reducer = withMissingBlocks(baseReducer)
@ -46,11 +47,13 @@ function baseReducer (state = initialState, action) {
blocks: [
action.msg,
...state.blocks.slice(0, -1)
]
],
blockCount: action.msg.blockNumber + 1
})
} else {
return Object.assign({}, state, {
blocks: state.blocks.map((block) => block.blockNumber === action.msg.blockNumber ? action.msg : block)
blocks: state.blocks.map((block) => block.blockNumber === action.msg.blockNumber ? action.msg : block),
blockCount: action.msg.blockNumber + 1
})
}
}
@ -152,6 +155,15 @@ const elements = {
$el.empty().append(numeral(state.transactionCount).format())
}
},
'[data-selector="block-count"]': {
load ($el) {
return { blockCount: numeral($el.text()).value() }
},
render ($el, state, oldState) {
if (oldState.blockCount === state.blockCount) return
$el.empty().append(numeral(state.blockCount).format())
}
},
'[data-selector="address-count"]': {
render ($el, state, oldState) {
if (oldState.addressCount === state.addressCount) return

@ -32,6 +32,8 @@ defmodule BlockScoutWeb.Chain do
@page_size 50
@default_paging_options %PagingOptions{page_size: @page_size + 1}
@address_hash_len 40
@tx_block_hash_len 64
def default_paging_options do
@default_paging_options
@ -60,13 +62,17 @@ defmodule BlockScoutWeb.Chain do
@spec from_param(String.t()) :: {:ok, Address.t() | Block.t() | Transaction.t()} | {:error, :not_found}
def from_param(param)
def from_param("0x" <> number_string = param) do
case String.length(number_string) do
40 -> address_from_param(param)
64 -> block_or_transaction_from_param(param)
_ -> {:error, :not_found}
end
end
def from_param("0x" <> number_string = param) when byte_size(number_string) == @address_hash_len,
do: address_from_param(param)
def from_param("0x" <> number_string = param) when byte_size(number_string) == @tx_block_hash_len,
do: block_or_transaction_from_param(param)
def from_param(param) when byte_size(param) == @address_hash_len,
do: address_from_param("0x" <> param)
def from_param(param) when byte_size(param) == @tx_block_hash_len,
do: block_or_transaction_from_param("0x" <> param)
def from_param(string) when is_binary(string) do
case param_to_block_number(string) do

@ -11,6 +11,7 @@ defmodule BlockScoutWeb.ChainController do
def show(conn, _params) do
transaction_estimated_count = Chain.transaction_estimated_count()
block_count = Chain.block_count()
exchange_rate = Market.get_exchange_rate(Explorer.coin()) || Token.null()
@ -22,7 +23,8 @@ defmodule BlockScoutWeb.ChainController do
exchange_rate: exchange_rate,
chart_data_path: market_history_chart_path(conn, :show),
transaction_estimated_count: transaction_estimated_count,
transactions_path: recent_transactions_path(conn, :index)
transactions_path: recent_transactions_path(conn, :index),
block_count: block_count
)
end

@ -35,38 +35,43 @@
</div>
</div>
</div>
<!-- Stats -->
<div class="dashboard-banner-network-plain-container">
<div class='dashboard-banner-network-stats'>
<%= case @average_block_time do %>
<% {:error, :disabled} -> %>
<%= nil %>
<% average_block_time -> %>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Average block time" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="average-block-time">
<%= Timex.format_duration(average_block_time, Explorer.Counters.AverageBlockTimeDurationFormat) %>
</span>
</div>
<% end %>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Total transactions" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="transaction-count">
<%= Cldr.Number.to_string!(@transaction_estimated_count, format: "#,###") %>
</span>
</div>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Wallet addresses" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="address-count">
<%= Cldr.Number.to_string!(@address_count, format: "#,###") %>
</span>
</div>
<div class="dashboard-banner-network-stats">
<%= case @average_block_time do %>
<% {:error, :disabled} -> %>
<%= nil %>
<% average_block_time -> %>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Average block time" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="average-block-time">
<%= Timex.format_duration(average_block_time, Explorer.Counters.AverageBlockTimeDurationFormat) %>
</span>
</div>
<% end %>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Total transactions" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="transaction-count">
<%= Cldr.Number.to_string!(@transaction_estimated_count, format: "#,###") %>
</span>
</div>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Total blocks" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="block-count">
<%= Cldr.Number.to_string!(@block_count, format: "#,###") %>
</span>
</div>
<div class="dashboard-banner-network-stats-item">
<span class="dashboard-banner-network-stats-label">
<%= gettext "Wallet addresses" %>
</span>
<span class="dashboard-banner-network-stats-value" data-selector="address-count">
<%= Cldr.Number.to_string!(@address_count, format: "#,###") %>
</span>
</div>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -121,6 +121,19 @@ defmodule BlockScoutWeb.ChainControllerTest do
assert redirected_to(conn) == transaction_path(conn, :show, transaction)
end
test "finds a transaction by hash when there are not 0x prefix", %{conn: conn} do
transaction =
:transaction
|> insert()
|> with_block()
"0x" <> non_prefix_hash = to_string(transaction.hash)
conn = get(conn, "search?q=#{to_string(non_prefix_hash)}")
assert redirected_to(conn) == transaction_path(conn, :show, transaction)
end
test "finds an address by hash", %{conn: conn} do
address = insert(:address)
conn = get(conn, "search?q=#{to_string(address.hash)}")
@ -135,6 +148,15 @@ defmodule BlockScoutWeb.ChainControllerTest do
assert redirected_to(conn) == address_path(conn, :show, address)
end
test "finds an address by hash when there are not 0x prefix", %{conn: conn} do
address = insert(:address)
"0x" <> non_prefix_hash = to_string(address.hash)
conn = get(conn, "search?q=#{to_string(non_prefix_hash)}")
assert redirected_to(conn) == address_path(conn, :show, address)
end
test "redirects to 404 when it finds nothing", %{conn: conn} do
conn = get(conn, "search?q=zaphod")
assert conn.status == 404

@ -0,0 +1,7 @@
#!/bin/sh
rm -rf ./_build
rm -rf ./deps
rm -rf ./logs/dev
rm -rf ./apps/explorer/node_modules
rm -rf ./apps/block_scout_web/assets/node_modules
Loading…
Cancel
Save