Refactoring

pull/6582/head
POA 2 years ago
parent fd4a4372ae
commit 9aa9c5399e
  1. 8
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex
  2. 1
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex
  3. 25
      apps/block_scout_web/priv/gettext/default.pot
  4. 25
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  5. 9
      apps/indexer/lib/indexer/fetcher/transaction_action.ex
  6. 5
      apps/indexer/lib/indexer/transform/transaction_actions.ex
  7. 14
      config/runtime.exs
  8. 4
      docker-compose/envs/common-blockscout.env
  9. 18
      docker/Makefile

@ -48,16 +48,16 @@
<% symbol1 = if symbol1 != "Ether", do: link(symbol1, to: token_path(BlockScoutWeb.Endpoint, :show, address1), "data-test": "token_link"), else: raw(symbol1) %>
<%= if @action.type == :mint do %>
<%= gettext("<span class=\"text-muted\">Add</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity To Uniswap V3</span>", amount0: amount0, symbol0: safe_to_string(symbol0), amount1: amount1, symbol1: safe_to_string(symbol1)) |> raw() %>
<%= render BlockScoutWeb.TransactionView, "_actions_uniswap.html", action: "Add", amount0: amount0, symbol0: symbol0, conjunction: "And", amount1: amount1, symbol1: symbol1, tail: "Liquidity To Uniswap V3" %>
<% end %>
<%= if @action.type == :burn do %>
<%= gettext("<span class=\"text-muted\">Remove</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity From Uniswap V3</span>", amount0: amount0, symbol0: safe_to_string(symbol0), amount1: amount1, symbol1: safe_to_string(symbol1)) |> raw() %>
<%= render BlockScoutWeb.TransactionView, "_actions_uniswap.html", action: "Remove", amount0: amount0, symbol0: symbol0, conjunction: "And", amount1: amount1, symbol1: symbol1, tail: "Liquidity From Uniswap V3" %>
<% end %>
<%= if @action.type == :collect do %>
<%= gettext("<span class=\"text-muted\">Collect</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">From Uniswap V3</span>", amount0: amount0, symbol0: safe_to_string(symbol0), amount1: amount1, symbol1: safe_to_string(symbol1)) |> raw() %>
<%= render BlockScoutWeb.TransactionView, "_actions_uniswap.html", action: "Collect", amount0: amount0, symbol0: symbol0, conjunction: "And", amount1: amount1, symbol1: symbol1, tail: "From Uniswap V3" %>
<% end %>
<%= if @action.type == :swap do %>
<%= gettext("<span class=\"text-muted\">Swap</span> %{amount0} %{symbol0} <span class=\"text-muted\">For</span> %{amount1} %{symbol1} <span class=\"text-muted\">On Uniswap V3</span>", amount0: amount0, symbol0: safe_to_string(symbol0), amount1: amount1, symbol1: safe_to_string(symbol1)) |> raw() %>
<%= render BlockScoutWeb.TransactionView, "_actions_uniswap.html", action: "Swap", amount0: amount0, symbol0: symbol0, conjunction: "For", amount1: amount1, symbol1: symbol1, tail: "On Uniswap V3" %>
<% end %>
</span>
<br />

@ -0,0 +1 @@
<%= gettext("<span class=\"text-muted\">%{action}</span> %{amount0} %{symbol0} <span class=\"text-muted\">%{conjunction}</span> %{amount1} %{symbol1} <span class=\"text-muted\">%{tail}</span>", action: @action, amount0: @amount0, symbol0: safe_to_string(@symbol0), conjunction: @conjunction, amount1: @amount1, symbol1: safe_to_string(@symbol1), tail: @tail) |> raw() %>

@ -3516,26 +3516,6 @@ msgstr ""
msgid "%{qty} of <span class=\"text-muted\">Token ID [%{link_to_id}]</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:51
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Add</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity To Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:57
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Collect</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">From Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:54
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Remove</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity From Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:60
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Swap</span> %{amount0} %{symbol0} <span class=\"text-muted\">For</span> %{amount1} %{symbol1} <span class=\"text-muted\">On Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/overview.html.eex:201
#, elixir-autogen, elixir-format
msgid "Highlighted events of the transaction."
@ -3555,3 +3535,8 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Transaction Action"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex:1
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">%{action}</span> %{amount0} %{symbol0} <span class=\"text-muted\">%{conjunction}</span> %{amount1} %{symbol1} <span class=\"text-muted\">%{tail}</span>"
msgstr ""

@ -3516,26 +3516,6 @@ msgstr ""
msgid "%{qty} of <span class=\"text-muted\">Token ID [%{link_to_id}]</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:51
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Add</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity To Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:57
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Collect</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">From Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:54
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Remove</span> %{amount0} %{symbol0} <span class=\"text-muted\">And</span> %{amount1} %{symbol1} <span class=\"text-muted\">Liquidity From Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions.html.eex:60
#, elixir-autogen, elixir-format
msgid "<span class=\"text-muted\">Swap</span> %{amount0} %{symbol0} <span class=\"text-muted\">For</span> %{amount1} %{symbol1} <span class=\"text-muted\">On Uniswap V3</span>"
msgstr ""
#: lib/block_scout_web/templates/transaction/overview.html.eex:201
#, elixir-autogen, elixir-format
msgid "Highlighted events of the transaction."
@ -3555,3 +3535,8 @@ msgstr ""
#, elixir-autogen, elixir-format, fuzzy
msgid "Transaction Action"
msgstr ""
#: lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex:1
#, elixir-autogen, elixir-format, fuzzy
msgid "<span class=\"text-muted\">%{action}</span> %{amount0} %{symbol0} <span class=\"text-muted\">%{conjunction}</span> %{amount1} %{symbol1} <span class=\"text-muted\">%{tail}</span>"
msgstr ""

@ -39,12 +39,11 @@ defmodule Indexer.Fetcher.TransactionAction do
@impl GenServer
def init(opts) when is_list(opts) do
opts =
:indexer
|> Application.get_all_env()
Application.get_all_env(:indexer)[__MODULE__]
|> Keyword.merge(opts)
first_block = Keyword.get(opts, :tx_actions_reindex_first_block)
last_block = Keyword.get(opts, :tx_actions_reindex_last_block)
first_block = Keyword.get(opts, :reindex_first_block)
last_block = Keyword.get(opts, :reindex_last_block)
cond do
!is_nil(first_block) and !is_nil(last_block) ->
@ -175,7 +174,7 @@ defmodule Indexer.Fetcher.TransactionAction do
protocols =
opts
|> Keyword.get(:tx_actions_reindex_protocols, "")
|> Keyword.get(:reindex_protocols, "")
|> String.trim()
|> String.split(",")
|> Enum.map(&String.trim(&1))

@ -513,10 +513,13 @@ defmodule Indexer.Transform.TransactionActions do
end
defp get_max_token_cache_size do
case Application.get_env(:indexer, :tx_actions_max_token_cache_size, @default_max_token_cache_size) do
case Application.get_env(:indexer, __MODULE__)[:max_token_cache_size] do
nil ->
@default_max_token_cache_size
"" ->
@default_max_token_cache_size
max_cache_size ->
if is_binary(max_cache_size), do: String.to_integer(max_cache_size), else: max_cache_size
end

@ -422,11 +422,15 @@ config :indexer,
last_block: System.get_env("LAST_BLOCK") || "",
trace_first_block: System.get_env("TRACE_FIRST_BLOCK") || "",
trace_last_block: System.get_env("TRACE_LAST_BLOCK") || "",
fetch_rewards_way: System.get_env("FETCH_REWARDS_WAY", "trace_block"),
tx_actions_reindex_first_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK"),
tx_actions_reindex_last_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK"),
tx_actions_reindex_protocols: System.get_env("INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS", ""),
tx_actions_max_token_cache_size: System.get_env("INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE")
fetch_rewards_way: System.get_env("FETCH_REWARDS_WAY", "trace_block")
config :indexer, Indexer.Fetcher.TransactionAction,
reindex_first_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK"),
reindex_last_block: System.get_env("INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK"),
reindex_protocols: System.get_env("INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS", "")
config :indexer, Indexer.Transform.TransactionActions,
max_token_cache_size: System.get_env("INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE")
{receipts_batch_size, _} = Integer.parse(System.get_env("INDEXER_RECEIPTS_BATCH_SIZE", "250"))
{receipts_concurrency, _} = Integer.parse(System.get_env("INDEXER_RECEIPTS_CONCURRENCY", "10"))

@ -90,6 +90,10 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
# INDEXER_COIN_BALANCES_CONCURRENCY=
# INDEXER_RECEIPTS_BATCH_SIZE=
# INDEXER_RECEIPTS_CONCURRENCY=
# INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE=
# INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK=
# INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK=
# INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS=
# TOKEN_ID_MIGRATION_FIRST_BLOCK=
# TOKEN_ID_MIGRATION_CONCURRENCY=
# TOKEN_ID_MIGRATION_BATCH_SIZE=

@ -476,13 +476,25 @@ ifdef INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE=$(INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE)'
endif
ifdef TOKEN_ID_MIGRATION_FIRST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE=$(INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE)'
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TOKEN_ID_MIGRATION_FIRST_BLOCK=$(TOKEN_ID_MIGRATION_FIRST_BLOCK)'
endif
ifdef TOKEN_ID_MIGRATION_CONCURRENCY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE=$(INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE)'
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TOKEN_ID_MIGRATION_CONCURRENCY=$(TOKEN_ID_MIGRATION_CONCURRENCY)'
endif
ifdef TOKEN_ID_MIGRATION_BATCH_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE=$(INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE)'
BLOCKSCOUT_CONTAINER_PARAMS += -e 'TOKEN_ID_MIGRATION_BATCH_SIZE=$(TOKEN_ID_MIGRATION_BATCH_SIZE)'
endif
ifdef INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE=$(INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE)'
endif
ifdef INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK=$(INDEXER_TX_ACTIONS_REINDEX_FIRST_BLOCK)'
endif
ifdef INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK=$(INDEXER_TX_ACTIONS_REINDEX_LAST_BLOCK)'
endif
ifdef INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS=$(INDEXER_TX_ACTIONS_REINDEX_PROTOCOLS)'
endif
ifdef SECRET_KEY_BASE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'SECRET_KEY_BASE=$(SECRET_KEY_BASE)'

Loading…
Cancel
Save