diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3fef2c90..304604deb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - [#6912](https://github.com/blockscout/blockscout/pull/6912) - Docker compose fix exposed ports - [#6833](https://github.com/blockscout/blockscout/pull/6833) - Fix an error occurred when decoding base64 encoded json +- [#6911](https://github.com/blockscout/blockscout/pull/6911) - Fix bugs in verification API v2 - [#6891](https://github.com/blockscout/blockscout/pull/6891) - Fix read contract for geth - [#6889](https://github.com/blockscout/blockscout/pull/6889) - Fix Internal Server Error on tx input decoding - [#6893](https://github.com/blockscout/blockscout/pull/6893) - Fix token type definition for multiple interface tokens diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/verification_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/verification_controller.ex index 380d3dc2a7..8ac0bf29cf 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/verification_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v2/verification_controller.ex @@ -113,7 +113,10 @@ defmodule BlockScoutWeb.API.V2.VerificationController do files_content <- PublishHelper.read_files(files_array) do chosen_contract = params["chosen_contract_index"] - Que.add(SolidityPublisherWorker, {"sourcify_api_v2", address_hash_string, files_content, conn, chosen_contract}) + Que.add( + SolidityPublisherWorker, + {"sourcify_api_v2", String.downcase(address_hash_string), files_content, conn, chosen_contract} + ) conn |> put_view(ApiView) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/verification_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/verification_controller_test.exs index 9ae14d31eb..cca0314023 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/verification_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/verification_controller_test.exs @@ -183,7 +183,7 @@ defmodule BlockScoutWeb.API.V2.VerificationControllerTest do _contract = insert(:address, hash: address, contract_code: "0x01") - topic = "addresses:#{address}" + topic = "addresses:#{String.downcase(address)}" {:ok, _reply, _socket} = UserSocketV2 diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/publish_helper.ex b/apps/explorer/lib/explorer/smart_contract/solidity/publish_helper.ex index 99784864d8..eb34687e53 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publish_helper.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publish_helper.ex @@ -94,15 +94,29 @@ defmodule Explorer.SmartContract.Solidity.PublishHelper do def get_one_json(files_array) do files_array - |> Enum.filter(fn file -> file.content_type == "application/json" end) + |> Enum.filter(fn file -> + case file do + %Plug.Upload{content_type: content_type} -> + content_type == "application/json" + + _ -> + false + end + end) |> Enum.at(0) end # sobelow_skip ["Traversal.FileModule"] def read_files(plug_uploads) do - Enum.reduce(plug_uploads, %{}, fn %Plug.Upload{path: path, filename: file_name}, acc -> - {:ok, file_content} = File.read(path) - Map.put(acc, file_name, file_content) + Enum.reduce(plug_uploads, %{}, fn file, acc -> + case file do + %Plug.Upload{path: path, filename: file_name} -> + {:ok, file_content} = File.read(path) + Map.put(acc, file_name, file_content) + + _ -> + acc + end end) end