diff --git a/src/token/CountdownERC721.sol b/src/token/CountdownERC721.sol index 4cb33594..15945848 100644 --- a/src/token/CountdownERC721.sol +++ b/src/token/CountdownERC721.sol @@ -75,31 +75,31 @@ contract CountdownERC721 is NonReentrant, ContractMetadata, ERC721H, ICustomERC7 /// @notice Getter for the base image URI /// @dev This storage variable is set during the init and can be updated by the owner - string public IMAGE_URI = "ar://o8eyC27OuSZF0z-zIen5NTjJOKTzOQzKJzIe3F7Lmg0/1.png"; + string public IMAGE_URI; /// @notice Getter for the base animation URI /// @dev This storage variable is set during the init and can be updated by the owner - string public ANIMATION_URI = ""; // Define if you have a specific animation URI + string public ANIMATION_URI; /// @notice Getter for the external url /// @dev This storage variable is set during the init and can be updated by the owner - string public EXTERNAL_URL = "https://your-nft-project.com"; + string public EXTERNAL_URL; /// @notice Getter for the encrypted media URI /// @dev This storage variable is set during the init and can be updated by the owner - string public ENCRYPTED_MEDIA_URL = "ar://encryptedMediaUriHere"; + string public ENCRYPTED_MEDIA_URL; /// @notice Getter for the decryption key /// @dev This storage variable is set during the init and can be updated by the owner - string public DECRYPTION_KEY = "decryptionKeyHere"; + string public DECRYPTION_KEY; /// @notice Getter for the hash /// @dev This storage variable is set during the init and can be updated by the owner - string public HASH = "uniqueNftHashHere"; + string public HASH; /// @notice Getter for the decrypted media URI /// @dev This storage variable is set during the init and can be updated by the owner - string public DECRYPTED_MEDIA_URI = "ar://decryptedMediaUriHere"; + string public DECRYPTED_MEDIA_URI; /* -------------------------------------------------------------------------- */ @@ -386,7 +386,6 @@ contract CountdownERC721 is NonReentrant, ContractMetadata, ERC721H, ICustomERC7 * @notice Returns the metadata params for the contract */ function setMetadataParams(MetadataParams memory params) external onlyOwner { - DESCRIPTION = params.description; IMAGE_URI = params.imageURI; ANIMATION_URI = params.animationURI; EXTERNAL_URL = params.externalUrl; diff --git a/test/foundry/CountdownERC721/CountdownERC721.tokenUri.t.sol b/test/foundry/CountdownERC721/CountdownERC721.tokenUri.t.sol index 41795a38..7720a68f 100644 --- a/test/foundry/CountdownERC721/CountdownERC721.tokenUri.t.sol +++ b/test/foundry/CountdownERC721/CountdownERC721.tokenUri.t.sol @@ -7,6 +7,8 @@ import {CountdownERC721Fixture} from "test/foundry/fixtures/CountdownERC721Fixtu import {Vm} from "forge-std/Test.sol"; import {console} from "forge-std/console.sol"; +import {MetadataParams} from "src/struct/MetadataParams.sol"; + import {DEFAULT_BASE_URI, DEFAULT_PLACEHOLDER_URI, DEFAULT_ENCRYPT_DECRYPT_KEY, DEFAULT_MAX_SUPPLY} from "test/foundry/CountdownERC721/utils/Constants.sol"; import {ICountdownERC721} from "src/interface/ICountdownERC721.sol"; @@ -60,4 +62,73 @@ contract CountdownERC721PurchaseTest is CountdownERC721Fixture, ICustomERC721Err assertEq(base64TokenUri, expectedTokenUri, "Incorrect tokenURI for newly minted token"); } + + function test_setMetadataParams() public setupTestCountdownErc721(DEFAULT_MAX_SUPPLY) setUpPurchase { + /* -------------------------------- Purchase -------------------------------- */ + vm.prank(address(TEST_ACCOUNT)); + vm.deal(address(TEST_ACCOUNT), totalCost); + uint256 tokenId = countdownErc721.purchase{value: totalCost}(1); + + // First token ID is this long number due to the chain id prefix + require(erc721Enforcer.ownerOf(tokenId) == address(TEST_ACCOUNT), "Incorrect owner for newly minted token"); + assertEq(address(sourceContractAddress).balance, nativePrice); + + /* ----------------------------- Check tokenURI ----------------------------- */ + + // assertEq(base64TokenUri, expectedTokenUri, "Incorrect tokenURI for newly minted token"); + + /* ----------------------------- Set Metadata Params ----------------------------- */ + + // Expected token URI for newly minted token + // { + // "name": "Contract Name 115792089183396302089269705419353877679230723318366275194376439045705909141505", + // "description": "Description of the token", + // "external_url": "https://example.com", + // "image": ar://o8eyC27OuSZF0z-zIen5NTjJOKTzOQzKJzIe3F7Lmg0/1.png", + // "encrypted_media_url": "ar://encryptedMediaUriHere", + // "decryption_key": "decryptionKeyHere", + // "hash": "uniqueHashHere", + // "decrypted_media_url": "ar://decryptedMediaUriHere", + // "animation_url": "ar://animationUriHere", + // "properties": { + // "number": 115792089183396302089269705419353877679230723318366275194376439045705909141505, + // "name": "Contract Name" + // } + // } + string memory expectedTokenUri = NFTMetadataRenderer.encodeMetadataJSON( + '{"name": "Contract Name 115792089183396302089269705419353877679230723318366275194376439045705909141505", "description": "Description of the token", "external_url": "https://example.com", "image": "ar://o8eyC27OuSZF0z-zIen5NTjJOKTzOQzKJzIe3F7Lmg0/1.png", "encrypted_media_url": "ar://encryptedMediaUriHere", "decryption_key": "decryptionKeyHere", "hash": "uniqueHashHere", "decrypted_media_url": "ar://decryptedMediaUriHere", "animation_url": "ar://animationUriHere", "properties": {"number": 115792089183396302089269705419353877679230723318366275194376439045705909141505, "name": "Contract Name"}}' + ); + + // string name; + // string description; + // string imageURI; + // string animationURI; + // string externalUrl; + // string encryptedMediaUrl; + // string decryptionKey; + // string hash; + // string decryptedMediaUrl; + // uint256 tokenOfEdition; + // uint256 editionSize; + + MetadataParams memory metadataParams = MetadataParams({ + name: "Contract Name", // NOT USED + description: "Description of the token", // NOT USED + tokenOfEdition: 0, // NOT USED + editionSize: 0, // NOT USED + imageURI: "ar://o8eyC27OuSZF0z-zIen5NTjJOKTzOQzKJzIe3F7Lmg0/1.png", + animationURI: "", + externalUrl: "https://example.com", + encryptedMediaUrl: "ar://encryptedMediaUriHere", + decryptionKey: "decryptionKeyHere", + hash: "uniqueHashHere", + decryptedMediaUrl: "ar://decryptedMediaUriHere" + }); + + vm.prank(address(DEFAULT_OWNER_ADDRESS)); + countdownErc721.setMetadataParams(metadataParams); + + string memory base64TokenUri = countdownErc721.tokenURI(tokenId); + console.log("base64TokenUri: ", base64TokenUri); + } }