diff --git a/functions/api/image/nfts/asset/[[index]].tsx b/functions/api/image/nfts/asset/[[index]].tsx index f666cf9729..ec8015703a 100644 --- a/functions/api/image/nfts/asset/[[index]].tsx +++ b/functions/api/image/nfts/asset/[[index]].tsx @@ -2,6 +2,7 @@ import { ImageResponse } from '@vercel/og' import React from 'react' +import { blocklistedCollections } from '../../../../../src/nft/utils/blocklist' import { WATERMARK_URL } from '../../../../constants' import getAsset from '../../../../utils/getAsset' import getFont from '../../../../utils/getFont' @@ -15,6 +16,10 @@ export const onRequest: PagesFunction = async ({ params, request }) => { const tokenId = index[1]?.toString() const cacheUrl = origin + '/nfts/asset/' + collectionAddress + '/' + tokenId + if (blocklistedCollections.includes(collectionAddress)) { + return new Response('Collection unsupported.', { status: 404 }) + } + const data = await getRequest( cacheUrl, () => getAsset(collectionAddress, tokenId, cacheUrl), diff --git a/functions/api/image/nfts/asset/nftImage.test.ts b/functions/api/image/nfts/asset/nftImage.test.ts index 0ce5b1a2a9..ed247ae183 100644 --- a/functions/api/image/nfts/asset/nftImage.test.ts +++ b/functions/api/image/nfts/asset/nftImage.test.ts @@ -18,3 +18,12 @@ test.each(invalidAssetImageUrl)('invalidAssetImageUrl', async (url) => { const response = await fetch(new Request(url)) expect(response.status).toBe(404) }) + +const blockedAssetImageUrl = [ + 'http://127.0.0.1:3000/api/image/nfts/asset/0xd4d871419714b778ebec2e22c7c53572b573706e/276', +] + +test.each(blockedAssetImageUrl)('blockedAssetImageUrl', async (url) => { + const response = await fetch(new Request(url)) + expect(response.status).toBe(404) +}) diff --git a/functions/api/image/nfts/collection/[index].tsx b/functions/api/image/nfts/collection/[index].tsx index b2672dd50e..94e99b74ba 100644 --- a/functions/api/image/nfts/collection/[index].tsx +++ b/functions/api/image/nfts/collection/[index].tsx @@ -2,6 +2,7 @@ import { ImageResponse } from '@vercel/og' import React from 'react' +import { blocklistedCollections } from '../../../../../src/nft/utils/blocklist' import { CHECK_URL, WATERMARK_URL } from '../../../../constants' import getCollection from '../../../../utils/getCollection' import getColor from '../../../../utils/getColor' @@ -15,6 +16,10 @@ export const onRequest: PagesFunction = async ({ params, request }) => { const collectionAddress = index?.toString() const cacheUrl = origin + '/nfts/collection/' + collectionAddress + if (blocklistedCollections.includes(collectionAddress)) { + return new Response('Collection unsupported.', { status: 404 }) + } + const data = await getRequest( cacheUrl, () => getCollection(collectionAddress, cacheUrl), diff --git a/functions/api/image/nfts/collection/collectionImage.test.ts b/functions/api/image/nfts/collection/collectionImage.test.ts index bbc52aa452..95f3a8b225 100644 --- a/functions/api/image/nfts/collection/collectionImage.test.ts +++ b/functions/api/image/nfts/collection/collectionImage.test.ts @@ -23,3 +23,12 @@ test.each(invalidCollectionImageUrls)('invalidAssetImageUrl', async (url) => { const response = await fetch(new Request(url)) expect(response.status).toBeOneOf([404, 500]) }) + +const blockedCollectionImageUrls = [ + 'http://127.0.0.1:3000/api/image/nfts/collection/0xd4d871419714b778ebec2e22c7c53572b573706e', +] + +test.each(blockedCollectionImageUrls)('blockedCollectionImageUrl', async (url) => { + const response = await fetch(new Request(url)) + expect(response.status).toBeOneOf([404, 500]) +}) diff --git a/src/nft/utils/blocklist.ts b/src/nft/utils/blocklist.ts new file mode 100644 index 0000000000..101b0396ff --- /dev/null +++ b/src/nft/utils/blocklist.ts @@ -0,0 +1,13 @@ +export const blocklistedCollections = [ + '0xd5eeac01b0d1d929d6cffaaf78020af137277293', + '0x85c08fffa9510f87019efdcf986301873cbb10d6', + '0x32d7e58933fceea6b73a13f8e30605d80915b616', + '0x85c08fffa9510f87019efdcf986301873cbb10d6', + '0xd5eeac01b0d1d929d6cffaaf78020af137277293', + '0x88e49f9fd4cc3d30f2f46c652f59fb52c4874f23', + '0xabefbc9fd2f806065b4f3c237d4b59d9a97bcac7', + '0xd945f759d422ae30a6166838317b937de08380e3', + '0x8e52fb89b6311bd9ec36bd7cea9a0c311fd27a92', + '0x2079c2765462af6d78a9ccbddb6ff3c6d4ba2e24', + '0xd4d871419714b778ebec2e22c7c53572b573706e', +] diff --git a/src/nft/utils/collection.ts b/src/nft/utils/collection.ts index 9c91a8c8f5..3f5e215879 100644 --- a/src/nft/utils/collection.ts +++ b/src/nft/utils/collection.ts @@ -22,17 +22,3 @@ export const isInSameSudoSwapPool = (assetA: GenieAsset, assetB: GenieAsset): bo export const isInSameMarketplaceCollection = (assetA: GenieAsset, assetB: GenieAsset): boolean => { return assetA.address === assetB.address && assetA.marketplace === assetB.marketplace } - -export const blocklistedCollections = [ - '0xd5eeac01b0d1d929d6cffaaf78020af137277293', - '0x85c08fffa9510f87019efdcf986301873cbb10d6', - '0x32d7e58933fceea6b73a13f8e30605d80915b616', - '0x85c08fffa9510f87019efdcf986301873cbb10d6', - '0xd5eeac01b0d1d929d6cffaaf78020af137277293', - '0x88e49f9fd4cc3d30f2f46c652f59fb52c4874f23', - '0xabefbc9fd2f806065b4f3c237d4b59d9a97bcac7', - '0xd945f759d422ae30a6166838317b937de08380e3', - '0x8e52fb89b6311bd9ec36bd7cea9a0c311fd27a92', - '0x2079c2765462af6d78a9ccbddb6ff3c6d4ba2e24', - '0xd4d871419714b778ebec2e22c7c53572b573706e', -] diff --git a/src/nft/utils/index.ts b/src/nft/utils/index.ts index 1a225ea94c..4ab2fd147d 100644 --- a/src/nft/utils/index.ts +++ b/src/nft/utils/index.ts @@ -1,4 +1,5 @@ export * from './asset' +export * from './blocklist' export * from './buildActivityAsset' export * from './buildSellObject' export * from './carousel'