Merge pull request #699 from poanetwork/gsf-easy-navigation-between-token-and-contract

easy navigation between token and contract
pull/610/head
Andrew Cravenho 6 years ago committed by GitHub
commit f813c1bf30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  2. 3
      apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex
  3. 24
      apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex
  4. 3
      apps/block_scout_web/lib/block_scout_web/templates/tokens/read_contract/index.html.eex
  5. 3
      apps/block_scout_web/lib/block_scout_web/templates/tokens/token/show.html.eex
  6. 10
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  7. 87
      apps/block_scout_web/priv/gettext/default.pot
  8. 87
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  9. 15
      apps/block_scout_web/test/block_scout_web/views/address_view_test.exs
  10. 4
      apps/explorer/lib/explorer/chain.ex
  11. 2
      apps/explorer/test/explorer/chain_test.exs

@ -18,31 +18,30 @@
<h1 class="card-title"><%= address_title(@address) %> <%= gettext "Details" %> </h1>
<h3 class="<%= if BlockScoutWeb.AddressView.contract?(@address) do %>contract-address<% end %>" data-test="address_detail_hash"><%= @address.hash %></h3>
<div class="d-flex flex-row flex-md-column justify-content-start text-muted">
<span class="mr-4 mb-md-2"><span data-selector="transaction-count"><%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %></span> <%= gettext "Transactions" %></span>
<div class="d-flex flex-row justify-content-start text-muted mr-4 mb-md-2">
<span class="mr-4 mb-md-2"><span data-selector="transaction-count"><%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %></span> <%= gettext "Transactions" %></span>
<%= if @address.token do %>
<span class="mb-md-2">
<%= link(token_title(@address.token), to: token_path(@conn, :show, @address.hash), "data-test": "token_hash_link" ) %>
</span>
<% end %>
</div>
<%= if contract?(@address) do %>
<span class="mr-4" data-test="address_contract_creator">
<%= gettext "Contract created by" %>
<%= link(
trimmed_hash(@address.contracts_creation_internal_transaction.from_address_hash),
to: address_path(
BlockScoutWeb.Endpoint,
:show,
@address.contracts_creation_internal_transaction.from_address_hash
)
) %>
trimmed_hash(@address.contracts_creation_internal_transaction.from_address_hash),
to: address_path(@conn, :show, @address.contracts_creation_internal_transaction.from_address_hash)
) %>
<%= gettext "at" %>
<%= link(
trimmed_hash(@address.contracts_creation_internal_transaction.transaction_hash),
to: transaction_path(
BlockScoutWeb.Endpoint,
:show,
@address.contracts_creation_internal_transaction.transaction_hash
),
"data-test": "transaction_hash_link"
) %>
trimmed_hash(@address.contracts_creation_internal_transaction.transaction_hash),
to: transaction_path(@conn, :show, @address.contracts_creation_internal_transaction.transaction_hash),
"data-test": "transaction_hash_link"
) %>
</span>
<% end %>
</div>

@ -4,7 +4,8 @@
"_details.html",
token: @token,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders
total_token_holders: @total_token_holders,
conn: @conn
) %>
<section>

@ -25,13 +25,23 @@
<h3><%= to_string(@token.contract_address_hash) %></h3>
<div class="d-flex flex-row justify-content-start text-muted">
<span class="mr-4"> <%= @token.type %> </span>
<span class="mr-4"><%= @total_token_holders %> <%= gettext "addresses" %></span>
<span class="mr-4"><%= @total_token_transfers %> <%= gettext "Transfers" %></span>
<%= if decimals?(@token) do %>
<span class="mr-4"><%= @token.decimals %> <%= gettext "decimals" %></span>
<% end %>
<div class="d-flex flex-column flex-md-row justify-content-start text-muted">
<span class="mr-4 mb-3 mb-md-0">
<%= link to:
address_path(@conn, :show, @token.contract_address_hash),
"data-test": "token_contract_address"
do %>
<%= gettext "View Contract" %>
<% end %>
</span>
<div class="d-flex flex-row justify-content-start text-muted">
<span class="mr-4"> <%= @token.type %> </span>
<span class="mr-4"><%= @total_token_holders %> <%= gettext "addresses" %></span>
<span class="mr-4"><%= @total_token_transfers %> <%= gettext "Transfers" %></span>
<%= if decimals?(@token) do %>
<span class="mr-4"><%= @token.decimals %> <%= gettext "decimals" %></span>
<% end %>
</div>
</div>
</div>
</div>

@ -4,7 +4,8 @@
"_details.html",
token: @token,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders
total_token_holders: @total_token_holders,
conn: @conn
) %>
<section>

@ -4,7 +4,8 @@
"_details.html",
token: @token,
total_token_transfers: @total_token_transfers,
total_token_holders: @total_token_holders
total_token_holders: @total_token_holders,
conn: @conn
) %>
<section>

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressView do
use BlockScoutWeb, :view
alias Explorer.Chain.{Address, Hash, SmartContract, TokenTransfer, Transaction}
alias Explorer.Chain.{Address, Hash, SmartContract, Token, TokenTransfer, Transaction}
@dialyzer :no_match
@ -102,6 +102,14 @@ defmodule BlockScoutWeb.AddressView do
def smart_contract_with_read_only_functions?(%Address{smart_contract: nil}), do: false
def token_title(%Token{name: nil, contract_address_hash: contract_address_hash}) do
contract_address_hash
|> to_string
|> String.slice(0..5)
end
def token_title(%Token{name: name, symbol: symbol}), do: "#{name} (#{symbol})"
def trimmed_hash(%Hash{} = hash) do
string_hash = to_string(hash)
"#{String.slice(string_hash, 0..5)}#{String.slice(string_hash, -6..-1)}"

@ -33,7 +33,7 @@ msgstr ""
msgid "BlockScout"
msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:21
#: lib/block_scout_web/templates/address/overview.html.eex:22
#: lib/block_scout_web/templates/address_contract/index.html.eex:10
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:13
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:62
@ -269,7 +269,7 @@ msgstr ""
msgid "TPM"
msgstr ""
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:86
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:87
msgid "Next Page"
msgstr ""
@ -500,7 +500,7 @@ msgstr ""
#: lib/block_scout_web/templates/block/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:78
#: lib/block_scout_web/templates/tokens/token/show.html.eex:85
#: lib/block_scout_web/templates/tokens/token/show.html.eex:86
#: lib/block_scout_web/templates/transaction/index.html.eex:66
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:72
msgid "Older"
@ -624,10 +624,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:13
#: lib/block_scout_web/templates/address/overview.html.eex:64
#: lib/block_scout_web/templates/address/overview.html.eex:63
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:71
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:81
msgid "QR Code"
msgstr ""
@ -654,12 +654,12 @@ msgid "Contract Call"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:25
#: lib/block_scout_web/templates/address/overview.html.eex:32
msgid "Contract created by"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:35
#: lib/block_scout_web/templates/address/overview.html.eex:38
msgid "at"
msgstr ""
@ -695,12 +695,12 @@ msgstr ""
#: lib/block_scout_web/templates/address_token/index.html.eex:50
#: lib/block_scout_web/templates/address_token/index.html.eex:58
#: lib/block_scout_web/templates/address_transaction/index.html.eex:49
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:26
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:54
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:25
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:51
#: lib/block_scout_web/templates/tokens/token/show.html.eex:26
#: lib/block_scout_web/templates/tokens/token/show.html.eex:54
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:55
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:26
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:52
#: lib/block_scout_web/templates/tokens/token/show.html.eex:27
#: lib/block_scout_web/templates/tokens/token/show.html.eex:55
msgid "Read Contract"
msgstr ""
@ -715,10 +715,10 @@ msgid "Block Height #%{height}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:65
#: lib/block_scout_web/templates/address/overview.html.eex:73
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:80
#: lib/block_scout_web/templates/address/overview.html.eex:64
#: lib/block_scout_web/templates/address/overview.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
msgid "Close"
msgstr ""
@ -761,7 +761,7 @@ msgid "Token Transfer"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:31
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
msgid "Transfers"
msgstr ""
@ -789,7 +789,7 @@ msgstr ""
msgid "Validated Transactions"
msgstr ""
#: lib/block_scout_web/templates/tokens/token/show.html.eex:78
#: lib/block_scout_web/templates/tokens/token/show.html.eex:79
msgid "There are no transfers for this Token."
msgstr ""
@ -799,15 +799,15 @@ msgid "Token Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:48
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:17
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:43
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:46
#: lib/block_scout_web/templates/tokens/token/show.html.eex:17
#: lib/block_scout_web/templates/tokens/token/show.html.eex:45
#: lib/block_scout_web/templates/tokens/token/show.html.eex:48
#: lib/block_scout_web/templates/tokens/token/show.html.eex:69
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:18
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:49
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:18
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:44
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:47
#: lib/block_scout_web/templates/tokens/token/show.html.eex:18
#: lib/block_scout_web/templates/tokens/token/show.html.eex:46
#: lib/block_scout_web/templates/tokens/token/show.html.eex:49
#: lib/block_scout_web/templates/tokens/token/show.html.eex:70
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:12
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:42
#: lib/block_scout_web/templates/transaction_log/index.html.eex:13
@ -820,17 +820,17 @@ msgid "Token Transfers"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:30
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:39
msgid "addresses"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:33
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "decimals"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:44
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:54
msgid "Total Supply"
msgstr ""
@ -846,7 +846,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:52
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:66
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:67
msgid "loading..."
msgstr ""
@ -1076,19 +1076,19 @@ msgid "There are no tokens for this address."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:79
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:80
msgid "There are no holders for this Token."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:34
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:45
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:59
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:70
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:32
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:55
#: lib/block_scout_web/templates/tokens/token/show.html.eex:34
#: lib/block_scout_web/templates/tokens/token/show.html.eex:59
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:35
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:46
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:60
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:71
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:33
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:56
#: lib/block_scout_web/templates/tokens/token/show.html.eex:35
#: lib/block_scout_web/templates/tokens/token/show.html.eex:60
msgid "Token Holders"
msgstr ""
@ -1202,3 +1202,8 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39
msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:34
msgid "View Contract"
msgstr ""

@ -45,7 +45,7 @@ msgstr "Height"
msgid "BlockScout"
msgstr "BlockScout"
#: lib/block_scout_web/templates/address/overview.html.eex:21
#: lib/block_scout_web/templates/address/overview.html.eex:22
#: lib/block_scout_web/templates/address_contract/index.html.eex:10
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:13
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:62
@ -281,7 +281,7 @@ msgstr ""
msgid "TPM"
msgstr ""
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:86
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:87
msgid "Next Page"
msgstr ""
@ -512,7 +512,7 @@ msgstr ""
#: lib/block_scout_web/templates/block/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:78
#: lib/block_scout_web/templates/tokens/token/show.html.eex:85
#: lib/block_scout_web/templates/tokens/token/show.html.eex:86
#: lib/block_scout_web/templates/transaction/index.html.eex:66
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:72
msgid "Older"
@ -636,10 +636,10 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:13
#: lib/block_scout_web/templates/address/overview.html.eex:64
#: lib/block_scout_web/templates/address/overview.html.eex:63
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:13
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:71
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:81
msgid "QR Code"
msgstr ""
@ -666,12 +666,12 @@ msgid "Contract Call"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:25
#: lib/block_scout_web/templates/address/overview.html.eex:32
msgid "Contract created by"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:35
#: lib/block_scout_web/templates/address/overview.html.eex:38
msgid "at"
msgstr ""
@ -707,12 +707,12 @@ msgstr ""
#: lib/block_scout_web/templates/address_token/index.html.eex:50
#: lib/block_scout_web/templates/address_token/index.html.eex:58
#: lib/block_scout_web/templates/address_transaction/index.html.eex:49
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:26
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:54
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:25
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:51
#: lib/block_scout_web/templates/tokens/token/show.html.eex:26
#: lib/block_scout_web/templates/tokens/token/show.html.eex:54
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:55
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:26
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:52
#: lib/block_scout_web/templates/tokens/token/show.html.eex:27
#: lib/block_scout_web/templates/tokens/token/show.html.eex:55
msgid "Read Contract"
msgstr ""
@ -727,10 +727,10 @@ msgid "Block Height #%{height}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:65
#: lib/block_scout_web/templates/address/overview.html.eex:73
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:80
#: lib/block_scout_web/templates/address/overview.html.eex:64
#: lib/block_scout_web/templates/address/overview.html.eex:72
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:82
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
msgid "Close"
msgstr ""
@ -773,7 +773,7 @@ msgid "Token Transfer"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:31
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:40
msgid "Transfers"
msgstr ""
@ -801,7 +801,7 @@ msgstr ""
msgid "Validated Transactions"
msgstr ""
#: lib/block_scout_web/templates/tokens/token/show.html.eex:78
#: lib/block_scout_web/templates/tokens/token/show.html.eex:79
msgid "There are no transfers for this Token."
msgstr ""
@ -811,15 +811,15 @@ msgid "Token Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:48
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:17
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:43
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:46
#: lib/block_scout_web/templates/tokens/token/show.html.eex:17
#: lib/block_scout_web/templates/tokens/token/show.html.eex:45
#: lib/block_scout_web/templates/tokens/token/show.html.eex:48
#: lib/block_scout_web/templates/tokens/token/show.html.eex:69
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:18
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:49
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:18
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:44
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:47
#: lib/block_scout_web/templates/tokens/token/show.html.eex:18
#: lib/block_scout_web/templates/tokens/token/show.html.eex:46
#: lib/block_scout_web/templates/tokens/token/show.html.eex:49
#: lib/block_scout_web/templates/tokens/token/show.html.eex:70
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:12
#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:42
#: lib/block_scout_web/templates/transaction_log/index.html.eex:13
@ -832,17 +832,17 @@ msgid "Token Transfers"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:30
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:39
msgid "addresses"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:33
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "decimals"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:44
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:54
msgid "Total Supply"
msgstr ""
@ -858,7 +858,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:52
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:66
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:67
msgid "loading..."
msgstr ""
@ -1088,19 +1088,19 @@ msgid "There are no tokens for this address."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:79
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:80
msgid "There are no holders for this Token."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:34
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:45
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:59
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:70
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:32
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:55
#: lib/block_scout_web/templates/tokens/token/show.html.eex:34
#: lib/block_scout_web/templates/tokens/token/show.html.eex:59
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:35
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:46
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:60
#: lib/block_scout_web/templates/tokens/holder/index.html.eex:71
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:33
#: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:56
#: lib/block_scout_web/templates/tokens/token/show.html.eex:35
#: lib/block_scout_web/templates/tokens/token/show.html.eex:60
msgid "Token Holders"
msgstr ""
@ -1214,3 +1214,8 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39
msgid "Yes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:34
msgid "View Contract"
msgstr ""

@ -212,4 +212,19 @@ defmodule BlockScoutWeb.AddressViewTest do
refute AddressView.smart_contract_with_read_only_functions?(address)
end
end
describe "token_title/1" do
test "returns the 6 first chars of address hash when token has no name" do
token = insert(:token, name: nil)
expected_hash = to_string(token.contract_address_hash)
assert String.starts_with?(expected_hash, AddressView.token_title(token))
end
test "returns name(symbol) when token has name" do
token = insert(:token, name: "super token money", symbol: "ST$")
assert AddressView.token_title(token) == "super token money (ST$)"
end
end
end

@ -488,7 +488,7 @@ defmodule Explorer.Chain do
query =
from(
address in Address,
preload: [:smart_contract, :contracts_creation_internal_transaction],
preload: [:smart_contract, :contracts_creation_internal_transaction, :token],
where: address.hash == ^hash
)
@ -521,7 +521,7 @@ defmodule Explorer.Chain do
query =
from(
address in Address,
preload: [:smart_contract, :contracts_creation_internal_transaction],
preload: [:smart_contract, :contracts_creation_internal_transaction, :token],
where: address.hash == ^hash and not is_nil(address.contract_code)
)

@ -1627,7 +1627,7 @@ defmodule Explorer.ChainTest do
test "finds an contract address" do
address =
insert(:address, contract_code: Factory.data("contract_code"), smart_contract: nil)
|> Repo.preload(:contracts_creation_internal_transaction)
|> Repo.preload([:contracts_creation_internal_transaction, :token])
response = Chain.find_contract_address(address.hash)

Loading…
Cancel
Save