diff --git a/apps/explorer/lib/explorer/token/metadata_retriever.ex b/apps/explorer/lib/explorer/token/metadata_retriever.ex index 30d0c9968343..19a94a411ddc 100644 --- a/apps/explorer/lib/explorer/token/metadata_retriever.ex +++ b/apps/explorer/lib/explorer/token/metadata_retriever.ex @@ -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-6.8.1"}] # https://eips.ethereum.org/EIPS/eip-1155#metadata @erc1155_token_id_placeholder "{id}" @@ -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 @@ -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, diff --git a/apps/explorer/test/explorer/token/metadata_retriever_test.exs b/apps/explorer/test/explorer/token/metadata_retriever_test.exs index 00d3ac5107a9..b45c3b2d4314 100644 --- a/apps/explorer/test/explorer/token/metadata_retriever_test.exs +++ b/apps/explorer/test/explorer/token/metadata_retriever_test.exs @@ -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", _}], _options -> {:ok, %HTTPoison.Response{status_code: 200, body: Jason.encode!(result)}} end) diff --git a/bin/version_bump.sh b/bin/version_bump.sh index 0359e289243f..bf79d90035f1 100755 --- a/bin/version_bump.sh +++ b/bin/version_bump.sh @@ -12,6 +12,7 @@ CONFIG_FILE="$(pwd)/rel/config.exs" DOCKER_COMPOSE_FILE="$(pwd)/docker-compose/docker-compose.yml" MAKE_FILE="$(pwd)/docker/Makefile" WORKFLOW_FILES=($(find "$(pwd)/.github/workflows" -type f \( -name "pre-release-*" -o -name "release-*" -o -name "publish-docker-image-*" \))) +METADATA_RETRIEVER_FILE="$(pwd)/apps/explorer/lib/explorer/token/metadata_retriever.ex" # Function to bump version bump_version() { @@ -69,6 +70,8 @@ bump_version() { sed -i '' "s/RELEASE_VERSION: $current_version/RELEASE_VERSION: $new_version/" "$WORKFLOW_FILE" done + sed -i '' "s/\"blockscout-$current_version\"/\"blockscout-$new_version\"/" "$METADATA_RETRIEVER_FILE" + echo "Version bumped from $current_version to $new_version" }