Don't show `IN` or `OUT` when the address ins't in the transaction

pull/417/head
Felipe Renan 6 years ago
parent b6a4e48414
commit 30824949ac
  1. 14
      apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex
  2. 10
      apps/explorer_web/lib/explorer_web/views/address_transaction_view.ex
  3. 4
      apps/explorer_web/test/explorer_web/features/pages/address_page.ex

@ -28,10 +28,16 @@
<% end %>
</span>
<span>
<%= if @address.hash == @transaction.from_address_hash do %>
<span class="badge badge-danger tile-badge"><%= gettext "OUT" %></span>
<% else %>
<span class="badge badge-success tile-badge"><%= gettext "IN" %></span>
<%= if transaction_from_or_to_current_address?(@transaction, @address.hash) do %>
<%= if @transaction.from_address_hash == @address.hash do %>
<span data-test="transaction_type" class="badge badge-danger tile-badge">
<%= gettext "OUT" %>
</span>
<% else %>
<span data-test="transaction_type" class="badge badge-success tile-badge">
<%= gettext "IN" %>
</span>
<% end %>
<% end %>
<span class="ml-1" data-from-now="<%= @transaction.block.timestamp %>"></span>
<span class="ml-1">

@ -11,4 +11,14 @@ defmodule ExplorerWeb.AddressTransactionView do
_ -> gettext("All")
end
end
@doc """
Check if the given address is the to_address_hash or from_address_hash from the transaction.
When the transaction has token transfers, the transaction is going to be shown even when the
transaction is the to or from of the given address.
"""
def transaction_from_or_to_current_address?(transaction, address_hash) do
transaction.from_address_hash == address_hash || transaction.to_address_hash == address_hash
end
end

@ -84,4 +84,8 @@ defmodule ExplorerWeb.AddressPage do
def token_transfer(address_hash, count: count) do
css("[data-test='token_transfer_address_hash']", count: count, text: to_string(address_hash))
end
def transaction_type do
css("[data-test='transaction_type']")
end
end

Loading…
Cancel
Save