This repository has been archived by the owner on Jun 3, 2023. It is now read-only.
generated from public-assembly/assemble-package
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return null from non existant contractURI query, reorg queries, …
…add customIpfs prop throughout queries
- Loading branch information
Showing
10 changed files
with
72 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { addIPFSGateway } from './addIPFSGateway' | ||
|
||
export async function decodeContractUri(contractURI?: string, ipfsGateway?: string) { | ||
const url = !contractURI.startsWith('data:application') | ||
? addIPFSGateway(contractURI, ipfsGateway) | ||
: undefined | ||
|
||
if (!url) return null | ||
|
||
try { | ||
const contractURIData = await fetch(url) | ||
.then((res) => res.text()) | ||
.then((t) => { | ||
try { | ||
return JSON.parse(t.replace(/\\n/g, ' ')) | ||
} catch (e) { | ||
return null | ||
} | ||
}) | ||
return contractURIData | ||
} catch (err) { | ||
console.error(err) | ||
return null | ||
} | ||
} |