-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable liverender on certain tokens (#2010)
* disable liverender on certain tokens * fix test
- Loading branch information
Showing
6 changed files
with
63 additions
and
16 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 was deleted.
Oops, something went wrong.
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,21 @@ | ||
import { isKnownComputeIntensiveToken } from './prohibition'; | ||
|
||
describe('prohibition', () => { | ||
test('isKnownComputeIntensiveToken', () => { | ||
// prohibition + offending tokens | ||
expect( | ||
isKnownComputeIntensiveToken('0x47a91457a3a1f700097199fd63c039c4784384ab', '1E84805') // 32000005 | ||
).toBe(true); | ||
expect( | ||
isKnownComputeIntensiveToken('0x47a91457a3a1f700097199fd63c039c4784384ab', '56C8D23') // 91000099 | ||
).toBe(true); | ||
|
||
// non-prohibition contract | ||
expect(isKnownComputeIntensiveToken('some_other_contract', '1E84805')).toBe(false); | ||
|
||
// prohibition + non-offending tokens | ||
expect( | ||
isKnownComputeIntensiveToken('0x47a91457a3a1f700097199fd63c039c4784384ab', 'F4240') // 1000000 | ||
).toBe(false); | ||
}); | ||
}); |
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,32 @@ | ||
import { hexToDec } from './hexToDec'; | ||
|
||
const PROHIBITION_CONTRACT_ADDRESSES = new Set(['0x47a91457a3a1f700097199fd63c039c4784384ab']); | ||
|
||
// Projects that are known to crash browsers | ||
const LIVE_RENDER_DISABLED_PROJECT_IDS = new Set([32, 91, 210]); | ||
|
||
/** | ||
* WARNING: you will rarely want to use this function directly; | ||
* prefer to use `extractRelevantMetadataFromToken.ts` | ||
*/ | ||
export function getProhibitionUrlDangerously(contractAddress: string, tokenId: string) { | ||
if (PROHIBITION_CONTRACT_ADDRESSES.has(contractAddress)) { | ||
return `https://prohibition.art/token/${contractAddress}-${hexToDec(tokenId)}`; | ||
} | ||
return ''; | ||
} | ||
|
||
function getProhibitionProjectId(tokenId: string) { | ||
// same formula as art blocks | ||
return Math.floor(Number(tokenId) / 1000000); | ||
} | ||
|
||
export function isKnownComputeIntensiveToken(contractAddress: string, tokenId: string) { | ||
if (PROHIBITION_CONTRACT_ADDRESSES.has(contractAddress)) { | ||
const projectId = getProhibitionProjectId(hexToDec(tokenId)); | ||
if (LIVE_RENDER_DISABLED_PROJECT_IDS.has(projectId)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
68b13ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
gallery – ./
gallery-gallery-so.vercel.app
gallery-git-main-gallery-so.vercel.app
gallery-preview.vercel.app
gallery.so
www.gallery.so