From 42b00b3b856f4abe95c0cae6b3b8aae07b8fafff Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:38:45 -0500 Subject: [PATCH] fix test cases to correspond with new contract implementations --- lib/go/templates/internal/assets/assets.go | 6 ++-- lib/go/templates/transaction_templates.go | 12 +++---- lib/go/test/metadata_test.go | 23 ++++++++++--- lib/go/test/nft_test.go | 34 +++++++++---------- tests/scripts/get_nft_metadata.cdc | 2 +- tests/scripts/get_nft_view.cdc | 2 +- tests/scripts/resolve_nft_views.cdc | 2 +- .../setup_account_from_nft_reference.cdc | 2 +- 8 files changed, 48 insertions(+), 35 deletions(-) diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go index 773dfe4f..717ddf0a 100644 --- a/lib/go/templates/internal/assets/assets.go +++ b/lib/go/templates/internal/assets/assets.go @@ -14,7 +14,7 @@ // ../../../transactions/nft-forwarding/transfer_nft_to_receiver.cdc (2.015kB) // ../../../transactions/nft-forwarding/unlink_forwarder_link_collection.cdc (1.103kB) // ../../../transactions/setup_account.cdc (1.342kB) -// ../../../transactions/setup_account_from_nft_reference.cdc (1.351kB) +// ../../../transactions/setup_account_from_nft_reference.cdc (1.352kB) // ../../../transactions/setup_account_to_receive_royalty.cdc (1.509kB) // ../../../transactions/test/upgrade_nft_contract.cdc (172B) // ../../../transactions/transfer_nft.cdc (2.226kB) @@ -368,7 +368,7 @@ func transactionsSetup_accountCdc() (*asset, error) { return a, nil } -var _transactionsSetup_account_from_nft_referenceCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\xc1\x4e\xe3\x30\x10\xbd\xe7\x2b\x1e\x3d\xa0\x44\x2a\xe9\x65\xb5\x87\xaa\x05\xa1\xee\x22\x71\x58\x84\x96\x2e\xf7\x69\x32\x6d\x2c\x82\x1d\xd9\x93\x46\x08\xf1\xef\x2b\xc7\x49\xda\x64\x17\xe1\x93\x65\xbf\x79\xf3\x66\xe6\xcd\x62\xb1\xc0\xb6\x50\x0e\x62\x49\x3b\xca\x44\x19\x0d\xe5\xd0\x14\x24\x20\x0d\xca\x32\x53\x6b\x41\x63\xea\x32\x87\xad\x75\xe4\x23\xc4\xc0\xb1\x40\x89\xe3\x72\x8f\xba\xf2\x0f\x96\x33\x56\x47\xc6\xc3\xdd\xd6\xa5\x81\x73\x5f\xeb\x96\xb0\x8d\xa9\x1d\x3b\x1c\x15\x37\xce\xa3\x5f\xb4\x69\xd0\x14\x6c\xb9\x27\xf3\x2c\x05\x23\x33\x65\xc9\xa7\x28\xa5\xe1\xc4\x58\x3a\x30\x48\xe7\x1e\x9b\x59\x26\xe1\x16\xcb\xaf\x95\xbc\x9d\x45\xa4\x51\xa4\x5e\x2b\x63\x05\x0f\x46\xdf\xd5\xfa\xa0\x76\x25\x6f\xcd\x0b\x6b\xec\xad\x79\xc5\x6c\xfa\x3c\xeb\xf1\xbf\x58\x28\x27\xa1\xe7\x56\x5f\x00\x8f\xde\x66\x51\x74\xd6\xa1\x98\xf2\xdc\xb2\x73\x4b\xdc\x86\xcb\x1c\x55\xbd\x2b\x55\xf6\x48\x52\x2c\xf1\x38\xdc\xe7\x50\xf9\x12\x7f\xee\xb5\x7c\xff\x96\xe0\x3d\x8a\x00\xa0\xb2\x5c\x91\xe5\xd8\xa9\x83\x66\xbb\x04\xd5\x52\xc4\xf7\xce\xd5\xfc\x14\x4a\xdd\x50\x45\x3b\x55\x2a\x79\xdb\x18\x2d\xd6\xd7\x67\xe7\x81\xd5\x15\xa7\xcf\x39\x9e\xe8\xc8\xcf\x54\xd6\x9c\xe0\xf2\x36\x4c\xca\x67\x41\x77\x4a\x96\xb3\xee\x60\x8d\x03\x4b\x07\xeb\x2b\x48\xd2\x2c\xf0\x89\x62\x97\xee\x8c\xb5\xa6\x59\x5d\xbe\x4f\x1b\x95\x6e\x06\x9a\x8f\xeb\xf8\x54\x6b\x32\xe4\xf2\xe7\xe6\x06\x15\x69\x95\xc5\xb3\x4d\x6b\x17\x6d\x04\x81\x12\x04\xcb\x7b\xb6\xac\xb3\x76\xe0\xe3\x49\xcf\x92\x68\xa4\xd9\xb2\x33\xe5\x91\x2d\xd6\xe7\xc3\x0d\x4c\x7e\x1a\xbf\xbb\xff\xd8\x37\x57\xe5\xc9\xc5\x27\x15\xff\x20\x21\xac\x07\xba\xb4\xbb\x78\x8a\x78\xfb\x56\xf1\x6a\x34\xe2\xf4\xe1\x6e\xbb\x19\xc5\x5e\xc7\x49\x72\x01\x72\x17\xf8\x02\x78\x92\xbf\x58\x60\x13\x0c\x4a\xd0\xdc\xfc\x63\x51\x37\x92\xda\xfe\x9e\xa8\xb0\xba\x9a\xa8\x4f\x83\xdb\x7f\x8e\x71\x71\x32\x4a\xe8\xe8\xc8\x50\xd2\xf7\xb5\x5b\xd9\x01\x11\x6c\x96\x76\x6b\x94\x7a\x74\xbc\xba\x9a\xa4\x9e\x43\xcc\x72\x9a\xbc\x0b\x09\x83\x3e\xcf\x98\xf5\x25\x06\x27\x20\x1b\x3c\x89\xbd\xb1\xd3\x3d\xfe\xff\x70\x36\x54\x61\xdd\x8b\x1b\x08\xbc\x0b\x7b\xa5\xca\xaf\xc4\x97\x66\x1c\x39\xd0\x9f\xcf\x8b\x18\x41\x93\x69\x83\x46\x1a\xaa\xb0\x6c\xf1\x48\xef\x1c\x24\x4b\x4c\xdd\xff\x11\x7d\x44\x7f\x03\x00\x00\xff\xff\x4d\xbb\x66\x1c\x47\x05\x00\x00" +var _transactionsSetup_account_from_nft_referenceCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\xc1\x6a\xe3\x30\x10\xbd\xfb\x2b\x5e\x73\x28\x36\xa4\xce\x65\xd9\x43\x48\x5a\x8a\x77\x0b\x3d\x6c\x29\xdb\x6c\xef\x13\x7b\x12\x8b\xba\x92\x91\xe4\x98\x50\xf2\xef\x8b\x2c\xdb\x89\xbc\x5b\xaa\x93\x90\xde\xbc\x79\x33\xf3\x66\xb1\x58\x60\x53\x0a\x03\xab\x49\x1a\xca\xad\x50\x12\xc2\xa0\x2d\xc9\x82\x24\x28\xcf\x55\x23\x2d\x5a\xd5\x54\x05\x74\x23\x23\x17\x61\x15\x0c\x5b\x08\x6b\xb8\xda\xa1\xa9\xdd\x83\xe6\x9c\xc5\x81\xf1\xf4\xb0\x31\xa9\xe7\xdc\x35\xb2\x23\xec\x62\x1a\xc3\x06\x07\xc1\xad\x71\xe8\x37\xa9\x5a\xb4\x25\x6b\x1e\xc8\x1c\x4b\xc9\xc8\x55\x55\xf1\x39\x4a\x48\x18\xab\x34\xed\x19\x24\x0b\x87\xcd\x35\x93\xe5\x0e\xcb\xef\xb5\x3d\x5e\x44\xa4\x51\x24\xde\x6b\xa5\x2d\x9e\x94\x7c\x68\xe4\x5e\x6c\x2b\xde\xa8\x37\x96\xd8\x69\xf5\x8e\xd9\xf4\x79\x36\xe0\x7f\xb1\xa5\x82\x2c\xbd\x76\xfa\x3c\x38\x78\x9b\x45\xd1\x45\x87\x62\x2a\x0a\xcd\xc6\x2c\x71\xef\x2f\x73\xd4\xcd\xb6\x12\xf9\x33\xd9\x72\x89\xe7\xf1\x3e\x87\x28\x96\xf8\xf3\x28\xed\xf7\x6f\x09\x3e\xa2\x08\x00\x6a\xcd\x35\x69\x8e\x8d\xd8\x4b\xd6\x4b\x50\x63\xcb\xf8\xd1\x98\x86\x5f\x7c\xa9\x19\xd5\xb4\x15\x95\xb0\xc7\x4c\x49\xab\x5d\x7d\x7a\xee\x59\x4d\x79\xfe\x9c\xe3\x85\x0e\xfc\x4a\x55\xc3\x09\xae\xef\xfd\xa4\x5c\x16\xf4\xa7\x62\x7b\xd1\x1d\xac\xb1\x67\xdb\xc3\x86\x0a\x92\x34\x1f\xf8\x04\x9b\x74\xab\xb4\x56\xed\xea\xfa\x63\xda\xa9\x34\x1b\x79\x4e\xb7\xf1\xb9\xd8\x64\x4c\xe6\xce\xdd\x1d\x6a\x92\x22\x8f\x67\x59\xe7\x17\xa9\x2c\x3c\x25\x08\x9a\x77\xac\x59\xe6\xdd\xc4\xc3\x51\xcf\x92\x28\x10\xad\xd9\xa8\xea\xc0\x1a\xeb\xcb\xe9\x7a\x26\x37\x8e\xdf\xfd\x7f\xec\xba\x2b\x8a\xe4\xea\x93\x92\x7f\x90\x25\xac\x47\xba\xb4\xbf\x38\x8a\x78\x73\xac\x79\x15\xcc\x38\x7d\x7a\xd8\x64\x41\xec\x6d\x9c\x24\x57\x20\x73\x85\x2f\x80\x67\xf9\x8b\x05\x32\xef\x50\x82\xe4\xf6\x1f\x8f\x9a\x40\x6a\xf7\x7b\xa6\xc2\xea\x66\xa2\x3e\xf5\x76\xff\x19\xe2\xe2\x24\x48\x68\xe8\xc0\x10\x76\xe8\x6b\xbf\xb3\x23\xc2\xfb\x2c\xed\xf7\x28\x75\xe8\x78\x75\x33\x49\x3d\x87\x55\xcb\x69\xf2\x3e\xc4\x0f\xfa\x32\x63\x3e\x94\xe8\x9d\x80\xd1\x44\x47\xec\x94\x9e\x2e\xf2\xff\x87\x93\x51\x8d\xf5\x20\x2e\x70\xe1\xa0\x54\xb8\x9d\xf8\xd2\x8c\x81\x03\xdd\xf9\xbc\x88\x00\x9a\x4c\x1b\x14\x68\xa8\xfd\xb6\xc5\x81\xde\x39\xc8\x2e\x31\x75\xff\x29\x3a\x45\x7f\x03\x00\x00\xff\xff\xf2\xd7\x61\x86\x48\x05\x00\x00" func transactionsSetup_account_from_nft_referenceCdcBytes() ([]byte, error) { return bindataRead( @@ -384,7 +384,7 @@ func transactionsSetup_account_from_nft_referenceCdc() (*asset, error) { } info := bindataFileInfo{name: "transactions/setup_account_from_nft_reference.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa6, 0xd2, 0xd7, 0xe0, 0xe, 0x9e, 0xfc, 0xe1, 0x66, 0xbb, 0x1c, 0x1c, 0x67, 0xd2, 0xf3, 0xbf, 0x79, 0xdc, 0x8c, 0xbe, 0x84, 0x89, 0x8b, 0xa8, 0xd8, 0xbc, 0xc6, 0x2d, 0x8c, 0x1e, 0x36, 0x20}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbc, 0x69, 0x91, 0x23, 0x5c, 0x8, 0xe1, 0x54, 0xca, 0xe0, 0xc, 0x46, 0x3c, 0xfd, 0x2f, 0x85, 0xf3, 0x45, 0xbc, 0x25, 0xc2, 0xbb, 0xda, 0x6, 0xc4, 0xa9, 0x18, 0x88, 0x19, 0xa6, 0xe5, 0x97}} return a, nil } diff --git a/lib/go/templates/transaction_templates.go b/lib/go/templates/transaction_templates.go index 9205e640..0acc6028 100644 --- a/lib/go/templates/transaction_templates.go +++ b/lib/go/templates/transaction_templates.go @@ -40,16 +40,16 @@ func GenerateMintNFTScript(nftAddress, exampleNFTAddress, metadataViewsAddress, // GenerateTransferNFTScript returns a script that withdraws an NFT token // from a collection and deposits it into another collection. -func GenerateTransferNFTScript(nftAddress, exampleNFTAddress flow.Address) []byte { +func GenerateTransferNFTScript(nftAddress, exampleNFTAddress, metadataAddress, viewResolverAddress flow.Address) []byte { code := assets.MustAssetString(filenameTransferNFT) - return replaceAddresses(code, nftAddress, exampleNFTAddress, flow.EmptyAddress, flow.EmptyAddress, flow.EmptyAddress) + return replaceAddresses(code, nftAddress, exampleNFTAddress, metadataAddress, flow.EmptyAddress, viewResolverAddress) } // GenerateDestroyNFTScript creates a script that withdraws an NFT token // from a collection and destroys it. -func GenerateDestroyNFTScript(nftAddress, exampleNFTAddress flow.Address) []byte { +func GenerateDestroyNFTScript(nftAddress, exampleNFTAddress, metadataAddress flow.Address) []byte { code := assets.MustAssetString(filenameDestroyNFT) - return replaceAddresses(code, nftAddress, exampleNFTAddress, flow.EmptyAddress, flow.EmptyAddress, flow.EmptyAddress) + return replaceAddresses(code, nftAddress, exampleNFTAddress, metadataAddress, flow.EmptyAddress, flow.EmptyAddress) } // GenerateSetupAccountToReceiveRoyaltyScript returns a script that @@ -62,7 +62,7 @@ func GenerateSetupAccountToReceiveRoyaltyScript(metadataViewsAddress, ftAddress // GenerateSetupAccountFromNftReferenceScript returns a script that instantiates a new // NFT collection instance, saves the collection in storage, then stores a // reference to the collection. -func GenerateSetupAccountFromNftReferenceScript(nftAddress flow.Address, exampleNFTAddress flow.Address, metadataViewsAddress flow.Address) []byte { +func GenerateSetupAccountFromNftReferenceScript(nftAddress, metadataViewsAddress flow.Address) []byte { code := assets.MustAssetString(filenameSetupAccountFromNftReference) - return replaceAddresses(code, nftAddress, exampleNFTAddress, metadataViewsAddress, flow.EmptyAddress, flow.EmptyAddress) + return replaceAddresses(code, nftAddress, flow.EmptyAddress, metadataViewsAddress, flow.EmptyAddress, flow.EmptyAddress) } diff --git a/lib/go/test/metadata_test.go b/lib/go/test/metadata_test.go index 12ed411f..b034ec0a 100644 --- a/lib/go/test/metadata_test.go +++ b/lib/go/test/metadata_test.go @@ -357,14 +357,27 @@ func TestSetupCollectionFromNFTReference(t *testing.T) { exampleNFTSigner) t.Run("Should be able to setup an account using the NFTCollectionData metadata view of a referenced NFT", func(t *testing.T) { - // Ideally, the exampleNFTAddress would not be needed in order to perform the full setup, but it is required - // until the following issue is supported in cadence: https://github.com/onflow/cadence/issues/1617 - script := templates.GenerateSetupAccountFromNftReferenceScript(nftAddress, exampleNFTAddress, metadataAddress) + const ( + pathName = "cadenceExampleNFTCollection" + ) + + idsScript := templates.GenerateGetCollectionIDsScript(nftAddress, exampleNFTAddress) + idsResult := executeScriptAndCheck( + t, b, + idsScript, + [][]byte{ + jsoncdc.MustEncode(cadence.NewAddress(exampleNFTAddress)), + jsoncdc.MustEncode(cadence.Path{Domain: common.PathDomainPublic, Identifier: pathName}), + }, + ) + mintedID := idsResult.(cadence.Array).Values[0].(cadence.UInt64) + + script := templates.GenerateSetupAccountFromNftReferenceScript(nftAddress, metadataAddress) tx := createTxWithTemplateAndAuthorizer(b, script, aAddress) tx.AddArgument(cadence.NewAddress(exampleNFTAddress)) - tx.AddArgument(cadence.Path{Domain: common.PathDomainPublic, Identifier: "exampleNFTCollection"}) - tx.AddArgument(cadence.NewUInt64(0)) + tx.AddArgument(cadence.Path{Domain: common.PathDomainPublic, Identifier: pathName}) + tx.AddArgument(mintedID) serviceSigner, _ := b.ServiceKey().Signer() diff --git a/lib/go/test/nft_test.go b/lib/go/test/nft_test.go index 8893d916..75704d7b 100644 --- a/lib/go/test/nft_test.go +++ b/lib/go/test/nft_test.go @@ -109,7 +109,7 @@ func TestTransferNFT(t *testing.T) { // Create new keys for the NFT contract account // and deploy all the NFT contracts exampleNFTAccountKey, exampleNFTSigner := accountKeys.NewWithSigner() - nftAddress, metadataAddress, exampleNFTAddress, _ := deployNFTContracts(t, b, adapter, accountKeys, exampleNFTAccountKey) + nftAddress, metadataAddress, exampleNFTAddress, viewResolverAddress := deployNFTContracts(t, b, adapter, accountKeys, exampleNFTAccountKey) // Create a new account to test transfers joshAddress, _, joshSigner := newAccountWithAddress(b, accountKeys) @@ -157,7 +157,7 @@ func TestTransferNFT(t *testing.T) { // This transaction tries to withdraw an NFT from a collection // and deposit it to another collection - script := templates.GenerateTransferNFTScript(nftAddress, exampleNFTAddress) + script := templates.GenerateTransferNFTScript(nftAddress, exampleNFTAddress, metadataAddress, viewResolverAddress) tx := createTxWithTemplateAndAuthorizer(b, script, exampleNFTAddress) // Specify ExampleNFT contract address & name @@ -199,9 +199,12 @@ func TestTransferNFT(t *testing.T) { // Transfer an NFT correctly t.Run("Should be able to withdraw an NFT and deposit to another accounts collection", func(t *testing.T) { - // Same transaction as before - script := templates.GenerateTransferNFTScript(nftAddress, exampleNFTAddress) - tx := createTxWithTemplateAndAuthorizer(b, script, exampleNFTAddress) + // // Mint a single NFT with standard royalty cuts and metadata + // mintExampleNFT(t, b, + // accountKeys, + // nftAddress, metadataAddress, exampleNFTAddress, + // exampleNFTAccountKey, + // exampleNFTSigner) idsScript := templates.GenerateGetCollectionIDsScript(nftAddress, exampleNFTAddress) idsResult := executeScriptAndCheck( @@ -214,12 +217,9 @@ func TestTransferNFT(t *testing.T) { ) mintedID := idsResult.(cadence.Array).Values[0].(cadence.UInt64) - // Mint a single NFT with standard royalty cuts and metadata - mintExampleNFT(t, b, - accountKeys, - nftAddress, metadataAddress, exampleNFTAddress, - exampleNFTAccountKey, - exampleNFTSigner) + // Same transaction as before + script := templates.GenerateTransferNFTScript(nftAddress, exampleNFTAddress, metadataAddress, viewResolverAddress) + tx := createTxWithTemplateAndAuthorizer(b, script, exampleNFTAddress) // Specify ExampleNFT contract address & name tx.AddArgument(cadence.NewAddress(exampleNFTAddress)) @@ -270,12 +270,6 @@ func TestTransferNFT(t *testing.T) { t.Run("Should be able to withdraw an NFT and destroy it, not reducing the supply", func(t *testing.T) { - // This transaction withdraws the specifed NFT from the authorizers account - // and calls `destroy NFT` - script := templates.GenerateDestroyNFTScript(nftAddress, exampleNFTAddress) - - tx := createTxWithTemplateAndAuthorizer(b, script, joshAddress) - idsScript := templates.GenerateGetCollectionIDsScript(nftAddress, exampleNFTAddress) idsResult := executeScriptAndCheck( t, b, @@ -287,6 +281,12 @@ func TestTransferNFT(t *testing.T) { ) mintedID := idsResult.(cadence.Array).Values[0].(cadence.UInt64) + // This transaction withdraws the specifed NFT from the authorizers account + // and calls `destroy NFT` + script := templates.GenerateDestroyNFTScript(nftAddress, exampleNFTAddress, metadataAddress) + + tx := createTxWithTemplateAndAuthorizer(b, script, joshAddress) + // Destroy the only NFT in the collection tx.AddArgument(mintedID) diff --git a/tests/scripts/get_nft_metadata.cdc b/tests/scripts/get_nft_metadata.cdc index 14faa7bc..da170146 100644 --- a/tests/scripts/get_nft_metadata.cdc +++ b/tests/scripts/get_nft_metadata.cdc @@ -161,7 +161,7 @@ access(all) fun main(address: Address, id: UInt64): Bool { assert(nft.getID() == nftMetadata.serialNumber) assert(/public/cadenceExampleNFTCollection == nftMetadata.collectionPublicPath) assert(/storage/cadenceExampleNFTCollection == nftMetadata.collectionStoragePath) - assert(/private/exampleNFTCollection == nftMetadata.collectionProviderPath) + assert(/private/cadenceExampleNFTCollection == nftMetadata.collectionProviderPath) // assert("&A.01cf0e2f2f715450.ExampleNFT.Collection" == nftMetadata.collectionPublic) // assert("&A.01cf0e2f2f715450.ExampleNFT.Collection" == nftMetadata.collectionPublicLinkedType) // assert("&A.01cf0e2f2f715450.ExampleNFT.Collection" == nftMetadata.collectionProviderLinkedType) diff --git a/tests/scripts/get_nft_view.cdc b/tests/scripts/get_nft_view.cdc index 1ca054c2..5ff42b3e 100644 --- a/tests/scripts/get_nft_view.cdc +++ b/tests/scripts/get_nft_view.cdc @@ -126,7 +126,7 @@ access(all) fun main(address: Address, id: UInt64): Bool { assert("https://example-nft.onflow.org/".concat(id.toString()) == nftViewResult.externalURL) assert(/public/cadenceExampleNFTCollection == nftViewResult.collectionPublicPath) assert(/storage/cadenceExampleNFTCollection == nftViewResult.collectionStoragePath) - assert(/private/exampleNFTCollection == nftViewResult.collectionProviderPath) + assert(/private/cadenceExampleNFTCollection == nftViewResult.collectionProviderPath) // assert("&A.01cf0e2f2f715450.ExampleNFT.Collection{A.01cf0e2f2f715450.ExampleNFT.ExampleNFTCollectionPublic}" == nftViewResult.collectionPublic) // assert("&A.01cf0e2f2f715450.ExampleNFT.Collection{A.01cf0e2f2f715450.ExampleNFT.ExampleNFTCollectionPublic,A.f8d6e0586b0a20c7.NonFungibleToken.CollectionPublic,A.f8d6e0586b0a20c7.NonFungibleToken.Receiver,A.f8d6e0586b0a20c7.MetadataViews.ResolverCollection}" == nftViewResult.collectionPublicLinkedType) // assert("auth(A.f8d6e0586b0a20c7.NonFungibleToken.Withdrawable)&A.01cf0e2f2f715450.ExampleNFT.Collection" == nftViewResult.collectionProviderLinkedType) diff --git a/tests/scripts/resolve_nft_views.cdc b/tests/scripts/resolve_nft_views.cdc index cdb84f51..80eb8ce0 100644 --- a/tests/scripts/resolve_nft_views.cdc +++ b/tests/scripts/resolve_nft_views.cdc @@ -28,7 +28,7 @@ access(all) fun main(): Bool { assert(/storage/cadenceExampleNFTCollection == collectionData.storagePath) assert(/public/cadenceExampleNFTCollection == collectionData.publicPath) - assert(/private/exampleNFTCollection == collectionData.providerPath) + assert(/private/cadenceExampleNFTCollection == collectionData.providerPath) assert(Type<&ExampleNFT.Collection>() == collectionData.publicCollection) assert(Type<&ExampleNFT.Collection>() == collectionData.publicLinkedType) assert(Type() == collectionData.providerLinkedType) diff --git a/transactions/setup_account_from_nft_reference.cdc b/transactions/setup_account_from_nft_reference.cdc index 98ab8250..f0ffbc8f 100644 --- a/transactions/setup_account_from_nft_reference.cdc +++ b/transactions/setup_account_from_nft_reference.cdc @@ -9,7 +9,7 @@ import MetadataViews from "MetadataViews" transaction(address: Address, publicPath: PublicPath, id: UInt64) { prepare(signer: auth(IssueStorageCapabilityController, PublishCapability, SaveValue) &Account) { - let collection = getAccount(address).capabilties.borrow<&{NonFungibleToken.Collection}>(publicPath) + let collection = getAccount(address).capabilities.borrow<&{NonFungibleToken.Collection}>(publicPath) ?? panic("Could not borrow a reference to the collection") let resolver = collection.borrowViewResolver(id: id)!