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 class="card-body">
<h2 class="card-title"><%= gettext "Contract bytecode" %></h2>
<%= if !smart_contract_verified?(@address) do %>
<p>
<%= link(
@ -48,7 +46,39 @@
</p>
<% 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>
</pre>
</div>

@ -2,4 +2,9 @@ defmodule ExplorerWeb.AddressContractView do
use ExplorerWeb, :view
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

@ -96,7 +96,10 @@ defmodule ExplorerWeb.Mixfile do
{:timex_ecto, "~> 3.2.1"},
{:wallaby, "~> 0.20", only: [:test], runtime: false},
{: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

@ -153,7 +153,6 @@ msgstr ""
msgid "%{count} transactions in this block"
msgstr ""
#: lib/explorer_web/templates/address/overview.html.eex:11
#: lib/explorer_web/templates/transaction_log/index.html.eex:29
#: lib/explorer_web/views/address_view.ex:17
msgid "Address"
@ -499,7 +498,7 @@ msgstr ""
msgid "Contract Address"
msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:38
#: lib/explorer_web/templates/address_contract/index.html.eex:39
msgid "Contract bytecode"
msgstr ""
@ -516,10 +515,18 @@ msgstr ""
msgid "Contract Source Code"
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"
msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:27
msgid "Code"
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"
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/views/address_view.ex:17
msgid "Address"
@ -511,7 +510,7 @@ msgstr ""
msgid "Contract Address"
msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:38
#: lib/explorer_web/templates/address_contract/index.html.eex:39
msgid "Contract bytecode"
msgstr ""
@ -528,10 +527,18 @@ msgstr ""
msgid "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"
msgstr ""
#: lib/explorer_web/templates/address_contract/index.html.eex:27
msgid "Code"
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