Address link helper

pull/199/head
jimmay5469 7 years ago
parent 47863044af
commit 95b4594ad8
  1. 2
      apps/explorer/lib/explorer/chain/statistics.ex
  2. 8
      apps/explorer_web/lib/explorer_web/templates/address/_link.html.eex
  3. 14
      apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex
  4. 14
      apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex
  5. 14
      apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex
  6. 7
      apps/explorer_web/lib/explorer_web/templates/chain/_blocks.html.eex
  7. 14
      apps/explorer_web/lib/explorer_web/templates/chain/_transactions.html.eex
  8. 24
      apps/explorer_web/lib/explorer_web/templates/pending_transaction/index.html.eex
  9. 14
      apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex
  10. 14
      apps/explorer_web/lib/explorer_web/templates/transaction/show.html.eex
  11. 4
      apps/explorer_web/lib/explorer_web/views/address_view.ex

@ -110,7 +110,7 @@ defmodule Explorer.Chain.Statistics do
from(
block in Block,
order_by: [desc: block.number],
preload: [:transactions],
preload: [:transactions, :miner],
limit: 5
)

@ -0,0 +1,8 @@
<%= if @address do %>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, @address),
"data-toggle": "tooltip",
"data-placement": "top",
title: @address do %>
<%= @address |> hash |> String.slice(0..3) %> <i class="fas fa-ellipsis-v"></i> <%= @address |> hash |> String.slice(-4..-1) %>
<% end %>
<% end %>

@ -82,20 +82,10 @@
</td>
<td><%= ExplorerWeb.BlockView.age(internal_transaction.transaction.block) %></td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, internal_transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: internal_transaction.from_address.hash do %>
<%= String.slice(internal_transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(internal_transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, internal_transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: internal_transaction.to_address.hash do %>
<%= String.slice(internal_transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(internal_transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %>
</td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction) %></td>
</tr>

@ -87,20 +87,10 @@
</td>
<td><%= transaction.block.timestamp |> Timex.from_now %></td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %></td>
<td><%= ExplorerWeb.TransactionView.fee(transaction) %></td>

@ -157,21 +157,11 @@
<%= transaction.block.timestamp |> Timex.from_now %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<div>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td>
<%= ExplorerWeb.TransactionView.value(transaction) %>

@ -29,12 +29,7 @@
<td><%= block.gas_used |> Cldr.Number.to_string! %></td>
<td>
<i class="fa fa-address-card"></i>
<%= link to: block_path(@conn, :show, @conn.assigns.locale, block.number),
"data-toggle": "tooltip",
"data-placement": "top",
title: block.miner do %>
<%= String.slice(block.miner, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(block.miner, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: block.miner %>
</td>
</tr>
<% end %>

@ -22,21 +22,11 @@
</td>
<td class="">
<i class="fa fa-address-card"></i>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<i class="fa fa-address-card"></i>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> </td>
<td><%= transaction.block.timestamp |> Timex.from_now() %></td>

@ -54,30 +54,10 @@
</td>
<td><%= last_seen(transaction) %></td>
<td>
<% from_address_hash = from_address_hash(transaction) %>
<%= if from_address_hash do %>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<% else %>
<%= gettext "Pending" %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<% to_address_hash = to_address_hash(transaction) %>
<%= if to_address_hash do %>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<% else %>
<%= gettext "Pending" %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -57,20 +57,10 @@
<%= transaction.block.timestamp |> Timex.from_now %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -34,20 +34,10 @@
<tr>
<td><%= transaction.call_type %></td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.from_address.hash do %>
<%= String.slice(transaction.from_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.from_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
</td>
<td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash),
"data-toggle": "tooltip",
"data-placement": "top",
title: transaction.to_address.hash do %>
<%= String.slice(transaction.to_address.hash, 0..3) %> <i class="fas fa-ellipsis-v"></i> <%= String.slice(transaction.to_address.hash, -4..-1) %>
<% end %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
</td>
<td><%= value(transaction, include_label: false) %></td>
<td><%= gas(transaction) %></td>

@ -13,4 +13,8 @@ defmodule ExplorerWeb.AddressView do
def balance(%Address{fetched_balance: balance}) do
format_wei_value(balance, :ether, fractional_digits: 18)
end
def hash(%Address{hash: hash}) do
to_string(hash)
end
end

Loading…
Cancel
Save