Extract error messages to the constant

pull/5647/head
Никита Поздняков 2 years ago
parent 043e89c983
commit 2d06ae6e9e
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 2
      .dialyzer-ignore
  2. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex
  3. 4
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex
  4. 7
      apps/explorer/lib/explorer/third_party_integrations/sourcify.ex

@ -27,8 +27,8 @@ lib/block_scout_web/templates/address_contract/index.html.eex:158
lib/block_scout_web/templates/address_contract/index.html.eex:195
lib/explorer/staking/stake_snapshotting.ex:15: Function do_snapshotting/7 has no local return
lib/explorer/staking/stake_snapshotting.ex:147
lib/explorer/third_party_integrations/sourcify.ex:70
lib/explorer/third_party_integrations/sourcify.ex:73
lib/explorer/third_party_integrations/sourcify.ex:76
lib/block_scout_web/views/transaction_view.ex:137
lib/block_scout_web/views/transaction_view.ex:152
lib/block_scout_web/views/transaction_view.ex:197

@ -198,10 +198,10 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
})
{:error, :metadata} ->
return_sourcify_error(conn, "Sourcify did not return metadata", address_hash_string)
return_sourcify_error(conn, Sourcify.no_metadata_message(), address_hash_string)
_ ->
return_sourcify_error(conn, "Unsuccessful sourcify verification", address_hash_string)
return_sourcify_error(conn, Sourcify.failed_verification_message(), address_hash_string)
end
end

@ -241,10 +241,10 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
)
{:error, :metadata} ->
render(conn, :error, error: "Sourcify did not return metadata")
render(conn, :error, error: Sourcify.no_metadata_message())
_ ->
render(conn, :error, error: "Unsuccessful sourcify verification")
render(conn, :error, error: Sourcify.failed_verification_message())
end
{:error, %{"error" => error}} ->

@ -7,6 +7,9 @@ defmodule Explorer.ThirdPartyIntegrations.Sourcify do
alias HTTPoison.{Error, Response}
alias Tesla.Multipart
@no_metadata_message "Sourcify did not return metadata"
@failed_verification_message "Unsuccessful Sourcify verification"
def check_by_address(address_hash_string) do
chain_id = config(:chain_id)
params = [addresses: address_hash_string, chainIds: chain_id]
@ -307,4 +310,8 @@ defmodule Explorer.ThirdPartyIntegrations.Sourcify do
chain_id = config(:chain_id)
"#{base_server_url()}" <> "/files/any/" <> chain_id
end
def no_metadata_message, do: @no_metadata_message
def failed_verification_message, do: @failed_verification_message
end

Loading…
Cancel
Save