diff --git a/CHANGELOG.md b/CHANGELOG.md index bdba20c840..bfff52565c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ### Chore +- [#8579](https://github.com/blockscout/blockscout/pull/8579) - IPFS gateway URL runtime env variable - [#8573](https://github.com/blockscout/blockscout/pull/8573) - Update Nginx to proxy all frontend paths - [#8290](https://github.com/blockscout/blockscout/pull/8290) - Update Chromedriver version - [#8536](https://github.com/blockscout/blockscout/pull/8536), [#8537](https://github.com/blockscout/blockscout/pull/8537), [#8540](https://github.com/blockscout/blockscout/pull/8540), [#8557](https://github.com/blockscout/blockscout/pull/8557) - New issue template 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 aa3e528bbf..ac4de5f378 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 @@ -81,6 +81,12 @@ defmodule BlockScoutWeb.NFTHelper do defp ipfs_link(image_url, prefix) do ipfs_uid = String.slice(image_url, String.length(prefix)..-1) - "https://ipfs.io/ipfs/" <> ipfs_uid + + ipfs_gateway_url = + :indexer + |> Application.get_env(:ipfs_gateway_url) + |> String.trim_trailing("/") + + ipfs_gateway_url <> "/" <> ipfs_uid end end diff --git a/apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex b/apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex index 89c383f5a5..975b7bed5f 100644 --- a/apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex +++ b/apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex @@ -11,7 +11,6 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do @no_uri_error "no uri" @vm_execution_error "VM execution error" @ipfs_protocol "ipfs://" - @ipfs_link "https://ipfs.io/ipfs/" # https://eips.ethereum.org/EIPS/eip-1155#metadata @erc1155_token_id_placeholder "{id}" @@ -20,6 +19,15 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do @ignored_hosts ["localhost", "127.0.0.1", "0.0.0.0", "", nil] + defp ipfs_link do + link = + :indexer + |> Application.get_env(:ipfs_gateway_url) + |> String.trim_trailing("/") + + link <> "/" + end + def query_contract(contract_address_hash, contract_functions, abi) do Reader.query_contract(contract_address_hash, abi, contract_functions, false) end @@ -54,7 +62,7 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do # CIDv0 IPFS links # https://docs.ipfs.tech/concepts/content-addressing/#version-0-v0 defp fetch_json_from_uri({:ok, ["Qm" <> _ = result]}, hex_token_id) do if String.length(result) == 46 do - fetch_json_from_uri({:ok, [@ipfs_link <> result]}, hex_token_id) + fetch_json_from_uri({:ok, [ipfs_link() <> result]}, hex_token_id) else Logger.debug(["Unknown metadata format result #{inspect(result)}."], fetcher: :token_instances) @@ -141,7 +149,7 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do end defp fetch_from_ipfs(ipfs_uid, hex_token_id) do - ipfs_url = @ipfs_link <> ipfs_uid + ipfs_url = ipfs_link() <> ipfs_uid fetch_metadata_inner(ipfs_url, hex_token_id) end diff --git a/config/runtime.exs b/config/runtime.exs index e83d0489d8..a80e8b88a3 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -437,7 +437,8 @@ config :indexer, token_balances_fetcher_init_limit: ConfigHelper.parse_integer_env_var("INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 100_000), coin_balances_fetcher_init_limit: - ConfigHelper.parse_integer_env_var("INDEXER_COIN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 2000) + ConfigHelper.parse_integer_env_var("INDEXER_COIN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 2000), + ipfs_gateway_url: System.get_env("IPFS_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 0d9f9ef254..38a1361972 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -232,7 +232,8 @@ EIP_1559_ELASTICITY_MULTIPLIER=2 # INDEXER_TOKEN_INSTANCE_RETRY_BATCH_SIZE=10 # INDEXER_TOKEN_INSTANCE_REALTIME_BATCH_SIZE=1 # INDEXER_TOKEN_INSTANCE_SANITIZE_BATCH_SIZE=10 -API_V2_ENABLED=true # INDEXER_TOKEN_INSTANCE_LEGACY_SANITIZE_BATCH_SIZE=10 # TOKEN_INSTANCE_OWNER_MIGRATION_CONCURRENCY=5 # TOKEN_INSTANCE_OWNER_MIGRATION_BATCH_SIZE=50 +# IPFS_GATEWAY_URL= +API_V2_ENABLED=true \ No newline at end of file