Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderattar committed Apr 30, 2024
1 parent d92da6f commit 45bfd20
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
27 changes: 14 additions & 13 deletions src/token/CountdownERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,6 @@ contract CountdownERC721 is NonReentrant, ContractMetadata, ERC721H, ICustomERC7
return NFTMetadataRenderer.createMetadataEdition(params);
}

/**
* @notice Returns the metadata params for the contract
*/
function setMetadataParams(MetadataParams memory params) external onlyOwner {
IMAGE_URI = params.imageURI;
ANIMATION_URI = params.animationURI;
EXTERNAL_URL = params.externalUrl;
ENCRYPTED_MEDIA_URL = params.encryptedMediaUrl;
DECRYPTION_KEY = params.decryptionKey;
HASH = params.hash;
DECRYPTED_MEDIA_URI = params.decryptedMediaUrl;
}

/**
* @notice Convert USD price to current price in native Ether units
*/
Expand Down Expand Up @@ -476,6 +463,20 @@ contract CountdownERC721 is NonReentrant, ContractMetadata, ERC721H, ICustomERC7
/* admin only */
/* -------------------------------------------------------------------------- */

/**
* @dev Returns the metadata params for the contract
* @notice This only sets the subset of metadata params that are settable by the owner
*/
function setMetadataParams(MetadataParams memory params) external onlyOwner {
IMAGE_URI = params.imageURI;
ANIMATION_URI = params.animationURI;
EXTERNAL_URL = params.externalUrl;
ENCRYPTED_MEDIA_URL = params.encryptedMediaUrl;
DECRYPTION_KEY = params.decryptionKey;
HASH = params.hash;
DECRYPTED_MEDIA_URI = params.decryptedMediaUrl;
}

/**
* @notice Minter account mints tokens to a recipient that has paid offchain
* @param recipient recipient to mint to
Expand Down
19 changes: 6 additions & 13 deletions test/foundry/CountdownERC721/CountdownERC721.tokenUri.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,16 @@ contract CountdownERC721PurchaseTest is CountdownERC721Fixture, ICustomERC721Err
'{"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;

// NOTE: The metadata params struct needs to have all it's values set,
// but the setMetadataParams function only sets the imageURI, externalUrl,
// encryptedMediaUrl, decryptionKey, hash, and decryptedMediaUrl
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: "",
animationURI: "ar://animationUriHere",
externalUrl: "https://example.com",
encryptedMediaUrl: "ar://encryptedMediaUriHere",
decryptionKey: "decryptionKeyHere",
Expand All @@ -130,5 +121,7 @@ contract CountdownERC721PurchaseTest is CountdownERC721Fixture, ICustomERC721Err

string memory base64TokenUri = countdownErc721.tokenURI(tokenId);
console.log("base64TokenUri: ", base64TokenUri);

assertEq(base64TokenUri, expectedTokenUri, "Incorrect tokenURI for newly minted token");
}
}

0 comments on commit 45bfd20

Please sign in to comment.