Merge pull request #328 from public-awesome/switch-ipfs-gateway

Switch default IPFS gateway
This commit is contained in:
Serkan Reis 2024-02-03 03:47:49 +02:00 committed by GitHub
commit 1bce40a6f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -161,7 +161,7 @@ const CollectionCreationPage: NextPage = () => {
const [baseTokenUri, setBaseTokenUri] = useState<string | null>(null)
const [coverImageUrl, setCoverImageUrl] = useState<string | null>(null)
const [transactionHash, setTransactionHash] = useState<string | null>(null)
const [isMatchingVendingFactoryPresent, setIsMatchingVendingFactoryPresent] = useState<boolean>(false)
const [isMatchingVendingFactoryPresent, setIsMatchingVendingFactoryPresent] = useState<boolean>(true)
const performVendingMinterChecks = () => {
try {

View File

@ -2,7 +2,11 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
export const checkTokenUri = async (tokenUri: string, isBaseTokenUri?: boolean) => {
if (isBaseTokenUri) {
await fetch(tokenUri.replace('ipfs://', 'https://ipfs.io/ipfs/').concat(tokenUri.endsWith('/') ? '1' : '/1'))
await fetch(
tokenUri
.replace('ipfs://', 'https://ipfs-gw.stargaze-apis.com/ipfs/')
.concat(tokenUri.endsWith('/') ? '1' : '/1'),
)
.then((res) =>
res
.json()
@ -22,7 +26,9 @@ export const checkTokenUri = async (tokenUri: string, isBaseTokenUri?: boolean)
)
.catch(async () => {
await fetch(
tokenUri.replace('ipfs://', 'https://ipfs.io/ipfs/').concat(tokenUri.endsWith('/') ? '1.json' : '/1.json'),
tokenUri
.replace('ipfs://', 'https://ipfs-gw.stargaze-apis.com/ipfs/')
.concat(tokenUri.endsWith('/') ? '1.json' : '/1.json'),
)
.then((response) =>
response
@ -48,7 +54,7 @@ export const checkTokenUri = async (tokenUri: string, isBaseTokenUri?: boolean)
})
})
} else {
await fetch(tokenUri.replace('ipfs://', 'https://ipfs.io/ipfs/'))
await fetch(tokenUri.replace('ipfs://', 'https://ipfs-gw.stargaze-apis.com/ipfs/'))
.then((res) =>
res
.json()