Merge pull request #4323 from blockscout/np-add-byte-code

Add creation contract code
pull/4345/head
Victor Baranov 3 years ago committed by GitHub
commit 5cf5f127bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 21
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  4. 10
      apps/block_scout_web/lib/block_scout_web/views/address_contract_view.ex
  5. 54
      apps/block_scout_web/priv/gettext/default.pot
  6. 54
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po

@ -23,7 +23,7 @@ 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:151
lib/block_scout_web/templates/address_contract/index.html.eex:162
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:65

@ -1,6 +1,7 @@
## Current
### Features
- [#4323](https://github.com/blockscout/blockscout/pull/4323) - Renamed Contract Byte Code, add Contract Creation Code on contract's page
- [#4312](https://github.com/blockscout/blockscout/pull/4312) - Display pending transactions on address page
- [#4299](https://github.com/blockscout/blockscout/pull/4299) - Added sourcify verification api endpoint
- [#4267](https://github.com/blockscout/blockscout/pull/4267) - Extend verification through [Sourcify](https://sourcify.dev) smart-contract verification: fetch smart contract metadata from Sourcify repo if it has been already verified there

@ -132,21 +132,32 @@
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= transaction_init %></code></pre>
</div>
<% {:ok, contract_code} -> %>
<%= if creation_code(@address) do %>
<div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Contract Creation Code" %></h3>
<button type="button" class="btn-line" style="float: left;" id="button" data-clipboard-text="<%= creation_code(@address) %>" aria-label="copy contract creation code">
<%= gettext "Copy Contract Creation Code" %>
</button>
</div>
<div class="tile tile-muted mb-4">
<pre class="pre-wrap pre-scrollable"><code class="nohighlight"><%= creation_code(@address) %></code></pre>
</div>
<% end %>
<%= if smart_contract_verified do %>
<div class="d-flex justify-content-between align-items-baseline">
<h3><%= gettext "Contract Byte Code" %></h3>
<h3><%= gettext "Deployed ByteCode" %></h3>
<button type="button" class="btn-line" style="float: left;" id="button" data-clipboard-text="<%= contract_code %>" aria-label="copy contract creation code">
<%= gettext "Copy Byte Code" %>
<%= gettext "Copy Deployed ByteCode" %>
</button>
</div>
<% else %>
<div class="d-flex justify-content-between align-items-baseline contract-code-container">
<div class="d-flex justify-content-between align-items-baseline">
<div>
<h3><%= gettext "Contract Byte Code" %></h3>
<h3><%= gettext "Deployed ByteCode" %></h3>
</div>
<div class="buttons">
<button type="button" class="btn-line" style="float: left;" id="button" data-clipboard-text="<%= contract_code %>" aria-label="copy contract creation code">
<%= gettext "Copy Byte Code" %>
<%= gettext "Copy Deployed ByteCode" %>
</button>
<%= if match?({:selfdestructed, _}, contract_creation_code) do %>
<div class="button button-disabled button-sm float-right ml-3">

@ -3,7 +3,7 @@ defmodule BlockScoutWeb.AddressContractView do
alias ABI.{FunctionSelector, TypeDecoder}
alias Explorer.Chain
alias Explorer.Chain.{Address, Data, InternalTransaction, SmartContract}
alias Explorer.Chain.{Address, Data, InternalTransaction, SmartContract, Transaction}
def render("scripts.html", %{conn: conn}) do
render_scripts(conn, "address_contract/code_highlighting.js")
@ -119,6 +119,14 @@ defmodule BlockScoutWeb.AddressContractView do
{:ok, contract_code}
end
def creation_code(%Address{contracts_creation_internal_transaction: %InternalTransaction{}} = address) do
address.contracts_creation_internal_transaction.input
end
def creation_code(%Address{contracts_creation_transaction: %Transaction{}} = address) do
address.contracts_creation_transaction.input
end
def sourcify_repo_url(address_hash) do
checksummed_hash = Address.checksum(address_hash)
chain_id = Application.get_env(:explorer, Explorer.ThirdPartyIntegrations.Sourcify)[:chain_id]

@ -354,12 +354,6 @@ msgstr ""
msgid "Contract Address Pending"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:137
#: lib/block_scout_web/templates/address_contract/index.html.eex:145
msgid "Contract Byte Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:351
msgid "Contract Call"
@ -372,6 +366,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:122
#: lib/block_scout_web/templates/address_contract/index.html.eex:137
msgid "Contract Creation Code"
msgstr ""
@ -422,6 +417,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:124
#: lib/block_scout_web/templates/address_contract/index.html.eex:139
msgid "Copy Contract Creation Code"
msgstr ""
@ -671,7 +667,7 @@ msgid "Nonce"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:186
#: lib/block_scout_web/templates/address_contract/index.html.eex:197
msgid "External libraries"
msgstr ""
@ -1580,8 +1576,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:24
#: lib/block_scout_web/templates/address_contract/index.html.eex:153
#: lib/block_scout_web/templates/address_contract/index.html.eex:165
#: lib/block_scout_web/templates/address_contract/index.html.eex:164
#: lib/block_scout_web/templates/address_contract/index.html.eex:176
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:19
msgid "Verify & Publish"
msgstr ""
@ -1989,12 +1985,6 @@ msgstr ""
msgid "Play"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:139
#: lib/block_scout_web/templates/address_contract/index.html.eex:149
msgid "Copy Byte Code"
msgstr ""
#: lib/block_scout_web/templates/stakes/_stakes_top.html.eex:6
msgid "%{blocks} block"
msgid_plural "%{blocks} blocks"
@ -2018,17 +2008,6 @@ msgstr ""
msgid "(inactive pool)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76
msgid "<p>Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.</p>\n <p>Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.</p>\n <p>If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.</p>\n"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36
msgid "<p>To become a candidate, your staking address must be funded with %{tokenSymbol} tokens <strong>and</strong> %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.</p>\n <p>To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the <strong>Stake</strong> button next to the address to begin the process.</p>"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:27
@ -2801,3 +2780,26 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:40
msgid "Sourcify: Sources and metadata JSON file"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:150
#: lib/block_scout_web/templates/address_contract/index.html.eex:160
msgid "Copy Deployed ByteCode"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:148
#: lib/block_scout_web/templates/address_contract/index.html.eex:156
msgid "Deployed ByteCode"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76
msgid "<p>Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.</p>\n <p>Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.</p>\n <p>If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.</p>\n"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36
msgid "<p>To become a candidate, your staking address must be funded with %{tokenSymbol} tokens <strong>and</strong> %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.</p>\n <p>To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the <strong>Stake</strong> button next to the address to begin the process.</p>"
msgstr ""

@ -354,12 +354,6 @@ msgstr ""
msgid "Contract Address Pending"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:137
#: lib/block_scout_web/templates/address_contract/index.html.eex:145
msgid "Contract Byte Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:351
msgid "Contract Call"
@ -372,6 +366,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:122
#: lib/block_scout_web/templates/address_contract/index.html.eex:137
msgid "Contract Creation Code"
msgstr ""
@ -422,6 +417,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:124
#: lib/block_scout_web/templates/address_contract/index.html.eex:139
msgid "Copy Contract Creation Code"
msgstr ""
@ -671,7 +667,7 @@ msgid "Nonce"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:186
#: lib/block_scout_web/templates/address_contract/index.html.eex:197
msgid "External libraries"
msgstr ""
@ -1580,8 +1576,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:24
#: lib/block_scout_web/templates/address_contract/index.html.eex:153
#: lib/block_scout_web/templates/address_contract/index.html.eex:165
#: lib/block_scout_web/templates/address_contract/index.html.eex:164
#: lib/block_scout_web/templates/address_contract/index.html.eex:176
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:19
msgid "Verify & Publish"
msgstr ""
@ -1989,12 +1985,6 @@ msgstr ""
msgid "Play"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:139
#: lib/block_scout_web/templates/address_contract/index.html.eex:149
msgid "Copy Byte Code"
msgstr ""
#: lib/block_scout_web/templates/stakes/_stakes_top.html.eex:6
msgid "%{blocks} block"
msgid_plural "%{blocks} blocks"
@ -2018,17 +2008,6 @@ msgstr ""
msgid "(inactive pool)"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76
msgid "<p>Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.</p>\n <p>Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.</p>\n <p>If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.</p>\n"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36
msgid "<p>To become a candidate, your staking address must be funded with %{tokenSymbol} tokens <strong>and</strong> %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.</p>\n <p>To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the <strong>Stake</strong> button next to the address to begin the process.</p>"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex:27
@ -2801,3 +2780,26 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:40
msgid "Sourcify: Sources and metadata JSON file"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:150
#: lib/block_scout_web/templates/address_contract/index.html.eex:160
msgid "Copy Deployed ByteCode"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:148
#: lib/block_scout_web/templates/address_contract/index.html.eex:156
msgid "Deployed ByteCode"
msgstr ""
#, elixir-format, fuzzy
#: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76
msgid "<p>Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.</p>\n <p>Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.</p>\n <p>If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.</p>\n"
msgstr ""
#, elixir-format, fuzzy
#:
#: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36
msgid "<p>To become a candidate, your staking address must be funded with %{tokenSymbol} tokens <strong>and</strong> %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.</p>\n <p>To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the <strong>Stake</strong> button next to the address to begin the process.</p>"
msgstr ""

Loading…
Cancel
Save