diff --git a/cadence/contracts/utils/SerializeMetadata.cdc b/cadence/contracts/utils/SerializeMetadata.cdc index 3f0a4d8d..d38c4045 100644 --- a/cadence/contracts/utils/SerializeMetadata.cdc +++ b/cadence/contracts/utils/SerializeMetadata.cdc @@ -31,14 +31,15 @@ access(all) contract SerializeMetadata { // Serialize the display values from the NFT's Display & NFTCollectionDisplay views let nftDisplay = nft.resolveView(Type()) as! MetadataViews.Display? let collectionDisplay = nft.resolveView(Type()) as! MetadataViews.NFTCollectionDisplay? + // Serialize the display & collection display views - nil if both views are nil let display = self.serializeFromDisplays(nftDisplay: nftDisplay, collectionDisplay: collectionDisplay) // Get the Traits view from the NFT, returning early if no traits are found let traits = nft.resolveView(Type()) as! MetadataViews.Traits? let attributes = self.serializeNFTTraitsAsAttributes(traits ?? MetadataViews.Traits([])) - // Return an empty string if nothing is serializable - if display == nil && attributes == nil { + // Return an empty string if all views are nil + if display == nil && traits == nil { return "" } // Init the data format prefix & concatenate the serialized display & attributes diff --git a/cadence/tests/serialize_tests.cdc b/cadence/tests/serialize_tests.cdc index b0c0b5ef..e472b907 100644 --- a/cadence/tests/serialize_tests.cdc +++ b/cadence/tests/serialize_tests.cdc @@ -239,7 +239,6 @@ fun testDictToJSONStringSucceeds() { var expectedTwo: String = "{\"arr\": [\"127\", \"Hello, World!\"], \"bool\": \"true\"}" var actual: String? = Serialize.dictToJSONString(dict: dict, excludedNames: nil) - log(actual) Test.assertEqual(true, expectedOne == actual! || expectedTwo == actual!) actual = Serialize.tryToJSONString(dict)