pull/7286/head
Nikita Pozdniakov 2 years ago
parent 19941a93f7
commit 0f902df011
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 22
      apps/explorer/lib/explorer/token/instance_metadata_retriever.ex

@ -110,17 +110,6 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
fetch_json_from_uri(uri, hex_token_id)
end
# CIDv0 IPFS links # https://docs.ipfs.tech/concepts/content-addressing/#version-0-v0
def fetch_json("Qm" <> _ = result, hex_token_id) do
if String.length(result) == 46 do
fetch_json_from_uri({:ok, [@ipfs_link <> result]}, hex_token_id)
else
Logger.debug(["Unknown metadata format result #{inspect(result)}."], fetcher: :token_instances)
{:error, :wrong_ipfs_link}
end
end
def fetch_json(result, hex_token_id) do
case URI.parse(result) do
%URI{host: nil} ->
@ -133,6 +122,17 @@ defmodule Explorer.Token.InstanceMetadataRetriever do
end
end
# 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)
else
Logger.debug(["Unknown metadata format result #{inspect(result)}."], fetcher: :token_instances)
{:error, result}
end
end
defp fetch_json_from_uri({:error, error}, _hex_token_id) do
if error =~ "execution reverted" or error =~ @vm_execution_error do
{:ok, %{error: @vm_execution_error}}

Loading…
Cancel
Save