From a44488c517d316e0a785fee53639ec0d4cc96352 Mon Sep 17 00:00:00 2001 From: nikitosing <32202610+nikitosing@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:15:16 +0300 Subject: [PATCH] feat: Support snake_case in metadata service (#10722) --- .../views/api/v2/proxy/metadata_view.ex | 4 ++-- .../lib/explorer/microservice_interfaces/metadata.ex | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/proxy/metadata_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/proxy/metadata_view.ex index 50b8cf2e03..301ae84af5 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/proxy/metadata_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/proxy/metadata_view.ex @@ -3,8 +3,8 @@ defmodule BlockScoutWeb.API.V2.Proxy.MetadataView do alias BlockScoutWeb.API.V2.AddressView - def render("addresses.json", %{result: {:ok, %{"addresses" => addresses} = body}}) do - Map.put(body, "addresses", Enum.map(addresses, &AddressView.prepare_address/1)) + def render("addresses.json", %{result: {:ok, %{"items" => addresses} = body}}) do + Map.put(body, "items", Enum.map(addresses, &AddressView.prepare_address/1)) end def render("addresses.json", %{result: :error}) do diff --git a/apps/explorer/lib/explorer/microservice_interfaces/metadata.ex b/apps/explorer/lib/explorer/microservice_interfaces/metadata.ex index ad9e692cbe..60c1476b17 100644 --- a/apps/explorer/lib/explorer/microservice_interfaces/metadata.ex +++ b/apps/explorer/lib/explorer/microservice_interfaces/metadata.ex @@ -22,8 +22,8 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do with :ok <- Microservice.check_enabled(__MODULE__) do body = %{ addresses: Enum.join(addresses, ","), - tagsLimit: @tags_per_address_limit, - chainId: Application.get_env(:block_scout_web, :chain_id) + tags_limit: @tags_per_address_limit, + chain_id: Application.get_env(:block_scout_web, :chain_id) } http_get_request(addresses_metadata_url(), body) @@ -38,8 +38,8 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do with :ok <- Microservice.check_enabled(__MODULE__) do params = params - |> Map.put("pageSize", @page_size) - |> Map.put("chainId", Application.get_env(:block_scout_web, :chain_id)) + |> Map.put("page_size", @page_size) + |> Map.put("chain_id", Application.get_env(:block_scout_web, :chain_id)) http_get_request_for_proxy_method(addresses_url(), params, &prepare_addresses_response/1) end @@ -136,11 +136,11 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do Map.put(tag, "meta", Jason.decode!(meta)) end - defp prepare_addresses_response({:ok, %{"addresses" => addresses} = response}) do + defp prepare_addresses_response({:ok, %{"items" => addresses} = response}) do {:ok, Map.put( response, - "addresses", + "items", addresses |> Chain.hashes_to_addresses( necessity_by_association: %{names: :optional, smart_contract: :optional, proxy_implementations: :optional}