Skip to content

Commit

Permalink
Fix unverified_smart_contract function: add md5 of bytecode to the ch…
Browse files Browse the repository at this point in the history
…angeset
  • Loading branch information
vbaranov committed Apr 13, 2022
1 parent 859d91b commit e114177
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -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 """
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e114177

Please sign in to comment.