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. 29
      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 %>
</div>
<div class="card-body">
<section>
<div class="d-flex justify-content-between align-items-baseline">
<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">
<%= gettext "Copy Decompiled Contract Code" %>
</button>
</div>
<%= for {contract, _i} <- Enum.with_index(@address.decompiled_smart_contracts) do %>
<div class="card-body">
<h3><%= gettext "Decompiler version" %></h3>
<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.decompiler_version %></code></pre>
</div>
</section>
</div>
<section>
<div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Decompiled contract code" %></h3>
<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" %>
</button>
</div>
<div class="tile tile-muted">
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= contract.decompiled_source_code %></code></pre>
</div>
</section>
</div>
<% end %>
</div>
</section>

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

@ -1709,7 +1709,7 @@ msgid "Decompiled code"
msgstr ""
#, 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"
msgstr ""
@ -1719,6 +1719,11 @@ msgid "Decompiled Code"
msgstr ""
#, 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"
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 ""
#, 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"
msgstr ""
@ -1719,6 +1719,11 @@ msgid "Decompiled Code"
msgstr ""
#, 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"
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
)
|> with_decompiled_code_flag(hash)
query
query_with_decompiled_flag = with_decompiled_code_flag(query, hash)
query_with_decompiled_flag
|> Repo.one()
|> case do
nil -> {:error, :not_found}
@ -778,9 +779,10 @@ defmodule Explorer.Chain do
],
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
{:ok, address}

Loading…
Cancel
Save