From e9f1b6281a063c8991c0bbdf2153dc77ef439b0e Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 7 Aug 2020 17:00:29 +0300 Subject: [PATCH] Finalize bridged tokens --- .dialyzer-ignore | 1 + .../tokens/overview/_details.html.eex | 4 +- apps/block_scout_web/priv/gettext/default.pot | 12 +-- .../priv/gettext/en/LC_MESSAGES/default.po | 12 +-- apps/indexer/config/config.exs | 2 - .../indexer/set_bridged_status_for_tokens.ex | 13 --- apps/indexer/lib/indexer/supervisor.ex | 97 ++++++++++--------- 7 files changed, 67 insertions(+), 74 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index ce9f536b60..4612a4c51e 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -2,6 +2,7 @@ :0: Unknown function 'Elixir.ExUnit.CaseTemplate':'__proxy__'/2 :0: Unknown type 'Elixir.Map':t/0 :0: Unknown type 'Elixir.Hash':t/0 +:0: Unknown type 'Elixir.Address':t/0 apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetime/1 has no local return lib/explorer/repo/prometheus_logger.ex:8 lib/block_scout_web/views/layout_view.ex:175 diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex index a543d4f6e7..4c1fdeedb7 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex @@ -48,7 +48,9 @@ Token is bridged - target="_blank">View Original Token <%= render BlockScoutWeb.IconsView, "_external_link.html" %> + <%= if Map.has_key?(@token, :foreign_token_contract_address_hash) do %> + target="_blank">View Original Token <%= render BlockScoutWeb.IconsView, "_external_link.html" %> + <% end %> <% end %> diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 342ad92dab..29c28c0b06 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1175,7 +1175,7 @@ msgstr "" #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:94 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:115 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:117 msgid "QR Code" msgstr "" @@ -1446,7 +1446,7 @@ msgid "Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:85 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:87 msgid "Total Supply" msgstr "" @@ -1601,7 +1601,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:16 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:20 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:65 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:67 msgid "View Contract" msgstr "" @@ -1715,8 +1715,8 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:142 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:95 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:103 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:116 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:124 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:118 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:126 msgid "Close" msgstr "" @@ -1733,7 +1733,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:69 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:73 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:75 msgid "Decimals" 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 342ad92dab..29c28c0b06 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 @@ -1175,7 +1175,7 @@ msgstr "" #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:94 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:115 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:117 msgid "QR Code" msgstr "" @@ -1446,7 +1446,7 @@ msgid "Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:85 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:87 msgid "Total Supply" msgstr "" @@ -1601,7 +1601,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:16 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:20 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:65 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:67 msgid "View Contract" msgstr "" @@ -1715,8 +1715,8 @@ msgstr "" #: lib/block_scout_web/templates/address/overview.html.eex:142 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:95 #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:103 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:116 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:124 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:118 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:126 msgid "Close" msgstr "" @@ -1733,7 +1733,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:69 -#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:73 +#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:75 msgid "Decimals" msgstr "" diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index f24a08a0d2..24b9edd909 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -44,8 +44,6 @@ config :indexer, Indexer.Fetcher.PendingTransaction.Supervisor, # config :indexer, Indexer.Fetcher.ReplacedTransaction.Supervisor, disabled?: true # config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: true config :indexer, Indexer.Fetcher.StakingPools.Supervisor, disabled?: true -# System.get_env("MULTI_TOKEN_BRIDGE_MEDIATOR", "") == "" -# config :indexer, Indexer.SetBridgedStatusForTokens.Supervisor, disabled?: true config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true" diff --git a/apps/indexer/lib/indexer/set_bridged_status_for_tokens.ex b/apps/indexer/lib/indexer/set_bridged_status_for_tokens.ex index 1b62dff4fe..d7d3d582ad 100644 --- a/apps/indexer/lib/indexer/set_bridged_status_for_tokens.ex +++ b/apps/indexer/lib/indexer/set_bridged_status_for_tokens.ex @@ -11,19 +11,6 @@ defmodule Indexer.SetBridgedStatusForTokens do @interval :timer.minutes(1) - # def child_spec([init_arguments]) do - # child_spec([init_arguments, []]) - # end - - # def child_spec([_init_arguments, _gen_server_options] = start_link_arguments) do - # default = %{ - # id: __MODULE__, - # start: {__MODULE__, :start_link, start_link_arguments} - # } - - # Supervisor.child_spec(default, []) - # end - def start_link([init_opts, gen_server_opts]) do start_link(init_opts, gen_server_opts) end diff --git a/apps/indexer/lib/indexer/supervisor.ex b/apps/indexer/lib/indexer/supervisor.ex index 590771e149..efbea9df1e 100644 --- a/apps/indexer/lib/indexer/supervisor.ex +++ b/apps/indexer/lib/indexer/supervisor.ex @@ -86,53 +86,58 @@ defmodule Indexer.Supervisor do realtime_subscribe_named_arguments = realtime_overrides[:subscribe_named_arguments] || subscribe_named_arguments + basic_fetchers = [ + # Root fetchers + {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, + {Realtime.Supervisor, + [ + %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, + [name: Realtime.Supervisor] + ]}, + {Catchup.Supervisor, + [ + %{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor}, + [name: Catchup.Supervisor] + ]}, + + # Async catchup fetchers + {UncleBlock.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor]]}, + {BlockReward.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {InternalTransaction.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {CoinBalance.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {Token.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {TokenInstance.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {ContractCode.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {TokenBalance.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {TokenUpdater.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {ReplacedTransaction.Supervisor, [[memory_monitor: memory_monitor]]}, + {StakingPools.Supervisor, [[memory_monitor: memory_monitor]]}, + + # Out-of-band fetchers + {CoinBalanceOnDemand.Supervisor, [json_rpc_named_arguments]}, + + # Temporary workers + {UncatalogedTokenTransfers.Supervisor, [[]]}, + {UnclesWithoutIndex.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {BlocksTransactionsMismatch.Supervisor, + [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, + {PendingOpsCleaner, [[], []]} + ] + + multi_token_bridge_mediator = Application.get_env(:block_scout_web, :multi_token_bridge_mediator) + + all_fetchers = + if multi_token_bridge_mediator && multi_token_bridge_mediator !== "" do + [{SetBridgedStatusForTokens, [[], []]} | basic_fetchers] + else + basic_fetchers + end + Supervisor.init( - [ - # Root fetchers - {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, - {Realtime.Supervisor, - [ - %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, - [name: Realtime.Supervisor] - ]}, - {Catchup.Supervisor, - [ - %{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor}, - [name: Catchup.Supervisor] - ]}, - - # Async catchup fetchers - {UncleBlock.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor]]}, - {BlockReward.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {InternalTransaction.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {CoinBalance.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {Token.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenInstance.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {ContractCode.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenBalance.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {TokenUpdater.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {ReplacedTransaction.Supervisor, [[memory_monitor: memory_monitor]]}, - {StakingPools.Supervisor, [[memory_monitor: memory_monitor]]}, - - # Out-of-band fetchers - {CoinBalanceOnDemand.Supervisor, [json_rpc_named_arguments]}, - {SetBridgedStatusForTokens, [[], []]}, - - # Temporary workers - {UncatalogedTokenTransfers.Supervisor, [[]]}, - {UnclesWithoutIndex.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {BlocksTransactionsMismatch.Supervisor, - [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - {PendingOpsCleaner, [[], []]} - ], + all_fetchers, strategy: :one_for_one ) end