Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/vb-erc1155-unnamed-tokens-2' int…
Browse files Browse the repository at this point in the history
…o production-optimism
  • Loading branch information
vbaranov committed Sep 27, 2024
2 parents a8cc4ed + c88b57d commit ac84cd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions apps/explorer/lib/explorer/token/metadata_retriever.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule Explorer.Token.MetadataRetriever do
@no_uri_error "no uri"
@vm_execution_error "VM execution error"
@invalid_base64_data "invalid data:application/json;base64"
@default_headers [{"User-Agent", "blockscout"}]

# https://eips.ethereum.org/EIPS/eip-1155#metadata
@erc1155_token_id_placeholder "{id}"
Expand Down Expand Up @@ -475,12 +476,12 @@ defmodule Explorer.Token.MetadataRetriever do
gateway_url_param_value = ipfs_params[:gateway_url_param_value]

if gateway_url_param_key && gateway_url_param_value do
[{gateway_url_param_key, gateway_url_param_value}]
[{gateway_url_param_key, gateway_url_param_value} | @default_headers]
else
[]
@default_headers
end
else
[]
@default_headers
end
end

Expand Down Expand Up @@ -670,7 +671,7 @@ defmodule Explorer.Token.MetadataRetriever do
end

defp fetch_metadata_from_uri_request(uri, hex_token_id, ipfs?) do
headers = if ipfs?, do: ipfs_headers(), else: []
headers = if ipfs?, do: ipfs_headers(), else: @default_headers

case Application.get_env(:explorer, :http_adapter).get(uri, headers,
recv_timeout: 30_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ defmodule Explorer.Token.MetadataRetrieverTest do

Explorer.Mox.HTTPoison
|> expect(:get, fn "https://ipfs.io/ipfs/QmT1Yz43R1PLn2RVovAnEM5dHQEvpTcnwgX8zftvY1FcjP",
[{"x-apikey", "mykey"}],
[{"x-apikey", "mykey"}, {"User-Agent", "blockscout"}],
_options ->
{:ok, %HTTPoison.Response{status_code: 200, body: Jason.encode!(result)}}
end)
Expand Down

0 comments on commit ac84cd2

Please sign in to comment.