Created
April 10, 2022 20:34
-
-
Save ilamanov/91c57bd4ca8cbcc1b4540b85e69171c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| pragma solidity ^0.5.0; | |
| function tokenURI(uint256 _tokenId) external | |
| view onlyValidTokenId(_tokenId) returns (string memory) { | |
| // if staticIpfsImageLink is present, | |
| // then return "{projectBaseIpfsURI}/{staticIpfsImageLink}" | |
| if (bytes(staticIpfsImageLink[_tokenId]).length > 0) { | |
| return Strings.strConcat( | |
| projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI, | |
| staticIpfsImageLink[_tokenId]); | |
| } | |
| // if project is not dynamic and useIpfs is true, | |
| // then return "{projectBaseIpfsURI}/{ipfsHash}" | |
| if (!projects[tokenIdToProjectId[_tokenId]].dynamic | |
| && projects[tokenIdToProjectId[_tokenId]].useIpfs) { | |
| return Strings.strConcat( | |
| projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI, | |
| projects[tokenIdToProjectId[_tokenId]].ipfsHash); | |
| } | |
| // else return "{projectBaseURI}/{_tokenId}" | |
| return Strings.strConcat( | |
| projects[tokenIdToProjectId[_tokenId]].projectBaseURI, | |
| Strings.uint2str(_tokenId)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment