Merge pull request #5455 from blockscout/vb-fix-unverified_smart_contract

Fix unverified_smart_contract function: add md5 of bytecode to the changeset
pull/5456/head
Victor Baranov 3 years ago committed by GitHub
commit 9e937f004d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex
  3. 7
      apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex

@ -6,6 +6,7 @@
- [#5268](https://github.com/blockscout/blockscout/pull/5268) - Contract names display improvement - [#5268](https://github.com/blockscout/blockscout/pull/5268) - Contract names display improvement
### Fixes ### 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 - [#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 - [#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 - [#5411](https://github.com/blockscout/blockscout/pull/5411) - Fix character_not_in_repertoire error for tx revert reason

@ -15,7 +15,7 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
alias Explorer.SmartContract.Vyper.Publisher, as: VyperPublisher alias Explorer.SmartContract.Vyper.Publisher, as: VyperPublisher
alias Explorer.ThirdPartyIntegrations.Sourcify 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." @verified "Smart-contract already verified."
@invalid_address "Invalid address hash" @invalid_address "Invalid address hash"
@invalid_args "Invalid args format" @invalid_args "Invalid args format"
@ -46,10 +46,22 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
}}} -> }}} ->
render(conn, :error, error: @verified) 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} -> {:publish, error} ->
Logger.error(fn -> Logger.error(fn ->
[ [
@smth_went_wrong, @smth_went_wrong,
": ",
inspect(error) inspect(error)
] ]
end) end)

@ -5,7 +5,7 @@ defmodule Explorer.SmartContract.Solidity.Publisher do
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.SmartContract alias Explorer.Chain.SmartContract
alias Explorer.SmartContract.CompilerVersion alias Explorer.SmartContract.{CompilerVersion, Helper}
alias Explorer.SmartContract.Solidity.Verifier alias Explorer.SmartContract.Solidity.Verifier
@doc """ @doc """
@ -91,7 +91,10 @@ defmodule Explorer.SmartContract.Solidity.Publisher do
end end
defp unverified_smart_contract(address_hash, params, error, error_message, json_verification \\ false) do 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 = changeset =
SmartContract.invalid_contract_changeset( SmartContract.invalid_contract_changeset(

Loading…
Cancel
Save