Skip to content

Commit

Permalink
fix: useStarkProfile to work with IPFS token URI (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek authored Apr 30, 2024
2 parents e4cc3e9 + 8480a43 commit 1f94f05
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/core/src/hooks/useStarkProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const notEqual = (call: number, pos: number, value: number) => {

const fetchImageUrl = async (url: string): Promise<string> => {
try {
const response = await fetch(url);
const response = await fetch(parseImageUrl(url));

if (!response.ok) {
throw new Error("Network response was not ok");
Expand All @@ -355,7 +355,7 @@ const fetchImageUrl = async (url: string): Promise<string> => {

// Check if the "image" key exists and is not null
if (data.image) {
return data.image;
return parseImageUrl(data.image);
} else {
return "Image is not set";
}
Expand All @@ -365,6 +365,12 @@ const fetchImageUrl = async (url: string): Promise<string> => {
}
};

const parseImageUrl = (url: string): string => {
return url.startsWith("ipfs://")
? url.replace("ipfs://", "https://gateway.pinata.cloud/ipfs/")
: url;
};

const StarknetIdcontracts: Record<string, Record<string, string>> = {
goerli: {
naming: "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce",
Expand Down

0 comments on commit 1f94f05

Please sign in to comment.