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( from(
block in Block, block in Block,
order_by: [desc: block.number], order_by: [desc: block.number],
preload: [:transactions], preload: [:transactions, :miner],
limit: 5 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>
<td><%= ExplorerWeb.BlockView.age(internal_transaction.transaction.block) %></td> <td><%= ExplorerWeb.BlockView.age(internal_transaction.transaction.block) %></td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, internal_transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, internal_transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %>
"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 %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction) %></td>
</tr> </tr>

@ -87,20 +87,10 @@
</td> </td>
<td><%= transaction.block.timestamp |> Timex.from_now %></td> <td><%= transaction.block.timestamp |> Timex.from_now %></td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
"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 %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %></td>
<td><%= ExplorerWeb.TransactionView.fee(transaction) %></td> <td><%= ExplorerWeb.TransactionView.fee(transaction) %></td>

@ -157,21 +157,11 @@
<%= transaction.block.timestamp |> Timex.from_now %> <%= transaction.block.timestamp |> Timex.from_now %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<div> <div>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
"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 %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction) %> <%= ExplorerWeb.TransactionView.value(transaction) %>

@ -29,12 +29,7 @@
<td><%= block.gas_used |> Cldr.Number.to_string! %></td> <td><%= block.gas_used |> Cldr.Number.to_string! %></td>
<td> <td>
<i class="fa fa-address-card"></i> <i class="fa fa-address-card"></i>
<%= link to: block_path(@conn, :show, @conn.assigns.locale, block.number), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: block.miner %>
"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 %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

@ -22,21 +22,11 @@
</td> </td>
<td class=""> <td class="">
<i class="fa fa-address-card"></i> <i class="fa fa-address-card"></i>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<i class="fa fa-address-card"></i> <i class="fa fa-address-card"></i>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
"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 %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> </td> <td><%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> </td>
<td><%= transaction.block.timestamp |> Timex.from_now() %></td> <td><%= transaction.block.timestamp |> Timex.from_now() %></td>

@ -54,30 +54,10 @@
</td> </td>
<td><%= last_seen(transaction) %></td> <td><%= last_seen(transaction) %></td>
<td> <td>
<% from_address_hash = from_address_hash(transaction) %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
<%= 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 %>
</td> </td>
<td> <td>
<% to_address_hash = to_address_hash(transaction) %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
<%= 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 %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -57,20 +57,10 @@
<%= transaction.block.timestamp |> Timex.from_now %> <%= transaction.block.timestamp |> Timex.from_now %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
"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 %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -34,20 +34,10 @@
<tr> <tr>
<td><%= transaction.call_type %></td> <td><%= transaction.call_type %></td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.from_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.from_address %>
"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 %>
</td> </td>
<td> <td>
<%= link to: address_path(@conn, :show, @conn.assigns.locale, transaction.to_address.hash), <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: transaction.to_address %>
"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 %>
</td> </td>
<td><%= value(transaction, include_label: false) %></td> <td><%= value(transaction, include_label: false) %></td>
<td><%= gas(transaction) %></td> <td><%= gas(transaction) %></td>

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

Loading…
Cancel
Save