Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SerializeNFT to SerializeMetadata #36

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cadence/contracts/bridge/FlowEVMBridge.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -671,7 +671,7 @@ contract FlowEVMBridge : IFlowEVMNFTBridge, IFlowEVMTokenBridge {
viewType: Type<MetadataViews.NFTCollectionDisplay>()
) 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("}")
}
}
Expand Down Expand Up @@ -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("}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cadence/scripts/serialize/serialize_nft.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cadence/tests/flow_evm_bridge_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand Down Expand Up @@ -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)
}

Expand All @@ -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!)
}

Expand All @@ -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!)
}

Expand All @@ -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!)
}
4 changes: 2 additions & 2 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion local/normalize_coverage_report.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion local/setup_emulator.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading