From 208b0a20b23fa8176aba93d2ed9cebded527dd63 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 5 Aug 2024 15:52:28 +0300 Subject: [PATCH] feat: Public IPFS gateway URL (#10511) --- .../lib/block_scout_web/views/nft_helper.ex | 8 +++++++- config/runtime.exs | 3 ++- docker-compose/envs/common-blockscout.env | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex b/apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex index 1ccdf145f9..7515dc32bd 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex @@ -84,6 +84,12 @@ defmodule BlockScoutWeb.NFTHelper do defp ipfs_link(image_url, prefix) do ipfs_uid = String.slice(image_url, String.length(prefix)..-1//1) - "https://ipfs.io/ipfs/" <> ipfs_uid + public_ipfs_gateway_url = + :indexer + |> Application.get_env(:ipfs) + |> Keyword.get(:public_gateway_url) + |> String.trim_trailing("/") + + public_ipfs_gateway_url <> "/" <> ipfs_uid end end diff --git a/config/runtime.exs b/config/runtime.exs index 9f4bf0005a..19c2bd4e8c 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -646,7 +646,8 @@ config :indexer, :ipfs, gateway_url_param_key: System.get_env("IPFS_GATEWAY_URL_PARAM_KEY"), gateway_url_param_value: System.get_env("IPFS_GATEWAY_URL_PARAM_VALUE"), gateway_url_param_location: - ConfigHelper.parse_catalog_value("IPFS_GATEWAY_URL_PARAM_LOCATION", ["query", "header"], true) + ConfigHelper.parse_catalog_value("IPFS_GATEWAY_URL_PARAM_LOCATION", ["query", "header"], true), + public_gateway_url: System.get_env("IPFS_PUBLIC_GATEWAY_URL", "https://ipfs.io/ipfs") config :indexer, Indexer.Supervisor, enabled: !ConfigHelper.parse_bool_env_var("DISABLE_INDEXER") diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 882f37241a..313ac7b8f6 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -367,6 +367,10 @@ EIP_1559_ELASTICITY_MULTIPLIER=2 # AMPLITUDE_API_KEY= # AMPLITUDE_URL= # IPFS_GATEWAY_URL= +# IPFS_GATEWAY_URL_PARAM_KEY= +# IPFS_GATEWAY_URL_PARAM_VALUE= +# IPFS_GATEWAY_URL_PARAM_LOCATION= +# IPFS_PUBLIC_GATEWAY_URL= # ADDRESSES_TABS_COUNTERS_TTL=10m # DENORMALIZATION_MIGRATION_BATCH_SIZE= # DENORMALIZATION_MIGRATION_CONCURRENCY=