Change how we identify contract creation transactions and update address link helper

Co-authored-by: Stamates <stamates@hotmail.com>
pull/380/head
jimmay5469 6 years ago
parent 5d4fe6824d
commit 7bbd24ffb3
  1. 14
      apps/explorer_web/lib/explorer_web/templates/address/_link.html.eex
  2. 4
      apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex
  3. 4
      apps/explorer_web/lib/explorer_web/templates/address_transaction/_transaction.html.eex
  4. 4
      apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex
  5. 2
      apps/explorer_web/lib/explorer_web/templates/chain/_transactions.html.eex
  6. 4
      apps/explorer_web/lib/explorer_web/templates/pending_transaction/index.html.eex
  7. 4
      apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex
  8. 4
      apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex
  9. 16
      apps/explorer_web/lib/explorer_web/views/transaction_view.ex

@ -1,16 +1,6 @@
<%= if @address do %> <%= if @address_hash do %>
<%= link to: address_path(ExplorerWeb.Endpoint, :show, @locale, @address), "data-address-hash": @address do %>
<%= if contract?(@address) do %>
<span class="tile-label d-none d-md-none d-lg-inline"><%= @address %></span>
<span class="tile-label d-md-block d-lg-none "><%= @address |> hash() |> String.slice(0..5) %>&ndash;<%= @address |> hash() |> String.slice(-6..-1) %></span>
<% else %>
<span class="d-none d-md-none d-lg-inline"> <%= @address %></span>
<span class="d-lg-none"><%= @address |> hash() |> String.slice(0..5) %>&ndash;<%= @address |> hash() |> String.slice(-6..-1) %></span>
<% end %>
<% end %>
<% else %>
<%= link to: address_path(ExplorerWeb.Endpoint, :show, @locale, @address_hash), "data-address-hash": @address_hash do %> <%= link to: address_path(ExplorerWeb.Endpoint, :show, @locale, @address_hash), "data-address-hash": @address_hash do %>
<span class="tile-label d-none d-md-none d-lg-inline"><%= @address_hash %></span> <span class="tile-label d-none d-md-none d-lg-inline"><%= @address_hash %></span>
<span class="tile-label d-lg-none"><%= to_string(@address_hash) |> String.slice(0..5) %>&ndash;<%= to_string(@address_hash) |> String.slice(-6..-1) %></span> <span class="tile-label d-md-block d-lg-none"><%= to_string(@address_hash) |> String.slice(0..5) %>&ndash;<%= to_string(@address_hash) |> String.slice(-6..-1) %></span>
<% end %> <% end %>
<% end %> <% end %>

@ -98,7 +98,7 @@
</td> </td>
<td data-from-now="<%= internal_transaction.transaction.block.timestamp %>"></td> <td data-from-now="<%= internal_transaction.transaction.block.timestamp %>"></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: internal_transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %> <%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %>
@ -111,7 +111,7 @@
title: internal_transaction.created_contract_address_hash title: internal_transaction.created_contract_address_hash
) %> ) %>
<% else %> <% else %>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: internal_transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: internal_transaction.to_address_hash %>
<% end %> <% end %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>

@ -11,13 +11,13 @@
</td> </td>
<td data-from-now="<%= @transaction.block.timestamp %>"></td> <td data-from-now="<%= @transaction.block.timestamp %>"></td>
<td class="address-cell"> <td class="address-cell">
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: @transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: @transaction.from_address_hash %>
</td> </td>
<td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td> <td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td>
<td> <td>
<%= cond do %> <%= cond do %>
<% @transaction.to_address_hash != nil -> %> <% @transaction.to_address_hash != nil -> %>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: @transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: @transaction.to_address_hash %>
<% @transaction.created_contract_address_hash != nil -> %> <% @transaction.created_contract_address_hash != nil -> %>
<i class="fas fa-plus-square"></i> <i class="fas fa-plus-square"></i>
<%= link( <%= link(

@ -162,13 +162,13 @@
</td> </td>
<td data-from-now="<%= transaction.block.timestamp %>"></td> <td data-from-now="<%= transaction.block.timestamp %>"></td>
<td class="address-cell"> <td class="address-cell">
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.from_address_hash %>
</td> </td>
<td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td> <td class="u-text-center"><i class="fas fa-arrow-circle-right"></i></td>
<td> <td>
<%= cond do %> <%= cond do %>
<% transaction.to_address_hash != nil -> %> <% transaction.to_address_hash != nil -> %>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.to_address_hash %>
<% transaction.created_contract_address_hash != nil -> %> <% transaction.created_contract_address_hash != nil -> %>
<i class="fas fa-plus-square"></i> <i class="fas fa-plus-square"></i>
<%= link( <%= link(

@ -11,7 +11,7 @@
<div class="col-md-7 col-lg-8 d-flex flex-column"> <div class="col-md-7 col-lg-8 d-flex flex-column">
<%= render ExplorerWeb.TransactionView, "_link.html", locale: @locale, transaction: transaction %> <%= render ExplorerWeb.TransactionView, "_link.html", locale: @locale, transaction: transaction %>
<span> <span>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.from_address_hash %>
&rarr; &rarr;
<%= render ExplorerWeb.AddressView, "_link.html", Keyword.merge(ExplorerWeb.TransactionView.display_to_address(transaction), locale: @locale) %> <%= render ExplorerWeb.AddressView, "_link.html", Keyword.merge(ExplorerWeb.TransactionView.display_to_address(transaction), locale: @locale) %>
</span> </span>

@ -50,10 +50,10 @@
</td> </td>
<td data-from-now="<%= transaction.updated_at %>"></td> <td data-from-now="<%= transaction.updated_at %>"></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.to_address_hash %>
</td> </td>
<td> <td>
<%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %> <%= ExplorerWeb.TransactionView.value(transaction, include_label: false) %>

@ -58,12 +58,12 @@
</td> </td>
<td data-from-now="<%= transaction.block.timestamp %>"></td> <td data-from-now="<%= transaction.block.timestamp %>"></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= cond do %> <%= cond do %>
<% transaction.to_address_hash != nil -> %> <% transaction.to_address_hash != nil -> %>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: transaction.to_address_hash %>
<% transaction.created_contract_address_hash != nil -> %> <% transaction.created_contract_address_hash != nil -> %>
<%= link( <%= link(
"Contract Creation", "Contract Creation",

@ -38,7 +38,7 @@
<tr> <tr>
<td><%= internal_transaction.type %></td> <td><%= internal_transaction.type %></td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: internal_transaction.from_address_hash %>
</td> </td>
<td> <td>
<%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %> <%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %>
@ -51,7 +51,7 @@
title: internal_transaction.created_contract_address_hash title: internal_transaction.created_contract_address_hash
) %> ) %>
<% else %> <% else %>
<%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address: internal_transaction.to_address %> <%= render ExplorerWeb.AddressView, "_link.html", locale: @locale, address_hash: internal_transaction.to_address_hash %>
<% end %> <% end %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>

@ -3,7 +3,7 @@ defmodule ExplorerWeb.TransactionView do
alias Cldr.Number alias Cldr.Number
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.{InternalTransaction, Transaction, Wei} alias Explorer.Chain.{Address, InternalTransaction, Transaction, Wei}
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
alias ExplorerWeb.{AddressView, BlockView} alias ExplorerWeb.{AddressView, BlockView}
alias ExplorerWeb.ExchangeRates.USD alias ExplorerWeb.ExchangeRates.USD
@ -23,7 +23,7 @@ defmodule ExplorerWeb.TransactionView do
def display_to_address(%Transaction{to_address_hash: nil, created_contract_address_hash: address_hash}), def display_to_address(%Transaction{to_address_hash: nil, created_contract_address_hash: address_hash}),
do: [address: nil, address_hash: address_hash] do: [address: nil, address_hash: address_hash]
def display_to_address(%Transaction{to_address: address}), do: [address: address] def display_to_address(%Transaction{to_address: %Address{hash: address_hash}}), do: [address_hash: address_hash]
def formatted_fee(%Transaction{} = transaction, opts) do def formatted_fee(%Transaction{} = transaction, opts) do
transaction transaction
@ -46,13 +46,9 @@ defmodule ExplorerWeb.TransactionView do
AddressView.contract?(from_address) || AddressView.contract?(to_address) AddressView.contract?(from_address) || AddressView.contract?(to_address)
end end
def involves_contract_creation?(%Transaction{created_contract_address_hash: nil}), do: false def contract_creation?(%Transaction{to_address: nil}), do: true
def involves_contract_creation?(_), do: true def contract_creation?(_), do: false
def contract_creation?(%Transaction{created_contract_address_hash: nil}), do: false
def contract_creation?(_), do: true
def qr_code(%Transaction{hash: hash}) do def qr_code(%Transaction{hash: hash}) do
hash hash
@ -105,7 +101,7 @@ defmodule ExplorerWeb.TransactionView do
def type_suffix(%Transaction{} = transaction) do def type_suffix(%Transaction{} = transaction) do
cond do cond do
involves_contract_creation?(transaction) -> "contract-creation" contract_creation?(transaction) -> "contract-creation"
involves_contract?(transaction) -> "contract" involves_contract?(transaction) -> "contract"
true -> "transaction" true -> "transaction"
end end
@ -113,7 +109,7 @@ defmodule ExplorerWeb.TransactionView do
def transaction_display_type(%Transaction{} = transaction) do def transaction_display_type(%Transaction{} = transaction) do
cond do cond do
involves_contract_creation?(transaction) -> gettext("Contract Creation") contract_creation?(transaction) -> gettext("Contract Creation")
involves_contract?(transaction) -> gettext("Contract") involves_contract?(transaction) -> gettext("Contract")
true -> gettext("Transaction") true -> gettext("Transaction")
end end

Loading…
Cancel
Save