Add Smart Contract details when verified

pull/182/head
Amanda Sposito 7 years ago
parent 57f6b4d6d1
commit 83994ba38e
  1. 36
      apps/explorer_web/lib/explorer_web/templates/address_contract/index.html.eex
  2. 5
      apps/explorer_web/lib/explorer_web/views/address_contract_view.ex
  3. 5
      apps/explorer_web/mix.exs
  4. 13
      apps/explorer_web/priv/gettext/default.pot
  5. 13
      apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po

@ -35,8 +35,6 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<h2 class="card-title"><%= gettext "Contract bytecode" %></h2>
<%= if !smart_contract_verified?(@address) do %> <%= if !smart_contract_verified?(@address) do %>
<p> <p>
<%= link( <%= link(
@ -48,7 +46,39 @@
</p> </p>
<% end %> <% end %>
<pre class="pre-wrap p-2 bg-light mb-0"> <%= if smart_contract_verified?(@address) do %>
<table class="table">
<tr>
<th>Contract name:</th>
<td><%= @address.smart_contract.name %></td>
</tr>
<tr>
<th>Optimization enabled:</th>
<td><%= format_optimization(@address.smart_contract.optimization) %></td>
</tr>
<tr>
<th>Compiler version:</th>
<td><%= @address.smart_contract.compiler_version %></td>
</tr>
</table>
<h4>Contract source code</h4>
<pre class="p-2 bg-light mb-4">
<code>
<%= text_to_html(@address.smart_contract.contract_source_code, insert_brs: false) %>
</code>
</pre>
<h4>Contract ABI</h4>
<pre class="p-2 bg-light mb-4">
<code>
<%= format_smart_contract_abi(@address.smart_contract.abi) %>
</code>
</pre>
<% end %>
<h4>Contract creation code</h4>
<pre class="pre-wrap p-2 bg-light mb-4">
<code><%= @address.contract_code %></code> <code><%= @address.contract_code %></code>
</pre> </pre>
</div> </div>

@ -2,4 +2,9 @@ defmodule ExplorerWeb.AddressContractView do
use ExplorerWeb, :view use ExplorerWeb, :view
import ExplorerWeb.AddressView, only: [smart_contract_verified?: 1] import ExplorerWeb.AddressView, only: [smart_contract_verified?: 1]
def format_smart_contract_abi(abi), do: Poison.encode!(abi, pretty: true)
def format_optimization(true), do: gettext("true")
def format_optimization(false), do: gettext("false")
end end

@ -96,7 +96,10 @@ defmodule ExplorerWeb.Mixfile do
{:timex_ecto, "~> 3.2.1"}, {:timex_ecto, "~> 3.2.1"},
{:wallaby, "~> 0.20", only: [:test], runtime: false}, {:wallaby, "~> 0.20", only: [:test], runtime: false},
{:qrcode, "~> 0.1.0"}, {:qrcode, "~> 0.1.0"},
{:bypass, "~> 0.8", only: :test} {:bypass, "~> 0.8", only: :test},
# Waiting for the Pretty Print to be implemented at the Jason lib
# https://github.com/michalmuskala/jason/issues/15
{:poison, "~> 3.1"}
] ]
end end

@ -153,7 +153,6 @@ msgstr ""
msgid "%{count} transactions in this block" msgid "%{count} transactions in this block"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address/overview.html.eex:11
#: lib/explorer_web/templates/transaction_log/index.html.eex:29 #: lib/explorer_web/templates/transaction_log/index.html.eex:29
#: lib/explorer_web/views/address_view.ex:17 #: lib/explorer_web/views/address_view.ex:17
msgid "Address" msgid "Address"
@ -499,7 +498,7 @@ msgstr ""
msgid "Contract Address" msgid "Contract Address"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:38 #: lib/explorer_web/templates/address_contract/index.html.eex:39
msgid "Contract bytecode" msgid "Contract bytecode"
msgstr "" msgstr ""
@ -516,10 +515,18 @@ msgstr ""
msgid "Contract Source Code" msgid "Contract Source Code"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:46 #: lib/explorer_web/templates/address_contract/index.html.eex:44
msgid "Verify and Publish" msgid "Verify and Publish"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:27 #: lib/explorer_web/templates/address_contract/index.html.eex:27
msgid "Code" msgid "Code"
msgstr "" msgstr ""
#: lib/explorer_web/views/address_contract_view.ex:12
msgid "false"
msgstr ""
#: lib/explorer_web/views/address_contract_view.ex:11
msgid "true"
msgstr ""

@ -165,7 +165,6 @@ msgstr "%{confirmations} block confirmations"
msgid "%{count} transactions in this block" msgid "%{count} transactions in this block"
msgstr "%{count} transactions in this block" msgstr "%{count} transactions in this block"
#: lib/explorer_web/templates/address/overview.html.eex:11
#: lib/explorer_web/templates/transaction_log/index.html.eex:29 #: lib/explorer_web/templates/transaction_log/index.html.eex:29
#: lib/explorer_web/views/address_view.ex:17 #: lib/explorer_web/views/address_view.ex:17
msgid "Address" msgid "Address"
@ -511,7 +510,7 @@ msgstr ""
msgid "Contract Address" msgid "Contract Address"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:38 #: lib/explorer_web/templates/address_contract/index.html.eex:39
msgid "Contract bytecode" msgid "Contract bytecode"
msgstr "" msgstr ""
@ -528,10 +527,18 @@ msgstr ""
msgid "Contract Source Code" msgid "Contract Source Code"
msgstr "Contract Source Code" msgstr "Contract Source Code"
#: lib/explorer_web/templates/address_contract/index.html.eex:46 #: lib/explorer_web/templates/address_contract/index.html.eex:44
msgid "Verify and Publish" msgid "Verify and Publish"
msgstr "" msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:27 #: lib/explorer_web/templates/address_contract/index.html.eex:27
msgid "Code" msgid "Code"
msgstr "" msgstr ""
#: lib/explorer_web/views/address_contract_view.ex:12
msgid "false"
msgstr "No"
#: lib/explorer_web/views/address_contract_view.ex:11
msgid "true"
msgstr "Yes"

Loading…
Cancel
Save