Merge branch 'master' into master

pull/2261/head
maxgrapps 5 years ago committed by GitHub
commit 97470977db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 12
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  3. 15
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
  4. 60
      apps/block_scout_web/priv/gettext/default.pot
  5. 84
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 33
      apps/explorer/lib/explorer/chain.ex
  7. 4
      apps/explorer/test/explorer/chain_test.exs

@ -6,6 +6,7 @@
- [#2151](https://github.com/poanetwork/blockscout/pull/2151) - hide dropdown menu then other networks list is empty - [#2151](https://github.com/poanetwork/blockscout/pull/2151) - hide dropdown menu then other networks list is empty
- [#2191](https://github.com/poanetwork/blockscout/pull/2191) - allow to configure token metadata update interval - [#2191](https://github.com/poanetwork/blockscout/pull/2191) - allow to configure token metadata update interval
- [#2146](https://github.com/poanetwork/blockscout/pull/2146) - feat: add eth_getLogs rpc endpoint - [#2146](https://github.com/poanetwork/blockscout/pull/2146) - feat: add eth_getLogs rpc endpoint
- [#2190](https://github.com/poanetwork/blockscout/pull/2190) - show all token transfers
- [#2193](https://github.com/poanetwork/blockscout/pull/2193) - feat: add BLOCKSCOUT_HOST, and use it in API docs - [#2193](https://github.com/poanetwork/blockscout/pull/2193) - feat: add BLOCKSCOUT_HOST, and use it in API docs
### Fixes ### Fixes

@ -170,17 +170,21 @@
</div> </div>
<%= case token_transfer_type(@transaction) do %> <%= case token_transfer_type(@transaction) do %>
<% {type, token_transfer} -> %> <% {type, transaction_with_transfers} when is_atom(type) -> %>
<div class="col-md-12 col-lg-4 d-flex flex-column flex-md-row flex-lg-column pl-0"> <div class="col-md-12 col-lg-4 d-flex flex-column flex-md-row flex-lg-column pl-0">
<!-- Value --> <!-- Value -->
<div class="card card-background-1 flex-grow-1"> <div class="card card-background-1 flex-grow-1">
<div class="card-body card-body-flex-column-space-between"> <div class="card-body card-body-flex-column-space-between">
<h2 class="card-title balance-card-title"><%= if type == :erc20, do: gettext("ERC-20"), else: gettext("ERC-721")%><%= gettext " Token Transfer" %></h2> <h2 class="card-title balance-card-title"><%= token_type_name(type)%><%= gettext " Token Transfer" %></h2>
<div class="text-right"> <div class="text-right">
<%= for transfer <- transaction_with_transfers.token_transfers do %>
<h3 class="address-balance-text"> <h3 class="address-balance-text">
<%= token_transfer_amount(token_transfer) %> <%= token_transfer_amount(transfer) %>
<%= link(token_symbol(token_transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, token_transfer.token.contract_address_hash)) %> <%= link(token_symbol(transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, transfer.token.contract_address_hash)) %>
</h3> </h3>
<% end %>
</div> </div>
</div> </div>
</div> </div>

@ -3,7 +3,7 @@ defmodule BlockScoutWeb.TransactionView do
alias BlockScoutWeb.{AddressView, BlockView, TabHelpers} alias BlockScoutWeb.{AddressView, BlockView, TabHelpers}
alias Cldr.Number alias Cldr.Number
alias Explorer.Chain alias Explorer.{Chain, Repo}
alias Explorer.Chain.Block.Reward alias Explorer.Chain.Block.Reward
alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei} alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei}
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
@ -33,7 +33,18 @@ defmodule BlockScoutWeb.TransactionView do
def value_transfer?(_), do: false def value_transfer?(_), do: false
def token_transfer_type(transaction) do def token_transfer_type(transaction) do
Chain.transaction_token_transfer_type(transaction) transaction_with_transfers = Repo.preload(transaction, token_transfers: :token)
type = Chain.transaction_token_transfer_type(transaction)
if type, do: {type, transaction_with_transfers}
end
def token_type_name(type) do
case type do
:erc20 -> gettext("ERC-20 ")
:erc721 -> gettext("ERC-721 ")
:token_transfer -> ""
end
end end
def processing_time_duration(%Transaction{block: nil}) do def processing_time_duration(%Transaction{block: nil}) do

@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:133 #: lib/block_scout_web/views/transaction_view.ex:144
msgid "(Awaiting internal transactions for status)" msgid "(Awaiting internal transactions for status)"
msgstr "" msgstr ""
@ -275,12 +275,12 @@ msgid "Contract Address Pending"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:210 #: lib/block_scout_web/views/transaction_view.ex:221
msgid "Contract Call" msgid "Contract Call"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:209 #: lib/block_scout_web/views/transaction_view.ex:220
msgid "Contract Creation" msgid "Contract Creation"
msgstr "" msgstr ""
@ -363,12 +363,12 @@ msgid "Error trying to fetch balances."
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:137 #: lib/block_scout_web/views/transaction_view.ex:148
msgid "Error: %{reason}" msgid "Error: %{reason}"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:135 #: lib/block_scout_web/views/transaction_view.ex:146
msgid "Error: (Awaiting internal transactions for reason)" msgid "Error: (Awaiting internal transactions for reason)"
msgstr "" msgstr ""
@ -378,7 +378,7 @@ msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:55 #: lib/block_scout_web/templates/layout/app.html.eex:55
#: 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:30 #: lib/block_scout_web/templates/transaction/_tile.html.eex:30
#: lib/block_scout_web/templates/transaction/overview.html.eex:192 #: lib/block_scout_web/templates/transaction/overview.html.eex:196
#: lib/block_scout_web/views/wei_helpers.ex:78 #: lib/block_scout_web/views/wei_helpers.ex:78
msgid "Ether" msgid "Ether"
msgstr "" msgstr ""
@ -473,7 +473,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:306 #: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/transaction_view.ex:263 #: lib/block_scout_web/views/transaction_view.ex:274
msgid "Internal Transactions" msgid "Internal Transactions"
msgstr "" msgstr ""
@ -490,7 +490,7 @@ msgid "Less than"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:220 #: lib/block_scout_web/templates/transaction/overview.html.eex:224
msgid "Limit" msgid "Limit"
msgstr "" msgstr ""
@ -500,7 +500,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:312 #: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/transaction_view.ex:264 #: lib/block_scout_web/views/transaction_view.ex:275
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
@ -512,7 +512,7 @@ msgid "Market Cap"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:118 #: lib/block_scout_web/views/transaction_view.ex:129
msgid "Max of" msgid "Max of"
msgstr "" msgstr ""
@ -602,8 +602,8 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/layout/_topnav.html.eex:44
#: lib/block_scout_web/views/transaction_view.ex:132 #: lib/block_scout_web/views/transaction_view.ex:143
#: lib/block_scout_web/views/transaction_view.ex:166 #: lib/block_scout_web/views/transaction_view.ex:177
msgid "Pending" msgid "Pending"
msgstr "" msgstr ""
@ -690,7 +690,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:134 #: lib/block_scout_web/views/transaction_view.ex:145
msgid "Success" msgid "Success"
msgstr "" msgstr ""
@ -795,7 +795,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5 #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
#: lib/block_scout_web/views/transaction_view.ex:208 #: lib/block_scout_web/views/transaction_view.ex:219
msgid "Token Transfer" msgid "Token Transfer"
msgstr "" msgstr ""
@ -805,7 +805,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/overview_view.ex:35 #: lib/block_scout_web/views/tokens/overview_view.ex:35
#: lib/block_scout_web/views/transaction_view.ex:262 #: lib/block_scout_web/views/transaction_view.ex:273
msgid "Token Transfers" msgid "Token Transfers"
msgstr "" msgstr ""
@ -845,7 +845,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
#: lib/block_scout_web/views/transaction_view.ex:211 #: lib/block_scout_web/views/transaction_view.ex:222
msgid "Transaction" msgid "Transaction"
msgstr "" msgstr ""
@ -907,7 +907,7 @@ msgid "Unique Token"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:214 #: lib/block_scout_web/templates/transaction/overview.html.eex:218
msgid "Used" msgid "Used"
msgstr "" msgstr ""
@ -927,7 +927,7 @@ msgid "Validations"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:192 #: lib/block_scout_web/templates/transaction/overview.html.eex:196
msgid "Value" msgid "Value"
msgstr "" msgstr ""
@ -1520,16 +1520,6 @@ msgstr ""
msgid "Optimization runs" msgid "Optimization runs"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid "ERC-20"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid "ERC-721"
msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/api_docs/index.html.eex:4 #: lib/block_scout_web/templates/api_docs/index.html.eex:4
msgid "API Documentation" msgid "API Documentation"
@ -1546,14 +1536,14 @@ msgid "View All Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:210 #: lib/block_scout_web/templates/transaction/overview.html.eex:214
msgid "Gas" msgid "Gas"
msgstr "" 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:265 #: lib/block_scout_web/views/transaction_view.ex:276
msgid "Raw Trace" msgid "Raw Trace"
msgstr "" msgstr ""
@ -1714,6 +1704,16 @@ msgstr ""
msgid "Anything not in this list is not supported. Click on the method to be taken to the documentation for that method, and check the notes section for any potential differences." msgid "Anything not in this list is not supported. Click on the method to be taken to the documentation for that method, and check the notes section for any potential differences."
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:44
msgid "ERC-20 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:45
msgid "ERC-721 "
msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:4 #: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:4
msgid "ETH RPC API Documentation" msgid "ETH RPC API Documentation"

@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:133 #: lib/block_scout_web/views/transaction_view.ex:144
msgid "(Awaiting internal transactions for status)" msgid "(Awaiting internal transactions for status)"
msgstr "" msgstr ""
@ -105,7 +105,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/index.html.eex:4 #: lib/block_scout_web/templates/address/index.html.eex:4
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:60
msgid "Addresses" msgid "Addresses"
msgstr "" msgstr ""
@ -210,8 +210,8 @@ msgstr ""
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37 #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:37
#: lib/block_scout_web/templates/address/overview.html.eex:144 #: lib/block_scout_web/templates/address/overview.html.eex:144
#: lib/block_scout_web/templates/address/overview.html.eex:152 #: lib/block_scout_web/templates/address/overview.html.eex:152
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:106 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:107
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:114 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:115
msgid "Close" msgid "Close"
msgstr "" msgstr ""
@ -275,12 +275,12 @@ msgid "Contract Address Pending"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:210 #: lib/block_scout_web/views/transaction_view.ex:221
msgid "Contract Call" msgid "Contract Call"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:209 #: lib/block_scout_web/views/transaction_view.ex:220
msgid "Contract Creation" msgid "Contract Creation"
msgstr "" msgstr ""
@ -363,12 +363,12 @@ msgid "Error trying to fetch balances."
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:137 #: lib/block_scout_web/views/transaction_view.ex:148
msgid "Error: %{reason}" msgid "Error: %{reason}"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:135 #: lib/block_scout_web/views/transaction_view.ex:146
msgid "Error: (Awaiting internal transactions for reason)" msgid "Error: (Awaiting internal transactions for reason)"
msgstr "" msgstr ""
@ -378,7 +378,7 @@ msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:55 #: lib/block_scout_web/templates/layout/app.html.eex:55
#: 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:30 #: lib/block_scout_web/templates/transaction/_tile.html.eex:30
#: lib/block_scout_web/templates/transaction/overview.html.eex:192 #: lib/block_scout_web/templates/transaction/overview.html.eex:196
#: lib/block_scout_web/views/wei_helpers.ex:78 #: lib/block_scout_web/views/wei_helpers.ex:78
msgid "Ether" msgid "Ether"
msgstr "POA" msgstr "POA"
@ -473,7 +473,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:306 #: lib/block_scout_web/views/address_view.ex:306
#: lib/block_scout_web/views/transaction_view.ex:263 #: lib/block_scout_web/views/transaction_view.ex:274
msgid "Internal Transactions" msgid "Internal Transactions"
msgstr "" msgstr ""
@ -490,7 +490,7 @@ msgid "Less than"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:220 #: lib/block_scout_web/templates/transaction/overview.html.eex:224
msgid "Limit" msgid "Limit"
msgstr "" msgstr ""
@ -500,7 +500,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:312 #: lib/block_scout_web/views/address_view.ex:312
#: lib/block_scout_web/views/transaction_view.ex:264 #: lib/block_scout_web/views/transaction_view.ex:275
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
@ -512,7 +512,7 @@ msgid "Market Cap"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:118 #: lib/block_scout_web/views/transaction_view.ex:129
msgid "Max of" msgid "Max of"
msgstr "" msgstr ""
@ -602,8 +602,8 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/layout/_topnav.html.eex:44
#: lib/block_scout_web/views/transaction_view.ex:132 #: lib/block_scout_web/views/transaction_view.ex:143
#: lib/block_scout_web/views/transaction_view.ex:166 #: lib/block_scout_web/views/transaction_view.ex:177
msgid "Pending" msgid "Pending"
msgstr "" msgstr ""
@ -626,8 +626,8 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:33 #: lib/block_scout_web/templates/address/overview.html.eex:33
#: lib/block_scout_web/templates/address/overview.html.eex:143 #: lib/block_scout_web/templates/address/overview.html.eex:143
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:35 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:105 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:106
msgid "QR Code" msgid "QR Code"
msgstr "" msgstr ""
@ -684,13 +684,13 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:34 #: lib/block_scout_web/templates/address/overview.html.eex:34
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:37
msgid "Show QR Code" msgid "Show QR Code"
msgstr "" 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:134 #: lib/block_scout_web/views/transaction_view.ex:145
msgid "Success" msgid "Success"
msgstr "" msgstr ""
@ -795,7 +795,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5 #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:5
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
#: lib/block_scout_web/views/transaction_view.ex:208 #: lib/block_scout_web/views/transaction_view.ex:219
msgid "Token Transfer" msgid "Token Transfer"
msgstr "" msgstr ""
@ -805,7 +805,7 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/overview_view.ex:35 #: lib/block_scout_web/views/tokens/overview_view.ex:35
#: lib/block_scout_web/views/transaction_view.ex:262 #: lib/block_scout_web/views/transaction_view.ex:273
msgid "Token Transfers" msgid "Token Transfers"
msgstr "" msgstr ""
@ -834,7 +834,7 @@ msgid "Total Difficulty"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:74 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:75
msgid "Total Supply" msgid "Total Supply"
msgstr "" msgstr ""
@ -845,7 +845,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
#: lib/block_scout_web/views/transaction_view.ex:211 #: lib/block_scout_web/views/transaction_view.ex:222
msgid "Transaction" msgid "Transaction"
msgstr "" msgstr ""
@ -881,7 +881,7 @@ msgid "Transactions sent"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:60 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:61
msgid "Transfers" msgid "Transfers"
msgstr "" msgstr ""
@ -907,7 +907,7 @@ msgid "Unique Token"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:214 #: lib/block_scout_web/templates/transaction/overview.html.eex:218
msgid "Used" msgid "Used"
msgstr "" msgstr ""
@ -927,7 +927,7 @@ msgid "Validations"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:192 #: lib/block_scout_web/templates/transaction/overview.html.eex:196
msgid "Value" msgid "Value"
msgstr "" msgstr ""
@ -943,7 +943,7 @@ msgid "Verify & publish"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:54 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:55
msgid "View Contract" msgid "View Contract"
msgstr "" msgstr ""
@ -1048,7 +1048,7 @@ msgid "Self-Destruct"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:62 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:63
msgid "Decimals" msgid "Decimals"
msgstr "" msgstr ""
@ -1520,16 +1520,6 @@ msgstr ""
msgid "Optimization runs" msgid "Optimization runs"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid "ERC-20"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid "ERC-721"
msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/api_docs/index.html.eex:4 #: lib/block_scout_web/templates/api_docs/index.html.eex:4
msgid "API Documentation" msgid "API Documentation"
@ -1546,14 +1536,14 @@ msgid "View All Transactions"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:210 #: lib/block_scout_web/templates/transaction/overview.html.eex:214
msgid "Gas" msgid "Gas"
msgstr "" 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:265 #: lib/block_scout_web/views/transaction_view.ex:276
msgid "Raw Trace" msgid "Raw Trace"
msgstr "" msgstr ""
@ -1714,7 +1704,17 @@ msgstr ""
msgid "Anything not in this list is not supported. Click on the method to be taken to the documentation for that method, and check the notes section for any potential differences." msgid "Anything not in this list is not supported. Click on the method to be taken to the documentation for that method, and check the notes section for any potential differences."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:44
msgid "ERC-20 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:45
msgid "ERC-721 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:4 #: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:4
msgid "ETH RPC API Documentation" msgid "ETH RPC API Documentation"
msgstr "" msgstr ""
@ -1744,7 +1744,7 @@ msgstr ""
msgid "custom RPC" msgid "custom RPC"
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:9 #: lib/block_scout_web/templates/api_docs/eth_rpc.html.eex:9
msgid "here." msgid "here."
msgstr "" msgstr ""

@ -2923,7 +2923,7 @@ defmodule Explorer.Chain do
end end
@spec transaction_token_transfer_type(Transaction.t()) :: @spec transaction_token_transfer_type(Transaction.t()) ::
{:erc20, TokenTransfer.t()} | {:erc721, TokenTransfer.t()} | nil :erc20 | :erc721 | :token_transfer | nil
def transaction_token_transfer_type( def transaction_token_transfer_type(
%Transaction{ %Transaction{
status: :ok, status: :ok,
@ -2933,8 +2933,19 @@ defmodule Explorer.Chain do
} = transaction } = transaction
) do ) do
zero_wei = %Wei{value: Decimal.new(0)} zero_wei = %Wei{value: Decimal.new(0)}
result = find_token_transfer_type(transaction, input, value)
transaction = Repo.preload(transaction, token_transfers: :token) if is_nil(result) && Enum.count(transaction.token_transfers) > 0 && value == zero_wei,
do: :token_transfer,
else: result
rescue
_ -> nil
end
def transaction_token_transfer_type(_), do: nil
defp find_token_transfer_type(transaction, input, value) do
zero_wei = %Wei{value: Decimal.new(0)}
# https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/ERC721.sol#L35 # https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/ERC721.sol#L35
case {to_string(input), value} do case {to_string(input), value} do
@ -2959,6 +2970,9 @@ defmodule Explorer.Chain do
find_erc721_token_transfer(transaction.token_transfers, {from_address, to_address}) find_erc721_token_transfer(transaction.token_transfers, {from_address, to_address})
{"0xf907fc5b" <> _params, ^zero_wei} ->
:erc20
# check for ERC 20 or for old ERC 721 token versions # check for ERC 20 or for old ERC 721 token versions
{unquote(TokenTransfer.transfer_function_signature()) <> params, ^zero_wei} -> {unquote(TokenTransfer.transfer_function_signature()) <> params, ^zero_wei} ->
types = [:address, {:uint, 256}] types = [:address, {:uint, 256}]
@ -2972,34 +2986,31 @@ defmodule Explorer.Chain do
_ -> _ ->
nil nil
end end
rescue
_ -> nil
end end
def transaction_token_transfer_type(_), do: nil
defp find_erc721_token_transfer(token_transfers, {from_address, to_address}) do defp find_erc721_token_transfer(token_transfers, {from_address, to_address}) do
token_transfer = token_transfer =
Enum.find(token_transfers, fn token_transfer -> Enum.find(token_transfers, fn token_transfer ->
token_transfer.from_address_hash.bytes == from_address && token_transfer.to_address_hash.bytes == to_address token_transfer.from_address_hash.bytes == from_address && token_transfer.to_address_hash.bytes == to_address
end) end)
if token_transfer, do: {:erc721, token_transfer} if token_transfer, do: :erc721
end end
defp find_erc721_or_erc20_token_transfer(token_transfers, {address, decimal_value}) do defp find_erc721_or_erc20_token_transfer(token_transfers, {address, decimal_value}) do
token_transfer = token_transfer =
Enum.find(token_transfers, fn token_transfer -> Enum.find(token_transfers, fn token_transfer ->
token_transfer.to_address_hash.bytes == address && token_transfer.to_address_hash.bytes == address && token_transfer.amount == decimal_value
(token_transfer.amount == decimal_value || token_transfer.token_id)
end) end)
if token_transfer do if token_transfer do
case token_transfer.token do case token_transfer.token do
%Token{type: "ERC-20"} -> {:erc20, token_transfer} %Token{type: "ERC-20"} -> :erc20
%Token{type: "ERC-721"} -> {:erc721, token_transfer} %Token{type: "ERC-721"} -> :erc721
_ -> nil _ -> nil
end end
else
:erc20
end end
end end

@ -3954,7 +3954,7 @@ defmodule Explorer.ChainTest do
insert(:token_transfer, from_address: from_address, to_address: to_address, transaction: transaction) insert(:token_transfer, from_address: from_address, to_address: to_address, transaction: transaction)
assert {:erc721, _found_token_transfer} = Chain.transaction_token_transfer_type(transaction) assert :erc721 = Chain.transaction_token_transfer_type(Repo.preload(transaction, token_transfers: :token))
end end
test "detects erc20 token transfer" do test "detects erc20 token transfer" do
@ -3980,7 +3980,7 @@ defmodule Explorer.ChainTest do
amount: 8_025_000_000_000_000_000_000 amount: 8_025_000_000_000_000_000_000
) )
assert {:erc20, _found_token_transfer} = Chain.transaction_token_transfer_type(transaction) assert :erc20 = Chain.transaction_token_transfer_type(Repo.preload(transaction, token_transfers: :token))
end end
end end

Loading…
Cancel
Save