From 8dc5f0039af3c1470862eea1fecc2de50ffab84a Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 24 Jul 2019 16:20:57 +0300 Subject: [PATCH 1/9] Force to show view for checksummed address --- .../address_transaction_controller.ex | 25 +++++++++++++++++-- .../address_transaction_controller_test.exs | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex index ba29c766c1..35dad3662c 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex @@ -83,7 +83,11 @@ defmodule BlockScoutWeb.AddressTransactionController do unprocessable_entity(conn) {:error, :not_found} -> - not_found(conn) + with {:ok, _} <- Chain.Hash.Address.validate(address_hash_string) do + json(conn, %{items: [], next_page_path: ""}) + else + {:error, _} -> not_found(conn) + end end end @@ -106,7 +110,24 @@ defmodule BlockScoutWeb.AddressTransactionController do unprocessable_entity(conn) {:error, :not_found} -> - not_found(conn) + {:ok, address_hash} = Chain.string_to_address_hash(address_hash_string) + address = %Chain.Address{hash: address_hash, smart_contract: nil, token: nil} + + with {:ok, _} <- Chain.Hash.Address.validate(address_hash_string) do + render( + conn, + "index.html", + address: address, + coin_balance_status: nil, + exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(), + filter: params["filter"], + transaction_count: 0, + validation_count: 0, + current_path: current_path(conn) + ) + else + {:error, _} -> not_found(conn) + end end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs index a29d6b9be6..dc5cff7308 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs @@ -16,7 +16,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do test "with valid address hash without address", %{conn: conn} do conn = get(conn, address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b")) - assert html_response(conn, 404) + assert html_response(conn, 200) end test "returns transactions for the address", %{conn: conn} do From 1c67e5640ab634a1bf9730c2d240466c0b0191bd Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 24 Jul 2019 19:31:47 +0300 Subject: [PATCH 2/9] Hide Last Balance Update in address view if there is no fetched_coin_balance_block_number --- .../block_scout_web/templates/address/overview.html.eex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex index 3cb95a5331..04e7c2c036 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex @@ -84,9 +84,11 @@ <%= gettext("Transactions Sent") %> <% end %> - - <%= gettext("Last Balance Update: Block #") %><%= @address.fetched_coin_balance_block_number %> - + <%= if @address.fetched_coin_balance_block_number do %> + + <%= gettext("Last Balance Update: Block #") %><%= @address.fetched_coin_balance_block_number %> + + <% end %> <%= if validator?(@validation_count) do %> From a78958653d1a4ada74a0e3d2af8abf9d26111883 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 24 Jul 2019 19:33:41 +0300 Subject: [PATCH 3/9] Fix coin balance history view --- .../controllers/address_coin_balance_controller.ex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex index 9267c0dcab..8b39de91a7 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex @@ -68,6 +68,12 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do validation_count: validation_count(address_hash), current_path: current_path(conn) ) + else + :error -> + unprocessable_entity(conn) + + {:error, :not_found} -> + not_found(conn) end end end From 701e0f6038b1b86b6b1b364e79919ebd78cc8022 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 24 Jul 2019 19:52:47 +0300 Subject: [PATCH 4/9] Fix gettext, add CHANGELOG entry --- CHANGELOG.md | 1 + apps/block_scout_web/priv/gettext/default.pot | 16 ++++++++-------- .../priv/gettext/en/LC_MESSAGES/default.po | 16 ++++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 033c1c9c4e..aefcdea38b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2425](https://github.com/poanetwork/blockscout/pull/2425) - Force to show address view for checksummed address even if it is not in DB - [#2416](https://github.com/poanetwork/blockscout/pull/2416) - Fix "page not found" handling in the router - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2405](https://github.com/poanetwork/blockscout/pull/2405) - added templates for table loader and tile loader diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 8f31b55e06..d413873e85 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -190,7 +190,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:32 -#: lib/block_scout_web/templates/address/overview.html.eex:95 +#: lib/block_scout_web/templates/address/overview.html.eex:97 #: lib/block_scout_web/templates/address_validation/index.html.eex:13 #: lib/block_scout_web/views/address_view.ex:311 msgid "Blocks Validated" @@ -209,8 +209,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37 -#: lib/block_scout_web/templates/address/overview.html.eex:144 -#: lib/block_scout_web/templates/address/overview.html.eex:152 +#: lib/block_scout_web/templates/address/overview.html.eex:146 +#: lib/block_scout_web/templates/address/overview.html.eex:154 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:107 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:115 msgid "Close" @@ -319,7 +319,7 @@ msgid "Copy Txn Hash" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:105 +#: lib/block_scout_web/templates/address/overview.html.eex:107 msgid "Created by" msgstr "" @@ -630,7 +630,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:33 -#: lib/block_scout_web/templates/address/overview.html.eex:143 +#: lib/block_scout_web/templates/address/overview.html.eex:145 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:106 msgid "QR Code" @@ -998,7 +998,7 @@ msgid "Yes" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:111 +#: lib/block_scout_web/templates/address/overview.html.eex:113 msgid "at" msgstr "" @@ -1437,7 +1437,7 @@ msgid "Contract Libraries" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:88 +#: lib/block_scout_web/templates/address/overview.html.eex:89 msgid "Last Balance Update: Block #" msgstr "" @@ -1483,7 +1483,7 @@ msgid "Incoming Transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:119 +#: lib/block_scout_web/templates/address/overview.html.eex:121 msgid "Error: Could not determine contract creator." 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 98feb8687d..b349db9ecf 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 @@ -190,7 +190,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:32 -#: lib/block_scout_web/templates/address/overview.html.eex:95 +#: lib/block_scout_web/templates/address/overview.html.eex:97 #: lib/block_scout_web/templates/address_validation/index.html.eex:13 #: lib/block_scout_web/views/address_view.ex:311 msgid "Blocks Validated" @@ -209,8 +209,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37 -#: lib/block_scout_web/templates/address/overview.html.eex:144 -#: lib/block_scout_web/templates/address/overview.html.eex:152 +#: lib/block_scout_web/templates/address/overview.html.eex:146 +#: lib/block_scout_web/templates/address/overview.html.eex:154 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:107 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:115 msgid "Close" @@ -319,7 +319,7 @@ msgid "Copy Txn Hash" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:105 +#: lib/block_scout_web/templates/address/overview.html.eex:107 msgid "Created by" msgstr "" @@ -630,7 +630,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:33 -#: lib/block_scout_web/templates/address/overview.html.eex:143 +#: lib/block_scout_web/templates/address/overview.html.eex:145 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:106 msgid "QR Code" @@ -998,7 +998,7 @@ msgid "Yes" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:111 +#: lib/block_scout_web/templates/address/overview.html.eex:113 msgid "at" msgstr "" @@ -1437,7 +1437,7 @@ msgid "Contract Libraries" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:88 +#: lib/block_scout_web/templates/address/overview.html.eex:89 msgid "Last Balance Update: Block #" msgstr "" @@ -1483,7 +1483,7 @@ msgid "Incoming Transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/overview.html.eex:119 +#: lib/block_scout_web/templates/address/overview.html.eex:121 msgid "Error: Could not determine contract creator." msgstr "" From e5b3ced87d58172d5deb5c944565d362dbe33fec Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 25 Jul 2019 13:42:01 +0300 Subject: [PATCH 5/9] bump timex --- apps/block_scout_web/mix.exs | 2 +- apps/ethereum_jsonrpc/mix.exs | 2 +- apps/explorer/mix.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index e431d4ecf5..623aba2089 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -125,7 +125,7 @@ defmodule BlockScoutWeb.Mixfile do {:spandex_datadog, "~> 0.4.0"}, # `:spandex` tracing of `:phoenix` {:spandex_phoenix, "~> 0.3.1"}, - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, {:wallaby, "~> 0.22", only: [:test], runtime: false}, # `:cowboy` `~> 2.0` and Phoenix 1.4 compatibility {:wobserver, "~> 0.2.0", github: "poanetwork/wobserver", branch: "support-https"}, diff --git a/apps/ethereum_jsonrpc/mix.exs b/apps/ethereum_jsonrpc/mix.exs index 7c2299c4a8..58dcff8fd5 100644 --- a/apps/ethereum_jsonrpc/mix.exs +++ b/apps/ethereum_jsonrpc/mix.exs @@ -82,7 +82,7 @@ defmodule EthereumJsonrpc.MixProject do # `:spandex` integration with Datadog {:spandex_datadog, "~> 0.4.0"}, # Convert unix timestamps in JSONRPC to DateTimes - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, # Encode/decode function names and arguments {:ex_abi, "~> 0.1.18"}, # `:verify_fun` for `Socket.Web.connect` diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index 4956363cc4..b9b887f838 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -117,7 +117,7 @@ defmodule Explorer.Mixfile do # Attach `:prometheus_ecto` to `:ecto` {:telemetry, "~> 0.3.0"}, # `Timex.Duration` for `Explorer.Counters.AverageBlockTime.average_block_time/0` - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, {:con_cache, "~> 0.13"} ] end From 62e5b43b67731fd6c5020c84be8bb4494a85a441 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 25 Jul 2019 13:44:40 +0300 Subject: [PATCH 6/9] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68005eba12..0c4e5c8c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - [#2326](https://github.com/poanetwork/blockscout/pull/2326) - fix nested constructor arguments ### Chore +- [#2434](https://github.com/poanetwork/blockscout/pull/2434) - get rid of timex warnings - [#2418](https://github.com/poanetwork/blockscout/pull/2418) - Remove parentheses in market cap percentage - [#2401](https://github.com/poanetwork/blockscout/pull/2401) - add ENV vars to manage updating period of average block time and market history cache - [#2363](https://github.com/poanetwork/blockscout/pull/2363) - add parameters example for eth rpc From a7e87390bb029366325939531313063d05bfff34 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 26 Jul 2019 15:55:15 +0300 Subject: [PATCH 7/9] Remove all logs/dev and all node_modules folders --- CHANGELOG.md | 1 + rel/commands/clear_build.sh | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99588261ea..db759aa6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes ### Chore +- [#2450](https://github.com/poanetwork/blockscout/pull/2450) - Fix clearance of logs and node_modules folders in clearing script ## 2.0.2-beta diff --git a/rel/commands/clear_build.sh b/rel/commands/clear_build.sh index 5faca7ffeb..a07a11870e 100755 --- a/rel/commands/clear_build.sh +++ b/rel/commands/clear_build.sh @@ -2,11 +2,13 @@ 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 +logs=$(find . -not -path '*/\.*' -name "logs" -type d) +dev=$(find ${logs} -name "dev") +rm -rf {ls -la ${dev}} + +find . -name "node_modules" -type d -exec rm -rf '{}' + case "$1" in -f) rm -rf ./apps/block_scout_web/priv/static;; -esac \ No newline at end of file +esac From 74b39c42b07134b2f66ffd491b3af975faa9682d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 29 Jul 2019 12:35:42 +0300 Subject: [PATCH 8/9] Extend tests with check of empty number of transactions --- .../controllers/address_transaction_controller_test.exs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs index dc5cff7308..d8e424b593 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs @@ -13,10 +13,12 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do assert html_response(conn, 422) end - test "with valid address hash without address", %{conn: conn} do - conn = get(conn, address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b")) + test "with valid address hash without address in the DB", %{conn: conn} do + conn = get(conn, address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b", %{"type" => "JSON"})) - assert html_response(conn, 200) + assert json_response(conn, 200) + transaction_tiles = json_response(conn, 200)["items"] + assert transaction_tiles |> length() == 0 end test "returns transactions for the address", %{conn: conn} do From 730eeeeb48c6f2e36902c5254003dc604d5e311f Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 29 Jul 2019 12:46:33 +0300 Subject: [PATCH 9/9] check format fix --- .../controllers/address_transaction_controller_test.exs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs index d8e424b593..63a27c7f7b 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs @@ -14,7 +14,11 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do end test "with valid address hash without address in the DB", %{conn: conn} do - conn = get(conn, address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b", %{"type" => "JSON"})) + conn = + get( + conn, + address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b", %{"type" => "JSON"}) + ) assert json_response(conn, 200) transaction_tiles = json_response(conn, 200)["items"]