From 3cb6de8540b7501184a76b5aa24faccd69c5ac4b Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 13 Apr 2022 11:01:40 +0300 Subject: [PATCH] Fix unverified_smart_contract function: add md5 of bytecode to the changeset --- CHANGELOG.md | 1 + .../controllers/api/rpc/contract_controller.ex | 14 +++++++++++++- .../explorer/smart_contract/solidity/publisher.ex | 7 +++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4de622554..64c327ff14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#5268](https://github.com/blockscout/blockscout/pull/5268) - Contract names display improvement ### Fixes +- [#5455](https://github.com/blockscout/blockscout/pull/5455) - Fix unverified_smart_contract function: add md5 of bytecode to the changeset - [#5443](https://github.com/blockscout/blockscout/pull/5443) - Geth: display tx revert reason - [#5416](https://github.com/blockscout/blockscout/pull/5416) - Fix getsourcecode for EOA addresses - [#5411](https://github.com/blockscout/blockscout/pull/5411) - Fix character_not_in_repertoire error for tx revert reason diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex index ae289a38a2..5ab78945a6 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex @@ -15,7 +15,7 @@ defmodule BlockScoutWeb.API.RPC.ContractController do alias Explorer.SmartContract.Vyper.Publisher, as: VyperPublisher alias Explorer.ThirdPartyIntegrations.Sourcify - @smth_went_wrong "Something went wrong while publishing the contract." + @smth_went_wrong "Something went wrong while publishing the contract" @verified "Smart-contract already verified." @invalid_address "Invalid address hash" @invalid_args "Invalid args format" @@ -46,10 +46,22 @@ defmodule BlockScoutWeb.API.RPC.ContractController do }}} -> render(conn, :error, error: @verified) + {:publish, {:error, error}} -> + Logger.error(fn -> + [ + @smth_went_wrong, + ": ", + inspect(error) + ] + end) + + render(conn, :error, error: "#{@smth_went_wrong}: #{inspect(error.errors)}") + {:publish, error} -> Logger.error(fn -> [ @smth_went_wrong, + ": ", inspect(error) ] end) diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex index e947461b11..7c55ead663 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex @@ -5,7 +5,7 @@ defmodule Explorer.SmartContract.Solidity.Publisher do alias Explorer.Chain alias Explorer.Chain.SmartContract - alias Explorer.SmartContract.CompilerVersion + alias Explorer.SmartContract.{CompilerVersion, Helper} alias Explorer.SmartContract.Solidity.Verifier @doc """ @@ -91,7 +91,10 @@ defmodule Explorer.SmartContract.Solidity.Publisher do end defp unverified_smart_contract(address_hash, params, error, error_message, json_verification \\ false) do - attrs = attributes(address_hash, params) + attrs = + address_hash + |> attributes(params) + |> Helper.add_contract_code_md5() changeset = SmartContract.invalid_contract_changeset(