From 0bc67c3a33e8497c986e56390b9d90c8cbc1fd56 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 30 Oct 2020 18:12:10 +0300 Subject: [PATCH] OTHER_EXPLORERS env var --- .dialyzer-ignore | 2 +- CHANGELOG.md | 1 + apps/block_scout_web/config/config.exs | 6 +----- .../lib/block_scout_web/views/layout_view.ex | 8 +++++++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 41b08448ed..ffb4263385 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -15,7 +15,7 @@ lib/block_scout_web/schema/types.ex:31 lib/phoenix/router.ex:324 lib/phoenix/router.ex:402 lib/block_scout_web/views/layout_view.ex:145: The call 'Elixir.Poison.Parser':'parse!' -lib/block_scout_web/views/layout_view.ex:231: The call 'Elixir.Poison.Parser':'parse!' +lib/block_scout_web/views/layout_view.ex:237: The call 'Elixir.Poison.Parser':'parse!' lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:21 lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:22 lib/explorer/smart_contract/reader.ex:330 diff --git a/CHANGELOG.md b/CHANGELOG.md index c51c860b26..da1a916005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - [#3335](https://github.com/poanetwork/blockscout/pull/3335) - MarketCap calculation: check that ETS tables exist before inserting new data or lookup from the table ### Chore +- [#3414](https://github.com/poanetwork/blockscout/pull/3414) - Manage lis of other explorers in the footer via env var - [#3407](https://github.com/poanetwork/blockscout/pull/3407) - Add EthereumJSONRPC.HTTP.HTTPoison.json_rpc function clause when URL is null - [#3405](https://github.com/poanetwork/blockscout/pull/3405) - N/A instead of 0 for market cap if it is not fetched - [#3404](https://github.com/poanetwork/blockscout/pull/3404) - DISABLE_KNOWN_TOKENS env var diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 299edad9a8..de69c50848 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -29,11 +29,7 @@ config :block_scout_web, BlockScoutWeb.Chain, config :block_scout_web, link_to_other_explorers: System.get_env("LINK_TO_OTHER_EXPLORERS") == "true", - other_explorers: %{ - "Etherscan" => "https://etherscan.io/", - "EtherChain" => "https://www.etherchain.org/", - "Bloxy" => "https://bloxy.info/" - }, + other_explorers: System.get_env("OTHER_EXPLORERS"), other_networks: System.get_env("SUPPORTED_CHAINS"), webapp_url: System.get_env("WEBAPP_URL"), api_url: System.get_env("API_URL"), diff --git a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex index b1c0ededb1..8e7523a2da 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex @@ -197,12 +197,18 @@ defmodule BlockScoutWeb.LayoutView do def other_explorers do if Application.get_env(:block_scout_web, :link_to_other_explorers) do - Application.get_env(:block_scout_web, :other_explorers, []) + decode_other_explorers_json(Application.get_env(:block_scout_web, :other_explorers, [])) else [] end end + defp decode_other_explorers_json(data) do + Jason.decode!(~s(#{data})) + rescue + _ -> [] + end + def webapp_url(conn) do :block_scout_web |> Application.get_env(:webapp_url)