IPFS gateway URL env var

pull/8579/head
Viktor Baranov 1 year ago
parent 68e54281af
commit a000c747fd
  1. 1
      CHANGELOG.md
  2. 8
      apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex
  3. 14
      apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex
  4. 3
      config/runtime.exs
  5. 3
      docker-compose/envs/common-blockscout.env

@ -22,6 +22,7 @@
### Chore ### 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 - [#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 - [#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 - [#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

@ -81,6 +81,12 @@ defmodule BlockScoutWeb.NFTHelper do
defp ipfs_link(image_url, prefix) do defp ipfs_link(image_url, prefix) do
ipfs_uid = String.slice(image_url, String.length(prefix)..-1) 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
end end

@ -11,7 +11,6 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do
@no_uri_error "no uri" @no_uri_error "no uri"
@vm_execution_error "VM execution error" @vm_execution_error "VM execution error"
@ipfs_protocol "ipfs://" @ipfs_protocol "ipfs://"
@ipfs_link "https://ipfs.io/ipfs/"
# https://eips.ethereum.org/EIPS/eip-1155#metadata # https://eips.ethereum.org/EIPS/eip-1155#metadata
@erc1155_token_id_placeholder "{id}" @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] @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 def query_contract(contract_address_hash, contract_functions, abi) do
Reader.query_contract(contract_address_hash, abi, contract_functions, false) Reader.query_contract(contract_address_hash, abi, contract_functions, false)
end end
@ -54,7 +62,7 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do
# CIDv0 IPFS links # https://docs.ipfs.tech/concepts/content-addressing/#version-0-v0 # 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 defp fetch_json_from_uri({:ok, ["Qm" <> _ = result]}, hex_token_id) do
if String.length(result) == 46 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 else
Logger.debug(["Unknown metadata format result #{inspect(result)}."], fetcher: :token_instances) Logger.debug(["Unknown metadata format result #{inspect(result)}."], fetcher: :token_instances)
@ -141,7 +149,7 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do
end end
defp fetch_from_ipfs(ipfs_uid, hex_token_id) do 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) fetch_metadata_inner(ipfs_url, hex_token_id)
end end

@ -437,7 +437,8 @@ config :indexer,
token_balances_fetcher_init_limit: token_balances_fetcher_init_limit:
ConfigHelper.parse_integer_env_var("INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 100_000), ConfigHelper.parse_integer_env_var("INDEXER_TOKEN_BALANCES_FETCHER_INIT_QUERY_LIMIT", 100_000),
coin_balances_fetcher_init_limit: 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") config :indexer, Indexer.Supervisor, enabled: !ConfigHelper.parse_bool_env_var("DISABLE_INDEXER")

@ -232,7 +232,8 @@ EIP_1559_ELASTICITY_MULTIPLIER=2
# INDEXER_TOKEN_INSTANCE_RETRY_BATCH_SIZE=10 # INDEXER_TOKEN_INSTANCE_RETRY_BATCH_SIZE=10
# INDEXER_TOKEN_INSTANCE_REALTIME_BATCH_SIZE=1 # INDEXER_TOKEN_INSTANCE_REALTIME_BATCH_SIZE=1
# INDEXER_TOKEN_INSTANCE_SANITIZE_BATCH_SIZE=10 # INDEXER_TOKEN_INSTANCE_SANITIZE_BATCH_SIZE=10
API_V2_ENABLED=true
# INDEXER_TOKEN_INSTANCE_LEGACY_SANITIZE_BATCH_SIZE=10 # INDEXER_TOKEN_INSTANCE_LEGACY_SANITIZE_BATCH_SIZE=10
# TOKEN_INSTANCE_OWNER_MIGRATION_CONCURRENCY=5 # TOKEN_INSTANCE_OWNER_MIGRATION_CONCURRENCY=5
# TOKEN_INSTANCE_OWNER_MIGRATION_BATCH_SIZE=50 # TOKEN_INSTANCE_OWNER_MIGRATION_BATCH_SIZE=50
# IPFS_GATEWAY_URL=
API_V2_ENABLED=true
Loading…
Cancel
Save