ERC-1155 finalization

pull/3902/head
Viktor Baranov 4 years ago
parent d8b6f073c1
commit 7148d5f990
  1. 8
      apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex
  2. 1
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_link_to_token_instance.html.eex
  3. 1
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_link_to_token_symbol.html.eex
  4. 20
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_total_transfers.html.eex
  5. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_transfer_token_with_id.html.eex
  6. 2
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  7. 24
      apps/block_scout_web/lib/block_scout_web/views/tokens/helpers.ex
  8. 22
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
  9. 87
      apps/block_scout_web/priv/gettext/default.pot
  10. 87
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  11. 4
      apps/explorer/lib/explorer/chain/address/current_token_balance.ex
  12. 4
      apps/explorer/lib/explorer/chain/address/token_balance.ex
  13. 2
      apps/explorer/lib/explorer/chain/import/runner/address/current_token_balances.ex
  14. 2
      apps/explorer/lib/explorer/chain/import/runner/address/token_balances.ex
  15. 12
      apps/explorer/lib/explorer/chain/token_transfer.ex
  16. 8
      apps/explorer/priv/repo/migrations/20210423084253_address_current_token_balances_add_token_id_to_unique_index.exs
  17. 8
      apps/explorer/priv/repo/migrations/20210423091652_address_token_balances_add_token_id_to_unique_index.exs
  18. 23
      apps/explorer/priv/repo/migrations/20210423094801_address_token_balances_change_unfetched_token_balances_unique_index.exs
  19. 10
      apps/explorer/priv/repo/migrations/20210423115108_extend_token_transfers_for_erc1155.exs
  20. 10
      apps/indexer/lib/indexer/token_balances.ex
  21. 2
      apps/indexer/lib/indexer/transform/token_transfers.ex

@ -10,8 +10,14 @@
data-token-name="<%= token_name(token_balance.token) %>" data-token-name="<%= token_name(token_balance.token) %>"
data-token-symbol="<%= token_balance.token.symbol %>" data-token-symbol="<%= token_balance.token.symbol %>"
> >
<% path = case token_balance.token_type do
"ERC-721" -> token_instance_path(@conn, :show, token_balance.token.contract_address_hash, to_string(token_balance.token_id))
"ERC-1155" -> token_instance_path(@conn, :show, token_balance.token.contract_address_hash, to_string(token_balance.token_id))
_ -> token_path(@conn, :show, to_string(token_balance.token.contract_address_hash))
end
%>
<%= link( <%= link(
to: token_path(@conn, :show, to_string(token_balance.token.contract_address_hash)), to: path,
class: "dropdown-item" class: "dropdown-item"
) do %> ) do %>
<div class="row"> <div class="row">

@ -0,0 +1 @@
<%= "[" %><%= link(short_token_id(@token_id, 30), to: token_instance_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash, to_string(@token_id)), "data-test": "token_link") %><%= "]" %>

@ -0,0 +1 @@
<%= link(token_symbol(@transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash), "data-test": "token_link") %>

@ -1,15 +1,23 @@
<%= case token_transfer_amount(@transfer) do %> <%= case token_transfer_amount(@transfer) do %>
<% {:ok, :erc721_instance} -> %> <% {:ok, :erc721_instance} -> %>
<%= "TokenID ["%><%= link(short_token_id(@transfer.token_id, 30), to: token_instance_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash, to_string(@transfer.token_id)), "data-test": "token_link") %><%= "]" %> <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: @transfer.token_id %>
<% {:ok, :erc1155_instance, value} -> %> <% {:ok, :erc1155_instance, value} -> %>
<% transfer_type = Chain.get_token_transfer_type(@transfer) %> <% transfer_type = Chain.get_token_transfer_type(@transfer) %>
<%= if transfer_type == :token_spawning do %> <%= if transfer_type == :token_spawning do %>
<%= "TokenID ["%><%= link(short_token_id(@transfer.token_id, 30), to: token_instance_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash, to_string(@transfer.token_id)), "data-test": "token_link") %><%= "]" %> <%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: @transfer.token_id %>
<% else %> <% else %>
<%= "#{value} TokenID ["%><%= link(short_token_id(@transfer.token_id, 30), to: token_instance_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash, to_string(@transfer.token_id)), "data-test": "token_link") %><%= "]" %> <%= "#{value} " %>
<%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: @transfer.token_id %>
<% end %>
<% {:ok, :erc1155_instance, values, token_ids, _decimals} -> %>
<% values_ids = Enum.zip(values, token_ids) %>
<%= for {value, token_id} <- values_ids do %>
<div>
<%= "#{value} "%>
<%= render BlockScoutWeb.TransactionView, "_transfer_token_with_id.html", transfer: @transfer, token_id: token_id %>
</div>
<% end %> <% end %>
<% {:ok, value} -> %> <% {:ok, value} -> %>
<%= value %> <%= value %>
<% end %> <%= " " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_symbol.html", transfer: @transfer %>
<%= " " %> <% end %>
<%= link(token_symbol(@transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @transfer.token.contract_address_hash), "data-test": "token_link") %>

@ -0,0 +1,2 @@
<%= "TokenID " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_instance.html", transfer: @transfer, token_id: @token_id %>
<%= " " %><%= render BlockScoutWeb.TransactionView, "_link_to_token_symbol.html", transfer: @transfer %>

@ -406,6 +406,8 @@ defmodule BlockScoutWeb.AddressView do
short_string(token_id, max_length) short_string(token_id, max_length)
end end
def short_string(nil, _max_length), do: ""
def short_string(name, max_length) do def short_string(name, max_length) do
part_length = Kernel.trunc(max_length / 4) part_length = Kernel.trunc(max_length / 4)

@ -16,31 +16,39 @@ defmodule BlockScoutWeb.Tokens.Helpers do
When the token's type is ERC-721, the function will return a string with the token_id that When the token's type is ERC-721, the function will return a string with the token_id that
represents the ERC-721 token since this kind of token doesn't have amount and decimals. represents the ERC-721 token since this kind of token doesn't have amount and decimals.
""" """
def token_transfer_amount(%{token: token, amount: amount, amounts: amounts, token_id: token_id, token_ids: token_ids}) do
do_token_transfer_amount(token, amount, amounts, token_id, token_ids)
end
def token_transfer_amount(%{token: token, amount: amount, token_id: token_id}) do def token_transfer_amount(%{token: token, amount: amount, token_id: token_id}) do
do_token_transfer_amount(token, amount, token_id) do_token_transfer_amount(token, amount, nil, token_id, nil)
end end
defp do_token_transfer_amount(%Token{type: "ERC-20"}, nil, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20"}, nil, nil, _token_id, _token_ids) do
{:ok, "--"} {:ok, "--"}
end end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: nil}, amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: nil}, amount, _amounts, _token_id, _token_ids) do
{:ok, CurrencyHelpers.format_according_to_decimals(amount, Decimal.new(0))} {:ok, CurrencyHelpers.format_according_to_decimals(amount, Decimal.new(0))}
end end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: decimals}, amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: decimals}, amount, _amounts, _token_id, _token_ids) do
{:ok, CurrencyHelpers.format_according_to_decimals(amount, decimals)} {:ok, CurrencyHelpers.format_according_to_decimals(amount, decimals)}
end end
defp do_token_transfer_amount(%Token{type: "ERC-721"}, _amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-721"}, _amount, _amounts, _token_id, _token_ids) do
{:ok, :erc721_instance} {:ok, :erc721_instance}
end end
defp do_token_transfer_amount(%Token{type: "ERC-1155", decimals: decimals}, amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-1155", decimals: decimals}, amount, amounts, _token_id, token_ids) do
{:ok, :erc1155_instance, CurrencyHelpers.format_according_to_decimals(amount, decimals)} if amount do
{:ok, :erc1155_instance, CurrencyHelpers.format_according_to_decimals(amount, decimals)}
else
{:ok, :erc1155_instance, amounts, token_ids, decimals}
end
end end
defp do_token_transfer_amount(_token, _amount, _token_id) do defp do_token_transfer_amount(_token, _amount, _amounts, _token_id, _token_ids) do
nil nil
end end

@ -138,11 +138,29 @@ defmodule BlockScoutWeb.TransactionView do
%{transfers: transfers, mintings: mintings, burnings: burnings, creations: creations} %{transfers: transfers, mintings: mintings, burnings: burnings, creations: creations}
end end
defp aggregate_reducer(%{amount: amount} = token_transfer, {acc1, acc2}) when is_nil(amount) do defp aggregate_reducer(%{amount: amount, amounts: amounts} = token_transfer, {acc1, acc2})
when is_nil(amount) and is_nil(amounts) do
new_entry = %{ new_entry = %{
token: token_transfer.token, token: token_transfer.token,
amount: nil, amount: nil,
amounts: [],
token_id: token_transfer.token_id, token_id: token_transfer.token_id,
token_ids: [],
to_address_hash: token_transfer.to_address_hash,
from_address_hash: token_transfer.from_address_hash
}
{acc1, [new_entry | acc2]}
end
defp aggregate_reducer(%{amount: amount, amounts: amounts} = token_transfer, {acc1, acc2})
when is_nil(amount) and not is_nil(amounts) do
new_entry = %{
token: token_transfer.token,
amount: nil,
amounts: amounts,
token_id: nil,
token_ids: token_transfer.token_ids,
to_address_hash: token_transfer.to_address_hash, to_address_hash: token_transfer.to_address_hash,
from_address_hash: token_transfer.from_address_hash from_address_hash: token_transfer.from_address_hash
} }
@ -154,7 +172,9 @@ defmodule BlockScoutWeb.TransactionView do
new_entry = %{ new_entry = %{
token: token_transfer.token, token: token_transfer.token,
amount: token_transfer.amount, amount: token_transfer.amount,
amounts: [],
token_id: token_transfer.token_id, token_id: token_transfer.token_id,
token_ids: [],
to_address_hash: token_transfer.to_address_hash, to_address_hash: token_transfer.to_address_hash,
from_address_hash: token_transfer.from_address_hash from_address_hash: token_transfer.from_address_hash
} }

@ -59,7 +59,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:262 #: lib/block_scout_web/views/transaction_view.ex:310
msgid "(Awaiting internal transactions for status)" msgid "(Awaiting internal transactions for status)"
msgstr "" msgstr ""
@ -187,7 +187,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/block/_link.html.eex:2 #: lib/block_scout_web/templates/block/_link.html.eex:2
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:28 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:28
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:50 #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:43
msgid "Block #%{number}" msgid "Block #%{number}"
msgstr "" msgstr ""
@ -222,7 +222,7 @@ msgid "Block Number"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:34 #: lib/block_scout_web/views/transaction_view.ex:33
msgid "Block Pending" msgid "Block Pending"
msgstr "" msgstr ""
@ -361,12 +361,12 @@ msgid "Contract Byte Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:351 #: lib/block_scout_web/views/transaction_view.ex:400
msgid "Contract Call" msgid "Contract Call"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:348 #: lib/block_scout_web/views/transaction_view.ex:397
msgid "Contract Creation" msgid "Contract Creation"
msgstr "" msgstr ""
@ -556,12 +556,12 @@ msgid "During times when the network is busy (i.e during ICOs) it can take a whi
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:148 #: lib/block_scout_web/views/transaction_view.ex:195
msgid "ERC-20 " msgid "ERC-20 "
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:149 #: lib/block_scout_web/views/transaction_view.ex:196
msgid "ERC-721 " msgid "ERC-721 "
msgstr "" msgstr ""
@ -621,12 +621,12 @@ msgid "Error trying to fetch balances."
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:266 #: lib/block_scout_web/views/transaction_view.ex:314
msgid "Error: %{reason}" msgid "Error: %{reason}"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:264 #: lib/block_scout_web/views/transaction_view.ex:312
msgid "Error: (Awaiting internal transactions for reason)" msgid "Error: (Awaiting internal transactions for reason)"
msgstr "" msgstr ""
@ -647,7 +647,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20
#: lib/block_scout_web/templates/transaction/_tile.html.eex:33 #: lib/block_scout_web/templates/transaction/_tile.html.eex:33
#: lib/block_scout_web/templates/transaction/overview.html.eex:215 #: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268 #: lib/block_scout_web/templates/transaction/overview.html.eex:279
#: lib/block_scout_web/views/wei_helpers.ex:78 #: lib/block_scout_web/views/wei_helpers.ex:78
msgid "Ether" msgid "Ether"
msgstr "" msgstr ""
@ -777,7 +777,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8
#: lib/block_scout_web/views/transaction_view.ex:263 #: lib/block_scout_web/views/transaction_view.ex:311
msgid "Success" msgid "Success"
msgstr "" msgstr ""
@ -890,9 +890,10 @@ msgid "Token ID"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:12 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:10 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:9
#: lib/block_scout_web/views/transaction_view.ex:344 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:11
#: lib/block_scout_web/views/transaction_view.ex:393
msgid "Token Transfer" msgid "Token Transfer"
msgstr "" msgstr ""
@ -908,7 +909,7 @@ msgstr ""
#: lib/block_scout_web/views/address_view.ex:346 #: lib/block_scout_web/views/address_view.ex:346
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:125 #: lib/block_scout_web/views/tokens/instance/overview_view.ex:125
#: lib/block_scout_web/views/tokens/overview_view.ex:41 #: lib/block_scout_web/views/tokens/overview_view.ex:41
#: lib/block_scout_web/views/transaction_view.ex:405 #: lib/block_scout_web/views/transaction_view.ex:454
msgid "Token Transfers" msgid "Token Transfers"
msgstr "" msgstr ""
@ -923,8 +924,8 @@ msgid "Total Difficulty"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:25 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:18
#: lib/block_scout_web/views/transaction_view.ex:354 #: lib/block_scout_web/views/transaction_view.ex:403
msgid "Transaction" msgid "Transaction"
msgstr "" msgstr ""
@ -1006,7 +1007,7 @@ msgid "License ID"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:296 #: lib/block_scout_web/templates/transaction/overview.html.eex:307
msgid "Limit" msgid "Limit"
msgstr "" msgstr ""
@ -1049,7 +1050,7 @@ msgid "Market Cap"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:243 #: lib/block_scout_web/views/transaction_view.ex:291
msgid "Max of" msgid "Max of"
msgstr "" msgstr ""
@ -1164,8 +1165,8 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:67 #: lib/block_scout_web/templates/layout/_topnav.html.eex:67
#: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:184 #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:184
#: lib/block_scout_web/views/transaction_view.ex:261 #: lib/block_scout_web/views/transaction_view.ex:309
#: lib/block_scout_web/views/transaction_view.ex:295 #: lib/block_scout_web/views/transaction_view.ex:343
msgid "Pending" msgid "Pending"
msgstr "" msgstr ""
@ -1210,7 +1211,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:24 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:24
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7 #: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7
#: lib/block_scout_web/views/transaction_view.ex:408 #: lib/block_scout_web/views/transaction_view.ex:457
msgid "Raw Trace" msgid "Raw Trace"
msgstr "" msgstr ""
@ -1543,7 +1544,7 @@ msgid "Use the search box to find a hosted network, or select from the list of a
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:290 #: lib/block_scout_web/templates/transaction/overview.html.eex:301
msgid "Used" msgid "Used"
msgstr "" msgstr ""
@ -1574,7 +1575,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:215 #: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268 #: lib/block_scout_web/templates/transaction/overview.html.eex:279
msgid "Value" msgid "Value"
msgstr "" msgstr ""
@ -1755,7 +1756,7 @@ msgid "Decimals"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:286 #: lib/block_scout_web/templates/transaction/overview.html.eex:297
msgid "Gas" msgid "Gas"
msgstr "" msgstr ""
@ -1841,7 +1842,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:344 #: lib/block_scout_web/views/address_view.ex:344
#: lib/block_scout_web/views/transaction_view.ex:406 #: lib/block_scout_web/views/transaction_view.ex:455
msgid "Internal Transactions" msgid "Internal Transactions"
msgstr "" msgstr ""
@ -1851,7 +1852,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 #: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:355 #: lib/block_scout_web/views/address_view.ex:355
#: lib/block_scout_web/views/transaction_view.ex:407 #: lib/block_scout_web/views/transaction_view.ex:456
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
@ -1886,26 +1887,26 @@ msgid "Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:252 #: lib/block_scout_web/templates/transaction/overview.html.eex:250
msgid " Token Burning" msgid " Token Burning"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:8 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:6 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:3
#: lib/block_scout_web/views/transaction_view.ex:343 #: lib/block_scout_web/views/transaction_view.ex:391
msgid "Token Burning" msgid "Token Burning"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:241 #: lib/block_scout_web/templates/transaction/overview.html.eex:240
msgid " Token Minting" msgid " Token Minting"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:10 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:8 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:5
#: lib/block_scout_web/views/transaction_view.ex:342 #: lib/block_scout_web/views/transaction_view.ex:390
msgid "Token Minting" msgid "Token Minting"
msgstr "" msgstr ""
@ -2786,6 +2787,16 @@ msgstr ""
msgid "Next" msgid "Next"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:261
msgid " Token Creation"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:197
msgid "ERC-1155 "
msgstr ""
#, elixir-format #, elixir-format
#: #:
#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:23 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:23
@ -2801,3 +2812,9 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract/index.html.eex:31 #: lib/block_scout_web/templates/address_contract/index.html.eex:31
msgid "This contract has been verified via Sourcify." msgid "This contract has been verified via Sourcify."
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:7
#: lib/block_scout_web/views/transaction_view.ex:392
msgid "Token Creation"
msgstr ""

@ -59,7 +59,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:262 #: lib/block_scout_web/views/transaction_view.ex:310
msgid "(Awaiting internal transactions for status)" msgid "(Awaiting internal transactions for status)"
msgstr "" msgstr ""
@ -187,7 +187,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/block/_link.html.eex:2 #: lib/block_scout_web/templates/block/_link.html.eex:2
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:28 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:28
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:50 #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:43
msgid "Block #%{number}" msgid "Block #%{number}"
msgstr "" msgstr ""
@ -222,7 +222,7 @@ msgid "Block Number"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:34 #: lib/block_scout_web/views/transaction_view.ex:33
msgid "Block Pending" msgid "Block Pending"
msgstr "" msgstr ""
@ -361,12 +361,12 @@ msgid "Contract Byte Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:351 #: lib/block_scout_web/views/transaction_view.ex:400
msgid "Contract Call" msgid "Contract Call"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:348 #: lib/block_scout_web/views/transaction_view.ex:397
msgid "Contract Creation" msgid "Contract Creation"
msgstr "" msgstr ""
@ -556,12 +556,12 @@ msgid "During times when the network is busy (i.e during ICOs) it can take a whi
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:148 #: lib/block_scout_web/views/transaction_view.ex:195
msgid "ERC-20 " msgid "ERC-20 "
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:149 #: lib/block_scout_web/views/transaction_view.ex:196
msgid "ERC-721 " msgid "ERC-721 "
msgstr "" msgstr ""
@ -621,12 +621,12 @@ msgid "Error trying to fetch balances."
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:266 #: lib/block_scout_web/views/transaction_view.ex:314
msgid "Error: %{reason}" msgid "Error: %{reason}"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:264 #: lib/block_scout_web/views/transaction_view.ex:312
msgid "Error: (Awaiting internal transactions for reason)" msgid "Error: (Awaiting internal transactions for reason)"
msgstr "" msgstr ""
@ -647,7 +647,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20
#: lib/block_scout_web/templates/transaction/_tile.html.eex:33 #: lib/block_scout_web/templates/transaction/_tile.html.eex:33
#: lib/block_scout_web/templates/transaction/overview.html.eex:215 #: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268 #: lib/block_scout_web/templates/transaction/overview.html.eex:279
#: lib/block_scout_web/views/wei_helpers.ex:78 #: lib/block_scout_web/views/wei_helpers.ex:78
msgid "Ether" msgid "Ether"
msgstr "" msgstr ""
@ -777,7 +777,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8
#: lib/block_scout_web/views/transaction_view.ex:263 #: lib/block_scout_web/views/transaction_view.ex:311
msgid "Success" msgid "Success"
msgstr "" msgstr ""
@ -890,9 +890,10 @@ msgid "Token ID"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:12 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:10 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:9
#: lib/block_scout_web/views/transaction_view.ex:344 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:11
#: lib/block_scout_web/views/transaction_view.ex:393
msgid "Token Transfer" msgid "Token Transfer"
msgstr "" msgstr ""
@ -908,7 +909,7 @@ msgstr ""
#: lib/block_scout_web/views/address_view.ex:346 #: lib/block_scout_web/views/address_view.ex:346
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:125 #: lib/block_scout_web/views/tokens/instance/overview_view.ex:125
#: lib/block_scout_web/views/tokens/overview_view.ex:41 #: lib/block_scout_web/views/tokens/overview_view.ex:41
#: lib/block_scout_web/views/transaction_view.ex:405 #: lib/block_scout_web/views/transaction_view.ex:454
msgid "Token Transfers" msgid "Token Transfers"
msgstr "" msgstr ""
@ -923,8 +924,8 @@ msgid "Total Difficulty"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:25 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:18
#: lib/block_scout_web/views/transaction_view.ex:354 #: lib/block_scout_web/views/transaction_view.ex:403
msgid "Transaction" msgid "Transaction"
msgstr "" msgstr ""
@ -1006,7 +1007,7 @@ msgid "License ID"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:296 #: lib/block_scout_web/templates/transaction/overview.html.eex:307
msgid "Limit" msgid "Limit"
msgstr "" msgstr ""
@ -1049,7 +1050,7 @@ msgid "Market Cap"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:243 #: lib/block_scout_web/views/transaction_view.ex:291
msgid "Max of" msgid "Max of"
msgstr "" msgstr ""
@ -1164,8 +1165,8 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:67 #: lib/block_scout_web/templates/layout/_topnav.html.eex:67
#: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:184 #: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:184
#: lib/block_scout_web/views/transaction_view.ex:261 #: lib/block_scout_web/views/transaction_view.ex:309
#: lib/block_scout_web/views/transaction_view.ex:295 #: lib/block_scout_web/views/transaction_view.ex:343
msgid "Pending" msgid "Pending"
msgstr "" msgstr ""
@ -1210,7 +1211,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:24 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:24
#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7 #: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7
#: lib/block_scout_web/views/transaction_view.ex:408 #: lib/block_scout_web/views/transaction_view.ex:457
msgid "Raw Trace" msgid "Raw Trace"
msgstr "" msgstr ""
@ -1543,7 +1544,7 @@ msgid "Use the search box to find a hosted network, or select from the list of a
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:290 #: lib/block_scout_web/templates/transaction/overview.html.eex:301
msgid "Used" msgid "Used"
msgstr "" msgstr ""
@ -1574,7 +1575,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:215 #: lib/block_scout_web/templates/transaction/overview.html.eex:215
#: lib/block_scout_web/templates/transaction/overview.html.eex:268 #: lib/block_scout_web/templates/transaction/overview.html.eex:279
msgid "Value" msgid "Value"
msgstr "" msgstr ""
@ -1755,7 +1756,7 @@ msgid "Decimals"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:286 #: lib/block_scout_web/templates/transaction/overview.html.eex:297
msgid "Gas" msgid "Gas"
msgstr "" msgstr ""
@ -1841,7 +1842,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6
#: lib/block_scout_web/views/address_view.ex:344 #: lib/block_scout_web/views/address_view.ex:344
#: lib/block_scout_web/views/transaction_view.ex:406 #: lib/block_scout_web/views/transaction_view.ex:455
msgid "Internal Transactions" msgid "Internal Transactions"
msgstr "" msgstr ""
@ -1851,7 +1852,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:17 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:17
#: lib/block_scout_web/templates/transaction_log/index.html.eex:8 #: lib/block_scout_web/templates/transaction_log/index.html.eex:8
#: lib/block_scout_web/views/address_view.ex:355 #: lib/block_scout_web/views/address_view.ex:355
#: lib/block_scout_web/views/transaction_view.ex:407 #: lib/block_scout_web/views/transaction_view.ex:456
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
@ -1886,26 +1887,26 @@ msgid "Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:252 #: lib/block_scout_web/templates/transaction/overview.html.eex:250
msgid " Token Burning" msgid " Token Burning"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:8 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:6 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:3
#: lib/block_scout_web/views/transaction_view.ex:343 #: lib/block_scout_web/views/transaction_view.ex:391
msgid "Token Burning" msgid "Token Burning"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:241 #: lib/block_scout_web/templates/transaction/overview.html.eex:240
msgid " Token Minting" msgid " Token Minting"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:10 #:
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:8 #: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:5
#: lib/block_scout_web/views/transaction_view.ex:342 #: lib/block_scout_web/views/transaction_view.ex:390
msgid "Token Minting" msgid "Token Minting"
msgstr "" msgstr ""
@ -2786,6 +2787,16 @@ msgstr ""
msgid "Next" msgid "Next"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:261
msgid " Token Creation"
msgstr ""
#, elixir-format, fuzzy
#: lib/block_scout_web/views/transaction_view.ex:197
msgid "ERC-1155 "
msgstr ""
#, elixir-format #, elixir-format
#: #:
#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:23 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:23
@ -2801,3 +2812,9 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract/index.html.eex:31 #: lib/block_scout_web/templates/address_contract/index.html.eex:31
msgid "This contract has been verified via Sourcify." msgid "This contract has been verified via Sourcify."
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/common_components/_token_transfer_type_display_name.html.eex:7
#: lib/block_scout_web/views/transaction_view.ex:392
msgid "Token Creation"
msgstr ""

@ -34,7 +34,9 @@ defmodule Explorer.Chain.Address.CurrentTokenBalance do
block_number: Block.block_number(), block_number: Block.block_number(),
inserted_at: DateTime.t(), inserted_at: DateTime.t(),
updated_at: DateTime.t(), updated_at: DateTime.t(),
value: Decimal.t() | nil value: Decimal.t() | nil,
token_id: non_neg_integer() | nil,
token_type: String.t()
} }
schema "address_current_token_balances" do schema "address_current_token_balances" do

@ -34,7 +34,9 @@ defmodule Explorer.Chain.Address.TokenBalance do
block_number: Block.block_number(), block_number: Block.block_number(),
inserted_at: DateTime.t(), inserted_at: DateTime.t(),
updated_at: DateTime.t(), updated_at: DateTime.t(),
value: Decimal.t() | nil value: Decimal.t() | nil,
token_id: non_neg_integer() | nil,
token_type: String.t()
} }
schema "address_token_balances" do schema "address_token_balances" do

@ -206,7 +206,7 @@ defmodule Explorer.Chain.Import.Runner.Address.CurrentTokenBalances do
Import.insert_changes_list( Import.insert_changes_list(
repo, repo,
ordered_changes_list, ordered_changes_list,
conflict_target: ~w(address_hash token_contract_address_hash)a, conflict_target: ~w(address_hash token_contract_address_hash token_id)a,
on_conflict: on_conflict, on_conflict: on_conflict,
for: CurrentTokenBalance, for: CurrentTokenBalance,
returning: true, returning: true,

@ -67,7 +67,7 @@ defmodule Explorer.Chain.Import.Runner.Address.TokenBalances do
Import.insert_changes_list( Import.insert_changes_list(
repo, repo,
ordered_changes_list, ordered_changes_list,
conflict_target: ~w(address_hash token_contract_address_hash block_number)a, conflict_target: ~w(address_hash token_contract_address_hash token_id block_number)a,
on_conflict: on_conflict, on_conflict: on_conflict,
for: TokenBalance, for: TokenBalance,
returning: true, returning: true,

@ -47,9 +47,11 @@ defmodule Explorer.Chain.TokenTransfer do
* `:transaction` - The `t:Explorer.Chain.Transaction.t/0` ledger * `:transaction` - The `t:Explorer.Chain.Transaction.t/0` ledger
* `:transaction_hash` - Transaction foreign key * `:transaction_hash` - Transaction foreign key
* `:log_index` - Index of the corresponding `t:Explorer.Chain.Log.t/0` in the transaction. * `:log_index` - Index of the corresponding `t:Explorer.Chain.Log.t/0` in the transaction.
* `:amounts` - Tokens transferred amounts in case of batched transfer in ERC-1155
* `:token_ids` - IDs of the tokens (applicable to ERC-1155 tokens)
""" """
@type t :: %TokenTransfer{ @type t :: %TokenTransfer{
amount: Decimal.t(), amount: Decimal.t() | nil,
block_number: non_neg_integer() | nil, block_number: non_neg_integer() | nil,
block_hash: Hash.Full.t(), block_hash: Hash.Full.t(),
from_address: %Ecto.Association.NotLoaded{} | Address.t(), from_address: %Ecto.Association.NotLoaded{} | Address.t(),
@ -61,7 +63,9 @@ defmodule Explorer.Chain.TokenTransfer do
token_id: non_neg_integer() | nil, token_id: non_neg_integer() | nil,
transaction: %Ecto.Association.NotLoaded{} | Transaction.t(), transaction: %Ecto.Association.NotLoaded{} | Transaction.t(),
transaction_hash: Hash.Full.t(), transaction_hash: Hash.Full.t(),
log_index: non_neg_integer() log_index: non_neg_integer(),
amounts: [Decimal.t()] | nil,
token_ids: [non_neg_integer()] | nil
} }
@typep paging_options :: {:paging_options, PagingOptions.t()} @typep paging_options :: {:paging_options, PagingOptions.t()}
@ -78,6 +82,8 @@ defmodule Explorer.Chain.TokenTransfer do
field(:block_number, :integer) field(:block_number, :integer)
field(:log_index, :integer, primary_key: true) field(:log_index, :integer, primary_key: true)
field(:token_id, :decimal) field(:token_id, :decimal)
field(:amounts, {:array, :decimal})
field(:token_ids, {:array, :decimal})
belongs_to(:from_address, Address, foreign_key: :from_address_hash, references: :hash, type: Hash.Address) belongs_to(:from_address, Address, foreign_key: :from_address_hash, references: :hash, type: Hash.Address)
belongs_to(:to_address, Address, foreign_key: :to_address_hash, references: :hash, type: Hash.Address) belongs_to(:to_address, Address, foreign_key: :to_address_hash, references: :hash, type: Hash.Address)
@ -117,7 +123,7 @@ defmodule Explorer.Chain.TokenTransfer do
end end
@required_attrs ~w(block_number log_index from_address_hash to_address_hash token_contract_address_hash transaction_hash block_hash)a @required_attrs ~w(block_number log_index from_address_hash to_address_hash token_contract_address_hash transaction_hash block_hash)a
@optional_attrs ~w(amount token_id)a @optional_attrs ~w(amount token_id amounts token_ids)a
@doc false @doc false
def changeset(%TokenTransfer{} = struct, params \\ %{}) do def changeset(%TokenTransfer{} = struct, params \\ %{}) do

@ -0,0 +1,8 @@
defmodule Explorer.Repo.Migrations.AddressCurrentTokenBalancesAddTokenIdToUniqueIndex do
use Ecto.Migration
def change do
drop(unique_index(:address_current_token_balances, ~w(address_hash token_contract_address_hash)a))
create(unique_index(:address_current_token_balances, ~w(address_hash token_contract_address_hash token_id)a))
end
end

@ -0,0 +1,8 @@
defmodule Explorer.Repo.Migrations.AddressTokenBalancesAddTokenIdToUniqueIndex do
use Ecto.Migration
def change do
drop(unique_index(:address_token_balances, ~w(address_hash token_contract_address_hash block_number)a))
create(unique_index(:address_token_balances, ~w(address_hash token_contract_address_hash token_id block_number)a))
end
end

@ -0,0 +1,23 @@
defmodule Explorer.Repo.Migrations.AddressTokenBalancesChangeUnfetchedTokenBalancesUniqueIndex do
use Ecto.Migration
def change do
drop(
unique_index(
:address_token_balances,
~w(address_hash token_contract_address_hash block_number)a,
name: :unfetched_token_balances,
where: "value_fetched_at IS NULL"
)
)
create(
unique_index(
:address_token_balances,
~w(address_hash token_contract_address_hash token_id block_number)a,
name: :unfetched_token_balances,
where: "value_fetched_at IS NULL"
)
)
end
end

@ -0,0 +1,10 @@
defmodule Explorer.Repo.Migrations.ExtendTokenTransfersForErc1155 do
use Ecto.Migration
def change do
alter table(:token_transfers) do
add(:amounts, {:array, :decimal}, null: true)
add(:token_ids, {:array, :numeric}, precision: 78, scale: 0, null: true)
end
end
end

@ -53,13 +53,17 @@ defmodule Indexer.TokenBalances do
def to_address_current_token_balances(address_token_balances) when is_list(address_token_balances) do def to_address_current_token_balances(address_token_balances) when is_list(address_token_balances) do
address_token_balances address_token_balances
|> Enum.group_by(fn %{address_hash: address_hash, token_contract_address_hash: token_contract_address_hash} -> |> Enum.group_by(fn %{
{address_hash, token_contract_address_hash} address_hash: address_hash,
token_contract_address_hash: token_contract_address_hash,
token_id: token_id
} ->
{address_hash, token_contract_address_hash, token_id}
end) end)
|> Enum.map(fn {_, grouped_address_token_balances} -> |> Enum.map(fn {_, grouped_address_token_balances} ->
Enum.max_by(grouped_address_token_balances, fn %{block_number: block_number} -> block_number end) Enum.max_by(grouped_address_token_balances, fn %{block_number: block_number} -> block_number end)
end) end)
|> Enum.sort_by(&{&1.token_contract_address_hash, &1.address_hash}) |> Enum.sort_by(&{&1.token_contract_address_hash, &1.token_id, &1.address_hash})
end end
defp set_token_balance_value({:ok, balance}, token_balance) do defp set_token_balance_value({:ok, balance}, token_balance) do

@ -187,7 +187,7 @@ defmodule Indexer.Transform.TokenTransfers do
token_type: "ERC-1155", token_type: "ERC-1155",
token_ids: token_ids, token_ids: token_ids,
token_id: nil, token_id: nil,
values: values amounts: values
} }
token = %{ token = %{

Loading…
Cancel
Save