diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 440ecae7f0..602489de42 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -11,7 +11,7 @@ on: env: MIX_ENV: test - OTP_VERSION: '24.2' + OTP_VERSION: '24.2.2' ELIXIR_VERSION: '1.12.3' jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index dadc883aa7..fe195ebc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - [#4862](https://github.com/blockscout/blockscout/pull/4862) - Fix internal transactions pagination ### Chore +- [#5230](https://github.com/blockscout/blockscout/pull/5230) - Contract verification forms refactoring - [#5227](https://github.com/blockscout/blockscout/pull/5227) - Major update of css-loader npm package - [#5226](https://github.com/blockscout/blockscout/pull/5226) - Update mini-css-extract-plugin, css-minimizer-webpack-plugin packages - [#5224](https://github.com/blockscout/blockscout/pull/5224) - Webpack config refactoring 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 2fa313e859..7193b11be9 100644 --- a/apps/block_scout_web/assets/js/pages/verification_form.js +++ b/apps/block_scout_web/assets/js/pages/verification_form.js @@ -143,41 +143,46 @@ if ($contractVerificationPage.length) { $(function () { function standardJSONBehavior () { - $('#json-dropzone-form').removeClass('dz-clickable') + $('#standard-json-dropzone-form').removeClass('dz-clickable') this.on('addedfile', function (_file) { - $('#verify-via-standart-json-input-submit').prop('disabled', false) + $('#verify-via-standard-json-input-submit').prop('disabled', false) $('#file-help-block').text('') $('#dropzone-previews').addClass('dz-started') }) this.on('removedfile', function (_file) { if (this.files.length === 0) { - $('#verify-via-standart-json-input-submit').prop('disabled', true) + $('#verify-via-standard-json-input-submit').prop('disabled', true) $('#dropzone-previews').removeClass('dz-started') } }) } function metadataJSONBehavior () { + $('#metadata-json-dropzone-form').removeClass('dz-clickable') this.on('addedfile', function (_file) { changeVisibilityOfVerifyButton(this.files.length) $('#file-help-block').text('') + $('#dropzone-previews').addClass('dz-started') }) this.on('removedfile', function (_file) { changeVisibilityOfVerifyButton(this.files.length) + if (this.files.length === 0) { + $('#dropzone-previews').removeClass('dz-started') + } }) } - const $jsonDropzoneMetadata = $('#metadata-json-dropzone') - const $jsonDropzoneStandardInput = $('#json-dropzone-form') + const $jsonDropzoneMetadata = $('#metadata-json-dropzone-form') + const $jsonDropzoneStandardInput = $('#standard-json-dropzone-form') if ($jsonDropzoneMetadata.length || $jsonDropzoneStandardInput.length) { const func = $jsonDropzoneMetadata.length ? metadataJSONBehavior : standardJSONBehavior const maxFiles = $jsonDropzoneMetadata.length ? 100 : 1 const acceptedFiles = $jsonDropzoneMetadata.length ? 'text/plain,application/json,.sol,.json' : 'text/plain,application/json,.json' - const tag = $jsonDropzoneMetadata.length ? '#metadata-json-dropzone' : '#json-dropzone-form' - const previewsContainer = $jsonDropzoneMetadata.length ? undefined : '#dropzone-previews' + 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, { autoProcessQueue: false, @@ -187,17 +192,17 @@ if ($contractVerificationPage.length) { addRemoveLinks: true, maxFilesize: 10, maxFiles: maxFiles, - previewsContainer: previewsContainer, - params: { address_hash: $('#smart_contract_address_hash').val() }, + previewsContainer: '#dropzone-previews', + params: { address_hash: $('#smart_contract_address_hash').val(), verification_type: jsonVerificationType }, init: func }) } function changeVisibilityOfVerifyButton (filesLength) { if (filesLength > 0) { - $('#verify-via-json-submit').prop('disabled', false) + $('#verify-via-metadata-json-submit').prop('disabled', false) } else { - $('#verify-via-json-submit').prop('disabled', true) + $('#verify-via-metadata-json-submit').prop('disabled', true) } } @@ -254,7 +259,7 @@ if ($contractVerificationPage.length) { } }) - $('#verify-via-standart-json-input-submit').on('click', (event) => { + $('#verify-via-standard-json-input-submit').on('click', (event) => { event.preventDefault() if (dropzone.files.length > 0) { dropzone.processQueue() @@ -263,7 +268,8 @@ if ($contractVerificationPage.length) { } }) - $('#verify-via-json-submit').on('click', function () { + $('#verify-via-metadata-json-submit').on('click', (event) => { + event.preventDefault() if (dropzone.files.length > 0) { dropzone.processQueue() } else { 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 f0d8a2bba4..ee9cba0d08 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 @@ -62,7 +62,8 @@ defmodule BlockScoutWeb.AddressContractVerificationController do conn, %{ "smart_contract" => smart_contract, - "file" => files + "file" => files, + "verification_type" => "json:standard" } ) do files_array = prepare_files_array(files) @@ -81,7 +82,8 @@ defmodule BlockScoutWeb.AddressContractVerificationController do def create( conn, %{ - "smart_contract" => smart_contract + "smart_contract" => smart_contract, + "verification_type" => "vyper" } ) do Que.add(VyperPublisherWorker, {smart_contract["address_hash"], smart_contract, conn}) @@ -93,7 +95,8 @@ defmodule BlockScoutWeb.AddressContractVerificationController do conn, %{ "address_hash" => address_hash_string, - "file" => files + "file" => files, + "verification_type" => "json:metadata" } ) do files_array = prepare_files_array(files) @@ -140,19 +143,10 @@ defmodule BlockScoutWeb.AddressContractVerificationController do end defp verify_and_publish(address_hash_string, files_array, conn) do - case Sourcify.verify(address_hash_string, files_array) do - {:ok, _verified_status} -> - case Sourcify.check_by_address(address_hash_string) do - {:ok, _verified_status} -> - get_metadata_and_publish(address_hash_string, conn) - - {:error, %{"error" => error}} -> - EventsPublisher.broadcast( - prepare_verification_error(error, address_hash_string, conn), - :on_demand - ) - end - + with {:ok, _verified_status} <- Sourcify.verify(address_hash_string, files_array), + {:ok, _verified_status} <- Sourcify.check_by_address(address_hash_string) do + get_metadata_and_publish(address_hash_string, conn) + else {:error, %{"error" => error}} -> EventsPublisher.broadcast( prepare_verification_error(error, address_hash_string, conn), @@ -221,7 +215,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do errors: [ file: {msg, []} ], - data: %SmartContract{}, + data: %SmartContract{address_hash: address_hash_string}, valid?: false }}, conn}} ] 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 1cde2173d4..e4f7136ba9 100644 --- a/apps/block_scout_web/lib/block_scout_web/notifier.ex +++ b/apps/block_scout_web/lib/block_scout_web/notifier.ex @@ -197,19 +197,23 @@ defmodule BlockScoutWeb.Notifier do end def select_contract_type_and_form_view(params) do - verification_from_json_upload? = Map.has_key?(params, "file") - verification_from_flattened_source? = Map.has_key?(params, "external_libraries") + verification_from_metadata_json? = + Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "json:metadata" - verification_from_standard_json_input? = verification_from_json_upload? && Map.has_key?(params, "smart_contract") + verification_from_standard_json_input? = + Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "json:standard" - compiler = if verification_from_flattened_source? || verification_from_standard_json_input?, do: :solc, else: :vyper + verification_from_vyper? = + Map.has_key?(params, "verification_type") && Map.get(params, "verification_type") == "vyper" + + compiler = if verification_from_vyper?, do: :vyper, else: :solc view = cond do verification_from_standard_json_input? -> AddressContractVerificationViaStandardJsonInputView - verification_from_json_upload? -> AddressContractVerificationViaJsonView - verification_from_flattened_source? -> AddressContractVerificationViaFlattenedCodeView - true -> AddressContractVerificationVyperView + verification_from_metadata_json? -> AddressContractVerificationViaJsonView + verification_from_vyper? -> AddressContractVerificationVyperView + true -> AddressContractVerificationViaFlattenedCodeView end %{view: view, compiler: compiler} diff --git a/apps/block_scout_web/lib/block_scout_web/router.ex b/apps/block_scout_web/lib/block_scout_web/router.ex index e287d05ab5..78a3bb2cd8 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -77,28 +77,6 @@ defmodule BlockScoutWeb.Router do end end - # if path != api_path do - # scope to_string(api_path) <> "/verify_smart_contract" do - # pipe_through(:api) - - # if Application.get_env(:explorer, Explorer.ThirdPartyIntegrations.Sourcify)[:enabled] do - # post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) - # else - # post("/contract_verifications", BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController, :create) - # end - # end - # else - # scope "/verify_smart_contract" do - # pipe_through(:api) - - # if Application.get_env(:explorer, Explorer.ThirdPartyIntegrations.Sourcify)[:enabled] do - # post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) - # else - # post("/contract_verifications", BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController, :create) - # end - # end - # end - if Application.get_env(:block_scout_web, WebRouter)[:enabled] do forward("/", BlockScoutWeb.WebRouter) else diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex index 18c69b13a3..5372e3f71c 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex @@ -9,16 +9,7 @@ [], fn f -> %> -
-
- <%= label f, :address_hash, gettext("Contract Address") %> -
- <%= text_input f, :address_hash, class: "form-control border-rounded", "aria-describedby": "contract-address-help-block", readonly: true %> - <%= error_tag f, :address_hash, id: "contract-address-help-block", class: "text-danger form-error" %> -
-
The 0x address supplied on contract creation.
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_address_field.html", address_hash: @address_hash, f: f %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex index 61775e6488..6084b3b9c1 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex @@ -1,9 +1,10 @@
- -
- readonly=""> -
-
The 0x address supplied on contract creation.
+ <%= label @f, :address_hash, gettext("Contract Address") %> +
+ <%= text_input @f, :address_hash, class: "form-control border-rounded", id: "smart_contract_address_hash", "aria-describedby": "contract-address-help-block", readonly: true %> + <%= error_tag @f, :address_hash, id: "contract-address-help-block", class: "text-danger form-error" %> +
+
The 0x address supplied on contract creation.
\ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_address.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_address.html.eex new file mode 100644 index 0000000000..4f44f6ea0d --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_address.html.eex @@ -0,0 +1,9 @@ +
+
+ <%= label :external_libraries, @library, gettext("Library Address") %> +
+ <%= text_input :external_libraries, @library_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> +
+
<%= if assigns[:tooltip_text] do @tooltip_text end %>
+
+
\ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_name.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_name.html.eex new file mode 100644 index 0000000000..3bd5001961 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_common_fields/_library_name.html.eex @@ -0,0 +1,9 @@ +
+
+ <%= label :external_libraries, @library, gettext("Library Name") %> +
+ <%= text_input :external_libraries, @library_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> +
+
<%= if assigns[:tooltip_text] do @tooltip_text end %>
+
+
\ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex index 52cae5b6f9..5bc87f0887 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex @@ -18,16 +18,7 @@ [], fn f -> %> -
-
- <%= label f, :address_hash, gettext("Contract Address") %> -
- <%= text_input f, :address_hash, class: "form-control border-rounded", "aria-describedby": "contract-address-help-block", readonly: true %> - <%= error_tag f, :address_hash, id: "contract-address-help-block", class: "text-danger form-error" %> -
-
The 0x address supplied on contract creation.
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_address_field.html", address_hash: @address_hash, f: f %> <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_name_field.html", f: f, tooltip: "Must match the name specified in the code. For example, in contract MyContract {..} MyContract is the contract name.", contract_name_value: contract_name_value %> @@ -100,113 +91,41 @@

<%= gettext "Contract Libraries" %>

-
-
- <%= label :external_libraries, :library1, gettext("Library Name") %> -
- <%= text_input :external_libraries, :library1_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
A library name called in the .sol file. Multiple libraries (up to 5) may be added for each contract. Click the Add Library button to add an additional one.
-
-
- -
-
- <%= label :external_libraries, :library1, gettext("Library Address") %> -
- <%= text_input :external_libraries, :library1_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
The 0x library address. This can be found in the generated json file or Truffle output (if using truffle).
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_name.html", + library: :library1, + library_name: :library1_name, + tooltip_text: "A library name called in the .sol file. Multiple libraries (up to 5) may be added for each contract. Click the Add Library button to add an additional one." + %> + + <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_address.html", + library: :library1, + library_address: :library1_address, + tooltip_text: "The 0x library address. This can be found in the generated json file or Truffle output (if using truffle)." + %>
-
-
- <%= label :external_libraries, :library2, gettext("Library Name") %> -
- <%= text_input :external_libraries, :library2_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_name.html", library: :library2, library_name: :library2_name %> -
-
- <%= label :external_libraries, :library2, gettext("Library Address") %> -
- <%= text_input :external_libraries, :library2_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_address.html", library: :library2, library_address: :library2_address %>
-
-
- <%= label :external_libraries, :library3, gettext("Library Name") %> -
- <%= text_input :external_libraries, :library3_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_name.html", library: :library3, library_name: :library3_name %> -
-
- <%= label :external_libraries, :library3, gettext("Library Address") %> -
- <%= text_input :external_libraries, :library3_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_address.html", library: :library3, library_address: :library3_address %>
-
-
- <%= label :external_libraries, :library4, gettext("Library Name") %> -
- <%= text_input :external_libraries, :library4_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_name.html", library: :library4, library_name: :library4_name %> -
-
- <%= label :external_libraries, :library4, gettext("Library Address") %> -
- <%= text_input :external_libraries, :library4_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_address.html", library: :library4, library_address: :library4_address %>
-
-
- <%= label :external_libraries, :library5, gettext("Library Name") %> -
- <%= text_input :external_libraries, :library5_name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_name.html", library: :library5, library_name: :library5_name %> -
-
- <%= label f, :library5, gettext("Library Address") %> -
- <%= text_input f, :library5_address, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_library_address.html", library: :library5, library_address: :library5_address %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex index 061a9b59c3..d12ea45a9f 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex @@ -3,34 +3,27 @@

<%= gettext "New Smart Contract Verification" %>

- -
-
- -
- readonly=""> -
-
The 0x address supplied on contract creation.
-
-
+ <%= form_for @changeset, + address_contract_verification_path(@conn, :create), + [id: "metadata-json-dropzone-form"], + fn f -> %> + <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_address_field.html", address_hash: @address_hash, f: f %>
- <%= form_for @changeset, - address_contract_verification_path(@conn, :create), - [class: "dropzone-1", style: "display: flex; margin: 0 auto;", id: "metadata-json-dropzone"], - fn f -> %> +
- <%= gettext("Drop sources and metadata JSON file or click here") %> + <%= gettext("Drop sources and metadata JSON file or click here") %> <%= error_tag f, :file, id: "file-help-block", class: "text-danger form-error", style: "max-width: 600px;" %>
- <% end %> +
Drop all Solidity contract source files and JSON metadata file(s) created during contract compilation into the drop zone.
+
- + <%= reset gettext("Reset"), class: "btn-line mr-2 js-smart-contract-form-reset" %> <%= link( @@ -51,6 +44,7 @@ ) %>
+ <% end %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex index 4a3eddcde3..49d1e7089b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex @@ -4,17 +4,13 @@ <% fetch_constructor_arguments_automatically = if metadata_for_verification, do: true, else: false %> <% display_constructor_arguments_text_area = if fetch_constructor_arguments_automatically, do: "none", else: "block" %>
- + <%= render BlockScoutWeb.CommonComponentsView, "_channel_disconnected_message.html", text: gettext("Connection Lost") %>

<%= gettext "New Smart Contract Verification" %>

<%= form_for @changeset, address_contract_verification_path(@conn, :create), - [id: "json-dropzone-form"], + [id: "standard-json-dropzone-form"], fn f -> %> <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_address_field.html", address_hash: @address_hash, f: f %> @@ -53,7 +49,7 @@ > <%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html", loading_text: gettext("Loading...") %> - + <%= reset gettext("Reset"), class: "btn-line mr-2 js-smart-contract-form-reset" %> <%= link( diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex index fd5a919e8c..327343e0d4 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex @@ -13,38 +13,11 @@ [], fn f -> %> -
-
- <%= label f, :address_hash, gettext("Contract Address") %> -
- <%= text_input f, :address_hash, class: "form-control border-rounded", "aria-describedby": "contract-address-help-block", readonly: true %> - <%= error_tag f, :address_hash, id: "contract-address-help-block", class: "text-danger form-error" %> -
-
The 0x address supplied on contract creation.
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_address_field.html", address_hash: @address_hash, f: f %> -
-
- <%= label f, :name, gettext("Contract Name") %> -
- <%= text_input f, :name, class: "form-control border-rounded", "aria-describedby": "contract-name-help-block", "data-test": "contract_name", value: contract_name_value, disabled: "true" %> - <%= error_tag f, :name, id: "contract-name-help-block", class: "text-danger form-error" %> -
-
Must match the name specified in the code.
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_contract_name_field.html", f: f, tooltip: "Must match the name specified in the code. For example, in contract MyContract {..} MyContract is the contract name.", contract_name_value: contract_name_value %> -
-
- <%= label f, :compiler_version, gettext("Compiler") %> -
- <%= select f, :compiler_version, @compiler_versions, class: "form-control border-rounded", selected: compiler_version, "aria-describedby": "compiler-help-block" %> - <%= error_tag f, :compiler_version, id: "compiler-help-block", class: "text-danger form-error" %> -
-
-
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_compiler_field.html", f: f, compiler_version: compiler_version, compiler_versions: @compiler_versions %>
@@ -57,15 +30,10 @@
-
-
- <%= label f, :constructor_arguments, gettext("ABI-encoded Constructor Arguments (if required by the contract)") %> -
- <%= textarea f, :constructor_arguments, class: "form-control border-rounded monospace", rows: 3, "aria-describedby": "contract-constructor-arguments-help-block" %> - <%= error_tag f, :constructor_arguments, id: "contract-constructor-arguments-help-block", class: "text-danger form-error", "data-test": "contract-constructor-arguments-error" %> -
-
Add arguments in ABI hex encoded form. Constructor arguments are written right to left, and will be found at the end of the input created bytecode. They may also be parsed here.
-
+ <%= render BlockScoutWeb.AddressContractVerificationCommonFieldsView, "_constructor_args.html", f: f, display_constructor_arguments_text_area: "block" %> + +
+
diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 401432c10b..4b58f3ec96 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -140,7 +140,7 @@ defmodule BlockScoutWeb.WebRouter do ) resources( - "/verify-via-json", + "/verify-via-metadata-json", AddressContractVerificationViaJsonController, only: [:new], as: :verify_contract_via_json diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 0eb7d65dc1..5db15c800c 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -135,7 +135,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification_common_fields/_constructor_args.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:62 msgid "ABI-encoded Constructor Arguments (if required by the contract)" msgstr "" @@ -488,11 +487,11 @@ msgid "Call Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:114 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:231 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:48 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:60 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:85 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:150 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:41 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:56 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:53 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:54 msgid "Cancel" msgstr "" @@ -587,7 +586,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification_common_fields/_compiler_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:40 msgid "Compiler" msgstr "" @@ -615,7 +613,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:11 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:2 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:9 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:7 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:6 lib/block_scout_web/templates/tokens/holder/index.html.eex:15 msgid "Connection Lost" msgstr "" @@ -659,11 +657,7 @@ msgid "Contract ABI" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:14 -#: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:23 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:9 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:18 lib/block_scout_web/views/address_view.ex:102 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex:3 lib/block_scout_web/views/address_view.ex:102 msgid "Contract Address" msgstr "" @@ -690,14 +684,13 @@ msgid "Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:100 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:91 msgid "Contract Libraries" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:93 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_name_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:29 msgid "Contract Name" msgstr "" @@ -992,12 +985,12 @@ msgid "Download" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:26 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:18 msgid "Drop sources and metadata JSON file or click here" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:33 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:29 msgid "Drop the standard input JSON file or click here" msgstr "" @@ -1040,7 +1033,7 @@ msgstr "" #, elixir-format #: 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:40 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:31 msgid "EVM Version" msgstr "" @@ -1060,12 +1053,12 @@ msgid "Emission Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:82 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:73 msgid "Enter the Solidity Contract Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:51 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:24 msgid "Enter the Vyper Contract Code" msgstr "" @@ -1426,20 +1419,12 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:115 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:137 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:159 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:181 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:203 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_library_address.html.eex:3 msgid "Library Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:105 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:127 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:149 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:171 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:193 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_library_name.html.eex:3 msgid "Library Name" msgstr "" @@ -1484,11 +1469,11 @@ msgid "Loading chart..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:79 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:225 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:42 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:54 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:79 lib/block_scout_web/templates/address_read_contract/index.html.eex:12 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:70 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:144 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:35 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:50 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:47 lib/block_scout_web/templates/address_read_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_read_proxy/index.html.eex:12 lib/block_scout_web/templates/address_write_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_write_proxy/index.html.eex:12 lib/block_scout_web/templates/tokens/contract/index.html.eex:16 msgid "Loading..." @@ -1672,7 +1657,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:5 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:5 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:14 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:10 msgid "New Smart Contract Verification" msgstr "" @@ -1687,9 +1672,9 @@ msgid "New Vyper Smart Contract Verification" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:82 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:89 lib/block_scout_web/templates/address_contract_verification/new.html.eex:97 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: 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 msgid "Next" msgstr "" @@ -1701,7 +1686,7 @@ msgstr "" #, elixir-format #: 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:56 lib/block_scout_web/templates/stakes/_rows.html.eex:24 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:47 lib/block_scout_web/templates/stakes/_rows.html.eex:24 msgid "No" msgstr "" @@ -1769,7 +1754,7 @@ msgstr "" #, elixir-format #: 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:72 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:63 msgid "Optimization runs" msgstr "" @@ -1990,10 +1975,10 @@ msgid "Request URL" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:228 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:45 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:57 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:82 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:147 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:38 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:53 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:50 msgid "Reset" msgstr "" @@ -2178,7 +2163,7 @@ msgid "Source Pool" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:19 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:14 msgid "Sources and Metadata JSON" msgstr "" @@ -2245,7 +2230,7 @@ msgid "Staking epochs are not specified or not in the allowed range" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:29 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:25 msgid "Standard Input JSON" msgstr "" @@ -3003,10 +2988,10 @@ msgid "Verify & Publish" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:227 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:44 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:56 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:81 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:146 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:37 +#: 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:49 msgid "Verify & publish" msgstr "" @@ -3022,17 +3007,17 @@ msgid "Version" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:42 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:33 msgid "Via Sourcify: Sources and metadata JSON file" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:36 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:27 msgid "Via Standard Input JSON" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:31 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:22 msgid "Via flattened source code" msgstr "" @@ -3088,7 +3073,7 @@ msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:48 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39 msgid "Vyper contract" msgstr "" @@ -3167,7 +3152,7 @@ msgstr "" #, elixir-format #: 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:61 lib/block_scout_web/templates/stakes/_rows.html.eex:24 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:52 lib/block_scout_web/templates/stakes/_rows.html.eex:24 msgid "Yes" 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 0eb7d65dc1..5db15c800c 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 @@ -135,7 +135,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification_common_fields/_constructor_args.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:62 msgid "ABI-encoded Constructor Arguments (if required by the contract)" msgstr "" @@ -488,11 +487,11 @@ msgid "Call Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:114 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:231 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:48 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:60 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:85 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:150 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:41 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:56 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:53 lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:54 msgid "Cancel" msgstr "" @@ -587,7 +586,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification_common_fields/_compiler_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:40 msgid "Compiler" msgstr "" @@ -615,7 +613,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:11 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:2 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:9 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:7 #: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:6 lib/block_scout_web/templates/tokens/holder/index.html.eex:15 msgid "Connection Lost" msgstr "" @@ -659,11 +657,7 @@ msgid "Contract ABI" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:14 -#: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:23 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:9 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:18 lib/block_scout_web/views/address_view.ex:102 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_address_field.html.eex:3 lib/block_scout_web/views/address_view.ex:102 msgid "Contract Address" msgstr "" @@ -690,14 +684,13 @@ msgid "Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:100 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:91 msgid "Contract Libraries" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:93 #: lib/block_scout_web/templates/address_contract_verification_common_fields/_contract_name_field.html.eex:3 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:29 msgid "Contract Name" msgstr "" @@ -992,12 +985,12 @@ msgid "Download" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:26 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:18 msgid "Drop sources and metadata JSON file or click here" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:33 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:29 msgid "Drop the standard input JSON file or click here" msgstr "" @@ -1040,7 +1033,7 @@ msgstr "" #, elixir-format #: 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:40 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:31 msgid "EVM Version" msgstr "" @@ -1060,12 +1053,12 @@ msgid "Emission Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:82 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:73 msgid "Enter the Solidity Contract Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:51 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:24 msgid "Enter the Vyper Contract Code" msgstr "" @@ -1426,20 +1419,12 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:115 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:137 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:159 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:181 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:203 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_library_address.html.eex:3 msgid "Library Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:105 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:127 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:149 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:171 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:193 +#: lib/block_scout_web/templates/address_contract_verification_common_fields/_library_name.html.eex:3 msgid "Library Name" msgstr "" @@ -1484,11 +1469,11 @@ msgid "Loading chart..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:79 -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:225 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:42 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:54 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:79 lib/block_scout_web/templates/address_read_contract/index.html.eex:12 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:70 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:144 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:35 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:50 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:47 lib/block_scout_web/templates/address_read_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_read_proxy/index.html.eex:12 lib/block_scout_web/templates/address_write_contract/index.html.eex:12 #: lib/block_scout_web/templates/address_write_proxy/index.html.eex:12 lib/block_scout_web/templates/tokens/contract/index.html.eex:16 msgid "Loading..." @@ -1672,7 +1657,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:5 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:5 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:14 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:10 msgid "New Smart Contract Verification" msgstr "" @@ -1687,9 +1672,9 @@ msgid "New Vyper Smart Contract Verification" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:82 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:89 lib/block_scout_web/templates/address_contract_verification/new.html.eex:97 -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:105 +#: 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 msgid "Next" msgstr "" @@ -1701,7 +1686,7 @@ msgstr "" #, elixir-format #: 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:56 lib/block_scout_web/templates/stakes/_rows.html.eex:24 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:47 lib/block_scout_web/templates/stakes/_rows.html.eex:24 msgid "No" msgstr "" @@ -1769,7 +1754,7 @@ msgstr "" #, elixir-format #: 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:72 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:63 msgid "Optimization runs" msgstr "" @@ -1990,10 +1975,10 @@ msgid "Request URL" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:228 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:45 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:57 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:82 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:147 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:38 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:53 +#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:50 msgid "Reset" msgstr "" @@ -2178,7 +2163,7 @@ msgid "Source Pool" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:19 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:14 msgid "Sources and Metadata JSON" msgstr "" @@ -2245,7 +2230,7 @@ msgid "Staking epochs are not specified or not in the allowed range" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:29 +#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:25 msgid "Standard Input JSON" msgstr "" @@ -3003,10 +2988,10 @@ msgid "Verify & Publish" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:227 -#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:44 -#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:56 -#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:81 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:146 +#: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:37 +#: 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:49 msgid "Verify & publish" msgstr "" @@ -3022,17 +3007,17 @@ msgid "Version" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:42 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:33 msgid "Via Sourcify: Sources and metadata JSON file" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:36 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:27 msgid "Via Standard Input JSON" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:31 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:22 msgid "Via flattened source code" msgstr "" @@ -3088,7 +3073,7 @@ msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:48 +#: lib/block_scout_web/templates/address_contract_verification/new.html.eex:39 msgid "Vyper contract" msgstr "" @@ -3167,7 +3152,7 @@ msgstr "" #, elixir-format #: 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:61 lib/block_scout_web/templates/stakes/_rows.html.eex:24 +#: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:52 lib/block_scout_web/templates/stakes/_rows.html.eex:24 msgid "Yes" msgstr "" diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index fc5d6efd27..53f05fbf9e 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -4152,47 +4152,48 @@ defmodule Explorer.Chain do Finds metadata for verification of a contract from verified twins: contracts with the same bytecode which were verified previously, returns a single t:SmartContract.t/0 """ - def get_address_verified_twin_contract(address_hash) do - case Repo.get(Address, address_hash) do - nil -> - %{:verified_contract => nil, :additional_sources => nil} + def get_address_verified_twin_contract(hash) when is_binary(hash) do + case string_to_address_hash(hash) do + {:ok, address_hash} -> get_address_verified_twin_contract(address_hash) + _ -> %{:verified_contract => nil, :additional_sources => nil} + end + end - target_address -> - target_address_hash = target_address.hash - contract_code = target_address.contract_code + def get_address_verified_twin_contract(%Explorer.Chain.Hash{} = address_hash) do + with target_address <- Repo.get(Address, address_hash), + false <- is_nil(target_address), + %{contract_code: %Chain.Data{bytes: contract_code_bytes}} <- target_address do + target_address_hash = target_address.hash - case contract_code do - %Chain.Data{bytes: contract_code_bytes} -> - contract_code_md5 = - Base.encode16(:crypto.hash(:md5, "\\x" <> Base.encode16(contract_code_bytes, case: :lower)), - case: :lower - ) - - verified_contract_twin_query = - from( - address in Address, - inner_join: smart_contract in SmartContract, - on: address.hash == smart_contract.address_hash, - where: fragment("md5(contract_code::text)") == ^contract_code_md5, - where: address.hash != ^target_address_hash, - select: smart_contract, - limit: 1 - ) + contract_code_md5 = + Base.encode16(:crypto.hash(:md5, "\\x" <> Base.encode16(contract_code_bytes, case: :lower)), + case: :lower + ) - verified_contract_twin = - verified_contract_twin_query - |> Repo.one(timeout: 10_000) + verified_contract_twin_query = + from( + address in Address, + inner_join: smart_contract in SmartContract, + on: address.hash == smart_contract.address_hash, + where: fragment("md5(contract_code::text)") == ^contract_code_md5, + where: address.hash != ^target_address_hash, + select: smart_contract, + limit: 1 + ) - verified_contract_twin_additional_sources = get_contract_additional_sources(verified_contract_twin) + verified_contract_twin = + verified_contract_twin_query + |> Repo.one(timeout: 10_000) - %{ - :verified_contract => verified_contract_twin, - :additional_sources => verified_contract_twin_additional_sources - } + verified_contract_twin_additional_sources = get_contract_additional_sources(verified_contract_twin) - _ -> - %{:verified_contract => nil, :additional_sources => nil} - end + %{ + :verified_contract => verified_contract_twin, + :additional_sources => verified_contract_twin_additional_sources + } + else + _ -> + %{:verified_contract => nil, :additional_sources => nil} end end diff --git a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex index e312f88ebf..e947461b11 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publisher.ex @@ -45,7 +45,7 @@ defmodule Explorer.SmartContract.Solidity.Publisher do end end - def publish_with_standart_json_input(%{"address_hash" => address_hash} = params, json_input) do + def publish_with_standard_json_input(%{"address_hash" => address_hash} = params, json_input) do case Verifier.evaluate_authenticity_via_standard_json_input(address_hash, params, json_input) do {:ok, %{abi: abi, constructor_arguments: constructor_arguments}, additional_params} -> params_with_constructor_arguments = 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 de7962d107..893d5a7934 100644 --- a/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex +++ b/apps/explorer/lib/explorer/smart_contract/solidity/publisher_worker.ex @@ -25,7 +25,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do def perform({%{"address_hash" => address_hash} = params, json_input, uid}) when is_binary(uid) do VerificationStatus.insert_status(uid, :pending, address_hash) - case Publisher.publish_with_standart_json_input(params, json_input) do + case Publisher.publish_with_standard_json_input(params, json_input) do {:ok, _contract} -> VerificationStatus.update_status(uid, :pass) @@ -36,7 +36,7 @@ defmodule Explorer.SmartContract.Solidity.PublisherWorker do def perform({%{"address_hash" => address_hash} = params, json_input, conn}) do result = - case Publisher.publish_with_standart_json_input(params, json_input) do + case Publisher.publish_with_standard_json_input(params, json_input) do {:ok, _contract} = result -> result