Skip to content

Commit

Permalink
feat: Support snake_case in metadata service (blockscout#10722)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitosing authored Oct 16, 2024
1 parent f71a4cc commit a44488c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions apps/explorer/lib/explorer/microservice_interfaces/metadata.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit a44488c

Please sign in to comment.