diff --git a/src/factory/index.ts b/src/factory/index.ts index 684ca32c..5fd5d849 100644 --- a/src/factory/index.ts +++ b/src/factory/index.ts @@ -52,7 +52,7 @@ export const injectMoralis = function (M: any) { console.log("Moralis injected ", Moralis.start); }; -export const setupURI = (uri: string): string => { +export const setupURI = (uri: string, other: boolean = false): string => { if (uri) { if (uri.includes(".json")) { uri = uri.replace(/(?!\.json)\d+$/gm, ""); @@ -60,6 +60,9 @@ export const setupURI = (uri: string): string => { if (uri.includes("https://ipfs.io") || uri.includes("moralis")) { return uri; } else if (/^ipfs:\/\//.test(uri)) { + if (other) { + return uri.replace(/ipfs:\/\/(?:ipfs)?/, "https://xpnetwork.infura-ipfs.io/ipfs/"); + } return uri.replace(/ipfs:\/\/(?:ipfs)?/, "https://ipfs.io/ipfs/"); // "https://ipfs.io/ipfs/" + uri.split("://")[1]; } else if (/ipfs\.infura\.io/.test(uri)) { return uri.replace(/ipfs\.infura\.io/, "ipfs.io"); diff --git a/src/factory/tezos.ts b/src/factory/tezos.ts index eec22b44..9228f17a 100644 --- a/src/factory/tezos.ts +++ b/src/factory/tezos.ts @@ -70,7 +70,19 @@ export const checkEmptyFromTezos = async (data: any) => { }; const getMetadata = async (nft: any, account = "", whitelisted = true) => { - const res = await axios(proxy + setupURI(nft.uri)); + + console.log("URI 1", proxy + setupURI(nft.uri)); + console.log("URI 2", proxy + setupURI(nft.uri, true)); + + let res; + + try { + res = await axios(proxy + setupURI(nft.uri)); + } + catch (ex) { + res = await axios(proxy + setupURI(nft.uri, true)); + } + const { data } = res; const parsed: NFT = {