From 40b1c7fac0352e691a04bffc05008dee1d297251 Mon Sep 17 00:00:00 2001 From: nikitosing Date: Wed, 25 Aug 2021 15:58:32 +0300 Subject: [PATCH] Remove comment with the submission date from contracts --- .dialyzer-ignore | 4 +- CHANGELOG.md | 1 + .../templates/address_contract/index.html.eex | 22 +++++---- .../views/address_contract_view.ex | 5 +- .../views/api/rpc/contract_view.ex | 2 +- apps/block_scout_web/priv/gettext/default.pot | 47 ++++++++++--------- .../priv/gettext/en/LC_MESSAGES/default.po | 47 ++++++++++--------- .../api/rpc/contract_controller_test.exs | 12 ++--- .../views/address_contract_view_test.exs | 38 +++++++-------- apps/explorer/lib/explorer/chain.ex | 7 +-- 10 files changed, 92 insertions(+), 93 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 973af2f831..af8336a5dd 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -23,8 +23,8 @@ lib/indexer/fetcher/token_total_supply_on_demand.ex:16 lib/explorer/exchange_rates/source.ex:110 lib/explorer/exchange_rates/source.ex:113 lib/explorer/smart_contract/verifier.ex:89 -lib/block_scout_web/templates/address_contract/index.html.eex:150 -lib/block_scout_web/templates/address_contract/index.html.eex:193 +lib/block_scout_web/templates/address_contract/index.html.eex:156 +lib/block_scout_web/templates/address_contract/index.html.eex:199 lib/explorer/staking/stake_snapshotting.ex:15: Function do_snapshotting/7 has no local return lib/explorer/staking/stake_snapshotting.ex:147 lib/explorer/third_party_integrations/sourcify.ex:70 diff --git a/CHANGELOG.md b/CHANGELOG.md index 00eb86217e..4623d1a49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#4569](https://github.com/blockscout/blockscout/pull/4569) - Smart-Contract: remove comment with the submission date - [#4568](https://github.com/blockscout/blockscout/pull/4568) - TX page: Token transfer and minting section improvements - [#4540](https://github.com/blockscout/blockscout/pull/4540) - Allign copy buttons for `Block Details` and `Transaction Details` pages - [#4528](https://github.com/blockscout/blockscout/pull/4528) - Block Details page: rework view diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex index aa38809367..fd93d40a4e 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex @@ -63,12 +63,18 @@
<%= target_contract.optimization_runs %>
<% end %> - <%= if smart_contract_verified && target_contract.evm_version do %> -
-
<%= gettext "EVM Version" %>
-
<%= target_contract.evm_version %>
-
- <% end %> +
+ <%= if smart_contract_verified && target_contract.evm_version do %> +
<%= gettext "EVM Version" %>
+
<%= target_contract.evm_version %>
+


+


+ <% end %> + <%= if target_contract.inserted_at do %> +
<%= gettext "Verified at" %>
+
<%= target_contract.inserted_at %>
+ <% end %> +

<%= if smart_contract_verified && target_contract.constructor_arguments do %>
@@ -89,7 +95,7 @@
-
<%= for {line, number} <- contract_lines_with_index(target_contract.contract_source_code, target_contract.inserted_at) do %>
<%= line %>
<% end %>
+
<%= for {line, number} <- contract_lines_with_index(target_contract.contract_source_code) do %>
<%= line %>
<% end %>
@@ -103,7 +109,7 @@
-
<%= for {line, number} <- contract_lines_with_index(additional_source.contract_source_code, additional_source.inserted_at) do %>
<%= line %>
<% end %>
+
<%= for {line, number} <- contract_lines_with_index(additional_source.contract_source_code) do %>
<%= line %>
<% end %>
<% end)%> diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex index 9e349bfe94..f26debafc2 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex @@ -3,7 +3,7 @@ defmodule BlockScoutWeb.AddressContractView do alias ABI.{FunctionSelector, TypeDecoder} alias Explorer.Chain - alias Explorer.Chain.{Address, Data, InternalTransaction, SmartContract, Transaction} + alias Explorer.Chain.{Address, Data, InternalTransaction, Transaction} def render("scripts.html", %{conn: conn}) do render_scripts(conn, "address_contract/code_highlighting.js") @@ -89,11 +89,10 @@ defmodule BlockScoutWeb.AddressContractView do end) end - def contract_lines_with_index(source_code, inserted_at \\ nil) do + def contract_lines_with_index(source_code) do contract_lines = source_code |> String.split("\n") - |> SmartContract.add_submitted_comment(inserted_at) max_digits = contract_lines diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex index 3f958dedd6..742f595536 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex @@ -160,7 +160,7 @@ defmodule BlockScoutWeb.API.RPC.ContractView do Enum.map(additional_sources, fn src -> %{ Filename: src.file_name, - SourceCode: SmartContract.add_submitted_comment(src.contract_source_code, src.inserted_at) + SourceCode: src.contract_source_code } end), else: [] diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 147f4920e4..a53a4d4fcf 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -618,7 +618,7 @@ msgid "Connection Lost, click to load newer validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:76 +#: lib/block_scout_web/templates/address_contract/index.html.eex:82 msgid "Constructor Arguments" msgstr "" @@ -628,7 +628,7 @@ msgid "Contract" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:114 +#: lib/block_scout_web/templates/address_contract/index.html.eex:120 msgid "Contract ABI" msgstr "" @@ -658,8 +658,8 @@ msgid "Contract Creation" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:130 -#: lib/block_scout_web/templates/address_contract/index.html.eex:145 +#: lib/block_scout_web/templates/address_contract/index.html.eex:136 +#: lib/block_scout_web/templates/address_contract/index.html.eex:151 msgid "Contract Creation Code" msgstr "" @@ -687,12 +687,12 @@ msgid "Contract name:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:86 +#: lib/block_scout_web/templates/address_contract/index.html.eex:92 msgid "Contract source code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:136 +#: lib/block_scout_web/templates/address_contract/index.html.eex:142 msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified." msgstr "" @@ -702,7 +702,7 @@ msgid "Contribute" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:116 +#: lib/block_scout_web/templates/address_contract/index.html.eex:122 msgid "Copy ABI" msgstr "" @@ -717,8 +717,8 @@ msgid "Copy Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:132 -#: lib/block_scout_web/templates/address_contract/index.html.eex:148 +#: lib/block_scout_web/templates/address_contract/index.html.eex:138 +#: lib/block_scout_web/templates/address_contract/index.html.eex:154 msgid "Copy Contract Creation Code" msgstr "" @@ -728,8 +728,8 @@ msgid "Copy Decompiled Contract Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:181 -#: lib/block_scout_web/templates/address_contract/index.html.eex:191 +#: lib/block_scout_web/templates/address_contract/index.html.eex:187 +#: lib/block_scout_web/templates/address_contract/index.html.eex:197 msgid "Copy Deployed ByteCode" msgstr "" @@ -767,8 +767,8 @@ msgid "Copy Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:88 -#: lib/block_scout_web/templates/address_contract/index.html.eex:102 +#: lib/block_scout_web/templates/address_contract/index.html.eex:94 +#: lib/block_scout_web/templates/address_contract/index.html.eex:108 msgid "Copy Source Code" msgstr "" @@ -945,8 +945,8 @@ msgid "Delegators’ Staked Amount" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:179 -#: lib/block_scout_web/templates/address_contract/index.html.eex:187 +#: lib/block_scout_web/templates/address_contract/index.html.eex:185 +#: lib/block_scout_web/templates/address_contract/index.html.eex:193 msgid "Deployed ByteCode" msgstr "" @@ -971,7 +971,7 @@ msgid "Difficulty" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:137 +#: lib/block_scout_web/templates/address_contract/index.html.eex:143 msgid "Displaying the init data provided of the creating transaction." msgstr "" @@ -1104,7 +1104,7 @@ msgid "Execute" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:228 +#: lib/block_scout_web/templates/address_contract/index.html.eex:234 msgid "External libraries" msgstr "" @@ -2762,12 +2762,17 @@ msgstr "" msgid "Value sent in the native token (and USD) if applicable." msgstr "" +#, elixir-format +#: lib/block_scout_web/templates/address_contract/index.html.eex:74 +msgid "Verified at" +msgstr "" + #, elixir-format #: lib/block_scout_web/templates/address_contract/index.html.eex:24 -#: lib/block_scout_web/templates/address_contract/index.html.eex:152 -#: lib/block_scout_web/templates/address_contract/index.html.eex:164 -#: lib/block_scout_web/templates/address_contract/index.html.eex:195 -#: lib/block_scout_web/templates/address_contract/index.html.eex:207 +#: lib/block_scout_web/templates/address_contract/index.html.eex:158 +#: lib/block_scout_web/templates/address_contract/index.html.eex:170 +#: lib/block_scout_web/templates/address_contract/index.html.eex:201 +#: lib/block_scout_web/templates/address_contract/index.html.eex:213 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:19 msgid "Verify & Publish" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 147f4920e4..a53a4d4fcf 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -618,7 +618,7 @@ msgid "Connection Lost, click to load newer validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:76 +#: lib/block_scout_web/templates/address_contract/index.html.eex:82 msgid "Constructor Arguments" msgstr "" @@ -628,7 +628,7 @@ msgid "Contract" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:114 +#: lib/block_scout_web/templates/address_contract/index.html.eex:120 msgid "Contract ABI" msgstr "" @@ -658,8 +658,8 @@ msgid "Contract Creation" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:130 -#: lib/block_scout_web/templates/address_contract/index.html.eex:145 +#: lib/block_scout_web/templates/address_contract/index.html.eex:136 +#: lib/block_scout_web/templates/address_contract/index.html.eex:151 msgid "Contract Creation Code" msgstr "" @@ -687,12 +687,12 @@ msgid "Contract name:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:86 +#: lib/block_scout_web/templates/address_contract/index.html.eex:92 msgid "Contract source code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:136 +#: lib/block_scout_web/templates/address_contract/index.html.eex:142 msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified." msgstr "" @@ -702,7 +702,7 @@ msgid "Contribute" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:116 +#: lib/block_scout_web/templates/address_contract/index.html.eex:122 msgid "Copy ABI" msgstr "" @@ -717,8 +717,8 @@ msgid "Copy Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:132 -#: lib/block_scout_web/templates/address_contract/index.html.eex:148 +#: lib/block_scout_web/templates/address_contract/index.html.eex:138 +#: lib/block_scout_web/templates/address_contract/index.html.eex:154 msgid "Copy Contract Creation Code" msgstr "" @@ -728,8 +728,8 @@ msgid "Copy Decompiled Contract Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:181 -#: lib/block_scout_web/templates/address_contract/index.html.eex:191 +#: lib/block_scout_web/templates/address_contract/index.html.eex:187 +#: lib/block_scout_web/templates/address_contract/index.html.eex:197 msgid "Copy Deployed ByteCode" msgstr "" @@ -767,8 +767,8 @@ msgid "Copy Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:88 -#: lib/block_scout_web/templates/address_contract/index.html.eex:102 +#: lib/block_scout_web/templates/address_contract/index.html.eex:94 +#: lib/block_scout_web/templates/address_contract/index.html.eex:108 msgid "Copy Source Code" msgstr "" @@ -945,8 +945,8 @@ msgid "Delegators’ Staked Amount" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:179 -#: lib/block_scout_web/templates/address_contract/index.html.eex:187 +#: lib/block_scout_web/templates/address_contract/index.html.eex:185 +#: lib/block_scout_web/templates/address_contract/index.html.eex:193 msgid "Deployed ByteCode" msgstr "" @@ -971,7 +971,7 @@ msgid "Difficulty" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:137 +#: lib/block_scout_web/templates/address_contract/index.html.eex:143 msgid "Displaying the init data provided of the creating transaction." msgstr "" @@ -1104,7 +1104,7 @@ msgid "Execute" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:228 +#: lib/block_scout_web/templates/address_contract/index.html.eex:234 msgid "External libraries" msgstr "" @@ -2762,12 +2762,17 @@ msgstr "" msgid "Value sent in the native token (and USD) if applicable." msgstr "" +#, elixir-format +#: lib/block_scout_web/templates/address_contract/index.html.eex:74 +msgid "Verified at" +msgstr "" + #, elixir-format #: lib/block_scout_web/templates/address_contract/index.html.eex:24 -#: lib/block_scout_web/templates/address_contract/index.html.eex:152 -#: lib/block_scout_web/templates/address_contract/index.html.eex:164 -#: lib/block_scout_web/templates/address_contract/index.html.eex:195 -#: lib/block_scout_web/templates/address_contract/index.html.eex:207 +#: lib/block_scout_web/templates/address_contract/index.html.eex:158 +#: lib/block_scout_web/templates/address_contract/index.html.eex:170 +#: lib/block_scout_web/templates/address_contract/index.html.eex:201 +#: lib/block_scout_web/templates/address_contract/index.html.eex:213 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:19 msgid "Verify & Publish" msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs index 6a2276bda5..af5c0912fa 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs @@ -431,9 +431,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do expected_result = [ %{ "Address" => to_string(contract.address_hash), - "SourceCode" => - "/**\n* Submitted for verification at blockscout.com on #{contract.inserted_at}\n*/\n" <> - contract.contract_source_code, + "SourceCode" => contract.contract_source_code, "ABI" => Jason.encode!(contract.abi), "ContractName" => contract.name, "CompilerVersion" => contract.compiler_version, @@ -476,9 +474,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do expected_result = [ %{ "Address" => to_string(contract.address_hash), - "SourceCode" => - "/**\n* Submitted for verification at blockscout.com on #{contract.inserted_at}\n*/\n" <> - contract.contract_source_code, + "SourceCode" => contract.contract_source_code, "ABI" => Jason.encode!(contract.abi), "ContractName" => contract.name, "CompilerVersion" => contract.compiler_version, @@ -576,9 +572,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do expected_result = [ %{ "Address" => to_string(contract.address_hash), - "SourceCode" => - "/**\n* Submitted for verification at blockscout.com on #{contract.inserted_at}\n*/\n" <> - contract.contract_source_code, + "SourceCode" => contract.contract_source_code, "ABI" => Jason.encode!(contract.abi), "ContractName" => contract.name, "CompilerVersion" => contract.compiler_version, diff --git a/apps/block_scout_web/test/block_scout_web/views/address_contract_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/address_contract_view_test.exs index 9f0314fb88..189c74033c 100644 --- a/apps/block_scout_web/test/block_scout_web/views/address_contract_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/address_contract_view_test.exs @@ -38,25 +38,22 @@ defmodule BlockScoutWeb.AddressContractViewTest do result = AddressContractView.contract_lines_with_index(code) assert result == [ - {"/**", " 1"}, - {"* Submitted for verification at blockscout.com on ", " 2"}, - {"*/", " 3"}, - {"pragma solidity >=0.4.22 <0.6.0;", " 4"}, - {"", " 5"}, - {"struct Proposal {", " 6"}, - {" uint voteCount;", " 7"}, - {"}", " 8"}, - {"", " 9"}, - {"address chairperson;", "10"}, - {"mapping(address => Voter) voters;", "11"}, - {"Proposal[] proposals;", "12"}, - {"", "13"}, - {"constructor(uint8 _numProposals) public {", "14"}, - {" chairperson = msg.sender;", "15"}, - {" voters[chairperson].weight = 1;", "16"}, - {" proposals.length = _numProposals;", "17"}, - {"}", "18"}, - {"", "19"} + {"pragma solidity >=0.4.22 <0.6.0;", " 1"}, + {"", " 2"}, + {"struct Proposal {", " 3"}, + {" uint voteCount;", " 4"}, + {"}", " 5"}, + {"", " 6"}, + {"address chairperson;", " 7"}, + {"mapping(address => Voter) voters;", " 8"}, + {"Proposal[] proposals;", " 9"}, + {"", "10"}, + {"constructor(uint8 _numProposals) public {", "11"}, + {" chairperson = msg.sender;", "12"}, + {" voters[chairperson].weight = 1;", "13"}, + {" proposals.length = _numProposals;", "14"}, + {"}", "15"}, + {"", "16"} ] end @@ -71,9 +68,6 @@ defmodule BlockScoutWeb.AddressContractViewTest do result = AddressContractView.contract_lines_with_index("a\nb\nc\nd\ne") assert Enum.map(result, fn {line, _number} -> line end) == [ - "/**", - "* Submitted for verification at blockscout.com on ", - "*/", "a", "b", "c", diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 1c99baed30..3a9807552a 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -3925,12 +3925,7 @@ defmodule Explorer.Chain do end end - defp format_source_code_output(smart_contract) do - SmartContract.add_submitted_comment( - smart_contract.contract_source_code, - smart_contract.inserted_at - ) - end + defp format_source_code_output(smart_contract), do: smart_contract.contract_source_code @doc """ Finds metadata for verification of a contract from verified twins: contracts with the same bytecode