From 1e4b5c25175abdc188b571600b387061cbe651dd Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Apr 2019 11:18:05 +0300 Subject: [PATCH 01/36] add pagination to addresses query --- .../lib/block_scout_web/chain.ex | 4 +++ apps/explorer/lib/explorer/chain.ex | 20 ++++++++++---- apps/explorer/test/explorer/chain_test.exs | 27 +++++++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index ebe196739c..b2fd0a188d 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -81,6 +81,10 @@ defmodule BlockScoutWeb.Chain do Map.merge(params, paging_params(List.last(list))) end + def paging_options(%{"hash" => hash, "fetched_coin_balance" => fetched_coin_balance}) do + [paging_options: %{@default_paging_options | key: {fetched_coin_balance, hash}}] + end + def paging_options(%{ "block_number" => block_number_string, "transaction_index" => transaction_index_string, diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index b45e0d13e4..e2a68ccbe9 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1121,17 +1121,21 @@ defmodule Explorer.Chain do """ @spec list_top_addresses :: [{Address.t(), non_neg_integer()}] - def list_top_addresses do - query = + def list_top_addresses(options \\ []) do + paging_options = Keyword.get(options, :paging_options, @default_paging_options) + + base_query = from(a in Address, where: a.fetched_coin_balance > ^0, order_by: [desc: a.fetched_coin_balance, asc: a.hash], preload: [:names], - select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)}, - limit: 250 + select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)} ) - Repo.all(query) + base_query + |> page_addresses(paging_options) + |> limit(^paging_options.page_size) + |> Repo.all() end @doc """ @@ -2267,6 +2271,12 @@ defmodule Explorer.Chain do end) end + defp page_addresses(query, %PagingOptions{key: nil}), do: query + + defp page_addresses(query, %PagingOptions{key: {coin_balance, hash}}) do + where(query, [address], address.fetched_coin_balance <= ^coin_balance and address.hash > ^hash) + end + defp page_blocks(query, %PagingOptions{key: nil}), do: query defp page_blocks(query, %PagingOptions{key: {block_number}}) do diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index 36edace635..a9b479c3bd 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -1415,6 +1415,33 @@ defmodule Explorer.ChainTest do |> Enum.map(fn {address, _transaction_count} -> address end) |> Enum.map(& &1.hash) end + + test "paginates addresses" do + test_hashes = + 4..0 + |> Enum.map(&Explorer.Chain.Hash.cast(Explorer.Chain.Hash.Address, &1)) + |> Enum.map(&elem(&1, 1)) + + result = + 4..1 + |> Enum.map(&insert(:address, fetched_coin_balance: &1, hash: Enum.fetch!(test_hashes, &1 - 1))) + |> Enum.map(& &1.hash) + + options = [paging_options: %PagingOptions{page_size: 1}] + + [{top_address, _}] = Chain.list_top_addresses(options) + assert top_address.hash == List.first(result) + + tail_options = [ + paging_options: %PagingOptions{key: {top_address.fetched_coin_balance.value, top_address.hash}, page_size: 3} + ] + + tail_result = tail_options |> Chain.list_top_addresses() |> Enum.map(fn {address, _} -> address.hash end) + + [_ | expected_tail] = result + + assert tail_result == expected_tail + end end describe "stream_blocks_without_rewards/2" do From 75cf4c9f271fcc424eb0684387f4e8269cd00334 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Apr 2019 13:27:59 +0300 Subject: [PATCH 02/36] add addresses pagination to view --- .../lib/block_scout_web/chain.ex | 15 ++++++++-- .../controllers/address_controller.ex | 30 +++++++++++++++++-- .../templates/address/index.html.eex | 9 +++++- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index b2fd0a188d..5903db1144 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -25,7 +25,8 @@ defmodule BlockScoutWeb.Chain do InternalTransaction, Log, TokenTransfer, - Transaction + Transaction, + Wei } alias Explorer.PagingOptions @@ -82,7 +83,13 @@ defmodule BlockScoutWeb.Chain do end def paging_options(%{"hash" => hash, "fetched_coin_balance" => fetched_coin_balance}) do - [paging_options: %{@default_paging_options | key: {fetched_coin_balance, hash}}] + with {coin_balance, ""} <- Integer.parse(fetched_coin_balance), + {:ok, address_hash} <- string_to_address_hash(hash) do + [paging_options: %{@default_paging_options | key: {%Wei{value: Decimal.new(coin_balance)}, address_hash}}] + else + _ -> + [paging_options: @default_paging_options] + end end def paging_options(%{ @@ -175,6 +182,10 @@ defmodule BlockScoutWeb.Chain do end end + defp paging_params({%Address{hash: hash, fetched_coin_balance: fetched_coin_balance}, _}) do + %{"hash" => hash, "fetched_coin_balance" => Decimal.to_string(fetched_coin_balance.value)} + end + defp paging_params({%Reward{block: %{number: number}}, _}) do %{"block_number" => number, "index" => 0} end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index a0c443aee6..730b09eb8f 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -1,16 +1,40 @@ defmodule BlockScoutWeb.AddressController do use BlockScoutWeb, :controller + import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1] + alias Explorer.{Chain, Market} alias Explorer.Chain.Address alias Explorer.ExchangeRates.Token - def index(conn, _params) do + def index(conn, params) do + addresses = + params + |> paging_options() + |> Chain.list_top_addresses() + + {addresses_page, next_page} = split_list_by_page(addresses) + + next_page_path = + case next_page_params(next_page, addresses_page, params) do + nil -> + nil + + next_page_params -> + address_path( + conn, + :index, + next_page_params + ) + end + render(conn, "index.html", - address_tx_count_pairs: Chain.list_top_addresses(), + address_tx_count_pairs: addresses_page, + page_address_count: Enum.count(addresses_page), address_count: Chain.count_addresses_with_balance_from_cache(), exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), - total_supply: Chain.total_supply() + total_supply: Chain.total_supply(), + next_page_path: next_page_path ) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index e0a10a8e65..cf4e0efb95 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -3,7 +3,9 @@

<%= gettext "Addresses" %>

- <%= gettext "Showing 250 addresses of" %> + <%= gettext "Showing " %> + <%= Cldr.Number.to_string!(@page_address_count, format: "#,###") %> + <%= gettext " addresses of" %> <%= Cldr.Number.to_string!(@address_count, format: "#,###") %> <%= gettext "total addresses with a balance" %>

@@ -15,6 +17,11 @@ total_supply: @total_supply, tx_count: tx_count, validation_count: validation_count(address) %> <% end %> + <%= if @next_page_path do %> + " class="button button-secondary button-small float-right mt-4"> + <%= gettext("Next") %> + + <% end %>
From 78036abeb58af5706d1ecbc0b495cbaa629f9d3b Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Apr 2019 13:30:47 +0300 Subject: [PATCH 03/36] add CHANGELOG entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f88ff0a14..4a03165c3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features + - [#1812](https://github.com/poanetwork/blockscout/pull/1812) - add pagination to addresses page + ### Fixes ### Chore From d5356c47841f46ad70f36fc415151dc2b6dd7c88 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Apr 2019 13:31:53 +0300 Subject: [PATCH 04/36] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 18 ++++++++++++------ .../priv/gettext/en/LC_MESSAGES/default.po | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index c4d03d82ec..d38e4fadfc 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -592,6 +592,7 @@ msgid "Newer" msgstr "" #, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:22 #: lib/block_scout_web/templates/address_token/index.html.eex:25 msgid "Next" msgstr "" @@ -755,11 +756,6 @@ msgstr "" msgid "Showing" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:6 -msgid "Showing 250 addresses of" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/views/transaction_view.ex:210 @@ -1114,7 +1110,7 @@ msgid "string" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:8 +#: lib/block_scout_web/templates/address/index.html.eex:10 msgid "total addresses with a balance" msgstr "" @@ -1744,3 +1740,13 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "ERC-721" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 26503607c4..fd1b565304 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -592,6 +592,7 @@ msgid "Newer" msgstr "" #, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:22 #: lib/block_scout_web/templates/address_token/index.html.eex:25 msgid "Next" msgstr "" @@ -755,11 +756,6 @@ msgstr "" msgid "Showing" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:6 -msgid "Showing 250 addresses of" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/views/transaction_view.ex:210 @@ -1114,7 +1110,7 @@ msgid "string" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:8 +#: lib/block_scout_web/templates/address/index.html.eex:10 msgid "total addresses with a balance" msgstr "" @@ -1744,3 +1740,13 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "ERC-721" msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" From d733a5d0f2a9eea957654ad2ceccd05b2224aec0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Apr 2019 15:13:33 +0300 Subject: [PATCH 05/36] add Back button --- .../controllers/address_controller.ex | 17 +++++++++++++++-- .../templates/address/index.html.eex | 18 ++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index 730b09eb8f..6f834034cf 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -21,10 +21,12 @@ defmodule BlockScoutWeb.AddressController do nil next_page_params -> + next_params = Map.put(next_page_params, "prev_page_path", cur_page_path(conn, params)) + address_path( conn, :index, - next_page_params + next_params ) end @@ -34,7 +36,8 @@ defmodule BlockScoutWeb.AddressController do address_count: Chain.count_addresses_with_balance_from_cache(), exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), total_supply: Chain.total_supply(), - next_page_path: next_page_path + next_page_path: next_page_path, + prev_page_path: params["prev_page_path"] ) end @@ -49,4 +52,14 @@ defmodule BlockScoutWeb.AddressController do def validation_count(%Address{} = address) do Chain.address_to_validation_count(address) end + + defp cur_page_path(conn, %{"hash" => _hash, "fetched_coin_balance" => _balance} = params) do + address_path( + conn, + :index, + params + ) + end + + defp cur_page_path(conn, _), do: address_path(conn, :index) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index cf4e0efb95..535b732f44 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -8,8 +8,19 @@ <%= gettext " addresses of" %> <%= Cldr.Number.to_string!(@address_count, format: "#,###") %> <%= gettext "total addresses with a balance" %> -

+ <%= if @next_page_path do %> + " class="button button-secondary button-small float-right mt-0 ml-1"> + <%= gettext("Next") %> + + <% end %> + <%= if @prev_page_path do %> + " class="button button-secondary button-small float-right mt-0"> + <%= gettext("Back") %> + + <% end %> +

+
<%= for {{address, tx_count}, index} <- Enum.with_index(@address_tx_count_pairs, 1) do %> <%= render "_tile.html", @@ -17,11 +28,6 @@ total_supply: @total_supply, tx_count: tx_count, validation_count: validation_count(address) %> <% end %> - <%= if @next_page_path do %> - " class="button button-secondary button-small float-right mt-4"> - <%= gettext("Next") %> - - <% end %> From e22ef81457d908ccc2ae35d4bac201e9ec19c881 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Apr 2019 15:42:43 +0300 Subject: [PATCH 06/36] add page number --- .../controllers/address_controller.ex | 20 ++++++++++++++++--- .../templates/address/index.html.eex | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index 6f834034cf..3d43ed7054 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -15,13 +15,24 @@ defmodule BlockScoutWeb.AddressController do {addresses_page, next_page} = split_list_by_page(addresses) + cur_page_number = + cond do + !params["prev_page_number"] -> 1 + params["next_page"] -> String.to_integer(params["prev_page_number"]) + 1 + params["prev_page"] -> String.to_integer(params["prev_page_number"]) - 1 + end + next_page_path = case next_page_params(next_page, addresses_page, params) do nil -> nil next_page_params -> - next_params = Map.put(next_page_params, "prev_page_path", cur_page_path(conn, params)) + next_params = + next_page_params + |> Map.put("prev_page_path", cur_page_path(conn, params)) + |> Map.put("next_page", true) + |> Map.put("prev_page_number", cur_page_number) address_path( conn, @@ -37,7 +48,8 @@ defmodule BlockScoutWeb.AddressController do exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), total_supply: Chain.total_supply(), next_page_path: next_page_path, - prev_page_path: params["prev_page_path"] + prev_page_path: params["prev_page_path"], + cur_page_number: cur_page_number ) end @@ -54,10 +66,12 @@ defmodule BlockScoutWeb.AddressController do end defp cur_page_path(conn, %{"hash" => _hash, "fetched_coin_balance" => _balance} = params) do + new_params = Map.put(params, "next_page", false) + address_path( conn, :index, - params + new_params ) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index 535b732f44..ff84c71c05 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -8,6 +8,8 @@ <%= gettext " addresses of" %> <%= Cldr.Number.to_string!(@address_count, format: "#,###") %> <%= gettext "total addresses with a balance" %> + <%= gettext " (page" %> + <%= Cldr.Number.to_string!(@cur_page_number, format: "#,###)") %> <%= if @next_page_path do %> " class="button button-secondary button-small float-right mt-0 ml-1"> From 760b94d68fb95409b515f2e194be054fe5b04f1b Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Apr 2019 15:46:10 +0300 Subject: [PATCH 07/36] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 27 ++++++++++++++++++- .../priv/gettext/en/LC_MESSAGES/default.po | 27 ++++++++++++++++++- apps/explorer/lib/explorer/chain.ex | 2 +- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 410a821df2..16d92c38bf 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -592,7 +592,7 @@ msgid "Newer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:22 +#: lib/block_scout_web/templates/address/index.html.eex:16 #: lib/block_scout_web/templates/address_token/index.html.eex:25 msgid "Next" msgstr "" @@ -1740,3 +1740,28 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "ERC-721" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:11 +msgid " (page" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:21 +msgid "Back" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/chain/show.html.eex:58 +msgid "Total blocks" +msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 547f288ae4..f8ad214ea1 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -592,7 +592,7 @@ msgid "Newer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:22 +#: lib/block_scout_web/templates/address/index.html.eex:16 #: lib/block_scout_web/templates/address_token/index.html.eex:25 msgid "Next" msgstr "" @@ -1740,3 +1740,28 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "ERC-721" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:11 +msgid " (page" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:21 +msgid "Back" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/chain/show.html.eex:58 +msgid "Total blocks" +msgstr "" diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index e2a68ccbe9..e26c229d9c 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1117,7 +1117,7 @@ defmodule Explorer.Chain do end @doc """ - Lists the top 250 `t:Explorer.Chain.Address.t/0`'s' in descending order based on coin balance. + Lists the top `t:Explorer.Chain.Address.t/0`'s' in descending order based on coin balance and address hash. """ @spec list_top_addresses :: [{Address.t(), non_neg_integer()}] From 01e79319f58abedc888ec2a7f18134ef9d798e60 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Wed, 1 May 2019 16:51:49 +0300 Subject: [PATCH 08/36] eth theme --- .../assets/css/theme/_ethereum_variables.scss | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss b/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss index 98d2da802c..7437274bf6 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss @@ -1,3 +1,50 @@ -$primary: #16465b; -$secondary: #5ab3ff; -$tertiary: #77a4c5; +// general +$primary: #153550; +$secondary: #49a2ee; +$tertiary: #4ad7a7; +$additional-font: #89cae6; + +// footer +$footer-background-color: $primary; +$footer-title-color: #fff; +$footer-text-color: #89cae6; +$footer-item-disc-color: $secondary; +.footer-logo { filter: brightness(0) invert(1); } + +// dashboard +$dashboard-line-color-price: $tertiary; // price left border + +$dashboard-banner-chart-legend-value-color: $additional-font; // chart labels + +$dashboard-stats-item-value-color: $additional-font; // stat values + +$dashboard-stats-item-border-color: $secondary; // stat border + +$dashboard-banner-gradient-start: $primary; // gradient begin + +$dashboard-banner-gradient-end: lighten($primary, 5); // gradient end + +$dashboard-banner-network-plain-container-background-color: #1c476c; // stats bg + + +// navigation +.navbar { box-shadow: 0px 0px 30px 0px rgba(21, 53, 80, 0.12); } // header shadow +$header-icon-border-color-hover: $secondary; // top border on hover +$header-icon-color-hover: $secondary; // nav icon on hover +.dropdown-item:hover, .dropdown-item:focus { background-color: $secondary !important; } // dropdown item on hover + +// buttons +$btn-line-bg: #fff; // button bg +$btn-line-color: $secondary; // button border and font color && hover bg color +$btn-copy-color: $secondary; // btn copy +$btn-qr-color: $secondary; // btn qr-code + +//links & tile +.tile a { color: $secondary !important; } // links color for badges +.tile-type-block { + border-left: 4px solid $secondary; +} // tab active bg + +// card +$card-background-1: $secondary; +$card-tab-active: $secondary; From 9b16de335686481dc5c4ac6d04e046818610b616 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Wed, 1 May 2019 16:52:38 +0300 Subject: [PATCH 09/36] eth logo --- .../assets/static/images/ethereum_logo.svg | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/apps/block_scout_web/assets/static/images/ethereum_logo.svg b/apps/block_scout_web/assets/static/images/ethereum_logo.svg index 3f47dc7fe2..b2ebb795f8 100644 --- a/apps/block_scout_web/assets/static/images/ethereum_logo.svg +++ b/apps/block_scout_web/assets/static/images/ethereum_logo.svg @@ -1,40 +1 @@ - - - - -ethereum-logo - - - - - - - - - - - - - + From 234c02d7cac627f0bb330c5d1c67cdd2176cb8be Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 09:10:33 +0300 Subject: [PATCH 10/36] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 27 +++++++++++++++- .../priv/gettext/en/LC_MESSAGES/default.po | 31 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 5b078d2ffe..92c3b244a6 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -579,7 +579,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/index.html.eex:16 -#: lib/block_scout_web/templates/address_token/index.html.eex:25 +#: lib/block_scout_web/templates/address_token/index.html.eex:22 msgid "Next" msgstr "" @@ -1730,3 +1730,28 @@ msgstr "" #: lib/block_scout_web/views/transaction_view.ex:341 msgid "Raw Trace" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:11 +msgid " (page" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:21 +msgid "Back" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/chain/show.html.eex:64 +msgid "Total blocks" +msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index a723d5b1f0..f59f67d08b 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -577,6 +577,12 @@ msgstr "" msgid "Newer" msgstr "" +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:16 +#: lib/block_scout_web/templates/address_token/index.html.eex:22 +msgid "Next" +msgstr "" + #, elixir-format #: lib/block_scout_web/templates/tokens/holder/index.html.eex:37 #: lib/block_scout_web/templates/tokens/inventory/index.html.eex:32 @@ -1724,3 +1730,28 @@ msgstr "" #: lib/block_scout_web/views/transaction_view.ex:341 msgid "Raw Trace" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:11 +msgid " (page" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:8 +msgid " addresses of" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:21 +msgid "Back" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address/index.html.eex:6 +msgid "Showing " +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/chain/show.html.eex:64 +msgid "Total blocks" +msgstr "" From 2bdab7372b2b5d1f76ad60eb9cbb971abc66cd2d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 12:15:53 +0300 Subject: [PATCH 11/36] address CR issues --- .../templates/address/index.html.eex | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index 5f45651724..fca5d5b50d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -1,6 +1,17 @@
+ <%= if @next_page_path do %> + " class="button button-secondary button-small float-right ml-1"> + <%= gettext("Next") %> + + <% end %> + <%= if @prev_page_path do %> + " class="button button-secondary button-small float-right"> + <%= gettext("Back") %> + + <% end %> +

<%= gettext "Addresses" %>

<%= gettext "Showing " %> @@ -10,26 +21,26 @@ <%= gettext "total addresses with a balance" %> <%= gettext " (page" %> <%= Cldr.Number.to_string!(@cur_page_number, format: "#,###)") %> +

+ + <%= for {{address, tx_count}, index} <- Enum.with_index(@address_tx_count_pairs, 1) do %> + <%= render "_tile.html", + address: address, index: index, exchange_rate: @exchange_rate, + total_supply: @total_supply, tx_count: tx_count, + validation_count: validation_count(address) %> + <% end %> +
<%= if @next_page_path do %> - " class="button button-secondary button-small float-right mt-0 ml-1"> + " class="button button-secondary button-small float-right mt-0 mb-0 ml-1"> <%= gettext("Next") %> <% end %> <%= if @prev_page_path do %> - " class="button button-secondary button-small float-right mt-0"> + " class="button button-secondary button-small float-right mt-0 mb-0"> <%= gettext("Back") %> <% end %> -

-
- - <%= for {{address, tx_count}, index} <- Enum.with_index(@address_tx_count_pairs, 1) do %> - <%= render "_tile.html", - address: address, index: index, exchange_rate: @exchange_rate, - total_supply: @total_supply, tx_count: tx_count, - validation_count: validation_count(address) %> - <% end %>
From 266f3f02ec59e519777035b667af8e63693bb2a9 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 12:19:37 +0300 Subject: [PATCH 12/36] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 16 ++++++++------ .../priv/gettext/en/LC_MESSAGES/default.po | 22 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 92c3b244a6..8ee6c84113 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -104,7 +104,7 @@ msgid "Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:4 +#: lib/block_scout_web/templates/address/index.html.eex:15 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59 msgid "Addresses" msgstr "" @@ -578,7 +578,8 @@ msgid "Newer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:16 +#: lib/block_scout_web/templates/address/index.html.eex:6 +#: lib/block_scout_web/templates/address/index.html.eex:36 #: lib/block_scout_web/templates/address_token/index.html.eex:22 msgid "Next" msgstr "" @@ -1074,7 +1075,7 @@ msgid "string" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:10 +#: lib/block_scout_web/templates/address/index.html.eex:21 msgid "total addresses with a balance" msgstr "" @@ -1732,22 +1733,23 @@ msgid "Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:11 +#: lib/block_scout_web/templates/address/index.html.eex:22 msgid " (page" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:8 +#: lib/block_scout_web/templates/address/index.html.eex:19 msgid " addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:21 +#: lib/block_scout_web/templates/address/index.html.eex:11 +#: lib/block_scout_web/templates/address/index.html.eex:41 msgid "Back" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:6 +#: lib/block_scout_web/templates/address/index.html.eex:17 msgid "Showing " msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index f59f67d08b..4612b16a72 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -104,7 +104,7 @@ msgid "Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:4 +#: lib/block_scout_web/templates/address/index.html.eex:15 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59 msgid "Addresses" msgstr "" @@ -577,8 +577,9 @@ msgstr "" msgid "Newer" msgstr "" -#, elixir-format, fuzzy -#: lib/block_scout_web/templates/address/index.html.eex:16 +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:6 +#: lib/block_scout_web/templates/address/index.html.eex:36 #: lib/block_scout_web/templates/address_token/index.html.eex:22 msgid "Next" msgstr "" @@ -1074,7 +1075,7 @@ msgid "string" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:10 +#: lib/block_scout_web/templates/address/index.html.eex:21 msgid "total addresses with a balance" msgstr "" @@ -1732,22 +1733,23 @@ msgid "Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:11 +#: lib/block_scout_web/templates/address/index.html.eex:22 msgid " (page" msgstr "" -#, elixir-format, fuzzy -#: lib/block_scout_web/templates/address/index.html.eex:8 +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:19 msgid " addresses of" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:21 +#: lib/block_scout_web/templates/address/index.html.eex:11 +#: lib/block_scout_web/templates/address/index.html.eex:41 msgid "Back" msgstr "" -#, elixir-format, fuzzy -#: lib/block_scout_web/templates/address/index.html.eex:6 +#, elixir-format +#: lib/block_scout_web/templates/address/index.html.eex:17 msgid "Showing " msgstr "" From eeb22049768eb92162e86427fd2f46c3295e5e1f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 14:02:01 +0300 Subject: [PATCH 13/36] remove extra new line --- .../views/address_decompiled_contract_view.ex | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex index 1418255594..bcfd2a5638 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex @@ -76,18 +76,12 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do part true -> - result = - part - |> String.split("\n") - |> Enum.reduce("", fn p, a -> - a <> new_style <> p <> "\n" - end) - - if String.ends_with?(part, "\n") do - result - else - String.slice(result, 0..-2) - end + part + |> String.split("\n") + |> Enum.reduce("", fn p, a -> + a <> new_style <> p <> "\n" + end) + |> String.slice(0..-2) end end end From fa2b21d1d9f82d64d959e82938e9c0ade5c53884 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Fri, 3 May 2019 14:11:38 +0300 Subject: [PATCH 14/36] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66676df93b..625c2485fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -195,3 +195,6 @@ - [https://github.com/poanetwork/blockscout/pull/1532](https://github.com/poanetwork/blockscout/pull/1532) - Upgrade elixir to 1.8.1 - [https://github.com/poanetwork/blockscout/pull/1553](https://github.com/poanetwork/blockscout/pull/1553) - Dockerfile: remove 1.7.1 version pin FROM bitwalker/alpine-elixir-phoenix - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert + +### Improvements +-[#1874] - add changes to ethereum theme and ethereum logo From 49615e04ef0793f2bb11289f1da1febde6e99cf5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 15:22:33 +0300 Subject: [PATCH 15/36] add custom colors to reserved words --- .../views/address_decompiled_contract_view.ex | 91 +++++++++++++++---- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex index bcfd2a5638..6964c3dede 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex @@ -2,51 +2,102 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do use BlockScoutWeb, :view @colors %{ - "\e[95m" => "136, 0, 0", + "\e[95m" => "", # red - "\e[91m" => "236, 89, 58", + "\e[91m" => "", # gray - "\e[38;5;8m" => "111, 110, 111", + "\e[38;5;8m" => "", # green - "\e[32m" => "57, 115, 0", + "\e[32m" => "", # yellowgreen - "\e[93m" => "57, 115, 0", + "\e[93m" => "", # yellow - "\e[92m" => "119, 232, 81", + "\e[92m" => "", # red - "\e[94m" => "136, 0, 0" + "\e[94m" => "" } + @reserved_words [ + "def", + "require", + "revert", + "return", + "assembly", + "memory", + "payable", + "public", + "view", + "pure", + "returns", + "internal" + ] + def highlight_decompiled_code(code) do {_, result} = @colors |> Enum.reduce(code, fn {symbol, rgb}, acc -> - String.replace(acc, symbol, "") + String.replace(acc, symbol, rgb) end) |> String.replace("\e[1m", "") |> String.replace("»", "»") |> String.replace("\e[0m", "") |> String.split(~r/\|\<\/span\>/, include_captures: true, trim: true) - |> Enum.reduce({"", []}, fn part, {style, acc} -> - new_style = - cond do - String.contains?(part, " part - part == "" -> "" - true -> style - end - - new_part = new_part(part, new_style) - - {new_style, [new_part | acc]} - end) + |> add_styles_to_every_line() result |> Enum.reduce("", fn part, acc -> part <> acc end) + |> add_styles_to_reserved_words() |> add_line_numbers() end + defp add_styles_to_every_line(lines) do + lines + |> Enum.reduce({"", []}, fn part, {style, acc} -> + new_style = + cond do + String.contains?(part, " part + part == "" -> "" + true -> style + end + + new_part = new_part(part, new_style) + + {new_style, [new_part | acc]} + end) + end + + defp add_styles_to_reserved_words(code) do + code + |> String.split("\n") + |> Enum.map(fn line -> + parts = + line + |> String.split(~r/def|require|revert|return|assembly|memory|payable|public|view|pure|returns|internal|#/, + include_captures: true + ) + + comment_position = Enum.find_index(parts, fn part -> part == "#" end) + + parts + |> Enum.with_index() + |> Enum.map(fn {el, index} -> + if (is_nil(comment_position) || comment_position > index) && el in @reserved_words do + "" <> el <> "" + else + el + end + end) + |> Enum.reduce("", fn el, acc -> + acc <> el + end) + end) + |> Enum.reduce("", fn el, acc -> + acc <> el <> "\n" + end) + end + def sort_contracts_by_version(decompiled_contracts) do decompiled_contracts |> Enum.sort_by(& &1.decompiler_version) From 05febe61586baca59522c42da246ce8fdca8c89d Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Fri, 3 May 2019 16:07:19 +0300 Subject: [PATCH 16/36] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 625c2485fd..295875742f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -197,4 +197,4 @@ - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert ### Improvements --[#1874] - add changes to ethereum theme and ethereum logo +- [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo From 5afc5319704c4dcc68c8211ea0f5b13df66028ae Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 3 May 2019 17:20:06 +0300 Subject: [PATCH 17/36] highlight reserved words --- .../views/address_decompiled_contract_view.ex | 171 +++++++++++++++--- .../address_decompiled_contract_view_test.exs | 4 +- 2 files changed, 152 insertions(+), 23 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex index 6964c3dede..f80a0ded99 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex @@ -17,13 +17,131 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do "\e[94m" => "" } - @reserved_words [ + @comment_start "#" + + @reserved_words_types [ + "var", + "bool", + "string", + "int", + "uint", + "int8", + "uint8", + "int16", + "uint16", + "int24", + "uint24", + "int32", + "uint32", + "int40", + "uint40", + "int48", + "uint48", + "int56", + "uint56", + "int64", + "uint64", + "int72", + "uint72", + "int80", + "uint80", + "int88", + "uint88", + "int96", + "uint96", + "int104", + "uint104", + "int112", + "uint112", + "int120", + "uint120", + "int128", + "uint128", + "int136", + "uint136", + "int144", + "uint144", + "int152", + "uint152", + "int160", + "uint160", + "int168", + "uint168", + "int176", + "uint176", + "int184", + "uint184", + "int192", + "uint192", + "int200", + "uint200", + "int208", + "uint208", + "int216", + "uint216", + "int224", + "uint224", + "int232", + "uint232", + "int240", + "uint240", + "int248", + "uint248", + "int256", + "uint256", + "byte", + "bytes", + "bytes1", + "bytes2", + "bytes3", + "bytes4", + "bytes5", + "bytes6", + "bytes7", + "bytes8", + "bytes9", + "bytes10", + "bytes11", + "bytes12", + "bytes13", + "bytes14", + "bytes15", + "bytes16", + "bytes17", + "bytes18", + "bytes19", + "bytes20", + "bytes21", + "bytes22", + "bytes23", + "bytes24", + "bytes25", + "bytes26", + "bytes27", + "bytes28", + "bytes29", + "bytes30", + "bytes31", + "bytes32", + "true", + "false", + "enum", + "struct", + "mapping", + "address" + ] + + @reserved_words_keywords [ "def", "require", "revert", "return", "assembly", "memory", + "mem" + ] + + @modifiers [ "payable", "public", "view", @@ -32,6 +150,12 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do "internal" ] + @reserved_words @reserved_words_keywords ++ @reserved_words_types + + @reserved_words_regexp ([@comment_start | @reserved_words] ++ @modifiers) + |> Enum.reduce("", fn el, acc -> acc <> "|" <> el end) + |> Regex.compile!() + def highlight_decompiled_code(code) do {_, result} = @colors @@ -72,32 +196,37 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do code |> String.split("\n") |> Enum.map(fn line -> - parts = - line - |> String.split(~r/def|require|revert|return|assembly|memory|payable|public|view|pure|returns|internal|#/, - include_captures: true - ) - - comment_position = Enum.find_index(parts, fn part -> part == "#" end) - - parts - |> Enum.with_index() - |> Enum.map(fn {el, index} -> - if (is_nil(comment_position) || comment_position > index) && el in @reserved_words do - "" <> el <> "" - else - el - end - end) - |> Enum.reduce("", fn el, acc -> - acc <> el - end) + add_styles_to_line(line) end) |> Enum.reduce("", fn el, acc -> acc <> el <> "\n" end) end + defp add_styles_to_line(line) do + parts = + line + |> String.split(@reserved_words_regexp, + include_captures: true + ) + + comment_position = Enum.find_index(parts, fn part -> part == "#" end) + + parts + |> Enum.with_index() + |> Enum.map(fn {el, index} -> + cond do + !(is_nil(comment_position) || comment_position > index) -> el + el in @reserved_words -> "" <> el <> "" + el in @modifiers -> "" <> el <> "" + true -> el + end + end) + |> Enum.reduce("", fn el, acc -> + acc <> el + end) + end + def sort_contracts_by_version(decompiled_contracts) do decompiled_contracts |> Enum.sort_by(& &1.decompiler_version) diff --git a/apps/block_scout_web/test/block_scout_web/views/address_decompiled_contract_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/address_decompiled_contract_view_test.exs index c3ff123584..8f1636ba06 100644 --- a/apps/block_scout_web/test/block_scout_web/views/address_decompiled_contract_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/address_decompiled_contract_view_test.exs @@ -56,7 +56,7 @@ defmodule BlockScoutWeb.AddressDecompiledContractViewTest do result = AddressDecompiledContractView.highlight_decompiled_code(code) assert result == - " #\n # eveem.org 6 Feb 2019\n # Decompiled source of 0x00Bd9e214FAb74d6fC21bf1aF34261765f57e875\n #\n # Let's make the world open source\n # \n #\n # I failed with these:\n # - unknowne77c646d(?)\n # - transferFromWithData(address _from, address _to, uint256 _value, bytes _data)\n # All the rest is below.\n #\n\n\n # Storage definitions and getters\n\n def storage:\n allowance is uint256 => uint256 # mask(256, 0) at storage #2\n stor4 is uint256 => uint8 # mask(8, 0) at storage #4\n\n def allowance(address _owner, address _spender) payable: 64\n return allowance[sha3(((320 - 1) and (320 - 1) and _owner), 1), ((320 - 1) and _spender and (320 - 1))]\n\n\n #\n # Regular functions - see Tutorial for understanding quirks of the code\n #\n\n\n # folder failed in this function - may be terribly long, sorry\n def unknownc47d033b(?) payable: not cd[4]:\n revert\n else:\n mem[0]cd[4]\n mem[32] = 4\n mem[96] = bool(stor4[((320 - 1) and (320 - 1) and cd[4])])\n return bool(stor4[((320 - 1) and (320 - 1) and cd[4])])\n\n def _fallback() payable: # default function\n revert\n\n" + " #\n # eveem.org 6 Feb 2019\n # Decompiled source of 0x00Bd9e214FAb74d6fC21bf1aF34261765f57e875\n #\n # Let's make the world open source\n # \n #\n # I failed with these:\n # - unknowne77c646d(?)\n # - transferFromWithData(address _from, address _to, uint256 _value, bytes _data)\n # All the rest is below.\n #\n\n\n # Storage definitions and getters\n\n def storage:\n allowance is uint256 => uint256 # mask(256, 0) at storage #2\n stor4 is uint256 => uint8 # mask(8, 0) at storage #4\n\n def allowance(address _owner, address _spender) payable: 64\n return allowance[_owner_spender(320 - 1))]\n\n\n #\n # Regular functions - see Tutorial for understanding quirks of the code\n #\n\n\n # folder failed in this function - may be terribly long, sorry\n def unknownc47d033b(?) payable: not cd[4]:\n revert\n else:\n mem[0]cd[4]\n mem[32] = 4\n mem[96] = bool(stor4[cd[4])])\n return bool(stor4[cd[4])])\n\n def _fallback() payable: # default function\n revert\n\n\n" end test "adds style span to every line" do @@ -70,7 +70,7 @@ defmodule BlockScoutWeb.AddressDecompiledContractViewTest do """ assert AddressDecompiledContractView.highlight_decompiled_code(code) == - " #\n # eveem.org 6 Feb 2019\n # Decompiled source of 0x00Bd9e214FAb74d6fC21bf1aF34261765f57e875\n #\n # Let's make the world open source\n # \n\n" + " #\n # eveem.org 6 Feb 2019\n # Decompiled source of 0x00Bd9e214FAb74d6fC21bf1aF34261765f57e875\n #\n # Let's make the world open source\n # \n\n\n" end end From 42b56fb62ba581e1f2a4c89eb63ead3afe237e4e Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Mon, 6 May 2019 11:06:45 +0300 Subject: [PATCH 18/36] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f80c101ff..132cad2fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features +- [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo - [#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 @@ -201,5 +202,3 @@ - [https://github.com/poanetwork/blockscout/pull/1553](https://github.com/poanetwork/blockscout/pull/1553) - Dockerfile: remove 1.7.1 version pin FROM bitwalker/alpine-elixir-phoenix - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert -### Improvements -- [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo From 7dadb446bed862e8818d521ca20da89882be2817 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 6 May 2019 14:17:51 +0300 Subject: [PATCH 19/36] add CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7901172443..7e566541cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - [#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 -- [#1857](https://github.com/poanetwork/blockscout/pull/1857) - Re-implement Geth JS internal transaction tracer in Elixir +- [#1857](https://github.com/poanetwork/blockscout/pull/1857) - Re-implement Geth JS internal transaction tracer in Elixir - [#1859](https://github.com/poanetwork/blockscout/pull/1859) - feat: show raw transaction traces ### Fixes @@ -18,6 +18,7 @@ - [#1869](https://github.com/poanetwork/blockscout/pull/1869) - Fix output and gas extraction in JS tracer for Geth - [#1868](https://github.com/poanetwork/blockscout/pull/1868) - fix: logs list endpoint performance - [#1822](https://github.com/poanetwork/blockscout/pull/1822) - Fix style breaks in decompiled contract code view +- [#1885](https://github.com/poanetwork/blockscout/pull/1885) - highlight reserved words in decompiled code ### Chore From f6905d4e3355b6696891c4b61490cbde040b20e0 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Mon, 6 May 2019 14:58:44 +0300 Subject: [PATCH 20/36] Update _poa_variables.scss --- .../assets/css/theme/_poa_variables.scss | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/assets/css/theme/_poa_variables.scss b/apps/block_scout_web/assets/css/theme/_poa_variables.scss index da2fe0de74..198c89ba5a 100644 --- a/apps/block_scout_web/assets/css/theme/_poa_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_poa_variables.scss @@ -1,11 +1,50 @@ -$primary: #5b389f; -$secondary: #7dd79f; -$tertiary: #997fdc; +// general +$primary: #5c34a2; +$secondary: #87e1a9; +$tertiary: #bf9cff; +$additional-font: #fff; -$header-links-color-active: #333; -$button-secondary-color: $primary; - -$footer-background-color: $primary; +// footer +$footer-background-color: #3c226a; $footer-title-color: #fff; -$footer-text-color: #fff; +$footer-text-color: #bda6e7; $footer-item-disc-color: $secondary; +.footer-logo { filter: brightness(0) invert(1); } + +// dashboard +$dashboard-line-color-price: $tertiary; // price left border + +$dashboard-banner-chart-legend-value-color: $additional-font; // chart labels + +$dashboard-stats-item-value-color: $additional-font; // stat values + +$dashboard-stats-item-border-color: $secondary; // stat border + +$dashboard-banner-gradient-start: $primary; // gradient begin + +$dashboard-banner-gradient-end: lighten($primary, 5); // gradient end + +$dashboard-banner-network-plain-container-background-color: #865bd4; // stats bg + + +// navigation +.navbar { box-shadow: 0px 0px 30px 0px rgba(21, 53, 80, 0.12); } // header shadow +$header-icon-border-color-hover: $primary; // top border on hover +$header-icon-color-hover: $primary; // nav icon on hover +.dropdown-item:hover, .dropdown-item:focus { background-color: $primary !important; } // dropdown item on hover + +// buttons +$btn-line-bg: #fff; // button bg +$btn-line-color: $primary; // button border and font color && hover bg color +$btn-copy-color: $primary; // btn copy +$btn-qr-color: $primary; // btn qr-code + +//links & tile +.tile a { color: $primary !important; } // links color for badges +.tile-type-block { + border-left: 4px solid $primary; +} // tab active bg + +// card +$card-background-1: $primary; +$card-tab-active: $primary; From 4af728ea8dc8ba584c76cbc5de473283a7829dd5 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Mon, 6 May 2019 14:59:44 +0300 Subject: [PATCH 21/36] Update poa_logo.svg --- apps/block_scout_web/assets/static/images/poa_logo.svg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/static/images/poa_logo.svg b/apps/block_scout_web/assets/static/images/poa_logo.svg index 551871a7e1..321033174f 100644 --- a/apps/block_scout_web/assets/static/images/poa_logo.svg +++ b/apps/block_scout_web/assets/static/images/poa_logo.svg @@ -1 +1,3 @@ -poa_logo \ No newline at end of file + + + From f0cb59c26b6c1c5b0cc351494f2e2f0cdff9d9b4 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Mon, 6 May 2019 15:08:29 +0300 Subject: [PATCH 22/36] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 132cad2fa7..9bf1a98a5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Current ### Features - +- [#1895](https://github.com/poanetwork/blockscout/pull/1874) - add changes to poa theme and poa logo - [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo - [#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 From fd64a6eb270f7cfd5de74a57cc0f81cbbb9b911c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 6 May 2019 15:38:07 +0300 Subject: [PATCH 23/36] requery tokens in top nav automplete --- .../lib/block_scout_web/templates/layout/_topnav.html.eex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 032ab22930..f7392a6b39 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -112,9 +112,8 @@ "data-test": "search_input" ], [ url: "#{chain_path(@conn, :token_autocomplete)}?q=", - prepop: true, - minChars: 3, - maxItems: 8, + limit: 0, + minChars: 2, value: "contract_address_hash", label: "contract_address_hash", descrSearch: true, From cbc701b789e498ef39ccc25ab2fcc5b6f974511e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 6 May 2019 15:40:53 +0300 Subject: [PATCH 24/36] add CHANGELOG entry --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b951086721..b7f41344db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - [#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 -- [#1857](https://github.com/poanetwork/blockscout/pull/1857) - Re-implement Geth JS internal transaction tracer in Elixir +- [#1857](https://github.com/poanetwork/blockscout/pull/1857) - Re-implement Geth JS internal transaction tracer in Elixir - [#1859](https://github.com/poanetwork/blockscout/pull/1859) - feat: show raw transaction traces ### Fixes @@ -20,6 +20,7 @@ - [#1869](https://github.com/poanetwork/blockscout/pull/1869) - Fix output and gas extraction in JS tracer for Geth - [#1868](https://github.com/poanetwork/blockscout/pull/1868) - fix: logs list endpoint performance - [#1822](https://github.com/poanetwork/blockscout/pull/1822) - Fix style breaks in decompiled contract code view +- [#1896](https://github.com/poanetwork/blockscout/pull/1896) - re-query tokens in top nav automplete ### Chore @@ -202,4 +203,3 @@ - [https://github.com/poanetwork/blockscout/pull/1532](https://github.com/poanetwork/blockscout/pull/1532) - Upgrade elixir to 1.8.1 - [https://github.com/poanetwork/blockscout/pull/1553](https://github.com/poanetwork/blockscout/pull/1553) - Dockerfile: remove 1.7.1 version pin FROM bitwalker/alpine-elixir-phoenix - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert - From e8b53ac8edc67a061bfebbeae1d8c371dfe4fa7a Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 6 May 2019 15:43:25 +0300 Subject: [PATCH 25/36] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 2 +- apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 8ee6c84113..d38ebaced2 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -714,7 +714,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:111 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:129 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:128 msgid "Search" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 4612b16a72..067af0cd66 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -714,7 +714,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:111 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:129 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:128 msgid "Search" msgstr "" From 2e0bab6cab343a4b2250a7b0c56447640be71deb Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Thu, 2 May 2019 13:48:05 -0400 Subject: [PATCH 26/36] fix: store solc versions locally for performance --- CHANGELOG.md | 1 + apps/explorer/.gitignore | 3 +- apps/explorer/lib/explorer/application.ex | 1 + .../smart_contract/solc_downloader.ex | 92 +++++++++++++++++++ .../smart_contract/solidity/code_compiler.ex | 57 +++++++----- apps/explorer/priv/compile_solc.js | 64 +++++++------ 6 files changed, 159 insertions(+), 59 deletions(-) create mode 100644 apps/explorer/lib/explorer/smart_contract/solc_downloader.ex diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb0f377f6..1460a1af7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [#1868](https://github.com/poanetwork/blockscout/pull/1868) - fix: logs list endpoint performance - [#1822](https://github.com/poanetwork/blockscout/pull/1822) - Fix style breaks in decompiled contract code view - [#1896](https://github.com/poanetwork/blockscout/pull/1896) - re-query tokens in top nav automplete +- [#1881](https://github.com/poanetwork/blockscout/pull/1881) - fix: store solc versions locally for performance ### Chore diff --git a/apps/explorer/.gitignore b/apps/explorer/.gitignore index f4cd5728cc..bf75b19355 100644 --- a/apps/explorer/.gitignore +++ b/apps/explorer/.gitignore @@ -1 +1,2 @@ -priv/.recovery \ No newline at end of file +priv/.recovery +priv/solc_compilers/ diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index 47b30cfa2b..b4f8589a57 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -26,6 +26,7 @@ defmodule Explorer.Application do Supervisor.Spec.worker(SpandexDatadog.ApiServer, [datadog_opts()]), Supervisor.child_spec({Task.Supervisor, name: Explorer.MarketTaskSupervisor}, id: Explorer.MarketTaskSupervisor), Supervisor.child_spec({Task.Supervisor, name: Explorer.TaskSupervisor}, id: Explorer.TaskSupervisor), + Explorer.SmartContract.SolcDownloader, {Registry, keys: :duplicate, name: Registry.ChainEvents, id: Registry.ChainEvents}, {Admin.Recovery, [[], [name: Admin.Recovery]]}, {TransactionCountCache, [[], []]} diff --git a/apps/explorer/lib/explorer/smart_contract/solc_downloader.ex b/apps/explorer/lib/explorer/smart_contract/solc_downloader.ex new file mode 100644 index 0000000000..1aa81d2488 --- /dev/null +++ b/apps/explorer/lib/explorer/smart_contract/solc_downloader.ex @@ -0,0 +1,92 @@ +defmodule Explorer.SmartContract.SolcDownloader do + @moduledoc """ + Checks to see if the requested solc compiler version exists, and if not it + downloads and stores the file. + """ + use GenServer + + alias Explorer.SmartContract.Solidity.CompilerVersion + + @latest_compiler_refetch_time :timer.minutes(30) + + def ensure_exists(version) do + path = file_path(version) + + if File.exists?(path) do + path + else + {:ok, compiler_versions} = CompilerVersion.fetch_versions() + + if version in compiler_versions do + GenServer.call(__MODULE__, {:ensure_exists, version}, 60_000) + else + false + end + end + end + + def start_link(_) do + GenServer.start_link(__MODULE__, [], name: __MODULE__) + end + + # sobelow_skip ["Traversal"] + @impl true + def init([]) do + File.mkdir(compiler_dir()) + + {:ok, []} + end + + # sobelow_skip ["Traversal"] + @impl true + def handle_call({:ensure_exists, version}, _from, state) do + path = file_path(version) + + if fetch?(version, path) do + temp_path = file_path("#{version}-tmp") + + contents = download(version) + + file = File.open!(temp_path, [:write, :exclusive]) + + IO.binwrite(file, contents) + + File.rename(temp_path, path) + end + + {:reply, path, state} + end + + defp fetch?("latest", path) do + case File.stat(path) do + {:error, :enoent} -> + true + + {:ok, %{mtime: mtime}} -> + last_modified = NaiveDateTime.from_erl!(mtime) + diff = Timex.diff(NaiveDateTime.utc_now(), last_modified, :milliseconds) + + diff > @latest_compiler_refetch_time + end + end + + defp fetch?(_, path) do + not File.exists?(path) + end + + defp file_path(version) do + Path.join(compiler_dir(), "#{version}.js") + end + + defp compiler_dir do + Application.app_dir(:explorer, "priv/solc_compilers/") + end + + defp download(version) do + download_path = "https://ethereum.github.io/solc-bin/bin/soljson-#{version}.js" + + download_path + |> HTTPoison.get!([], timeout: 60_000) + |> Map.get(:body) + end +end diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex index e7f6090707..72c5bae186 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex @@ -3,6 +3,8 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do Module responsible to compile the Solidity code of a given Smart Contract. """ + alias Explorer.SmartContract.SolcDownloader + @new_contract_name "New.sol" @allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"] @@ -79,31 +81,36 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do "byzantium" end - {response, _status} = - System.cmd( - "node", - [ - Application.app_dir(:explorer, "priv/compile_solc.js"), - code, - compiler_version, - optimize_value(optimize), - optimization_runs, - @new_contract_name, - external_libs_string, - checked_evm_version - ] - ) - - with {:ok, contracts} <- Jason.decode(response), - %{"abi" => abi, "evm" => %{"deployedBytecode" => %{"object" => bytecode}}} <- - get_contract_info(contracts, name) do - {:ok, %{"abi" => abi, "bytecode" => bytecode, "name" => name}} - else - {:error, %Jason.DecodeError{}} -> - {:error, :compilation} - - error -> - parse_error(error) + path = SolcDownloader.ensure_exists(compiler_version) + + if path do + {response, _status} = + System.cmd( + "node", + [ + Application.app_dir(:explorer, "priv/compile_solc.js"), + code, + compiler_version, + optimize_value(optimize), + optimization_runs, + @new_contract_name, + external_libs_string, + checked_evm_version, + path + ] + ) + + with {:ok, contracts} <- Jason.decode(response), + %{"abi" => abi, "evm" => %{"deployedBytecode" => %{"object" => bytecode}}} <- + get_contract_info(contracts, name) do + {:ok, %{"abi" => abi, "bytecode" => bytecode, "name" => name}} + else + {:error, %Jason.DecodeError{}} -> + {:error, :compilation} + + error -> + parse_error(error) + end end end diff --git a/apps/explorer/priv/compile_solc.js b/apps/explorer/priv/compile_solc.js index 7179ebda56..5aaf3f54d7 100755 --- a/apps/explorer/priv/compile_solc.js +++ b/apps/explorer/priv/compile_solc.js @@ -1,7 +1,5 @@ #!/usr/bin/env node -const solc = require('solc'); - var sourceCode = process.argv[2]; var version = process.argv[3]; var optimize = process.argv[4]; @@ -9,38 +7,38 @@ var optimizationRuns = parseInt(process.argv[5], 10); var newContractName = process.argv[6]; var externalLibraries = JSON.parse(process.argv[7]) var evmVersion = process.argv[8]; +var compilerVersionPath = process.argv[9]; + +var solc = require('solc') +var compilerSnapshot = require(compilerVersionPath); +var solc = solc.setupMethods(compilerSnapshot); -var compiled_code = solc.loadRemoteVersion(version, function (err, solcSnapshot) { - if (err) { - console.log(JSON.stringify(err.message)); - } else { - const input = { - language: 'Solidity', - sources: { - [newContractName]: { - content: sourceCode - } - }, - settings: { - evmVersion: evmVersion, - optimizer: { - enabled: optimize == '1', - runs: optimizationRuns - }, - libraries: { - [newContractName]: externalLibraries - }, - outputSelection: { - '*': { - '*': ['*'] - } - } +const input = { + language: 'Solidity', + sources: { + [newContractName]: { + content: sourceCode + } + }, + settings: { + evmVersion: evmVersion, + optimizer: { + enabled: optimize == '1', + runs: optimizationRuns + }, + libraries: { + [newContractName]: externalLibraries + }, + outputSelection: { + '*': { + '*': ['*'] } } - - const output = JSON.parse(solcSnapshot.compile(JSON.stringify(input))) - /** Older solc-bin versions don't use filename as contract key */ - const response = output.contracts[newContractName] || output.contracts[''] - console.log(JSON.stringify(response)); } -}); +} + + +const output = JSON.parse(solc.compile(JSON.stringify(input))) +/** Older solc-bin versions don't use filename as contract key */ +const response = output.contracts[newContractName] || output.contracts[''] +console.log(JSON.stringify(response)); From 98eb50cc03a5db9f76c36e89ff8e5e9242bcc497 Mon Sep 17 00:00:00 2001 From: Andrew Gross Date: Mon, 6 May 2019 16:13:31 -0600 Subject: [PATCH 27/36] add location clarification for mix phx.server command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2df24f85c..289a3d35ed 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ The [development stack page](https://github.com/poanetwork/blockscout/wiki/Devel ``` * If using Chrome, Enable `chrome://flags/#allow-insecure-localhost`. - 9. Start Phoenix Server. + 9. Run the Phoenix Server from the root directory of your application. `mix phx.server` Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. From 201158ca03ad9c4511a2eec39496bdec47267bbc Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 14:49:57 +0300 Subject: [PATCH 28/36] Rsk theme scss file --- .../assets/css/theme/_rsk_variables.scss | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 apps/block_scout_web/assets/css/theme/_rsk_variables.scss diff --git a/apps/block_scout_web/assets/css/theme/_rsk_variables.scss b/apps/block_scout_web/assets/css/theme/_rsk_variables.scss new file mode 100644 index 0000000000..c357f0f571 --- /dev/null +++ b/apps/block_scout_web/assets/css/theme/_rsk_variables.scss @@ -0,0 +1,50 @@ +// general +$primary: #101f25; +$secondary: #27ac8d; +$tertiary: #e39a54; +$additional-font: #a1ded1; + +// footer +$footer-background-color: $primary; +$footer-title-color: #fff; +$footer-text-color: $additional-font; +$footer-item-disc-color: $secondary; +.footer-logo { filter: brightness(0) invert(1); } + +// dashboard +$dashboard-line-color-price: $tertiary; // price left border + +$dashboard-banner-chart-legend-value-color: $additional-font; // chart labels + +$dashboard-stats-item-value-color: $additional-font; // stat values + +$dashboard-stats-item-border-color: $secondary; // stat border + +$dashboard-banner-gradient-start: $primary; // gradient begin + +$dashboard-banner-gradient-end: lighten($primary, 5); // gradient end + +$dashboard-banner-network-plain-container-background-color: #1a323b; // stats bg + + +// navigation +.navbar { box-shadow: 0px 0px 30px 0px rgba(21, 53, 80, 0.12); } // header shadow +$header-icon-border-color-hover: $secondary; // top border on hover +$header-icon-color-hover: $secondary; // nav icon on hover +.dropdown-item:hover, .dropdown-item:focus { background-color: $secondary !important; } // dropdown item on hover + +// buttons +$btn-line-bg: #fff; // button bg +$btn-line-color: $secondary; // button border and font color && hover bg color +$btn-copy-color: $secondary; // btn copy +$btn-qr-color: $secondary; // btn qr-code + +//links & tile +.tile a { color: $secondary !important; } // links color for badges +.tile-type-block { + border-left: 4px solid $secondary; +} // tab active bg + +// card +$card-background-1: $secondary; +$card-tab-active: $secondary; \ No newline at end of file From 7da2f26d3b020058aea5b47efa467f8791b02c4a Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 14:50:58 +0300 Subject: [PATCH 29/36] Rsk logo --- .../assets/static/images/rsk_logo.svg | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 apps/block_scout_web/assets/static/images/rsk_logo.svg diff --git a/apps/block_scout_web/assets/static/images/rsk_logo.svg b/apps/block_scout_web/assets/static/images/rsk_logo.svg new file mode 100644 index 0000000000..8502c921e5 --- /dev/null +++ b/apps/block_scout_web/assets/static/images/rsk_logo.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2c3a549577f392ba34fdbc088b4c64d4976f2307 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 14:54:20 +0300 Subject: [PATCH 30/36] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f2c2605a4..58ad50f180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Current ### Features - +- [#1903](https://github.com/poanetwork/blockscout/pull/1874) - added rsk theme and rsk logo - [#1895](https://github.com/poanetwork/blockscout/pull/1874) - add changes to poa theme and poa logo - [#1812](https://github.com/poanetwork/blockscout/pull/1812) - add pagination to addresses page - [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo From d6e6601365a6c35734275e0088f8f51db103b53b Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 14:56:14 +0300 Subject: [PATCH 31/36] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ad50f180..708ab60e5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ ## Current ### Features -- [#1903](https://github.com/poanetwork/blockscout/pull/1874) - added rsk theme and rsk logo -- [#1895](https://github.com/poanetwork/blockscout/pull/1874) - add changes to poa theme and poa logo +- [#1903](https://github.com/poanetwork/blockscout/pull/1903) - added rsk theme and rsk logo +- [#1895](https://github.com/poanetwork/blockscout/pull/1895) - add changes to poa theme and poa logo - [#1812](https://github.com/poanetwork/blockscout/pull/1812) - add pagination to addresses page - [#1874](https://github.com/poanetwork/blockscout/pull/1874) - add changes to ethereum theme and ethereum logo - [#1815](https://github.com/poanetwork/blockscout/pull/1815) - able to search without prefix "0x" From e1684ee265eea0ae38a26d97c66bddefe38526dd Mon Sep 17 00:00:00 2001 From: Michael Ira Krufky Date: Tue, 7 May 2019 12:57:23 -0400 Subject: [PATCH 32/36] README.md: add blocks.ether1.wattpool.net for Ether-1 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 289a3d35ed..9755475dbe 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Currently available block explorers (i.e. Etherscan and Etherchain) are closed s * [SpringChain](https://explorer.springrole.com/) * [PIRL](http://pirl.es/) * [Petrichor](https://explorer.petrichor-dev.com/) +* [Ether-1](https://blocks.ether1.wattpool.net/) ### Visual Interface From 76fdd30fcaf7a902242cc16a7257e36d8e28b535 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 20:52:29 +0300 Subject: [PATCH 33/36] Update _lukso_variables.scss --- apps/block_scout_web/assets/css/theme/_lukso_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/theme/_lukso_variables.scss b/apps/block_scout_web/assets/css/theme/_lukso_variables.scss index a09049e7c8..c1d8d630f9 100644 --- a/apps/block_scout_web/assets/css/theme/_lukso_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_lukso_variables.scss @@ -12,7 +12,7 @@ $dashboard-stats-item-value-color: $primary; $dashboard-stats-item-border-color: $primary; $header-links-color-active: #333; - +.dropdown-item:hover, .dropdown-item:focus { background-color: $primary !important; } $tile-type-block-color: $secondary; $navbar-logo-height: 18px; From 630cce349a5375a57de1b3566bc6180100a347e5 Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 20:53:02 +0300 Subject: [PATCH 34/36] Update _tooltip.scss --- apps/block_scout_web/assets/css/components/_tooltip.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/components/_tooltip.scss b/apps/block_scout_web/assets/css/components/_tooltip.scss index 1cd7797785..9a1027b782 100644 --- a/apps/block_scout_web/assets/css/components/_tooltip.scss +++ b/apps/block_scout_web/assets/css/components/_tooltip.scss @@ -13,6 +13,7 @@ $tooltip-color: #fff !default; } .arrow::before { - border-top-color: $tooltip-background-color; + border-top-color: $tooltip-background-color !important; + border-bottom-color: $tooltip-background-color !important; } } From 0135f09b45a8522134b128ecc975eb442575cbab Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 20:54:42 +0300 Subject: [PATCH 35/36] Update _tooltip.scss --- apps/block_scout_web/assets/css/components/_tooltip.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/assets/css/components/_tooltip.scss b/apps/block_scout_web/assets/css/components/_tooltip.scss index 9a1027b782..4c845a7c1c 100644 --- a/apps/block_scout_web/assets/css/components/_tooltip.scss +++ b/apps/block_scout_web/assets/css/components/_tooltip.scss @@ -13,7 +13,7 @@ $tooltip-color: #fff !default; } .arrow::before { - border-top-color: $tooltip-background-color !important; - border-bottom-color: $tooltip-background-color !important; + border-top-color: $tooltip-background-color; + border-bottom-color: $tooltip-background-color; } } From 417027b80ffba3bd3d7fdceba216347e7bda85cf Mon Sep 17 00:00:00 2001 From: maxgrapps <50101080+maxgrapps@users.noreply.github.com> Date: Tue, 7 May 2019 20:57:12 +0300 Subject: [PATCH 36/36] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 708ab60e5b..9301cff144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#1907](https://github.com/poanetwork/blockscout/pull/1907) - dropdown color bug fix (lukso theme) and tooltip color bug fix - [#1903](https://github.com/poanetwork/blockscout/pull/1903) - added rsk theme and rsk logo - [#1895](https://github.com/poanetwork/blockscout/pull/1895) - add changes to poa theme and poa logo - [#1812](https://github.com/poanetwork/blockscout/pull/1812) - add pagination to addresses page