From e699b1e0de1b189dcd711ab777c87657d71d81ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=9F=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=BD=D1=8F=D0=BA=D0=BE=D0=B2?= Date: Tue, 9 Aug 2022 14:46:42 +0300 Subject: [PATCH] Finalize rust verifier micro-service integration --- .dialyzer-ignore | 6 +- .../assets/js/pages/verification_form.js | 5 +- ...ddress_contract_verification_controller.ex | 7 +- ...ification_via_flattened_code_controller.ex | 2 +- .../api/rpc/contract_controller.ex | 2 +- .../lib/block_scout_web/notifier.ex | 15 +-- apps/block_scout_web/priv/gettext/default.pot | 125 +++++++++++------- .../priv/gettext/en/LC_MESSAGES/default.po | 125 +++++++++++------- .../lib/explorer/smart_contract/helper.ex | 4 +- .../smart_contract/rust_verifier_interface.ex | 17 ++- .../smart_contract/solidity/publisher.ex | 95 ++++++------- .../solidity/publisher_worker.ex | 8 +- .../smart_contract/solidity/verifier.ex | 18 ++- .../third_party_integrations/sourcify.ex | 7 +- 14 files changed, 257 insertions(+), 179 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 7f10f09ac2..654d998e12 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -22,11 +22,11 @@ lib/explorer/smart_contract/reader.ex:435 lib/indexer/fetcher/token_total_supply_on_demand.ex:16 lib/explorer/exchange_rates/source.ex:116 lib/explorer/exchange_rates/source.ex:119 -lib/explorer/smart_contract/solidity/verifier.ex:223 +lib/explorer/smart_contract/solidity/verifier.ex:310 lib/block_scout_web/templates/address_contract/index.html.eex:158 lib/block_scout_web/templates/address_contract/index.html.eex:195 -lib/explorer/third_party_integrations/sourcify.ex:73 -lib/explorer/third_party_integrations/sourcify.ex:76 +lib/explorer/third_party_integrations/sourcify.ex:120 +lib/explorer/third_party_integrations/sourcify.ex:123 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 diff --git a/apps/block_scout_web/assets/js/pages/verification_form.js b/apps/block_scout_web/assets/js/pages/verification_form.js index 0f052f05be..008209c1a3 100644 --- a/apps/block_scout_web/assets/js/pages/verification_form.js +++ b/apps/block_scout_web/assets/js/pages/verification_form.js @@ -188,6 +188,7 @@ if ($contractVerificationPage.length) { const $jsonDropzoneMetadata = $('#metadata-json-dropzone-form') const $jsonDropzoneStandardInput = $('#standard-json-dropzone-form') + let dropzone if ($jsonDropzoneMetadata.length || $jsonDropzoneStandardInput.length) { const func = $jsonDropzoneMetadata.length ? metadataJSONBehavior : standardJSONBehavior @@ -196,7 +197,7 @@ if ($contractVerificationPage.length) { const tag = $jsonDropzoneMetadata.length ? '#metadata-json-dropzone-form' : '#standard-json-dropzone-form' const jsonVerificationType = $jsonDropzoneMetadata.length ? 'json:metadata' : 'json:standard' - var dropzone = new Dropzone(tag, { + dropzone = new Dropzone(tag, { autoProcessQueue: false, acceptedFiles, parallelUploads: 100, @@ -219,7 +220,7 @@ if ($contractVerificationPage.length) { const tag = '#multi-part-dropzone-form' const jsonVerificationType = 'multi-part-files' - var dropzone = new Dropzone(tag, { + dropzone = new Dropzone(tag, { autoProcessQueue: false, acceptedFiles, parallelUploads: 100, 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 2d93d61037..7a56e647a4 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 @@ -59,7 +59,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do |> Map.values() |> read_files() - Que.add(SolidityPublisherWorker, {smart_contract, files_array, external_libraries, conn}) + Que.add(SolidityPublisherWorker, {"multipart", smart_contract, files_array, external_libraries, conn}) send_resp(conn, 204, "") end @@ -71,7 +71,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do "external_libraries" => external_libraries } ) do - Que.add(SolidityPublisherWorker, {smart_contract, external_libraries, conn}) + Que.add(SolidityPublisherWorker, {"flattened", smart_contract, external_libraries, conn}) send_resp(conn, 204, "") end @@ -89,7 +89,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do with %Plug.Upload{path: path} <- get_one_json(files_array), {:ok, json_input} <- File.read(path) do - Que.add(SolidityPublisherWorker, {smart_contract, json_input, conn}) + Que.add(SolidityPublisherWorker, {"json_web", smart_contract, json_input, conn}) else _ -> nil @@ -245,6 +245,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do |> Enum.at(0) end + # sobelow_skip ["Traversal.FileModule"] defp read_files(plug_uploads) do Enum.reduce(plug_uploads, %{}, fn %Plug.Upload{path: path, filename: file_name}, acc -> {:ok, file_content} = File.read(path) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_flattened_code_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_flattened_code_controller.ex index 6cde85f131..632c057814 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_flattened_code_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_flattened_code_controller.ex @@ -46,7 +46,7 @@ defmodule BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController do "external_libraries" => external_libraries } ) do - Que.add(PublisherWorker, {smart_contract, external_libraries, conn}) + Que.add(PublisherWorker, {"flattened", smart_contract, external_libraries, conn}) send_resp(conn, 204, "") end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex index 50279bad53..d1e132b15e 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex @@ -120,7 +120,7 @@ defmodule BlockScoutWeb.API.RPC.ContractController do {:format, {:ok, _casted_address_hash}} <- to_address_hash(address_hash), {:params, {:ok, fetched_params}} <- {:params, fetch_verifysourcecode_params(params)}, uid <- VerificationStatus.generate_uid(address_hash) do - Que.add(SolidityPublisherWorker, {fetched_params, json_input, uid}) + Que.add(SolidityPublisherWorker, {"json_api", fetched_params, json_input, uid}) render(conn, :show, %{result: uid}) else diff --git a/apps/block_scout_web/lib/block_scout_web/notifier.ex b/apps/block_scout_web/lib/block_scout_web/notifier.ex index 714b879d37..286d911453 100644 --- a/apps/block_scout_web/lib/block_scout_web/notifier.ex +++ b/apps/block_scout_web/lib/block_scout_web/notifier.ex @@ -207,17 +207,13 @@ defmodule BlockScoutWeb.Notifier do end def select_contract_type_and_form_view(params) do - verification_from_metadata_json? = - Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "json:metadata" + verification_from_metadata_json? = check_verification_type(params, "json:metadata") - verification_from_standard_json_input? = - Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "json:standard" + verification_from_standard_json_input? = check_verification_type(params, "json:standard") - verification_from_vyper? = - Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "vyper" + verification_from_vyper? = check_verification_type(params, "vyper") - verification_from_multi_part_files? = - Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "multi-part-files" + verification_from_multi_part_files? = check_verification_type(params, "multi-part-files") compiler = if verification_from_vyper?, do: :vyper, else: :solc @@ -233,6 +229,9 @@ defmodule BlockScoutWeb.Notifier do %{view: view, compiler: compiler} end + defp check_verification_type(params, type), + do: Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == type + @doc """ Broadcast the percentage of blocks indexed so far. """ diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 72955cf949..62b8db0fbf 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1,12 +1,12 @@ #: lib/block_scout_web/views/address_token_balance_view.ex:10 -#, elixir-format +#, elixir-autogen, elixir-format msgid "%{count} token" msgid_plural "%{count} tokens" msgstr[0] "" msgstr[1] "" #: lib/block_scout_web/templates/block/_tile.html.eex:29 -#, elixir-format +#, elixir-autogen, elixir-format msgid "%{count} transaction" msgid_plural "%{count} transactions" msgstr[0] "" @@ -158,6 +158,11 @@ msgstr "" msgid "Address (external or contract) sending the transaction." msgstr "" +#: lib/block_scout_web/templates/address/overview.html.eex:165 +#, elixir-autogen, elixir-format +msgid "Address balance in" +msgstr "" + #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:50 #, elixir-autogen, elixir-format msgid "Address of the token contract" @@ -214,6 +219,11 @@ msgstr "" msgid "Apps" msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:21 +#, elixir-autogen, elixir-format +msgid "Average" +msgstr "" + #: lib/block_scout_web/templates/chain/show.html.eex:100 #, elixir-autogen, elixir-format msgid "Average block time" @@ -367,9 +377,10 @@ msgstr "" msgid "Call Code" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:120 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:145 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:41 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:141 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:55 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:51 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 @@ -452,6 +463,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:2 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:6 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:2 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:6 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:4 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 @@ -528,6 +540,7 @@ msgid "Contract Creation Code" msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:86 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:80 #, elixir-autogen, elixir-format msgid "Contract Libraries" msgstr "" @@ -702,6 +715,11 @@ msgstr "" msgid "Current transaction state: Success, Failed (Error), or Pending (In Process)" msgstr "" +#: lib/block_scout_web/templates/chain/show.html.eex:69 +#, elixir-autogen, elixir-format +msgid "Daily Transactions" +msgstr "" + #: lib/block_scout_web/templates/address_logs/_logs.html.eex:101 #: lib/block_scout_web/templates/log/_data_decoded_view.html.eex:7 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:23 @@ -803,6 +821,11 @@ msgstr "" msgid "Drop sources and metadata JSON file or click here" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:67 +#, elixir-autogen, elixir-format +msgid "Drop sources or click here" +msgstr "" + #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:28 #, elixir-autogen, elixir-format msgid "Drop the standard input JSON file or click here" @@ -848,6 +871,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:76 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:26 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:22 #, elixir-autogen, elixir-format msgid "EVM Version" msgstr "" @@ -883,6 +907,11 @@ msgstr "" msgid "Error" msgstr "" +#: lib/block_scout_web/templates/transaction/_tile.html.eex:9 +#, elixir-autogen, elixir-format +msgid "Error in internal transactions" +msgstr "" + #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:33 #, elixir-autogen, elixir-format msgid "Error rendering value" @@ -966,6 +995,11 @@ msgstr "" msgid "Failed to decode log data." msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22 +#, elixir-autogen, elixir-format +msgid "Fast" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:263 #, elixir-autogen, elixir-format msgid "Fetching gas used..." @@ -1049,6 +1083,12 @@ msgstr "" msgid "Gas Used by Transaction" msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:3 +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:18 +#, elixir-autogen, elixir-format +msgid "Gas tracker" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:255 #, elixir-autogen, elixir-format msgid "Gas used by the address." @@ -1254,9 +1294,10 @@ msgstr "" msgid "Loading chart..." msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:70 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:77 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:139 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:35 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:133 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:49 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:45 #: lib/block_scout_web/templates/address_read_contract/index.html.eex:12 @@ -1416,6 +1457,7 @@ msgid "New Smart Contract Verification" msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:9 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:7 #, elixir-autogen, elixir-format msgid "New Solidity Smart Contract Verification" msgstr "" @@ -1425,10 +1467,11 @@ msgstr "" msgid "New Vyper Smart Contract Verification" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:73 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:80 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:88 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:96 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:87 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:95 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:103 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:111 #, elixir-autogen, elixir-format msgid "Next" msgstr "" @@ -1436,6 +1479,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_common_fields/_fetch_constructor_args.html.eex:9 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_include_nightly_builds_field.html.eex:9 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:42 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:38 #, elixir-autogen, elixir-format msgid "No" msgstr "" @@ -1499,6 +1543,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:70 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:58 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:54 #, elixir-autogen, elixir-format msgid "Optimization runs" msgstr "" @@ -1658,6 +1703,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:142 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:38 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:138 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:52 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:48 #, elixir-autogen, elixir-format @@ -1775,6 +1821,11 @@ msgstr "" msgid "Size of the block in bytes." msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:20 +#, elixir-autogen, elixir-format +msgid "Slow" +msgstr "" + #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:30 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:50 #: lib/block_scout_web/templates/address_logs/index.html.eex:23 @@ -1808,6 +1859,11 @@ msgstr "" msgid "Sorry, We are unable to locate this transaction Hash" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:63 +#, elixir-autogen, elixir-format +msgid "Sources *.sol files" +msgstr "" + #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:14 #, elixir-autogen, elixir-format msgid "Sources and Metadata JSON" @@ -2473,6 +2529,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:141 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:37 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:137 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:51 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:47 #, elixir-autogen, elixir-format @@ -2506,6 +2563,11 @@ msgstr "" msgid "Via flattened source code" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:40 +#, elixir-autogen, elixir-format +msgid "Via multi-part files" +msgstr "" + #: lib/block_scout_web/templates/chain/show.html.eex:152 #, elixir-autogen, elixir-format msgid "View All Blocks" @@ -2557,7 +2619,7 @@ msgstr "" msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:46 #, elixir-autogen, elixir-format msgid "Vyper contract" msgstr "" @@ -2609,6 +2671,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_common_fields/_fetch_constructor_args.html.eex:14 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_include_nightly_builds_field.html.eex:14 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:47 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:43 #, elixir-autogen, elixir-format msgid "Yes" msgstr "" @@ -2648,6 +2711,11 @@ msgstr "" msgid "custom RPC" msgstr "" +#: lib/block_scout_web/templates/address/overview.html.eex:165 +#, elixir-autogen, elixir-format +msgid "doesn't include ERC20, ERC721, ERC1155 tokens)." +msgstr "" + #: lib/block_scout_web/templates/common_components/_rap_pagination_container.html.eex:13 #, elixir-autogen, elixir-format msgid "elements are displayed" @@ -2718,44 +2786,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "true" msgstr "" - -#: lib/block_scout_web/templates/transaction/_tile.html.eex:9 -#, elixir-autogen, elixir-format -msgid "Error in internal transactions" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:21 -#, elixir-autogen, elixir-format -msgid "Average" -msgstr "" - -#: lib/block_scout_web/templates/chain/show.html.eex:69 -#, elixir-autogen, elixir-format -msgid "Daily Transactions" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22 -#, elixir-autogen, elixir-format -msgid "Fast" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:3 -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:18 -#, elixir-autogen, elixir-format -msgid "Gas tracker" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:20 -#, elixir-autogen, elixir-format -msgid "Slow" -msgstr "" - -#: lib/block_scout_web/templates/address/overview.html.eex:165 -#, elixir-autogen, elixir-format -msgid "Address balance in" -msgstr "" - -#: lib/block_scout_web/templates/address/overview.html.eex:165 -#, elixir-autogen, elixir-format -msgid "doesn't include ERC20, ERC721, ERC1155 tokens)." -msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index bf94736835..62b8db0fbf 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -1,12 +1,12 @@ #: lib/block_scout_web/views/address_token_balance_view.ex:10 -#, elixir-format +#, elixir-autogen, elixir-format msgid "%{count} token" msgid_plural "%{count} tokens" msgstr[0] "" msgstr[1] "" #: lib/block_scout_web/templates/block/_tile.html.eex:29 -#, elixir-format +#, elixir-autogen, elixir-format msgid "%{count} transaction" msgid_plural "%{count} transactions" msgstr[0] "" @@ -158,6 +158,11 @@ msgstr "" msgid "Address (external or contract) sending the transaction." msgstr "" +#: lib/block_scout_web/templates/address/overview.html.eex:165 +#, elixir-autogen, elixir-format +msgid "Address balance in" +msgstr "" + #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:50 #, elixir-autogen, elixir-format msgid "Address of the token contract" @@ -214,6 +219,11 @@ msgstr "" msgid "Apps" msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:21 +#, elixir-autogen, elixir-format +msgid "Average" +msgstr "" + #: lib/block_scout_web/templates/chain/show.html.eex:100 #, elixir-autogen, elixir-format msgid "Average block time" @@ -367,9 +377,10 @@ msgstr "" msgid "Call Code" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:120 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:145 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:41 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:141 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:55 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:51 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 @@ -452,6 +463,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:2 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:6 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:2 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:6 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:4 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 @@ -528,6 +540,7 @@ msgid "Contract Creation Code" msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:86 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:80 #, elixir-autogen, elixir-format msgid "Contract Libraries" msgstr "" @@ -702,6 +715,11 @@ msgstr "" msgid "Current transaction state: Success, Failed (Error), or Pending (In Process)" msgstr "" +#: lib/block_scout_web/templates/chain/show.html.eex:69 +#, elixir-autogen, elixir-format +msgid "Daily Transactions" +msgstr "" + #: lib/block_scout_web/templates/address_logs/_logs.html.eex:101 #: lib/block_scout_web/templates/log/_data_decoded_view.html.eex:7 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:23 @@ -803,6 +821,11 @@ msgstr "" msgid "Drop sources and metadata JSON file or click here" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:67 +#, elixir-autogen, elixir-format +msgid "Drop sources or click here" +msgstr "" + #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:28 #, elixir-autogen, elixir-format msgid "Drop the standard input JSON file or click here" @@ -848,6 +871,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:76 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:26 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:22 #, elixir-autogen, elixir-format msgid "EVM Version" msgstr "" @@ -883,6 +907,11 @@ msgstr "" msgid "Error" msgstr "" +#: lib/block_scout_web/templates/transaction/_tile.html.eex:9 +#, elixir-autogen, elixir-format +msgid "Error in internal transactions" +msgstr "" + #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:33 #, elixir-autogen, elixir-format msgid "Error rendering value" @@ -966,6 +995,11 @@ msgstr "" msgid "Failed to decode log data." msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22 +#, elixir-autogen, elixir-format +msgid "Fast" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:263 #, elixir-autogen, elixir-format msgid "Fetching gas used..." @@ -1049,6 +1083,12 @@ msgstr "" msgid "Gas Used by Transaction" msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:3 +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:18 +#, elixir-autogen, elixir-format +msgid "Gas tracker" +msgstr "" + #: lib/block_scout_web/templates/address/overview.html.eex:255 #, elixir-autogen, elixir-format msgid "Gas used by the address." @@ -1254,9 +1294,10 @@ msgstr "" msgid "Loading chart..." msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:70 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:77 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:139 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:35 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:133 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:49 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:45 #: lib/block_scout_web/templates/address_read_contract/index.html.eex:12 @@ -1416,6 +1457,7 @@ msgid "New Smart Contract Verification" msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:9 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:7 #, elixir-autogen, elixir-format msgid "New Solidity Smart Contract Verification" msgstr "" @@ -1425,10 +1467,11 @@ msgstr "" msgid "New Vyper Smart Contract Verification" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:73 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:80 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:88 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:96 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:87 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:95 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:103 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:111 #, elixir-autogen, elixir-format msgid "Next" msgstr "" @@ -1436,6 +1479,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_common_fields/_fetch_constructor_args.html.eex:9 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_include_nightly_builds_field.html.eex:9 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:42 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:38 #, elixir-autogen, elixir-format msgid "No" msgstr "" @@ -1499,6 +1543,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:70 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:58 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:54 #, elixir-autogen, elixir-format msgid "Optimization runs" msgstr "" @@ -1658,6 +1703,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:142 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:38 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:138 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:52 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:48 #, elixir-autogen, elixir-format @@ -1775,6 +1821,11 @@ msgstr "" msgid "Size of the block in bytes." msgstr "" +#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:20 +#, elixir-autogen, elixir-format +msgid "Slow" +msgstr "" + #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:30 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:50 #: lib/block_scout_web/templates/address_logs/index.html.eex:23 @@ -1808,6 +1859,11 @@ msgstr "" msgid "Sorry, We are unable to locate this transaction Hash" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:63 +#, elixir-autogen, elixir-format +msgid "Sources *.sol files" +msgstr "" + #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:14 #, elixir-autogen, elixir-format msgid "Sources and Metadata JSON" @@ -2473,6 +2529,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:141 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:37 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:137 #: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:51 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:47 #, elixir-autogen, elixir-format @@ -2506,6 +2563,11 @@ msgstr "" msgid "Via flattened source code" msgstr "" +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:40 +#, elixir-autogen, elixir-format +msgid "Via multi-part files" +msgstr "" + #: lib/block_scout_web/templates/chain/show.html.eex:152 #, elixir-autogen, elixir-format msgid "View All Blocks" @@ -2557,7 +2619,7 @@ msgstr "" msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:46 #, elixir-autogen, elixir-format msgid "Vyper contract" msgstr "" @@ -2609,6 +2671,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification_common_fields/_fetch_constructor_args.html.eex:14 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_include_nightly_builds_field.html.eex:14 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:47 +#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:43 #, elixir-autogen, elixir-format msgid "Yes" msgstr "" @@ -2648,6 +2711,11 @@ msgstr "" msgid "custom RPC" msgstr "" +#: lib/block_scout_web/templates/address/overview.html.eex:165 +#, elixir-autogen, elixir-format +msgid "doesn't include ERC20, ERC721, ERC1155 tokens)." +msgstr "" + #: lib/block_scout_web/templates/common_components/_rap_pagination_container.html.eex:13 #, elixir-autogen, elixir-format msgid "elements are displayed" @@ -2718,44 +2786,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "true" msgstr "" - -#: lib/block_scout_web/templates/transaction/_tile.html.eex:9 -#, elixir-autogen, elixir-format -msgid "Error in internal transactions" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:21 -#, elixir-autogen, elixir-format -msgid "Average" -msgstr "" - -#: lib/block_scout_web/templates/chain/show.html.eex:69 -#, elixir-autogen, elixir-format -msgid "Daily Transactions" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22 -#, elixir-autogen, elixir-format -msgid "Fast" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:3 -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:18 -#, elixir-autogen, elixir-format -msgid "Gas tracker" -msgstr "" - -#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:20 -#, elixir-autogen, elixir-format -msgid "Slow" -msgstr "" - -#: lib/block_scout_web/templates/address/overview.html.eex:165 -#, elixir-autogen, elixir-format -msgid "Address balance in" -msgstr "" - -#: lib/block_scout_web/templates/address/overview.html.eex:165 -#, elixir-autogen, elixir-format, fuzzy -msgid "doesn't include ERC20, ERC721, ERC1155 tokens)." -msgstr "" diff --git a/apps/explorer/lib/explorer/smart_contract/helper.ex b/apps/explorer/lib/explorer/smart_contract/helper.ex index a314e2ed4a..89a58f0cc8 100644 --- a/apps/explorer/lib/explorer/smart_contract/helper.ex +++ b/apps/explorer/lib/explorer/smart_contract/helper.ex @@ -82,7 +82,7 @@ defmodule Explorer.SmartContract.Helper do |> String.trim() end - defp sol_file?(filename) do + def sol_file?(filename) do case List.last(String.split(String.downcase(filename), ".")) do "sol" -> true @@ -92,7 +92,7 @@ defmodule Explorer.SmartContract.Helper do end end - defp json_file?(filename) do + def json_file?(filename) do case List.last(String.split(String.downcase(filename), ".")) do "json" -> true diff --git a/apps/explorer/lib/explorer/smart_contract/rust_verifier_interface.ex b/apps/explorer/lib/explorer/smart_contract/rust_verifier_interface.ex index b4f10fa95e..8d973ae354 100644 --- a/apps/explorer/lib/explorer/smart_contract/rust_verifier_interface.ex +++ b/apps/explorer/lib/explorer/smart_contract/rust_verifier_interface.ex @@ -1,4 +1,7 @@ defmodule Explorer.SmartContract.RustVerifierInterface do + @moduledoc """ + Adapter for contracts verification with https://github.com/blockscout/blockscout-rs/tree/main/verification + """ alias HTTPoison.Response require Logger @@ -26,7 +29,7 @@ defmodule Explorer.SmartContract.RustVerifierInterface do "input" => _ } = body ) do - http_post_request(multiple_files_verification_url(), body) + http_post_request(standard_json_input_verification_url(), body) end def http_post_request(url, body) do @@ -71,7 +74,7 @@ defmodule Explorer.SmartContract.RustVerifierInterface do end end - def get_versions_list() do + def get_versions_list do http_get_request(versions_list_url()) end @@ -97,13 +100,13 @@ defmodule Explorer.SmartContract.RustVerifierInterface do def proccess_verifier_response(other), do: {:error, other} - def multiple_files_verification_url(), do: "#{base_url()}" <> "/api/v1/solidity/verify/multiple-files" + def multiple_files_verification_url, do: "#{base_url()}" <> "/api/v1/solidity/verify/multiple-files" - def standard_json_input_verification_url(), do: "#{base_url()}" <> "/api/v1/solidity/verify/standard-json" + def standard_json_input_verification_url, do: "#{base_url()}" <> "/api/v1/solidity/verify/standard-json" - def versions_list_url(), do: "#{base_url()}" <> "/api/v1/solidity/versions" + def versions_list_url, do: "#{base_url()}" <> "/api/v1/solidity/versions" - def base_url(), do: Application.get_env(:explorer, __MODULE__)[:service_url] + def base_url, do: Application.get_env(:explorer, __MODULE__)[:service_url] - def enabled?(), do: Application.get_env(:explorer, __MODULE__)[:enabled] + def enabled?, do: Application.get_env(:explorer, __MODULE__)[:enabled] end diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex index 9d1fe0bbb1..094d7ed761 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex @@ -41,12 +41,12 @@ defmodule Explorer.SmartContract.Solidity.Publisher do "optimization" => _, "optimization_runs" => _, "sources" => sources - } = params + } = result_params } -> %{^file_name => contract_source_code} = sources prepared_params = - params + result_params |> Map.put("contract_source_code", contract_source_code) |> Map.put("external_libraries", contract_libraries) |> Map.put("name", contract_name) @@ -77,33 +77,18 @@ defmodule Explorer.SmartContract.Solidity.Publisher do case Verifier.evaluate_authenticity_via_standard_json_input(address_hash, params, json_input) do {:ok, %{ - "abi" => abi_string, + "abi" => _, "compiler_version" => _, "constructor_arguments" => _, - "contract_libraries" => contract_libraries, - "contract_name" => contract_name, + "contract_libraries" => _, + "contract_name" => _, "evm_version" => _, - "file_name" => file_name, + "file_name" => _, "optimization" => _, "optimization_runs" => _, - "sources" => sources - } = params} -> - secondary_sources = - for {file, source} <- sources, - file != file_name, - do: %{"file_name" => file, "contract_source_code" => source, "address_hash" => address_hash} - - %{^file_name => contract_source_code} = sources - - prepared_params = - params - |> Map.put("contract_source_code", contract_source_code) - |> Map.put("external_libraries", contract_libraries) - |> Map.put("name", contract_name) - |> Map.put("file_path", file_name) - |> Map.put("secondary_sources", secondary_sources) - - publish_smart_contract(address_hash, prepared_params, Jason.decode!(abi_string)) + "sources" => _ + } = result_params} -> + proccess_rust_verifier_response(result_params, address_hash) {:ok, %{abi: abi, constructor_arguments: constructor_arguments}, additional_params} -> params_with_constructor_arguments = @@ -134,33 +119,18 @@ defmodule Explorer.SmartContract.Solidity.Publisher do case Verifier.evaluate_authenticity_via_multi_part_files(address_hash, params_with_external_libaries, files) do {:ok, %{ - "abi" => abi_string, + "abi" => _, "compiler_version" => _, "constructor_arguments" => _, - "contract_libraries" => contract_libraries, - "contract_name" => contract_name, + "contract_libraries" => _, + "contract_name" => _, "evm_version" => _, - "file_name" => file_name, + "file_name" => _, "optimization" => _, "optimization_runs" => _, - "sources" => sources - } = params} -> - secondary_sources = - for {file, source} <- sources, - file != file_name, - do: %{"file_name" => file, "contract_source_code" => source, "address_hash" => address_hash} - - %{^file_name => contract_source_code} = sources - - prepared_params = - params - |> Map.put("contract_source_code", contract_source_code) - |> Map.put("external_libraries", contract_libraries) - |> Map.put("name", contract_name) - |> Map.put("file_path", file_name) - |> Map.put("secondary_sources", secondary_sources) - - publish_smart_contract(address_hash, prepared_params, Jason.decode!(abi_string)) + "sources" => _ + } = result_params} -> + proccess_rust_verifier_response(result_params, address_hash) {:error, error} -> {:error, unverified_smart_contract(address_hash, params, error, nil, true)} @@ -170,6 +140,39 @@ defmodule Explorer.SmartContract.Solidity.Publisher do end end + def proccess_rust_verifier_response( + %{ + "abi" => abi_string, + "compiler_version" => _, + "constructor_arguments" => _, + "contract_libraries" => contract_libraries, + "contract_name" => contract_name, + "evm_version" => _, + "file_name" => file_name, + "optimization" => _, + "optimization_runs" => _, + "sources" => sources + } = result_params, + address_hash + ) do + secondary_sources = + for {file, source} <- sources, + file != file_name, + do: %{"file_name" => file, "contract_source_code" => source, "address_hash" => address_hash} + + %{^file_name => contract_source_code} = sources + + prepared_params = + result_params + |> Map.put("contract_source_code", contract_source_code) + |> Map.put("external_libraries", contract_libraries) + |> Map.put("name", contract_name) + |> Map.put("file_path", file_name) + |> Map.put("secondary_sources", secondary_sources) + + publish_smart_contract(address_hash, prepared_params, Jason.decode!(abi_string)) + end + def publish_smart_contract(address_hash, params, abi) do attrs = address_hash |> attributes(params, abi) diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex b/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex index a3484fe0d9..dce4ac6a36 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex @@ -9,7 +9,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do alias Explorer.Chain.SmartContract.VerificationStatus alias Explorer.SmartContract.Solidity.Publisher - def perform({%{"address_hash" => address_hash} = params, external_libraries, conn}) do + def perform({"flattened", %{"address_hash" => address_hash} = params, external_libraries, conn}) do result = case Publisher.publish(address_hash, params, external_libraries) do {:ok, _contract} = result -> @@ -22,7 +22,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand) end - def perform({%{"address_hash" => address_hash} = params, files_map, external_libraries, conn}) + def perform({"multipart", %{"address_hash" => address_hash} = params, files_map, external_libraries, conn}) when is_map(files_map) do result = case Publisher.publish_with_multi_part_files(params, external_libraries, files_map) do @@ -36,7 +36,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do EventsPublisher.broadcast([{:contract_verification_result, {address_hash, result, conn}}], :on_demand) end - def perform({%{"address_hash" => address_hash} = params, json_input, uid}) when is_binary(uid) do + def perform({"json_api", %{"address_hash" => address_hash} = params, json_input, uid}) when is_binary(uid) do VerificationStatus.insert_status(uid, :pending, address_hash) case Publisher.publish_with_standard_json_input(params, json_input) do @@ -48,7 +48,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do end end - def perform({%{"address_hash" => address_hash} = params, json_input, conn}) do + def perform({"json_web", %{"address_hash" => address_hash} = params, json_input, conn}) do result = case Publisher.publish_with_standard_json_input(params, json_input) do {:ok, _contract} = result -> diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/verifier.ex b/apps/explorer/lib/explorer/smart_contract/solidity/verifier.ex index 55bec7a010..64ed84aa67 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/verifier.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/verifier.ex @@ -113,8 +113,22 @@ defmodule Explorer.SmartContract.Solidity.Verifier do end def evaluate_authenticity_via_standard_json_input_inner(true, address_hash, params, json_input) do - # wait update from rust team with modifying json verification end point - verify(address_hash, params, json_input) + deployed_bytecode = Chain.smart_contract_bytecode(address_hash) + + creation_tx_input = + case Chain.smart_contract_creation_tx_bytecode(address_hash) do + %{init: init, created_contract_code: _created_contract_code} -> + init + + _ -> + "" + end + + params + |> Map.put("creation_bytecode", creation_tx_input) + |> Map.put("deployed_bytecode", deployed_bytecode) + |> Map.put("input", json_input) + |> RustVerifierInterface.verify_standard_json_input() end def evaluate_authenticity_via_standard_json_input_inner(false, address_hash, params, json_input) do diff --git a/apps/explorer/lib/explorer/third_party_integrations/sourcify.ex b/apps/explorer/lib/explorer/third_party_integrations/sourcify.ex index 8d5dd1de13..d0885884a4 100644 --- a/apps/explorer/lib/explorer/third_party_integrations/sourcify.ex +++ b/apps/explorer/lib/explorer/third_party_integrations/sourcify.ex @@ -4,8 +4,7 @@ defmodule Explorer.ThirdPartyIntegrations.Sourcify do """ use Tesla - alias Explorer.SmartContract.Helper - alias Explorer.SmartContract.RustVerifierInterface + alias Explorer.SmartContract.{Helper, RustVerifierInterface} alias HTTPoison.{Error, Response} alias Tesla.Multipart @@ -61,6 +60,7 @@ defmodule Explorer.ThirdPartyIntegrations.Sourcify do http_post_request(verify_url(), multipart_body) end + # sobelow_skip ["Traversal.FileModule"] def verify_via_rust_microservice(address_hash_string, files) do chain_id = config(__MODULE__, :chain_id) @@ -180,6 +180,9 @@ defmodule Explorer.ThirdPartyIntegrations.Sourcify do %{"status" => "0"} -> {:ok, body_json} + %{"status" => "1", "message" => message} -> + {:error, message} + %{"result" => [%{"status" => unknown_status}]} -> {:error, unknown_status}