Show correct internal transaction type and contract link
pull/315/head
Tim Mecklem 7 years ago committed by GitHub
commit 3e6aab55e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex
  2. 13
      apps/explorer_web/lib/explorer_web/templates/transaction_internal_transaction/index.html.eex
  3. 5
      apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex
  4. 14
      apps/explorer_web/priv/gettext/default.pot
  5. 14
      apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 19
      apps/explorer_web/test/explorer_web/views/internal_transaction_view_test.exs

@ -103,7 +103,18 @@
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> <%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %>
<i class="fas fa-plus-square"></i>
<%= link(
gettext("Contract Creation"),
class: "transaction__link",
"data-address-hash": internal_transaction.created_contract_address_hash,
to: address_path(ExplorerWeb.Endpoint, :show, @locale, internal_transaction.created_contract_address_hash),
title: internal_transaction.created_contract_address_hash
) %>
<% else %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %>
<% end %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>
</tr> </tr>

@ -41,7 +41,18 @@
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %> <%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.from_address %>
</td> </td>
<td> <td>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %> <%= if ExplorerWeb.InternalTransactionView.create?(internal_transaction) do %>
<i class="fas fa-plus-square"></i>
<%= link(
gettext("Contract Creation"),
class: "transaction__link",
"data-address-hash": internal_transaction.created_contract_address_hash,
to: address_path(ExplorerWeb.Endpoint, :show, @locale, internal_transaction.created_contract_address_hash),
title: internal_transaction.created_contract_address_hash
) %>
<% else %>
<%= render ExplorerWeb.AddressView, "_link.html", conn: @conn, address: internal_transaction.to_address %>
<% end %>
</td> </td>
<td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td> <td><%= ExplorerWeb.TransactionView.value(internal_transaction, include_label: false) %></td>
<td><%= ExplorerWeb.TransactionView.gas(internal_transaction) %></td> <td><%= ExplorerWeb.TransactionView.gas(internal_transaction) %></td>

@ -1,4 +1,9 @@
defmodule ExplorerWeb.InternalTransactionView do defmodule ExplorerWeb.InternalTransactionView do
use ExplorerWeb, :view use ExplorerWeb, :view
@dialyzer :no_match @dialyzer :no_match
alias Explorer.Chain.InternalTransaction
def create?(%InternalTransaction{type: :create}), do: true
def create?(_), do: false
end end

@ -355,8 +355,8 @@ msgstr ""
msgid "Search by address, transaction hash, or block number" msgid "Search by address, transaction hash, or block number"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:114 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:125
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:53 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:64
msgid "There are no Internal Transactions" msgid "There are no Internal Transactions"
msgstr "" msgstr ""
@ -504,13 +504,13 @@ msgstr ""
msgid "There are no Transactions" msgid "There are no Transactions"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:120 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:131
#: lib/explorer_web/templates/address_transaction/index.html.eex:139 #: lib/explorer_web/templates/address_transaction/index.html.eex:139
#: lib/explorer_web/templates/block/index.html.eex:60 #: lib/explorer_web/templates/block/index.html.eex:60
#: lib/explorer_web/templates/block_transaction/index.html.eex:200 #: lib/explorer_web/templates/block_transaction/index.html.eex:200
#: lib/explorer_web/templates/pending_transaction/index.html.eex:69 #: lib/explorer_web/templates/pending_transaction/index.html.eex:69
#: lib/explorer_web/templates/transaction/index.html.eex:90 #: lib/explorer_web/templates/transaction/index.html.eex:90
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:60 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:71
msgid "Older" msgid "Older"
msgstr "" msgstr ""
@ -544,3 +544,9 @@ msgstr ""
#: lib/explorer_web/templates/transaction_log/index.html.eex:73 #: lib/explorer_web/templates/transaction_log/index.html.eex:73
msgid "Newer" msgid "Newer"
msgstr "" msgstr ""
#, elixir-format
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:109
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:47
msgid "Contract Creation"
msgstr ""

@ -367,8 +367,8 @@ msgstr ""
msgid "Search by address, transaction hash, or block number" msgid "Search by address, transaction hash, or block number"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:114 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:125
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:53 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:64
msgid "There are no Internal Transactions" msgid "There are no Internal Transactions"
msgstr "" msgstr ""
@ -516,13 +516,13 @@ msgstr ""
msgid "There are no Transactions" msgid "There are no Transactions"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:120 #: lib/explorer_web/templates/address_internal_transaction/index.html.eex:131
#: lib/explorer_web/templates/address_transaction/index.html.eex:139 #: lib/explorer_web/templates/address_transaction/index.html.eex:139
#: lib/explorer_web/templates/block/index.html.eex:60 #: lib/explorer_web/templates/block/index.html.eex:60
#: lib/explorer_web/templates/block_transaction/index.html.eex:200 #: lib/explorer_web/templates/block_transaction/index.html.eex:200
#: lib/explorer_web/templates/pending_transaction/index.html.eex:69 #: lib/explorer_web/templates/pending_transaction/index.html.eex:69
#: lib/explorer_web/templates/transaction/index.html.eex:90 #: lib/explorer_web/templates/transaction/index.html.eex:90
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:60 #: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:71
msgid "Older" msgid "Older"
msgstr "" msgstr ""
@ -556,3 +556,9 @@ msgstr ""
#: lib/explorer_web/templates/transaction_log/index.html.eex:73 #: lib/explorer_web/templates/transaction_log/index.html.eex:73
msgid "Newer" msgid "Newer"
msgstr "" msgstr ""
#, elixir-format
#: lib/explorer_web/templates/address_internal_transaction/index.html.eex:109
#: lib/explorer_web/templates/transaction_internal_transaction/index.html.eex:47
msgid "Contract Creation"
msgstr ""

@ -0,0 +1,19 @@
defmodule ExplorerWeb.InternalTransactionViewTest do
use ExplorerWeb.ConnCase, async: true
alias ExplorerWeb.InternalTransactionView
describe "create?/1" do
test "with internal transaction of type create returns true" do
internal_transaction = build(:internal_transaction_create)
assert InternalTransactionView.create?(internal_transaction)
end
test "with non-create type internal transaction returns false" do
internal_transaction = build(:internal_transaction)
refute InternalTransactionView.create?(internal_transaction)
end
end
end
Loading…
Cancel
Save