show multiple decompiled contracts

pull/1654/head
Ayrat Badykov 6 years ago
parent 545a88b65e
commit 1e5a1a8ab1
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 11
      apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex
  2. 3
      apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex
  3. 9
      apps/block_scout_web/priv/gettext/default.pot
  4. 9
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  5. 10
      apps/explorer/lib/explorer/chain.ex

@ -6,19 +6,24 @@
<%= render BlockScoutWeb.AddressView, "_tabs.html", assigns %> <%= render BlockScoutWeb.AddressView, "_tabs.html", assigns %>
</div> </div>
<%= for {contract, _i} <- Enum.with_index(@address.decompiled_smart_contracts) do %>
<div class="card-body"> <div class="card-body">
<h3><%= gettext "Decompiler version" %></h3>
<div class="tile tile-muted">
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= contract.decompiler_version %></code></pre>
</div>
<section> <section>
<div class="d-flex justify-content-between align-items-baseline"> <div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Decompiled contract code" %></h3> <h3><%= gettext "Decompiled contract code" %></h3>
<button type="button" class="button button-secondary button-sm" id="button" data-clipboard-text="<%= List.first(@address.decompiled_smart_contracts).decompiled_source_code %>" aria-label="copy decompiled contract code"> <button type="button" class="button button-secondary button-sm" id="button" data-clipboard-text="<%= contract.decompiled_source_code %>" aria-label="copy decompiled contract code">
<%= gettext "Copy Decompiled Contract Code" %> <%= gettext "Copy Decompiled Contract Code" %>
</button> </button>
</div> </div>
<div class="tile tile-muted"> <div class="tile tile-muted">
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= List.first(@address.decompiled_smart_contracts).decompiled_source_code %></code></pre> <pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= contract.decompiled_source_code %></code></pre>
</div> </div>
</section> </section>
</div> </div>
<% end %>
</div> </div>
</section> </section>

@ -0,0 +1,3 @@
defmodule BlockScoutWeb.AddressDecompiledContractView do
use BlockScoutWeb, :view
end

@ -1709,7 +1709,7 @@ msgid "Decompiled code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:14 #: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:19
msgid "Copy Decompiled Contract Code" msgid "Copy Decompiled Contract Code"
msgstr "" msgstr ""
@ -1719,6 +1719,11 @@ msgid "Decompiled Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:17
msgid "Decompiled contract code" msgid "Decompiled contract code"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:11
msgid "Decompiler version"
msgstr ""

@ -1709,7 +1709,7 @@ msgid "Decompiled code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:14 #: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:19
msgid "Copy Decompiled Contract Code" msgid "Copy Decompiled Contract Code"
msgstr "" msgstr ""
@ -1719,6 +1719,11 @@ msgid "Decompiled Code"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:17
msgid "Decompiled contract code" msgid "Decompiled contract code"
msgstr "" msgstr ""
#, elixir-format, fuzzy
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:11
msgid "Decompiler version"
msgstr ""

@ -659,9 +659,10 @@ defmodule Explorer.Chain do
], ],
where: address.hash == ^hash where: address.hash == ^hash
) )
|> with_decompiled_code_flag(hash)
query query_with_decompiled_flag = with_decompiled_code_flag(query, hash)
query_with_decompiled_flag
|> Repo.one() |> Repo.one()
|> case do |> case do
nil -> {:error, :not_found} nil -> {:error, :not_found}
@ -778,9 +779,10 @@ defmodule Explorer.Chain do
], ],
where: address.hash == ^hash and not is_nil(address.contract_code) where: address.hash == ^hash and not is_nil(address.contract_code)
) )
|> with_decompiled_code_flag(hash)
address = Repo.one(query) query_with_decompiled_flag = with_decompiled_code_flag(query, hash)
address = Repo.one(query_with_decompiled_flag)
if address do if address do
{:ok, address} {:ok, address}

Loading…
Cancel
Save