diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a5066706..8774508569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features ### Fixes +- [#4388](https://github.com/blockscout/blockscout/pull/4388) - Fix internal server error on contract page for insctances without sourcify envs ### Chore - [#4382](https://github.com/blockscout/blockscout/pull/4382) - Replace awesomplete with autocomplete.js diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex index b2909bb508..37fc1991d2 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex @@ -275,25 +275,29 @@ defmodule BlockScoutWeb.AddressContractVerificationController do if Chain.smart_contract_fully_verified?(address_hash_string) do {:ok, :already_fully_verified} else - if Chain.smart_contract_verified?(address_hash_string) do - case Sourcify.check_by_address(address_hash_string) do - {:ok, _verified_status} -> - get_metadata_and_publish(address_hash_string, nil) - - _ -> - {:error, :not_verified} - end - else - case Sourcify.check_by_address_any(address_hash_string) do - {:ok, "full", metadata} -> - proccess_metadata_add_publish(address_hash_string, metadata, false) + if Application.get_env(:explorer, Explorer.ThirdPartyIntegrations.Sourcify)[:enabled] do + if Chain.smart_contract_verified?(address_hash_string) do + case Sourcify.check_by_address(address_hash_string) do + {:ok, _verified_status} -> + get_metadata_and_publish(address_hash_string, nil) + + _ -> + {:error, :not_verified} + end + else + case Sourcify.check_by_address_any(address_hash_string) do + {:ok, "full", metadata} -> + proccess_metadata_add_publish(address_hash_string, metadata, false) - {:ok, "partial", metadata} -> - proccess_metadata_add_publish(address_hash_string, metadata, true) + {:ok, "partial", metadata} -> + proccess_metadata_add_publish(address_hash_string, metadata, true) - _ -> - {:error, :not_verified} + _ -> + {:error, :not_verified} + end end + else + {:error, :sourcify_disabled} end end end