Merge pull request #1650 from poanetwork/ab-add-petersburg-evm-version

add petersburg evm version to smart contract verifier
pull/1663/head
Victor Baranov 6 years ago committed by GitHub
commit ad3c86f9c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 18
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex
  3. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex
  4. 3
      apps/block_scout_web/test/block_scout_web/features/address_contract_verification_test.exs
  5. 8
      apps/block_scout_web/test/block_scout_web/features/pages/contract_verify_page.ex
  6. 4
      apps/explorer/lib/explorer/smart_contract/solidity/code_compiler.ex

@ -14,6 +14,7 @@
- [#1639](https://github.com/poanetwork/blockscout/pull/1614) - Optimize token holder count updates when importing address current balances
- [#1643](https://github.com/poanetwork/blockscout/pull/1643) - Set internal_transactions_indexed_at for empty blocks
- [#1647](https://github.com/poanetwork/blockscout/pull/1647) - Fix typo in view
- [#1650](https://github.com/poanetwork/blockscout/pull/1650) - Add petersburg evm version to smart contract verifier
### Chore

@ -2,9 +2,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
use BlockScoutWeb, :controller
alias Explorer.Chain.SmartContract
alias Explorer.SmartContract.{Publisher, Solidity.CompilerVersion}
@evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople"]
alias Explorer.SmartContract.{Publisher, Solidity.CodeCompiler, Solidity.CompilerVersion}
def new(conn, %{"address_id" => address_hash_string}) do
changeset =
@ -15,7 +13,11 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
{:ok, compiler_versions} = CompilerVersion.fetch_versions()
render(conn, "new.html", changeset: changeset, compiler_versions: compiler_versions, evm_versions: @evm_versions)
render(conn, "new.html",
changeset: changeset,
compiler_versions: compiler_versions,
evm_versions: CodeCompiler.allowed_evm_versions()
)
end
def create(
@ -27,7 +29,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
"evm_version" => evm_version
}
) do
smart_sontact_with_evm_version = Map.put(smart_contract, "evm_version", evm_version)
smart_sontact_with_evm_version = Map.put(smart_contract, "evm_version", evm_version["evm_version"])
case Publisher.publish(address_hash_string, smart_sontact_with_evm_version, external_libraries) do
{:ok, _smart_contract} ->
@ -36,7 +38,11 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
{:error, changeset} ->
{:ok, compiler_versions} = CompilerVersion.fetch_versions()
render(conn, "new.html", changeset: changeset, compiler_versions: compiler_versions, evm_versions: @evm_versions)
render(conn, "new.html",
changeset: changeset,
compiler_versions: compiler_versions,
evm_versions: CodeCompiler.allowed_evm_versions()
)
end
end
end

@ -29,7 +29,7 @@
<div class="form-group">
<%= label :evm_version, :evm_version, gettext("EVM Version") %>
<%= select :evm_version, :evm_version, @evm_versions, class: "form-control", selected: "byzantium", "aria-describedby": "evm-version-help-block" %>
<%= select :evm_version, :evm_version, @evm_versions, class: "form-control", selected: "petersburg", "aria-describedby": "evm-version-help-block" %>
</div>
<div class="form-group mb-4">

@ -36,7 +36,8 @@ defmodule BlockScoutWeb.AddressContractVerificationTest do
contract_name: name,
version: version,
optimization: false,
source_code: source_code
source_code: source_code,
evm_version: "byzantium"
})
|> ContractVerifyPage.verify_and_publish()

@ -13,7 +13,8 @@ defmodule BlockScoutWeb.ContractVerifyPage do
contract_name: contract_name,
version: version,
optimization: optimization,
source_code: source_code
source_code: source_code,
evm_version: evm_version
}) do
session
|> fill_in(css("[data-test='contract_name']"), with: contract_name)
@ -24,6 +25,11 @@ defmodule BlockScoutWeb.ContractVerifyPage do
_ -> click(session, option(version))
end
case evm_version do
nil -> nil
_ -> click(session, option(evm_version))
end
case optimization do
true ->
click(session, radio_button("Yes"))

@ -4,7 +4,7 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
"""
@new_contract_name "New.sol"
@allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople"]
@allowed_evm_versions ["homestead", "tangerineWhistle", "spuriousDragon", "byzantium", "constantinople", "petersburg"]
@doc """
Compiles a code in the solidity command line.
@ -98,6 +98,8 @@ defmodule Explorer.SmartContract.Solidity.CodeCompiler do
end
end
def allowed_evm_versions, do: @allowed_evm_versions
def get_contract_info(contracts, _) when contracts == %{}, do: {:error, :compilation}
def get_contract_info(contracts, name) do

Loading…
Cancel
Save