|
|
|
@ -18,16 +18,34 @@ defmodule Explorer.MicroserviceInterfaces.Metadata do |
|
|
|
|
@page_size 50 |
|
|
|
|
@request_error_msg "Error while sending request to Metadata microservice" |
|
|
|
|
|
|
|
|
|
@spec get_addresses_tags([String.t()]) :: {:error, :disabled | <<_::416>> | Jason.DecodeError.t()} | {:ok, any()} |
|
|
|
|
@doc """ |
|
|
|
|
Retrieves tags for a list of addresses. |
|
|
|
|
|
|
|
|
|
## Parameters |
|
|
|
|
- `addresses`: A list of addresses for which tags need to be fetched. |
|
|
|
|
|
|
|
|
|
## Returns |
|
|
|
|
- A map with metadata tags from microservice. Returns `:ignore` when the input list is empty. |
|
|
|
|
|
|
|
|
|
## Examples |
|
|
|
|
|
|
|
|
|
iex> get_addresses_tags([]) |
|
|
|
|
:ignore |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
@spec get_addresses_tags([String.t()]) :: |
|
|
|
|
{:error, :disabled | <<_::416>> | Jason.DecodeError.t()} | {:ok, any()} | :ignore |
|
|
|
|
def get_addresses_tags([]), do: :ignore |
|
|
|
|
|
|
|
|
|
def get_addresses_tags(addresses) do |
|
|
|
|
with :ok <- Microservice.check_enabled(__MODULE__) do |
|
|
|
|
body = %{ |
|
|
|
|
params = %{ |
|
|
|
|
addresses: Enum.join(addresses, ","), |
|
|
|
|
tags_limit: @tags_per_address_limit, |
|
|
|
|
chain_id: Application.get_env(:block_scout_web, :chain_id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
http_get_request(addresses_metadata_url(), body) |
|
|
|
|
http_get_request(addresses_metadata_url(), params) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|