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

Commit ac84cd2

Browse files
committed
Merge remote-tracking branch 'origin/vb-erc1155-unnamed-tokens-2' into production-optimism
2 parents a8cc4ed + c88b57d commit ac84cd2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

apps/explorer/lib/explorer/token/metadata_retriever.ex

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ defmodule Explorer.Token.MetadataRetriever do
1414
@no_uri_error "no uri"
1515
@vm_execution_error "VM execution error"
1616
@invalid_base64_data "invalid data:application/json;base64"
17+
@default_headers [{"User-Agent", "blockscout"}]
1718

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

477478
if gateway_url_param_key && gateway_url_param_value do
478-
[{gateway_url_param_key, gateway_url_param_value}]
479+
[{gateway_url_param_key, gateway_url_param_value} | @default_headers]
479480
else
480-
[]
481+
@default_headers
481482
end
482483
else
483-
[]
484+
@default_headers
484485
end
485486
end
486487

@@ -670,7 +671,7 @@ defmodule Explorer.Token.MetadataRetriever do
670671
end
671672

672673
defp fetch_metadata_from_uri_request(uri, hex_token_id, ipfs?) do
673-
headers = if ipfs?, do: ipfs_headers(), else: []
674+
headers = if ipfs?, do: ipfs_headers(), else: @default_headers
674675

675676
case Application.get_env(:explorer, :http_adapter).get(uri, headers,
676677
recv_timeout: 30_000,

apps/explorer/test/explorer/token/metadata_retriever_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ defmodule Explorer.Token.MetadataRetrieverTest do
763763

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

0 commit comments

Comments
 (0)