diff --git a/cadence/contracts/bridge/FlowEVMBridge.cdc b/cadence/contracts/bridge/FlowEVMBridge.cdc index a9e94207..39f81074 100644 --- a/cadence/contracts/bridge/FlowEVMBridge.cdc +++ b/cadence/contracts/bridge/FlowEVMBridge.cdc @@ -21,7 +21,7 @@ import "FlowEVMBridgeUtils" import "FlowEVMBridgeNFTEscrow" import "FlowEVMBridgeTokenEscrow" import "FlowEVMBridgeTemplates" -import "SerializeNFT" +import "SerializeMetadata" /// The FlowEVMBridge contract is the main entrypoint for bridging NFT & FT assets between Flow & FlowEVM. /// @@ -207,7 +207,7 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { uri = metadata.uri.uri() } else { // Otherwise, serialize the NFT - uri = SerializeNFT.serializeNFTMetadataAsURI(&token as &{NonFungibleToken.NFT}) + uri = SerializeMetadata.serializeNFTMetadataAsURI(&token as &{NonFungibleToken.NFT}) } // Lock the NFT & calculate the storage used by the NFT @@ -671,7 +671,7 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { viewType: Type() ) as! MetadataViews.NFTCollectionDisplay? { name = collectionDisplay.name - let serializedDisplay = SerializeNFT.serializeFromDisplays(nftDisplay: nil, collectionDisplay: collectionDisplay)! + let serializedDisplay = SerializeMetadata.serializeFromDisplays(nftDisplay: nil, collectionDisplay: collectionDisplay)! contractURI = "data:application/json;utf8,{".concat(serializedDisplay).concat("}") } } @@ -738,7 +738,7 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge { symbol = ftDisplay!.symbol } if contractURI.length == 0 && ftDisplay != nil { - let serializedDisplay = SerializeNFT.serializeFTDisplay(ftDisplay!) + let serializedDisplay = SerializeMetadata.serializeFTDisplay(ftDisplay!) contractURI = "data:application/json;utf8,{".concat(serializedDisplay).concat("}") } diff --git a/cadence/contracts/utils/SerializeNFT.cdc b/cadence/contracts/utils/SerializeMetadata.cdc similarity index 99% rename from cadence/contracts/utils/SerializeNFT.cdc rename to cadence/contracts/utils/SerializeMetadata.cdc index 7c75e734..d9bee9f7 100644 --- a/cadence/contracts/utils/SerializeNFT.cdc +++ b/cadence/contracts/utils/SerializeMetadata.cdc @@ -8,7 +8,7 @@ import "Serialize" /// This contract defines methods for serializing NFT metadata as a JSON compatible string, according to the common /// OpenSea metadata format. NFTs and metadata views can be serialized by reference via contract methods. /// -access(all) contract SerializeNFT { +access(all) contract SerializeMetadata { /// Serializes the metadata (as a JSON compatible String) for a given NFT according to formats expected by EVM /// platforms like OpenSea. If you are a project owner seeking to expose custom traits on bridged NFTs and your diff --git a/cadence/scripts/serialize/serialize_nft.cdc b/cadence/scripts/serialize/serialize_nft.cdc index 3cb72baa..aa6c1b75 100644 --- a/cadence/scripts/serialize/serialize_nft.cdc +++ b/cadence/scripts/serialize/serialize_nft.cdc @@ -2,7 +2,7 @@ import "ViewResolver" import "MetadataViews" import "NonFungibleToken" -import "SerializeNFT" +import "SerializeMetadata" access(all) fun main(address: Address, storagePathIdentifier: String, id: UInt64): String? { @@ -13,7 +13,7 @@ fun main(address: Address, storagePathIdentifier: String, id: UInt64): String? { from: storagePath ) { if let nft = collection.borrowNFT(id) { - return SerializeNFT.serializeNFTMetadataAsURI(nft) + return SerializeMetadata.serializeNFTMetadataAsURI(nft) } } return nil diff --git a/cadence/tests/flow_evm_bridge_tests.cdc b/cadence/tests/flow_evm_bridge_tests.cdc index c5d2ce80..a3ef446c 100644 --- a/cadence/tests/flow_evm_bridge_tests.cdc +++ b/cadence/tests/flow_evm_bridge_tests.cdc @@ -65,8 +65,8 @@ fun setup() { ) Test.expect(err, Test.beNil()) err = Test.deployContract( - name: "SerializeNFT", - path: "../contracts/utils/SerializeNFT.cdc", + name: "SerializeMetadata", + path: "../contracts/utils/SerializeMetadata.cdc", arguments: [] ) Test.expect(err, Test.beNil()) diff --git a/cadence/tests/serialize_nft_tests.cdc b/cadence/tests/serialize_metadata_tests.cdc similarity index 89% rename from cadence/tests/serialize_nft_tests.cdc rename to cadence/tests/serialize_metadata_tests.cdc index 06ad51bf..33340339 100644 --- a/cadence/tests/serialize_nft_tests.cdc +++ b/cadence/tests/serialize_metadata_tests.cdc @@ -4,7 +4,7 @@ import BlockchainHelpers import "MetadataViews" import "Serialize" -import "SerializeNFT" +import "SerializeMetadata" access(all) let admin = Test.getAccount(0x0000000000000008) access(all) let alice = Test.createAccount() @@ -26,8 +26,8 @@ fun setup() { ) Test.expect(err, Test.beNil()) err = Test.deployContract( - name: "SerializeNFT", - path: "../contracts/utils/SerializeNFT.cdc", + name: "SerializeMetadata", + path: "../contracts/utils/SerializeMetadata.cdc", arguments: [] ) Test.expect(err, Test.beNil()) @@ -81,7 +81,7 @@ fun testSerializeNFTSucceeds() { // Returns nil when no displays are provided access(all) fun testSerializeNilDisplaysReturnsNil() { - let serializedResult = SerializeNFT.serializeFromDisplays(nftDisplay: nil, collectionDisplay: nil) + let serializedResult = SerializeMetadata.serializeFromDisplays(nftDisplay: nil, collectionDisplay: nil) Test.assertEqual(nil, serializedResult) } @@ -96,7 +96,7 @@ fun testSerializeNFTDisplaySucceeds() { let expected = "\"name\": \"NAME\", \"description\": \"NFT Description\", \"image\": \"https://flow.com/examplenft.jpg\"" - let serializedResult = SerializeNFT.serializeFromDisplays(nftDisplay: display, collectionDisplay: nil) + let serializedResult = SerializeMetadata.serializeFromDisplays(nftDisplay: display, collectionDisplay: nil) Test.assertEqual(expected, serializedResult!) } @@ -114,7 +114,7 @@ fun testSerializeNFTCollectionDisplaySucceeds() { let expected = "\"name\": \"NAME\", \"description\": \"NFT Description\", \"image\": \"https://flow.com/square_image.jpg\", \"external_link\": \"https://flow.com\"" - let serializedResult = SerializeNFT.serializeFromDisplays(nftDisplay: nil, collectionDisplay: collectionDisplay) + let serializedResult = SerializeMetadata.serializeFromDisplays(nftDisplay: nil, collectionDisplay: collectionDisplay) Test.assertEqual(expected, serializedResult!) } @@ -138,6 +138,6 @@ fun testSerializeBothDisplaysSucceeds() { let expected = "\"name\": \"NAME\", \"description\": \"NFT Description\", \"image\": \"https://flow.com/examplenft.jpg\", \"external_url\": \"https://flow.com\"" - let serializedResult = SerializeNFT.serializeFromDisplays(nftDisplay: nftDisplay, collectionDisplay: collectionDisplay) + let serializedResult = SerializeMetadata.serializeFromDisplays(nftDisplay: nftDisplay, collectionDisplay: collectionDisplay) Test.assertEqual(expected, serializedResult!) } diff --git a/flow.json b/flow.json index 71159b1b..9fe93644 100644 --- a/flow.json +++ b/flow.json @@ -221,8 +221,8 @@ "testing": "0000000000000007" } }, - "SerializeNFT": { - "source": "./cadence/contracts/utils/SerializeNFT.cdc", + "SerializeMetadata": { + "source": "./cadence/contracts/utils/SerializeMetadata.cdc", "aliases": { "emulator": "f8d6e0586b0a20c7", "testing": "0000000000000007" diff --git a/local/normalize_coverage_report.sh b/local/normalize_coverage_report.sh index 494d78a7..d2d2bb8c 100644 --- a/local/normalize_coverage_report.sh +++ b/local/normalize_coverage_report.sh @@ -1,5 +1,5 @@ sed -i 's/A.0000000000000007.Serialize/cadence\/contracts\/utils\/Serialize.cdc/' coverage.lcov -sed -i 's/A.0000000000000007.SerializeNFT/cadence\contracts\/SerializeNFT.cdc/' coverage.lcov +sed -i 's/A.0000000000000007.SerializeMetadata/cadence\contracts\/SerializeMetadata.cdc/' coverage.lcov sed -i 's/A.0000000000000007.BridgePermissions/cadence\/contracts\/bridge\/BridgePermissions.cdc/' coverage.lcov sed -i 's/A.0000000000000007.ICrossVM/cadence\/contracts\/bridge\/ICrossVM.cdc/' coverage.lcov sed -i 's/A.0000000000000007.CrossVMNFT/cadence\/contracts\/bridge\/CrossVMNFT.cdc/' coverage.lcov diff --git a/local/setup_emulator.1.sh b/local/setup_emulator.1.sh index 58c1dfe8..a7cb9bdf 100644 --- a/local/setup_emulator.1.sh +++ b/local/setup_emulator.1.sh @@ -8,7 +8,7 @@ flow-c1 accounts add-contract ./cadence/contracts/utils/ArrayUtils.cdc flow-c1 accounts add-contract ./cadence/contracts/utils/StringUtils.cdc flow-c1 accounts add-contract ./cadence/contracts/utils/ScopedFTProviders.cdc flow-c1 accounts add-contract ./cadence/contracts/utils/Serialize.cdc -flow-c1 accounts add-contract ./cadence/contracts/utils/SerializeNFT.cdc +flow-c1 accounts add-contract ./cadence/contracts/utils/SerializeMetadata.cdc flow-c1 accounts update-contract ./cadence/contracts/standards/EVM.cdc