Merge branch 'master' into vb-solc_0_5_family_verification_fix

pull/3233/head
Victor Baranov 4 years ago committed by GitHub
commit 0e81afd256
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 8
      apps/block_scout_web/assets/css/components/_navbar.scss
  3. 18
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  4. 8
      apps/block_scout_web/priv/gettext/default.pot
  5. 8
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 33
      apps/explorer/lib/explorer/chain.ex

@ -6,6 +6,9 @@
### Fixes
- [#3233](https://github.com/poanetwork/blockscout/pull/3233) - Fix for the contract verifiaction for solc 0.5 family with experimental features enabled
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: unlimited number of searching results
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: allow search with space
- [#3231](https://github.com/poanetwork/blockscout/pull/3231) - Improve search: order by token holders in descending order and token/contract name is ascending order
- [#3226](https://github.com/poanetwork/blockscout/pull/3226) - Fix notifier query for live update of token transfers
- [#3220](https://github.com/poanetwork/blockscout/pull/3220) - Allow interaction with navbar menu at block-not-found page

@ -186,6 +186,14 @@ $navbar-logo-width: auto !default;
}
}
.input-group {
.awesomplete > ul {
overflow-y: auto !important;
max-height: 300px !important;
}
}
.navbar-collapse.collapsing,
.navbar-collapse.collapse.show {
display: flex;

@ -167,18 +167,32 @@
<%= awesomplete(f, :q,
[
class: "form-control me auto",
placeholder: gettext("Search by address, token symbol name, transaction hash, or block number"),
placeholder: gettext("Search by address, token symbol, name, transaction hash, or block number"),
"aria-describedby": "search-icon",
"aria-label": gettext("Search"),
"data-test": "search_input"
],
[ url: "#{chain_path(@conn, :token_autocomplete)}?q=",
limit: 0,
maxItems: 1000,
minChars: 2,
value: "contract_address_hash",
label: "contract_address_hash",
descrSearch: true,
descr: "symbol"
descr: "name",
sort: "function(x1, x2){
const tokenName1 = x1.split('<b>').length > 1 ? x1.split('<b>')[1].split('</b>')[0].toLowerCase() : ''
const tokenName2 = x2.split('<b>').length > 1 ? x2.split('<b>')[1].split('</b>')[0].toLowerCase() : ''
const holdersCount1 = x1.split('<i>').length > 1 ? parseInt(x1.split('<i>')[1].split('</i>')[0].split('holder')[0], 10) : null
const holdersCount2 = x2.split('<i>').length > 1 ? parseInt(x2.split('<i>')[1].split('</i>')[0].split('holder')[0], 10) : null
if (holdersCount1 && holdersCount2 && holdersCount1 !== holdersCount2 || (holdersCount1 && !holdersCount2) || (!holdersCount1 && holdersCount2)) {
holdersCount1 > holdersCount2
} else {
if (tokenName1 < tokenName2) { return -1 }
if (tokenName1 > tokenName2) { return 1 }
return 0
}
}"
]) %>
<div class="input-group-append">
<button class="input-group-text" id="search-icon">

@ -1244,13 +1244,12 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:172
#: lib/block_scout_web/templates/layout/_topnav.html.eex:189
#: lib/block_scout_web/templates/layout/_topnav.html.eex:203
msgid "Search"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:166
#: lib/block_scout_web/templates/layout/_topnav.html.eex:170
msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
@ -1940,3 +1939,8 @@ msgstr ""
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:15
msgid "Copy Raw Trace"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:170
msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""

@ -1244,13 +1244,12 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:172
#: lib/block_scout_web/templates/layout/_topnav.html.eex:189
#: lib/block_scout_web/templates/layout/_topnav.html.eex:203
msgid "Search"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:166
#: lib/block_scout_web/templates/layout/_topnav.html.eex:170
msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
@ -1940,3 +1939,8 @@ msgstr ""
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:15
msgid "Copy Raw Trace"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:170
msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""

@ -1034,13 +1034,27 @@ defmodule Explorer.Chain do
@spec search_token(String.t()) :: [Token.t()]
def search_token(word) do
term = String.replace(word, ~r/\W/u, "") <> ":*"
term =
word
|> String.replace(~r/ +/, " & ")
term_final = term <> ":*"
query =
from(token in Token,
where: fragment("to_tsvector('english', symbol || ' ' || name ) @@ to_tsquery(?)", ^term),
limit: 5,
select: %{contract_address_hash: token.contract_address_hash, symbol: token.symbol, name: token.name}
where: fragment("to_tsvector('english', symbol || ' ' || name ) @@ to_tsquery(?)", ^term_final),
select: %{
contract_address_hash: token.contract_address_hash,
symbol: token.symbol,
name:
fragment(
"'<b>' || coalesce(?, '') || '</b>' || ' (' || coalesce(?, '') || ') ' || '<i>' || coalesce(?::varchar(255), '') || ' holder(s)' || '</i>'",
token.name,
token.symbol,
token.holder_count
)
},
order_by: [desc: token.holder_count]
)
Repo.all(query)
@ -1048,13 +1062,16 @@ defmodule Explorer.Chain do
@spec search_contract(String.t()) :: [SmartContract.t()]
def search_contract(word) do
term = String.replace(word, ~r/\W/u, "") <> ":*"
term =
word
|> String.replace(~r/ +/, " & ")
term_final = term <> ":*"
query =
from(smart_contract in SmartContract,
where: fragment("to_tsvector('english', name ) @@ to_tsquery(?)", ^term),
limit: 5,
select: %{contract_address_hash: smart_contract.address_hash, symbol: smart_contract.name}
where: fragment("to_tsvector('english', name ) @@ to_tsquery(?)", ^term_final),
select: %{contract_address_hash: smart_contract.address_hash, name: smart_contract.name}
)
Repo.all(query)

Loading…
Cancel
Save