add link to token on addresses that are contracts

pull/699/head
Gustavo Santos Ferreira 6 years ago
parent 3e6c1b005d
commit 9d8c4d5089
  1. 3
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  2. 4
      apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex
  3. 23
      apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs

@ -21,6 +21,9 @@
<span class="mr-4 mb-md-2"><span data-selector="transaction-count"><%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %></span> <%= gettext "Transactions" %></span>
<%= if contract?(@address) do %>
<span class="mr-4 mb-md-2">
<%= link(gettext("Token"), to: token_path(BlockScoutWeb.Endpoint, :show, @address.hash), "data-test": "token_hash_link" ) %>
</span>
<span class="mr-4" data-test="address_contract_creator">
<%= gettext "Contract created by" %>
<%= link(

@ -15,6 +15,10 @@ defmodule BlockScoutWeb.AddressPage do
css("[data-test='address_balance']")
end
def token_hash_link do
css("[data-test='token_hash_link']")
end
def contract_creator do
css("[data-test='address_contract_creator']")
end

@ -94,6 +94,29 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
end
end
describe "viewing contract token" do
test "see a link to the token of the contract", %{session: session} do
address = insert(:address)
contract = insert(:address, contract_code: Factory.data("contract_code"))
transaction = insert(:transaction, from_address: address, created_contract_address: contract)
internal_transaction =
insert(
:internal_transaction_create,
index: 0,
transaction: transaction,
from_address: address,
created_contract_address: contract
)
insert(:token, contract_address: address)
session
|> AddressPage.visit_page(internal_transaction.created_contract_address)
|> assert_has(AddressPage.token_hash_link())
end
end
describe "viewing transactions" do
test "sees all addresses transactions by default", %{
addresses: addresses,

Loading…
Cancel
Save