Merge pull request #2118 from poanetwork/ab-show-only-the-last-decompiled-version

show only the last decompiled contract
pull/2179/head
Victor Baranov 6 years ago committed by GitHub
commit acd11f03ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 7
      apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex
  3. 6
      apps/block_scout_web/lib/block_scout_web/views/address_decompiled_contract_view.ex
  4. 11
      apps/block_scout_web/priv/gettext/default.pot
  5. 13
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 8
      apps/block_scout_web/test/block_scout_web/views/address_decompiled_contract_view_test.exs

@ -29,6 +29,7 @@
### Chore
- [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version
- [#2118](https://github.com/poanetwork/blockscout/pull/2118) - show only the last decompiled contract
### Chore

@ -2,7 +2,8 @@
<%= render BlockScoutWeb.AddressView, "overview.html", assigns %>
<div class="card">
<%= render BlockScoutWeb.AddressView, "_tabs.html", assigns %>
<%= for contract <- sort_contracts_by_version(@address.decompiled_smart_contracts) do %>
<% contract = last_decompiled_contract_version(@address.decompiled_smart_contracts) %>
<%= if contract do %>
<div class="card-body">
<h3><%= gettext "Decompiler version" %></h3>
<div class="tile tile-muted">
@ -21,6 +22,10 @@
</div>
</section>
</div>
<% else %>
<div class="tile tile-muted text-center">
<%= gettext "There is no decompilded contracts for this address." %>
</div>
<% end %>
</div>
</section>

@ -230,10 +230,8 @@ defmodule BlockScoutWeb.AddressDecompiledContractView do
end)
end
def sort_contracts_by_version(decompiled_contracts) do
decompiled_contracts
|> Enum.sort_by(& &1.decompiler_version)
|> Enum.reverse()
def last_decompiled_contract_version(decompiled_contracts) do
Enum.max_by(decompiled_contracts, & &1.decompiler_version)
end
defp add_line_numbers(code) do

@ -1490,7 +1490,7 @@ msgid "EVM Version"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:17
msgid "Copy Decompiled Contract Code"
msgstr ""
@ -1505,12 +1505,12 @@ 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:15
msgid "Decompiled contract code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:7
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:8
msgid "Decompiler version"
msgstr ""
@ -1697,3 +1697,8 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid " Token Transfer"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:27
msgid "There is no decompilded contracts for this address."
msgstr ""

@ -1490,7 +1490,7 @@ msgid "EVM Version"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:17
msgid "Copy Decompiled Contract Code"
msgstr ""
@ -1505,12 +1505,12 @@ 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:15
msgid "Decompiled contract code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:7
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:8
msgid "Decompiler version"
msgstr ""
@ -1693,7 +1693,12 @@ msgstr ""
msgid "New Smart Contract Verification"
msgstr ""
#, elixir-format, fuzzy
#, elixir-format
#: lib/block_scout_web/templates/transaction/overview.html.eex:178
msgid " Token Transfer"
msgstr ""
#, elixir-format, fuzzy
#: lib/block_scout_web/templates/address_decompiled_contract/index.html.eex:27
msgid "There is no decompilded contracts for this address."
msgstr ""

@ -96,15 +96,15 @@ defmodule BlockScoutWeb.AddressDecompiledContractViewTest do
end
end
describe "sort_contracts_by_version/1" do
test "sorts contracts in lexicographical order" do
describe "last_decompiled_contract_version/1" do
test "returns last version" do
contract2 = insert(:decompiled_smart_contract, decompiler_version: "v2")
contract1 = insert(:decompiled_smart_contract, decompiler_version: "v1")
contract3 = insert(:decompiled_smart_contract, decompiler_version: "v3")
result = AddressDecompiledContractView.sort_contracts_by_version([contract2, contract1, contract3])
result = AddressDecompiledContractView.last_decompiled_contract_version([contract2, contract1, contract3])
assert result == [contract3, contract2, contract1]
assert result == contract3
end
end
end

Loading…
Cancel
Save