diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4d67d77d..df4f3003b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - [#5014](https://github.com/blockscout/blockscout/pull/5014) - Separate FIRST_BLOCK and TRACE_FIRST_BLOCK option for blocks import and tracing methods - [#4998](https://github.com/blockscout/blockscout/pull/4998) - API endpoints logger - [#4983](https://github.com/blockscout/blockscout/pull/4983), [#5038](https://github.com/blockscout/blockscout/pull/5038) - Fix contract verification tests +- [#4861](https://github.com/blockscout/blockscout/pull/4861) - Add separate column for token icons ## 4.0.0-beta diff --git a/apps/block_scout_web/assets/css/components/_table.scss b/apps/block_scout_web/assets/css/components/_table.scss index 837652c042..7026697523 100644 --- a/apps/block_scout_web/assets/css/components/_table.scss +++ b/apps/block_scout_web/assets/css/components/_table.scss @@ -24,3 +24,7 @@ .address-cell { width: 150px; } + +.token-icon { + padding-right: 5px; +} diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex index 36303dfd1e..5fa75a64d4 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex @@ -1,13 +1,7 @@ - - - - - + <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> <% chain_id_for_token_icon = if @bridged_token && @bridged_token.foreign_chain_id, do: @bridged_token.foreign_chain_id |> Decimal.to_integer() |> to_string(), else: System.get_env("CHAIN_ID") %> <% address_hash = if @bridged_token && @bridged_token.foreign_token_contract_address_hash, do: @bridged_token.foreign_token_contract_address_hash, else: @token.contract_address_hash %> @@ -18,7 +12,8 @@ address: Address.checksum(address_hash) %> <% end %> - + + <%= link( to: address_token_transfers_path(@conn, :index, to_string(@address.hash), to_string(@token.contract_address_hash)), class: "tile-title-lg", diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token/index.html.eex index 9b35fb6e24..8c682078ac 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token/index.html.eex @@ -24,6 +24,9 @@
 
+ +
 
+
Asset
@@ -48,7 +51,7 @@ - <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 8 %> + <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 9 %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex index 84033ccbd1..a50c1b1048 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex @@ -1,5 +1,5 @@
- @@ -21,19 +21,30 @@ class: "dropdown-item" ) do %>
-

<%= token_name(token) %> + <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> + <% chain_id_for_token_icon = if bridged_token && bridged_token.foreign_chain_id, do: bridged_token.foreign_chain_id |> Decimal.to_integer() |> to_string(), else: System.get_env("CHAIN_ID") %> + <% address_hash = if bridged_token && bridged_token.foreign_token_contract_address_hash, do: bridged_token.foreign_token_contract_address_hash, else: token.contract_address_hash %> + <%= + render BlockScoutWeb.TokensView, + "_token_icon.html", + chain_id: chain_id_for_token_icon, + address: Address.checksum(address_hash), + style: "height: fit-content; margin-right: 5px; margin-top: -1px;" + %> + <% end %> +

<%= token_name(token) %> <%= if bridged_token && bridged_token.custom_metadata do %> <%= "(" <> bridged_token.custom_metadata <> ")" %> <% end %>

<%= if bridged_token && bridged_token.lp_token && bridged_token.custom_cap do %> <% lp_token_balance_usd = token_balance.value |> Decimal.div(token.total_supply) |> Decimal.mult(bridged_token.custom_cap) |> Decimal.round(4) %> -

+

<% else %> <%= if token_balance.token.usd_value do %> -

+

<% end %> @@ -41,7 +52,7 @@
<% col_md = if token_balance.token.usd_value, do: "col-md-6", else: "col-md-12" %> -

+

<%= if token_balance.token_type == "ERC-721" && !is_nil(token_balance.token_id) do %> 1 <% else %> @@ -52,7 +63,7 @@ <% end %>

<%= if token_balance.token.usd_value do %> -

+

<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex index ce94318894..ae99b76fa6 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex @@ -5,23 +5,25 @@ <%= @index %> + + <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> + <% foreign_chain_id = if Map.has_key?(@bridged_token, :foreign_chain_id), do: @bridged_token.foreign_chain_id, else: nil %> + <% chain_id_for_token_icon = if foreign_chain_id, do: foreign_chain_id |> Decimal.to_integer() |> to_string(), else: System.get_env("CHAIN_ID") %> + <% foreign_token_contract_address_hash = if Map.has_key?(@bridged_token, :foreign_token_contract_address_hash), do: Address.checksum(@bridged_token.foreign_token_contract_address_hash), else: nil %> + <% token_hash_for_token_icon = if foreign_token_contract_address_hash, do: foreign_token_contract_address_hash, else: Address.checksum(@token.contract_address_hash) %> + <%= + render BlockScoutWeb.TokensView, + "_token_icon.html", + chain_id: chain_id_for_token_icon, + address: token_hash_for_token_icon + %> + <% end %> + <% token = token_display_name(@token) %>
- <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> - <% foreign_chain_id = if Map.has_key?(@bridged_token, :foreign_chain_id), do: @bridged_token.foreign_chain_id, else: nil %> - <% chain_id_for_token_icon = if foreign_chain_id, do: foreign_chain_id |> Decimal.to_integer() |> to_string(), else: System.get_env("CHAIN_ID") %> - <% foreign_token_contract_address_hash = if Map.has_key?(@bridged_token, :foreign_token_contract_address_hash), do: Address.checksum(@bridged_token.foreign_token_contract_address_hash), else: nil %> - <% token_hash_for_token_icon = if foreign_token_contract_address_hash, do: foreign_token_contract_address_hash, else: Address.checksum(@token.contract_address_hash) %> - <%= - render BlockScoutWeb.TokensView, - "_token_icon.html", - chain_id: chain_id_for_token_icon, - address: token_hash_for_token_icon - %> - <% end %> <%= link(token, to: token_path(BlockScoutWeb.Endpoint, :show, @token.contract_address_hash), "data-test": "token_link", diff --git a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex index a3b83217c5..8754136016 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex @@ -23,6 +23,9 @@
 
+ + +
 
Token
@@ -51,9 +54,9 @@ <%= if @destination == :eth do %> - <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 6 %> + <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 7 %> <% else %> - <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 5 %> + <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 6 %> <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/search/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/search/_tile.html.eex index a7aa674519..ee93c644e8 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/search/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/search/_tile.html.eex @@ -5,9 +5,9 @@ - - <%= case @result.type do %> - <% "token" -> %> +<%= case @result.type do %> + <% "token" -> %> + <% end %> + + <% res = @result.name <> " (" <> @result.symbol <> ")" %> <%= highlight_search_result(res, @query) %> - <% "address" -> %> + <% "address" -> %> + <%= if @result.name do %> <%= highlight_search_result(@result.name, @query) %> <% end %> - <% "contract" -> %> + <% "contract" -> %> + <%= if @result.name do %> <%= highlight_search_result(@result.name, @query) %> <% end %> - <% "block" -> %> + <% "block" -> %> + <%= link( highlight_search_result(to_string(@result.block_number), @query), to: block_path(@conn, :show, @result.block_number) ) %> - <% _ -> %> - <% end %> + <% _ -> %> + +<% end %> <%= case @result.type do %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/search/results.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/search/results.html.eex index 4b634d8fd4..bb6891c818 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/search/results.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/search/results.html.eex @@ -24,6 +24,9 @@
 
+ +
 
+
Search Result
@@ -36,7 +39,7 @@ - <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 4 %> + <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 5 %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex index e0c1d8592d..582b918e95 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex @@ -5,7 +5,7 @@ <%= @index %> - + <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> <% chain_id_for_token_icon = System.get_env("CHAIN_ID") %> <% foreign_token_contract_address_hash = nil %> @@ -16,6 +16,8 @@ chain_id: chain_id_for_token_icon, address: token_hash_for_token_icon %> + + <% end %> <% token = token_display_name(@token) %> <%= link(token, diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/_token_icon.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/_token_icon.html.eex index 4cc2883e9e..fa9dc4cc16 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/_token_icon.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/_token_icon.html.eex @@ -1,2 +1,2 @@ <% token_icon_url = Explorer.Chain.get_token_icon_url_by(@chain_id, @address) %> - \ No newline at end of file + \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex index 266f613659..52fa1300ba 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex @@ -24,6 +24,9 @@
 
+ +
 
+
Token
@@ -43,7 +46,7 @@ - <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 5 %> + <%= render BlockScoutWeb.CommonComponentsView, "_table-loader.html", columns_num: 6 %>
diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_token_balance_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_token_balance_view.ex index f8299ed2d3..252a9fb82a 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_token_balance_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_token_balance_view.ex @@ -3,6 +3,7 @@ defmodule BlockScoutWeb.AddressTokenBalanceView do alias BlockScoutWeb.AccessHelpers alias Explorer.Chain + alias Explorer.Chain.Address alias Explorer.Counters.AddressTokenUsdSum def tokens_count_title(token_balances) do diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 24c2573c7f..41599db1e6 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -6,7 +6,7 @@ msgstr[0] "" msgstr[1] "" #, elixir-format -#: lib/block_scout_web/views/address_token_balance_view.ex:9 +#: lib/block_scout_web/views/address_token_balance_view.ex:10 msgid "%{count} token" msgid_plural "%{count} tokens" msgstr[0] "" @@ -2088,7 +2088,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:30 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:50 lib/block_scout_web/templates/address_logs/index.html.eex:23 -#: lib/block_scout_web/templates/address_token/index.html.eex:57 lib/block_scout_web/templates/address_token_transfer/index.html.eex:58 +#: lib/block_scout_web/templates/address_token/index.html.eex:60 lib/block_scout_web/templates/address_token_transfer/index.html.eex:58 #: lib/block_scout_web/templates/address_transaction/index.html.eex:50 lib/block_scout_web/templates/address_validation/index.html.eex:20 #: lib/block_scout_web/templates/block_transaction/index.html.eex:22 lib/block_scout_web/templates/chain/show.html.eex:180 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:18 lib/block_scout_web/templates/stakes/_table.html.eex:49 @@ -2400,7 +2400,7 @@ msgid "There are no token transfers for this transaction" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token/index.html.eex:62 +#: lib/block_scout_web/templates/address_token/index.html.eex:65 msgid "There are no tokens for this address." 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 24c2573c7f..41599db1e6 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 @@ -6,7 +6,7 @@ msgstr[0] "" msgstr[1] "" #, elixir-format -#: lib/block_scout_web/views/address_token_balance_view.ex:9 +#: lib/block_scout_web/views/address_token_balance_view.ex:10 msgid "%{count} token" msgid_plural "%{count} tokens" msgstr[0] "" @@ -2088,7 +2088,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:30 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:50 lib/block_scout_web/templates/address_logs/index.html.eex:23 -#: lib/block_scout_web/templates/address_token/index.html.eex:57 lib/block_scout_web/templates/address_token_transfer/index.html.eex:58 +#: lib/block_scout_web/templates/address_token/index.html.eex:60 lib/block_scout_web/templates/address_token_transfer/index.html.eex:58 #: lib/block_scout_web/templates/address_transaction/index.html.eex:50 lib/block_scout_web/templates/address_validation/index.html.eex:20 #: lib/block_scout_web/templates/block_transaction/index.html.eex:22 lib/block_scout_web/templates/chain/show.html.eex:180 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:18 lib/block_scout_web/templates/stakes/_table.html.eex:49 @@ -2400,7 +2400,7 @@ msgid "There are no token transfers for this transaction" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token/index.html.eex:62 +#: lib/block_scout_web/templates/address_token/index.html.eex:65 msgid "There are no tokens for this address." msgstr ""