feat: Support snake_case in metadata service (#10722)

ap-allow-other-postgres-schemas
nikitosing 1 month ago committed by GitHub
parent f71a4cc4c6
commit a44488c517
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      apps/block_scout_web/lib/block_scout_web/views/api/v2/proxy/metadata_view.ex
  2. 12
      apps/explorer/lib/explorer/microservice_interfaces/metadata.ex

@ -3,8 +3,8 @@ defmodule BlockScoutWeb.API.V2.Proxy.MetadataView do
alias BlockScoutWeb.API.V2.AddressView alias BlockScoutWeb.API.V2.AddressView
def render("addresses.json", %{result: {:ok, %{"addresses" => addresses} = body}}) do def render("addresses.json", %{result: {:ok, %{"items" => addresses} = body}}) do
Map.put(body, "addresses", Enum.map(addresses, &AddressView.prepare_address/1)) Map.put(body, "items", Enum.map(addresses, &AddressView.prepare_address/1))
end end
def render("addresses.json", %{result: :error}) do def render("addresses.json", %{result: :error}) do

@ -22,8 +22,8 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do
with :ok <- Microservice.check_enabled(__MODULE__) do with :ok <- Microservice.check_enabled(__MODULE__) do
body = %{ body = %{
addresses: Enum.join(addresses, ","), addresses: Enum.join(addresses, ","),
tagsLimit: @tags_per_address_limit, tags_limit: @tags_per_address_limit,
chainId: Application.get_env(:block_scout_web, :chain_id) chain_id: Application.get_env(:block_scout_web, :chain_id)
} }
http_get_request(addresses_metadata_url(), body) http_get_request(addresses_metadata_url(), body)
@ -38,8 +38,8 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do
with :ok <- Microservice.check_enabled(__MODULE__) do with :ok <- Microservice.check_enabled(__MODULE__) do
params = params =
params params
|> Map.put("pageSize", @page_size) |> Map.put("page_size", @page_size)
|> Map.put("chainId", Application.get_env(:block_scout_web, :chain_id)) |> 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) http_get_request_for_proxy_method(addresses_url(), params, &prepare_addresses_response/1)
end end
@ -136,11 +136,11 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do
Map.put(tag, "meta", Jason.decode!(meta)) Map.put(tag, "meta", Jason.decode!(meta))
end end
defp prepare_addresses_response({:ok, %{"addresses" => addresses} = response}) do defp prepare_addresses_response({:ok, %{"items" => addresses} = response}) do
{:ok, {:ok,
Map.put( Map.put(
response, response,
"addresses", "items",
addresses addresses
|> Chain.hashes_to_addresses( |> Chain.hashes_to_addresses(
necessity_by_association: %{names: :optional, smart_contract: :optional, proxy_implementations: :optional} necessity_by_association: %{names: :optional, smart_contract: :optional, proxy_implementations: :optional}

Loading…
Cancel
Save