Minimal proxy pattern support (EIP-1167)

pull/3743/head
Viktor Baranov 4 years ago
parent 668eefceeb
commit 5f2b5f24f9
  1. 2
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 19
      apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex
  5. 4
      apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex
  6. 1
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_info.html.eex
  7. 10
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex
  8. 23
      apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex
  9. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_learn-more.html.eex
  10. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_warning.html.eex
  11. 84
      apps/block_scout_web/priv/gettext/default.pot
  12. 84
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  13. 2
      apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs
  14. 113
      apps/explorer/lib/explorer/chain.ex

@ -23,6 +23,6 @@ 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:118
lib/block_scout_web/templates/address_contract/index.html.eex:123
lib/explorer/staking/stake_snapshotting.ex:15: Function do_snapshotting/7 has no local return
lib/explorer/staking/stake_snapshotting.ex:207

@ -1,6 +1,7 @@
## Current
### Features
- [#3743](https://github.com/blockscout/blockscout/pull/3743) - Minimal proxy pattern support (EIP-1167)
- [#3722](https://github.com/poanetwork/blockscout/pull/3722) - Allow double quotes for (u)int arrays inputs during contract interaction
- [#3694](https://github.com/poanetwork/blockscout/pull/3694) - LP tokens total liquidity
- [#3676](https://github.com/poanetwork/blockscout/pull/3676) - Bridged tokens TLV in USD

@ -1,5 +1,6 @@
<% contract_creation_code = contract_creation_code(@address) %>
<% metadata_for_verification = Chain.address_verified_twin_contract(@address.hash) %>
<% minimal_proxy_template = Chain.get_minimal_proxy_template(@address.hash) %>
<% metadata_for_verification = minimal_proxy_template || Chain.get_address_verified_twin_contract(@address.hash).verified_contract %>
<% smart_contract_verified = BlockScoutWeb.AddressView.smart_contract_verified?(@address) %>
<section class="container">
@ -9,12 +10,16 @@
<%= render BlockScoutWeb.AddressView, "_tabs.html", assigns %>
<div class="card-body">
<%= unless smart_contract_verified do %>
<%= if metadata_for_verification do %>
<div class="mb-4">
<i style="color: #f7b32b;" class="fa fa-info-circle"></i><span> <%= gettext("Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB") %> <%= link(
metadata_for_verification.address_hash,
to: address_contract_path(@conn, :index, metadata_for_verification.address_hash)) %>.<br/> <%= gettext("All metadata displayed below is from that contract. In order to verify current contract, click") %> <i><%= gettext("Verify & Publish") %></i> <%= gettext("button") %></span>
</div>
<%= if minimal_proxy_template do %>
<%= render BlockScoutWeb.CommonComponentsView, "_minimal_proxy_pattern.html", address_hash: metadata_for_verification.address_hash, conn: @conn %>
<% else %>
<%= if metadata_for_verification do %>
<div class="mb-4">
<%= render BlockScoutWeb.CommonComponentsView, "_info.html" %><span> <%= gettext("Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB") %> <%= link(
metadata_for_verification.address_hash,
to: address_contract_path(@conn, :index, metadata_for_verification.address_hash)) %>.<br/> <%= gettext("All metadata displayed below is from that contract. In order to verify current contract, click") %> <i><%= gettext("Verify & Publish") %></i> <%= gettext("button") %></span>
</div>
<% end %>
<% end %>
<% end %>
<%= if smart_contract_verified || (!smart_contract_verified && metadata_for_verification) do %>

@ -1,4 +1,4 @@
<% metadata_for_verification = Chain.address_verified_twin_contract(@address_hash) %>
<% metadata_for_verification = Chain.get_address_verified_twin_contract(@address_hash).verified_contract %>
<% contract_name_value = if metadata_for_verification, do: metadata_for_verification.name, else: "" %>
<% optimization_runs_value = if metadata_for_verification, do: metadata_for_verification.optimization_runs, else: "200" %>
<% optimization = if metadata_for_verification, do: metadata_for_verification.optimization, else: true %>

@ -20,7 +20,7 @@
data-placement="top"
data-html="true"
title="<%= owl_token_amb_info() %>">
<i style="color: #f7b32b;" class="fa fa-info-circle ml-1" data-test="owl_info"></i>
<%= render BlockScoutWeb.CommonComponentsView, "_info.html", extra_class: "ml-1" %>
</span>
<% end %>
<%= if owl_token_omni?(@token.contract_address.hash) do %>
@ -29,7 +29,7 @@
data-placement="top"
data-html="true"
title="<%= owl_token_omni_info() %>">
<i style="color: #f7b32b;" class="fa fa-info-circle ml-1" data-test="owl_info"></i>
<%= render BlockScoutWeb.CommonComponentsView, "_info.html", extra_class: "ml-1" %>
</span>
<% end %>
<%= if @bridged_token.custom_metadata do %>

@ -0,0 +1 @@
<i style="color: #f7b32b;" class="fa fa-info-circle <%= if assigns[:extra_class] do @extra_class end %>"></i>

@ -0,0 +1,10 @@
<div class="mb-4">
<%= render BlockScoutWeb.CommonComponentsView, "_info.html" %>
<span> <%= gettext("Minimal Proxy Contract for") %> <%= link(
@address_hash,
to: address_contract_path(@conn, :index, @address_hash)) %>.<br/> <%= link(
gettext("EIP-1167"),
to: "https://eips.ethereum.org/EIPS/eip-1167",
target: "_blank"
) %><%= gettext(" - minimal bytecode implementation that delegates all calls to a known address") %> </span>
</div>

@ -1,14 +1,19 @@
<% metadata_for_verification = Chain.address_verified_twin_contract(@address.hash) %>
<% minimal_proxy_template = Chain.get_minimal_proxy_template(@address.hash) %>
<% metadata_for_verification = minimal_proxy_template || Chain.get_address_verified_twin_contract(@address.hash).verified_contract %>
<%= unless BlockScoutWeb.AddressView.smart_contract_verified?(@address) do %>
<%= if metadata_for_verification do %>
<div class="mb-4">
<i style="color: #f7b32b;" class="fa fa-info-circle"></i><span> <%= gettext("Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB") %> <%= link(
metadata_for_verification.address_hash,
to: address_contract_path(@conn, :index, metadata_for_verification.address_hash)) %>.<br/> <%= gettext("All functions displayed below are from ABI of that contract. In order to verify current contract, proceed with") %> <%= link(
gettext("Verify & Publish"),
to: address_verify_contract_path(@conn, :new, @address.hash)
) %> <%= gettext("page") %></span>
</div>
<%= if minimal_proxy_template do %>
<%= render BlockScoutWeb.CommonComponentsView, "_minimal_proxy_pattern.html", address_hash: metadata_for_verification.address_hash, conn: @conn %>
<% else %>
<div class="mb-4">
<%= render BlockScoutWeb.CommonComponentsView, "_info.html" %><span> <%= gettext("Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB") %> <%= link(
metadata_for_verification.address_hash,
to: address_contract_path(@conn, :index, metadata_for_verification.address_hash)) %>.<br/> <%= gettext("All functions displayed below are from ABI of that contract. In order to verify current contract, proceed with") %> <%= link(
gettext("Verify & Publish"),
to: address_verify_contract_path(@conn, :new, @address.hash)
) %> <%= gettext("page") %></span>
</div>
<% end %>
<% end %>
<% end %>
<%= if @action== "write" do %>

@ -7,7 +7,7 @@
</svg>
</button>
<span style="font-size: 1.3em;">
<i style="color: #f7b32b;" class="fa fa-info-circle ml-1"></i>
<%= render BlockScoutWeb.CommonComponentsView, "_info.html", extra_class: "ml-1" %>
Participate in Proof-of-Stake consensus on the xDai chain as a delegator or validator. To start you will need STAKE on the xDai network. <a href="https://www.xdaichain.com/for-stakers/staking-protocol" target="_blank">Learn More</a>
</span>
</div>

@ -7,7 +7,7 @@
</svg>
</button>
<span style="font-size: 1.3em;">
<i style="color: #f7b32b;" class="fa fa-info-circle ml-1"></i>
<%= render BlockScoutWeb.CommonComponentsView, "_info.html", extra_class: "ml-1" %>
<%= if @message do %>
<%= "#{@message}" %>
<% else %>

@ -291,7 +291,7 @@ msgid "Compiler"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:32
#: lib/block_scout_web/templates/address_contract/index.html.eex:37
msgid "Compiler version"
msgstr ""
@ -324,12 +324,12 @@ msgid "Connection Lost, click to load newer validations"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:51
#: lib/block_scout_web/templates/address_contract/index.html.eex:56
msgid "Constructor Arguments"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:73
#: lib/block_scout_web/templates/address_contract/index.html.eex:78
msgid "Contract ABI"
msgstr ""
@ -347,8 +347,8 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:104
#: lib/block_scout_web/templates/address_contract/index.html.eex:112
#: lib/block_scout_web/templates/address_contract/index.html.eex:109
#: lib/block_scout_web/templates/address_contract/index.html.eex:117
msgid "Contract Byte Code"
msgstr ""
@ -363,7 +363,7 @@ msgid "Contract Creation"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:89
#: lib/block_scout_web/templates/address_contract/index.html.eex:94
msgid "Contract Creation Code"
msgstr ""
@ -378,17 +378,17 @@ msgid "Contract Name"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:24
#: lib/block_scout_web/templates/address_contract/index.html.eex:29
msgid "Contract name:"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:61
#: lib/block_scout_web/templates/address_contract/index.html.eex:66
msgid "Contract source code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:95
#: lib/block_scout_web/templates/address_contract/index.html.eex:100
msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified."
msgstr ""
@ -398,7 +398,7 @@ msgid "Contribute"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:75
#: lib/block_scout_web/templates/address_contract/index.html.eex:80
msgid "Copy ABI"
msgstr ""
@ -411,7 +411,7 @@ msgid "Copy Address"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:91
#: lib/block_scout_web/templates/address_contract/index.html.eex:96
msgid "Copy Contract Creation Code"
msgstr ""
@ -421,7 +421,7 @@ msgid "Copy Decompiled Contract Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:63
#: lib/block_scout_web/templates/address_contract/index.html.eex:68
msgid "Copy Source Code"
msgstr ""
@ -535,7 +535,7 @@ msgid "Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:96
#: lib/block_scout_web/templates/address_contract/index.html.eex:101
msgid "Displaying the init data provided of the creating transaction."
msgstr ""
@ -555,8 +555,8 @@ msgid "ERC-721 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:108
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:78
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:113
msgid "ETH"
msgstr ""
@ -566,7 +566,7 @@ msgid "ETH RPC API Documentation"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:43
#: lib/block_scout_web/templates/address_contract/index.html.eex:48
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:82
msgid "EVM Version"
msgstr ""
@ -659,7 +659,7 @@ msgid "Nonce"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:146
#: lib/block_scout_web/templates/address_contract/index.html.eex:151
msgid "External libraries"
msgstr ""
@ -1109,12 +1109,12 @@ msgid "OUT"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:28
#: lib/block_scout_web/templates/address_contract/index.html.eex:33
msgid "Optimization enabled"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:37
#: lib/block_scout_web/templates/address_contract/index.html.eex:42
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:114
msgid "Optimization runs"
msgstr ""
@ -1187,7 +1187,7 @@ msgid "QR Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:77
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:82
msgid "Query"
msgstr ""
@ -1573,10 +1573,10 @@ msgid "Value"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:120
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
#: lib/block_scout_web/templates/address_contract/index.html.eex:125
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:8
#: lib/block_scout_web/templates/address_contract/index.html.eex:130
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:12
msgid "Verify & Publish"
msgstr ""
@ -1640,7 +1640,7 @@ msgid "View transaction %{transaction} on %{subnetwork}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:107
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:112
msgid "WEI"
msgstr ""
@ -1931,7 +1931,7 @@ msgid "Waiting for transaction's confirmation..."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:77
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:82
msgid "Write"
msgstr ""
@ -1957,22 +1957,22 @@ msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:7
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:11
msgid "All functions displayed below are from ABI of that contract. In order to verify current contract, proceed with"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
msgid "All metadata displayed below is from that contract. In order to verify current contract, click"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
msgid "button"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:10
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:14
msgid "page"
msgstr ""
@ -1983,8 +1983,8 @@ msgid "Play"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:106
#: lib/block_scout_web/templates/address_contract/index.html.eex:116
#: lib/block_scout_web/templates/address_contract/index.html.eex:111
#: lib/block_scout_web/templates/address_contract/index.html.eex:121
msgid "Copy Byte Code"
msgstr ""
@ -2604,8 +2604,8 @@ msgid "Stakes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:14
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:5
#: lib/block_scout_web/templates/address_contract/index.html.eex:18
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:9
msgid "Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB"
msgstr ""
@ -2706,3 +2706,21 @@ msgstr ""
#: lib/block_scout_web/templates/stakes/_stakes_top.html.eex:52
msgid "Trade STAKE on BitMax"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:9
msgid " - minimal bytecode implementation that delegates all calls to a known address"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:6
msgid "EIP-1167"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:3
msgid "Minimal Proxy Contract for"
msgstr ""

@ -291,7 +291,7 @@ msgid "Compiler"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:32
#: lib/block_scout_web/templates/address_contract/index.html.eex:37
msgid "Compiler version"
msgstr ""
@ -324,12 +324,12 @@ msgid "Connection Lost, click to load newer validations"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:51
#: lib/block_scout_web/templates/address_contract/index.html.eex:56
msgid "Constructor Arguments"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:73
#: lib/block_scout_web/templates/address_contract/index.html.eex:78
msgid "Contract ABI"
msgstr ""
@ -347,8 +347,8 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:104
#: lib/block_scout_web/templates/address_contract/index.html.eex:112
#: lib/block_scout_web/templates/address_contract/index.html.eex:109
#: lib/block_scout_web/templates/address_contract/index.html.eex:117
msgid "Contract Byte Code"
msgstr ""
@ -363,7 +363,7 @@ msgid "Contract Creation"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:89
#: lib/block_scout_web/templates/address_contract/index.html.eex:94
msgid "Contract Creation Code"
msgstr ""
@ -378,17 +378,17 @@ msgid "Contract Name"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:24
#: lib/block_scout_web/templates/address_contract/index.html.eex:29
msgid "Contract name:"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:61
#: lib/block_scout_web/templates/address_contract/index.html.eex:66
msgid "Contract source code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:95
#: lib/block_scout_web/templates/address_contract/index.html.eex:100
msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified."
msgstr ""
@ -398,7 +398,7 @@ msgid "Contribute"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:75
#: lib/block_scout_web/templates/address_contract/index.html.eex:80
msgid "Copy ABI"
msgstr ""
@ -411,7 +411,7 @@ msgid "Copy Address"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:91
#: lib/block_scout_web/templates/address_contract/index.html.eex:96
msgid "Copy Contract Creation Code"
msgstr ""
@ -421,7 +421,7 @@ msgid "Copy Decompiled Contract Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:63
#: lib/block_scout_web/templates/address_contract/index.html.eex:68
msgid "Copy Source Code"
msgstr ""
@ -535,7 +535,7 @@ msgid "Details"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:96
#: lib/block_scout_web/templates/address_contract/index.html.eex:101
msgid "Displaying the init data provided of the creating transaction."
msgstr ""
@ -555,8 +555,8 @@ msgid "ERC-721 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:108
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:78
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:113
msgid "ETH"
msgstr ""
@ -566,7 +566,7 @@ msgid "ETH RPC API Documentation"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:43
#: lib/block_scout_web/templates/address_contract/index.html.eex:48
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:82
msgid "EVM Version"
msgstr ""
@ -659,7 +659,7 @@ msgid "Nonce"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:146
#: lib/block_scout_web/templates/address_contract/index.html.eex:151
msgid "External libraries"
msgstr ""
@ -1109,12 +1109,12 @@ msgid "OUT"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:28
#: lib/block_scout_web/templates/address_contract/index.html.eex:33
msgid "Optimization enabled"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:37
#: lib/block_scout_web/templates/address_contract/index.html.eex:42
#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:114
msgid "Optimization runs"
msgstr ""
@ -1187,7 +1187,7 @@ msgid "QR Code"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:77
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:82
msgid "Query"
msgstr ""
@ -1573,10 +1573,10 @@ msgid "Value"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:120
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
#: lib/block_scout_web/templates/address_contract/index.html.eex:125
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:8
#: lib/block_scout_web/templates/address_contract/index.html.eex:130
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:12
msgid "Verify & Publish"
msgstr ""
@ -1640,7 +1640,7 @@ msgid "View transaction %{transaction} on %{subnetwork}"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:107
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:112
msgid "WEI"
msgstr ""
@ -1931,7 +1931,7 @@ msgid "Waiting for transaction's confirmation..."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:77
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:82
msgid "Write"
msgstr ""
@ -1957,22 +1957,22 @@ msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:7
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:11
msgid "All functions displayed below are from ABI of that contract. In order to verify current contract, proceed with"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
msgid "All metadata displayed below is from that contract. In order to verify current contract, click"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:16
#: lib/block_scout_web/templates/address_contract/index.html.eex:20
msgid "button"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:10
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:14
msgid "page"
msgstr ""
@ -1983,8 +1983,8 @@ msgid "Play"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:106
#: lib/block_scout_web/templates/address_contract/index.html.eex:116
#: lib/block_scout_web/templates/address_contract/index.html.eex:111
#: lib/block_scout_web/templates/address_contract/index.html.eex:121
msgid "Copy Byte Code"
msgstr ""
@ -2604,8 +2604,8 @@ msgid "Stakes"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:14
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:5
#: lib/block_scout_web/templates/address_contract/index.html.eex:18
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:9
msgid "Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB"
msgstr ""
@ -2706,3 +2706,21 @@ msgstr ""
#: lib/block_scout_web/templates/stakes/_stakes_top.html.eex:52
msgid "Trade STAKE on BitMax"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:9
msgid " - minimal bytecode implementation that delegates all calls to a known address"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:6
msgid "EIP-1167"
msgstr ""
#, elixir-format
#:
#: lib/block_scout_web/templates/common_components/_minimal_proxy_pattern.html.eex:3
msgid "Minimal Proxy Contract for"
msgstr ""

@ -135,7 +135,7 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
assert conn.assigns.read_only_functions == []
end
test "lists [] proxy read only functions if no verified eip-1967 implementation and eth_getStorageAt returns not nnormalized address hash" do
test "lists [] proxy read only functions if no verified eip-1967 implementation and eth_getStorageAt returns not normalized address hash" do
token_contract_address = insert(:contract_address)
insert(:smart_contract,

@ -1023,7 +1023,9 @@ defmodule Explorer.Chain do
if smart_contract do
address_result
else
address_verified_twin_contract = Chain.address_verified_twin_contract(hash)
address_verified_twin_contract =
Chain.get_minimal_proxy_template(hash) ||
Chain.get_address_verified_twin_contract(hash).verified_contract
if address_verified_twin_contract do
address_verified_twin_contract_updated =
@ -1333,7 +1335,9 @@ defmodule Explorer.Chain do
if smart_contract do
address_result
else
address_verified_twin_contract = Chain.address_verified_twin_contract(hash)
address_verified_twin_contract =
Chain.get_minimal_proxy_template(hash) ||
Chain.get_address_verified_twin_contract(hash).verified_contract
if address_verified_twin_contract do
address_verified_twin_contract_updated =
@ -3411,7 +3415,9 @@ defmodule Explorer.Chain do
| smart_contract: %{address_with_smart_contract.smart_contract | contract_source_code: formatted_code}
}
else
address_verified_twin_contract = Chain.address_verified_twin_contract(address_hash)
address_verified_twin_contract =
Chain.get_minimal_proxy_template(address_hash) ||
Chain.get_address_verified_twin_contract(address_hash).verified_contract
if address_verified_twin_contract do
formatted_code = format_source_code_output(address_verified_twin_contract)
@ -3438,45 +3444,90 @@ defmodule Explorer.Chain do
Finds metadata for verification of a contract from verified twins: contracts with the same bytecode
which were verified previously, returns a single t:SmartContract.t/0
"""
def address_verified_twin_contract(address_hash) do
address_verified_twins =
def get_address_verified_twin_contract(address_hash) do
case Repo.get(Address, address_hash) do
nil ->
%{:verified_contract => nil}
target_address ->
target_address_hash = target_address.hash
contract_code = target_address.contract_code
case contract_code do
%Chain.Data{bytes: contract_code_bytes} ->
contract_code_md5 =
Base.encode16(:crypto.hash(:md5, "\\x" <> Base.encode16(contract_code_bytes, case: :lower)),
case: :lower
)
verified_contract_twin_query =
from(
address in Address,
inner_join: smart_contract in SmartContract,
on: address.hash == smart_contract.address_hash,
where: fragment("md5(contract_code::text)") == ^contract_code_md5,
where: address.hash != ^target_address_hash,
select: smart_contract,
limit: 1
)
verified_contract_twin =
verified_contract_twin_query
|> Repo.one()
%{
:verified_contract => verified_contract_twin
}
_ ->
%{:verified_contract => nil}
end
end
end
def get_minimal_proxy_template(address_hash) do
minimal_proxy_template =
case Repo.get(Address, address_hash) do
nil ->
[]
nil
target_address ->
target_address_hash = target_address.hash
contract_code = target_address.contract_code
case contract_code do
%Chain.Data{bytes: contract_code_bytes} ->
contract_code_md5 =
Base.encode16(:crypto.hash(:md5, "\\x" <> Base.encode16(contract_code_bytes, case: :lower)),
case: :lower
)
query =
from(
address in Address,
inner_join: smart_contract in SmartContract,
on: address.hash == smart_contract.address_hash,
where: fragment("md5(contract_code::text)") == ^contract_code_md5,
where: address.hash != ^target_address_hash,
select: smart_contract
)
query
|> Repo.all()
contract_bytecode = Base.encode16(contract_code_bytes, case: :lower)
get_minimal_proxy_from_template_code(contract_bytecode)
_ ->
[]
nil
end
end
if Enum.count(address_verified_twins) > 0 do
Enum.at(address_verified_twins, 0)
else
nil
minimal_proxy_template
end
defp get_minimal_proxy_from_template_code(contract_bytecode) do
case contract_bytecode do
"363d3d373d3d3d363d73" <> <<template_address::binary-size(40)>> <> _ ->
template_address = "0x" <> template_address
query =
from(
smart_contract in SmartContract,
where: smart_contract.address_hash == ^template_address,
select: smart_contract
)
template =
query
|> Repo.one(timeout: 10_000)
template
_ ->
nil
end
end
@ -3493,7 +3544,9 @@ defmodule Explorer.Chain do
if current_smart_contract do
current_smart_contract
else
address_verified_twin_contract = Chain.address_verified_twin_contract(address_hash)
address_verified_twin_contract =
Chain.get_minimal_proxy_template(address_hash) ||
Chain.get_address_verified_twin_contract(address_hash).verified_contract
if address_verified_twin_contract do
Map.put(address_verified_twin_contract, :address_hash, address_hash)

Loading…
Cancel
Save