Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unverified_smart_contract function: add md5 of bytecode to the changeset #5455

Merged
merged 1 commit into from Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
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