Skip to content

Commit

Permalink
Merge pull request blockscout#4569 from blockscout/np-del-comment-in-src
Browse files Browse the repository at this point in the history
Smart-Contract: remove comment with the submission date
  • Loading branch information
vbaranov authored and jagdeep sidhu committed Aug 27, 2021
1 parent fc56785 commit 5f1524e
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .dialyzer-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
<% end %>
<dl class="row">
<%= 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>
Expand All @@ -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>

Expand All @@ -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)%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
47 changes: 26 additions & 21 deletions apps/block_scout_web/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

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

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

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""
Expand Down
47 changes: 26 additions & 21 deletions apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

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

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

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""

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

Expand Down Expand Up @@ -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 ""

Expand Down Expand Up @@ -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 ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 5f1524e

Please sign in to comment.