diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex index 3ef0e0c4ad..09e71a084f 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex @@ -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("Add %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity To Uniswap V3", 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("Remove %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity From Uniswap V3", 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("Collect %{amount0} %{symbol0} And %{amount1} %{symbol1} From Uniswap V3", 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("Swap %{amount0} %{symbol0} For %{amount1} %{symbol1} On Uniswap V3", 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 %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex new file mode 100644 index 0000000000..3fd8a1c6e4 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_uniswap.html.eex @@ -0,0 +1 @@ +<%= gettext("%{action} %{amount0} %{symbol0} %{conjunction} %{amount1} %{symbol1} %{tail}", action: @action, amount0: @amount0, symbol0: safe_to_string(@symbol0), conjunction: @conjunction, amount1: @amount1, symbol1: safe_to_string(@symbol1), tail: @tail) |> raw() %> \ No newline at end of file diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 08da91a847..4153a46b1c 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -3516,26 +3516,6 @@ msgstr "" msgid "%{qty} of Token ID [%{link_to_id}]" msgstr "" -#: lib/block_scout_web/templates/transaction/_actions.html.eex:51 -#, elixir-autogen, elixir-format -msgid "Add %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity To Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:57 -#, elixir-autogen, elixir-format -msgid "Collect %{amount0} %{symbol0} And %{amount1} %{symbol1} From Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:54 -#, elixir-autogen, elixir-format -msgid "Remove %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity From Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:60 -#, elixir-autogen, elixir-format -msgid "Swap %{amount0} %{symbol0} For %{amount1} %{symbol1} On Uniswap V3" -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 "%{action} %{amount0} %{symbol0} %{conjunction} %{amount1} %{symbol1} %{tail}" +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 eb873b6ef9..cdf80cc4bd 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 @@ -3516,26 +3516,6 @@ msgstr "" msgid "%{qty} of Token ID [%{link_to_id}]" msgstr "" -#: lib/block_scout_web/templates/transaction/_actions.html.eex:51 -#, elixir-autogen, elixir-format -msgid "Add %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity To Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:57 -#, elixir-autogen, elixir-format -msgid "Collect %{amount0} %{symbol0} And %{amount1} %{symbol1} From Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:54 -#, elixir-autogen, elixir-format -msgid "Remove %{amount0} %{symbol0} And %{amount1} %{symbol1} Liquidity From Uniswap V3" -msgstr "" - -#: lib/block_scout_web/templates/transaction/_actions.html.eex:60 -#, elixir-autogen, elixir-format -msgid "Swap %{amount0} %{symbol0} For %{amount1} %{symbol1} On Uniswap V3" -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 "%{action} %{amount0} %{symbol0} %{conjunction} %{amount1} %{symbol1} %{tail}" +msgstr "" diff --git a/apps/indexer/lib/indexer/fetcher/transaction_action.ex b/apps/indexer/lib/indexer/fetcher/transaction_action.ex index 9208d10ebc..2c267b3482 100644 --- a/apps/indexer/lib/indexer/fetcher/transaction_action.ex +++ b/apps/indexer/lib/indexer/fetcher/transaction_action.ex @@ -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)) diff --git a/apps/indexer/lib/indexer/transform/transaction_actions.ex b/apps/indexer/lib/indexer/transform/transaction_actions.ex index b6ee8df977..0cac3979ed 100644 --- a/apps/indexer/lib/indexer/transform/transaction_actions.ex +++ b/apps/indexer/lib/indexer/transform/transaction_actions.ex @@ -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 diff --git a/config/runtime.exs b/config/runtime.exs index 631c51c4a4..b19f76b3ef 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -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")) diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index d152c17bb7..38b5fd0046 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -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= diff --git a/docker/Makefile b/docker/Makefile index d4d3123f63..e2862a2012 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -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)'