diff --git a/CHANGELOG.md b/CHANGELOG.md index e3460c8fc6..7993e7c126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,11 @@ ### Features ### Fixes +- [#2425](https://github.com/poanetwork/blockscout/pull/2425) - Force to show address view for checksummed address even if it is not in DB ### Chore +- [#2450](https://github.com/poanetwork/blockscout/pull/2450) - Fix clearance of logs and node_modules folders in clearing script +- [#2434](https://github.com/poanetwork/blockscout/pull/2434) - get rid of timex warnings ## 2.0.2-beta 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 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 8f5e5d96d5..47100b972e 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/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 %> 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/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 7047c6966a..e356d87df9 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 "" @@ -621,7 +621,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" @@ -983,7 +983,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 "" @@ -1379,7 +1379,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 "" @@ -1425,7 +1425,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 76e3303bf9..58e159d0bb 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 "" @@ -621,7 +621,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" @@ -983,7 +983,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 "" @@ -1380,7 +1380,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 "" @@ -1426,7 +1426,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/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..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 @@ -13,10 +13,16 @@ 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, 404) + 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 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 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