Merge pull request #4569 from blockscout/np-del-comment-in-src

Smart-Contract: remove comment with the submission date
pull/4582/head
Victor Baranov 3 years ago committed by GitHub
commit f277d8660c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 18
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  4. 5
      apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex
  5. 2
      apps/block_scout_web/lib/block_scout_web/views/api/rpc/contract_view.ex
  6. 47
      apps/block_scout_web/priv/gettext/default.pot
  7. 47
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  8. 12
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs
  9. 38
      apps/block_scout_web/test/block_scout_web/views/address_contract_view_test.exs
  10. 7
      apps/explorer/lib/explorer/chain.ex

@ -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

@ -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

@ -63,12 +63,18 @@
<dd class="col-md-4"><%= target_contract.optimization_runs %></dd>
<% end %>
</dl>
<%= if smart_contract_verified && target_contract.evm_version do %>
<dl class="row">
<dt class="col-sm-4 col-md-2 text-muted"><%= gettext "EVM Version" %></dt>
<dd class="col-sm-8 col-md-10"><%= target_contract.evm_version %></dd>
</dl>
<%= if smart_contract_verified && target_contract.evm_version do %>
<dt class="col-md-2 text-muted"><%= gettext "EVM Version" %></dt>
<dd class="col-md-4"><%= target_contract.evm_version %></dd>
<div class="d-none d-sm-block d-md-none"></br></br></div>
<div class="d-block d-sm-none"></br></br></div>
<% end %>
<%= if target_contract.inserted_at do %>
<dt class="col-md-2 text-muted"><%= gettext "Verified at" %></dt>
<dd class="col-md-4"><%= target_contract.inserted_at %></dd>
<% end %>
</dl>
<hr/>
<%= if smart_contract_verified && target_contract.constructor_arguments do %>
<section>
@ -89,7 +95,7 @@
</button>
</div>
<div class="tile tile-muted mb-4">
<pre class="pre-scrollable line-numbers" data-activate-highlight><code class="solidity"><%= for {line, number} <- contract_lines_with_index(target_contract.contract_source_code, target_contract.inserted_at) do %><div data-line-number="<%= number %>"><%= line %></div><% end %></code></pre>
<pre class="pre-scrollable line-numbers" data-activate-highlight><code class="solidity"><%= for {line, number} <- contract_lines_with_index(target_contract.contract_source_code) do %><div data-line-number="<%= number %>"><%= line %></div><% end %></code></pre>
</div>
</section>
@ -103,7 +109,7 @@
</button>
</div>
<div class="tile tile-muted mb-4">
<pre class="pre-scrollable line-numbers" data-activate-highlight><code class="solidity"><%= for {line, number} <- contract_lines_with_index(additional_source.contract_source_code, additional_source.inserted_at) do %><div data-line-number="<%= number %>"><%= line %></div><% end %></code></pre>
<pre class="pre-scrollable line-numbers" data-activate-highlight><code class="solidity"><%= for {line, number} <- contract_lines_with_index(additional_source.contract_source_code) do %><div data-line-number="<%= number %>"><%= line %></div><% end %></code></pre>
</div>
</section>
<% end)%>

@ -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

@ -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: []

@ -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 ""

@ -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 ""

@ -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,

@ -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",

@ -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

Loading…
Cancel
Save