From c7aa593359fcfbf613a9bf9337ed99f83560ba9d Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:16:58 -0500 Subject: [PATCH] add NFTForwarding Cadence tests & fix txn bugs --- lib/go/templates/internal/assets/assets.go | 12 +- tests/nft_forwarding_tests.cdc | 106 ++++++++++++++++++ transactions/mint_nft.cdc | 4 +- .../nft-forwarding/create_forwarder.cdc | 2 +- 4 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 tests/nft_forwarding_tests.cdc diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go index 717ddf0a..b72f0040 100644 --- a/lib/go/templates/internal/assets/assets.go +++ b/lib/go/templates/internal/assets/assets.go @@ -8,9 +8,9 @@ // ../../../scripts/get_nft_metadata.cdc (6.032kB) // ../../../scripts/get_nft_view.cdc (4.896kB) // ../../../transactions/destroy_nft.cdc (1.227kB) -// ../../../transactions/mint_nft.cdc (2.872kB) +// ../../../transactions/mint_nft.cdc (2.868kB) // ../../../transactions/nft-forwarding/change_forwarder_recipient.cdc (1.298kB) -// ../../../transactions/nft-forwarding/create_forwarder.cdc (1.573kB) +// ../../../transactions/nft-forwarding/create_forwarder.cdc (1.594kB) // ../../../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) @@ -248,7 +248,7 @@ func transactionsDestroy_nftCdc() (*asset, error) { return a, nil } -var _transactionsMint_nftCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x56\xc1\x6e\xe3\x36\x10\xbd\xeb\x2b\xa6\x3e\x78\x65\x34\x6b\xb7\x40\xd1\x83\x10\x27\x48\xb2\x0d\xd0\xc3\x06\x8b\xac\xbb\x97\x20\x87\xb1\x34\x96\xd8\xca\xa4\x4a\x8e\xec\x18\x46\xfe\xbd\xa0\x48\xd1\xa2\xa3\xa4\x3e\xd8\x32\xf9\x66\x86\xf3\xe6\xcd\x50\x8b\xc5\x02\x56\x95\x30\x60\x72\x2d\x1a\x86\xd6\x90\x01\xae\x08\x1e\xee\x57\x5f\x85\x64\xd2\xa0\xc9\xa8\x56\xe7\x04\xac\x60\x2b\x24\x03\x82\xa4\xbd\x05\x24\xd6\xfa\x4f\x86\x6d\x6b\x18\xd6\x04\xba\x95\xb0\x17\x5c\x75\x0e\x30\xcf\x55\x2b\x19\xb8\x42\x86\x0a\x9d\xd7\x6d\xec\xb2\x73\x60\x58\x69\x2a\x40\x48\x58\xd8\x47\x2c\x69\x11\x82\x27\x89\xd8\x36\x4a\x33\x3c\x28\x79\xdf\xca\x52\xac\x6b\x5a\xa9\x7f\x48\xc2\x46\xab\x2d\x4c\xce\x97\x27\x3d\xfe\x8f\x17\xdc\x36\x35\x3d\xdc\xaf\x3c\xf2\xb4\x10\x30\x5f\x89\xb1\x40\xc6\x1f\x82\xf6\xc6\xc3\xa2\xb5\x80\x1c\x0b\x7d\x16\x37\x61\x8d\xd2\x60\xce\x42\xc9\x34\x01\x00\xd0\x94\x8b\x46\x90\xe4\x0c\x6e\x8a\x42\x93\x31\x17\xdd\xba\xc4\x2d\x65\xf0\x9d\xb5\x90\xa5\x5b\x29\xc8\xb1\x2f\x94\x8c\x37\xb8\x6a\xb7\x6b\x89\xa2\x8e\x97\xf3\x96\x4d\x06\x4f\x7f\xdd\x8b\x97\xdf\x7f\x7b\x76\x6b\x5a\x1d\xb0\xe6\xc3\x97\x93\x2b\x0b\x71\x56\x31\xe4\x96\x24\x6d\x44\x2e\x50\x0b\xb2\x18\x7f\xb8\xe7\x64\x06\xc7\xa4\x03\xda\xaa\xd4\x2a\xc7\x1a\x76\xa8\x05\xae\x6b\x82\x8d\xd2\x5d\xa1\x84\x2c\xe3\x42\x6e\x48\x93\xcc\xa9\xb3\xab\x89\xfd\x46\x06\xd3\x13\xe1\xf3\x41\x39\x7b\xf7\x8f\xbd\xa1\x55\x95\x75\xa8\x29\x27\xb1\x23\xfd\xc9\x40\xae\xea\x9a\x3a\x22\x83\xd7\xc0\xe5\x5d\xd8\x7b\xa4\x4d\x06\xd3\xe3\xb9\x02\xe6\x27\xc4\xab\x0b\xd7\x68\x6a\x50\x53\x6a\x44\x29\xed\xc9\xb0\xe5\x2a\xbd\x55\x5a\xab\xfd\x0f\xac\x5b\x9a\xc1\xf4\xc6\x69\x35\x10\xd0\x87\x3d\x9d\xe4\x0b\x32\xc2\x72\x20\xab\xb9\xd5\x70\xbd\x23\x2b\x94\x74\x75\x68\xe8\x32\x92\x8e\xcd\xf9\x2e\xb2\xbe\x4a\x67\x33\x40\xf3\x13\xfc\x0f\xee\x3a\x9c\xc0\x7e\xae\xaf\xa1\x41\x29\xf2\x74\x62\xe1\x8f\x2e\xa6\x86\x42\x91\x01\xa9\x18\xfc\x29\xe0\x8d\x1b\xd8\x09\xda\x4f\x66\xc1\x59\x78\x58\x2c\x60\xdd\x25\x0f\x78\x2a\x5f\x5f\x85\x91\xae\x17\x12\x7c\x5b\x06\x17\x86\xea\xcd\xdc\x2b\x60\x09\x8e\xd7\xb9\x07\xcd\x9d\xf3\xcb\xd1\xfa\x5f\xa5\xb6\x77\xb2\x21\x8d\x6e\xe3\xbb\x33\xfe\x86\x5c\xcd\xde\xc9\xdf\xd7\xe8\x94\x7a\x37\x37\x00\x25\xa8\xf5\xdf\x94\x33\x20\x77\x29\x98\x86\x72\xb1\x11\x54\x40\x83\x5c\x4d\x66\xc9\x30\x73\x57\xf6\x5e\x70\x4e\x52\x9f\x0c\x34\xed\xba\x16\xb9\xcd\x7e\x50\xf2\x33\x71\x87\xc4\xc7\xb5\x08\x4b\x28\x89\xfd\x21\xd3\x80\x99\xcd\x73\x6c\x70\x2d\x6a\xc1\x82\x4c\x20\xe7\x43\xd9\x5e\xa5\x11\x05\x5d\xc7\x47\xb5\x9d\xbb\xf3\x5a\xb6\x22\xe4\x6c\x40\xd7\x9d\x6a\xeb\xa2\xe3\xa9\x74\xfd\xd3\x75\xd7\x68\xc5\xe1\x14\xdb\x0b\xe6\xd4\x39\x70\x0c\x11\xec\xd4\x99\xd7\x24\x4b\xae\x60\xb9\x1c\x1b\x38\xfd\xee\x74\xfa\x0e\x38\x1a\x3d\x7e\x3b\x83\xc9\x8d\xd6\x78\x00\x8f\x36\x55\x77\xf2\x35\x01\xfd\xdb\x62\xdd\x4d\x1e\x6f\x0e\x9a\x6a\x64\x2a\xa0\x20\x46\x51\x9b\xc9\xf0\xb0\xf4\x42\x79\xcb\x34\x6c\xe1\xc5\x02\xee\x34\x21\x93\x2b\xb8\x77\xe2\x8d\x03\x6a\x87\x1a\x9c\xb4\x96\xf0\x4b\xb4\xea\x2c\xdc\x94\x8c\xbb\xf6\xd1\xf9\x7a\x86\x25\x3c\x3d\x07\x9b\x7d\x25\x6a\xfa\x28\x57\xb8\xf2\x91\x8e\x51\xdd\xec\xa8\x59\x07\xf8\x01\xc6\xf9\x7a\xea\x4c\x9f\x3f\xb2\xbc\xeb\xb5\x76\x88\xe5\x38\x80\x9c\x09\xb2\x24\xbe\x9c\x1e\x63\x29\x3e\x7a\xb1\x8c\x09\xd1\x7e\x62\x2a\x4a\x62\xcf\x46\x6f\xf7\x2d\xa8\x33\x9d\xbd\x71\x30\xd4\xe8\xed\x20\xe7\xd0\xd6\x15\xee\x08\x7a\x57\x90\x2b\xb9\x11\x65\x6b\x5f\x10\x90\xe1\xdd\x40\xc3\x36\x87\x70\xd5\xd9\x04\xb1\x69\x48\x16\x6f\x13\x19\xad\xe7\x78\xbe\x7d\xf3\x64\xe3\x54\x5f\x8c\x1a\xe5\x2d\x67\x5d\x17\xf8\xb2\x8d\xa3\xa2\x9b\x7f\xa4\xa3\xc6\x6a\xde\xb1\x98\xbc\xff\xaf\xd7\xb2\xfb\xfd\x19\x7e\x0d\xbb\xaf\x49\xd4\x1b\x76\xf4\x86\x19\x80\xd2\xb6\x55\xa3\x8c\x60\x10\x3c\xb8\x95\xc3\x90\x3c\xbb\x96\x61\x78\xe1\x17\xd6\xc5\xe5\xe7\xe1\xcd\xd0\xfd\x3c\xdc\xaf\x62\x4e\xdd\xcb\x8f\xfd\x8e\x09\x89\x88\x18\xfc\x89\x51\x83\xf7\xa1\xf0\x78\x31\x5e\xf8\xec\xf4\x98\xbc\xe5\xe9\x83\x41\x3e\xf7\x2c\xa4\x6c\x9b\x21\x83\xcb\xcf\x21\xc3\x30\x1c\x5f\x93\xff\x02\x00\x00\xff\xff\xb6\x12\x62\xd1\x38\x0b\x00\x00" +var _transactionsMint_nftCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x56\x41\x6f\xe3\x36\x13\xbd\xeb\x57\xcc\xe7\x83\x57\xc6\x97\xb5\x5b\xa0\xe8\x41\x88\x13\x24\xd9\x06\xe8\x61\x83\x45\xd6\xdd\x4b\x90\xc3\x58\x1a\x4b\x6c\x65\x52\x25\x47\x76\x0c\x23\xff\xbd\xa0\x48\xd1\xa2\xa3\xa4\xf5\xc1\x96\xc9\x37\xc3\x99\x37\x6f\x86\x5a\x2c\x16\xb0\xaa\x84\x01\x93\x6b\xd1\x30\xb4\x86\x0c\x70\x45\xf0\x70\xbf\xfa\x2a\x24\x93\x06\x4d\x46\xb5\x3a\x27\x60\x05\x5b\x21\x19\x10\x24\xed\x2d\x20\xb1\xd6\xbf\x33\x6c\x5b\xc3\xb0\x26\xd0\xad\x84\xbd\xe0\xaa\x73\x80\x79\xae\x5a\xc9\xc0\x15\x32\x54\xe8\xbc\x6e\x63\x97\x9d\x03\xc3\x4a\x53\x01\x42\xc2\xc2\x3e\x62\x49\x8b\x70\x78\x92\x88\x6d\xa3\x34\xc3\x83\x92\xf7\xad\x2c\xc5\xba\xa6\x95\xfa\x8b\x24\x6c\xb4\xda\xc2\xe4\x7c\x79\xd2\xe3\x7f\x7b\xc1\x6d\x53\xd3\xc3\xfd\xca\x23\x4f\x0b\x01\xf3\x95\x18\x0b\x64\xfc\x21\x68\x6f\x3c\x2c\x5a\x0b\xc8\xb1\xa3\xcf\xce\x4d\x58\xa3\x34\x98\xb3\x50\x32\x4d\x00\x00\x34\xe5\xa2\x11\x24\x39\x83\x9b\xa2\xd0\x64\xcc\x45\xb7\x2e\x71\x4b\x19\x7c\x67\x2d\x64\xe9\x56\x0a\x72\xec\x0b\x25\xe3\x0d\xae\xda\xed\x5a\xa2\xa8\xe3\xe5\xbc\x65\x93\xc1\xd3\x1f\xf7\xe2\xe5\xd7\x5f\x9e\xdd\x9a\x56\x07\xac\xf9\xf0\xe5\xe4\xca\x42\x9c\x55\x0c\xb9\x25\x49\x1b\x91\x0b\xd4\x82\x2c\xc6\x07\xf7\x9c\xcc\xe0\x98\x74\x40\x5b\x95\x5a\xe5\x58\xc3\x0e\xb5\xc0\x75\x4d\xb0\x51\xba\x2b\x94\x90\x65\x5c\xc8\x0d\x69\x92\x39\x75\x76\x35\xb1\xdf\xc8\x60\x7a\x22\x7c\x3e\x28\x67\xef\xfe\xb1\x37\xb4\xaa\xb2\x0e\x35\xe5\x24\x76\xa4\x3f\x19\xc8\x55\x5d\x53\x47\x64\xf0\x1a\xb8\xbc\x0b\x7b\x8f\xb4\xc9\x60\x7a\x3c\x57\xc0\xfc\xd1\x3b\x7a\x75\x87\x35\x9a\x1a\xd4\x94\x1a\x51\x4a\x1b\x17\xb6\x5c\xa5\xb7\x4a\x6b\xb5\xff\x81\x75\x4b\x33\x98\xde\x38\xa5\x86\xf4\xfb\x43\x4f\x71\x7c\x41\x46\x58\x0e\x44\x35\xb7\x0a\xae\x77\x64\x65\x92\xae\x0e\x0d\x5d\x46\xc2\xb1\x19\xdf\x45\xd6\x57\xe9\x6c\x06\x68\xfe\x07\xff\x82\xbb\x0e\x11\xd8\xcf\xf5\x35\x34\x28\x45\x9e\x4e\x2c\xfc\xd1\x9d\xa9\xa1\x50\x64\x40\x2a\x06\x1f\x05\xbc\x71\x03\x3b\x41\xfb\xc9\x2c\x38\x0b\x0f\x8b\x05\xac\xbb\xe4\x01\x4f\xc5\xeb\x6b\x30\xd2\xf3\x42\x82\x6f\xca\xe0\xc2\x50\xbd\x99\xfb\xfa\x2f\xc1\xf1\x3a\xf7\xa0\xb9\x73\x7e\x39\x5a\xfd\xab\xd4\x76\x4e\x36\xa4\xd1\x6d\x7c\x77\xc6\xdf\x90\xab\xd9\x3b\xf9\xfb\x1a\x9d\x52\xef\xa6\x06\xa0\x04\xb5\xfe\x93\x72\x06\xe4\x2e\x05\xd3\x50\x2e\x36\x82\x0a\x68\x90\xab\xc9\x2c\x19\x66\xee\xca\xde\xcb\xcd\x09\xea\x93\x81\xa6\x5d\xd7\x22\xb7\xd9\x0f\x4a\x7e\x26\xed\x90\xf8\xb8\x12\x61\x09\x25\xb1\x0f\x32\x0d\x98\xd9\x3c\xc7\x06\xd7\xa2\x16\x2c\xc8\x04\x72\x3e\x10\xed\x55\x1a\x11\xd0\x75\x7b\x54\xd9\xb9\x8b\xd6\x72\x15\x21\x67\x03\xb2\xee\x54\x5b\x17\x1d\x4b\xa5\xeb\x9d\xce\xf7\x68\xbd\xe1\x94\x86\x97\xcb\xa9\x6f\xe0\x18\x4e\xb0\x13\x67\x5e\x93\x2c\xb9\x82\xe5\x72\x6c\xd8\xf4\xbb\xd3\xe9\x3b\xe0\x68\xec\xf8\xed\x0c\x26\x37\x5a\xe3\x01\x3c\xda\x54\x5d\xe4\x6b\x02\xfa\xbb\xc5\xba\x9b\x3a\xde\x1c\x34\xd5\xc8\x54\x40\x41\x8c\xa2\x36\x93\x61\xb0\xf4\x42\x79\xcb\x34\x6c\xe0\xc5\x02\xee\x34\x21\x93\x2b\xb7\x77\xe2\x8d\x03\x6a\x87\x1a\x9c\xb0\x96\xf0\x53\xb4\xea\x2c\xdc\x84\x8c\x7b\xf6\xd1\xf9\x7a\x86\x25\x3c\x3d\x07\x9b\x7d\x25\x6a\xfa\x28\x57\xb8\xf2\x27\x1d\xa3\xba\xd9\x41\xb3\x0e\xf0\x03\x8c\xf3\xf5\xd4\x99\x3e\x7f\x64\x79\xd7\x2b\xed\x10\x8b\x71\x00\x39\x93\x63\x49\x7c\x39\x3d\xfe\x77\x21\xda\x4f\x4c\x45\x49\xec\xd9\xe8\xed\xbe\x05\x75\xa6\xb3\x37\x0e\x86\x1a\xbd\x1d\xe4\x1c\x9a\xba\xc2\x1d\x41\xef\x0a\x72\x25\x37\xa2\x6c\xed\xcb\x01\x32\xbc\x7b\xd0\xb0\xc9\x21\x5c\x73\x36\x41\x6c\x1a\x92\xc5\xdb\x44\x46\xeb\x39\x9e\x6f\xdf\x3c\xd9\x38\xd5\x17\xa3\x46\x79\xcb\x59\xd7\x05\xbe\x6c\xe3\xa8\xe8\xd6\x1f\xe9\xa8\xb1\x9a\x77\x2c\x26\xef\xff\xeb\xb5\xec\x7e\xff\x0f\x3f\x87\xdd\xd7\x24\xea\x0d\x3b\x78\xc3\x0c\x40\x69\xdb\xaa\x51\x46\x30\x08\x1e\xdc\xc8\x61\x44\x9e\x5d\xc9\x30\xbc\xec\x0b\xeb\xe2\xf2\xf3\xf0\x5e\xe8\x7e\x1e\xee\x57\x31\xa7\xee\xc5\xc7\x7e\xc7\x84\x44\x44\x0c\xfe\xc4\xa8\xc1\xbb\x50\x78\xbc\x18\x2f\x7c\x76\x7a\x4c\xde\xf2\xf4\xc1\x18\x9f\x7b\x16\x52\xb6\xcd\x90\xc1\xe5\xe7\x90\x61\x18\x8e\xaf\xc9\x3f\x01\x00\x00\xff\xff\x5b\x9c\xef\xb7\x34\x0b\x00\x00" func transactionsMint_nftCdcBytes() ([]byte, error) { return bindataRead( @@ -264,7 +264,7 @@ func transactionsMint_nftCdc() (*asset, error) { } info := bindataFileInfo{name: "transactions/mint_nft.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0xc4, 0x17, 0x64, 0xdc, 0x7c, 0x4f, 0xdb, 0x86, 0x39, 0x53, 0x3f, 0x79, 0x4f, 0x4b, 0xd9, 0x44, 0xf9, 0x4b, 0x5e, 0x34, 0xc0, 0xc4, 0x43, 0xc5, 0x3c, 0x12, 0xdf, 0xd9, 0xa5, 0x20, 0x70}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x90, 0x68, 0x38, 0x26, 0x46, 0x24, 0xa2, 0x97, 0xf2, 0x69, 0xa1, 0xa4, 0xa2, 0x1a, 0x30, 0x43, 0x29, 0x93, 0xe9, 0x14, 0x78, 0xf3, 0xf8, 0x49, 0xeb, 0xdd, 0xce, 0xe, 0xaa, 0x88, 0xbb, 0x14}} return a, nil } @@ -288,7 +288,7 @@ func transactionsNftForwardingChange_forwarder_recipientCdc() (*asset, error) { return a, nil } -var _transactionsNftForwardingCreate_forwarderCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x54\x4f\x6f\xe2\x3e\x10\xbd\xe7\x53\x8c\x38\xd0\x20\xa5\x70\x47\xfd\xb5\xea\x0f\x09\x69\x0f\x8b\xaa\x16\xf5\x3e\x24\x43\x62\x6d\xb0\xa3\xf1\x98\x2c\xaa\xf8\xee\x2b\x93\x7f\x0e\x9b\x6d\x4e\xc6\x99\xbc\xf7\xfc\xde\x33\xea\x54\x19\x16\xd8\x19\xbd\x75\x3a\x57\x87\x92\xf6\xe6\x17\x69\x38\xb2\x39\xc1\xec\x7e\x7b\x16\xb5\xf3\x3f\x49\x30\x43\xc1\x4f\x45\xb5\x6d\x87\x47\x7b\xfd\xe4\x6e\xbb\xdf\x1a\xae\x91\x33\xa5\xf3\x0e\x36\xdc\x9b\x45\xd1\x6a\xb5\x82\x7d\xa1\x2c\x08\xa3\xb6\x98\x8a\x32\x1a\x94\x85\xba\x40\x01\xd4\x80\x69\x6a\x9c\x16\xa8\x8d\x2b\x33\x60\xa7\x41\x0c\x58\x12\x50\x62\xa9\x3c\x82\xab\xfc\xc6\xb1\x81\xf4\x8c\xd6\xff\x46\xc8\xc8\xaa\x5c\xa3\x50\x06\x4c\xa9\xaa\x14\x69\x79\xb0\x70\xe3\xdb\x6d\xf7\xcb\x8d\x29\x4b\x6a\xd8\xd0\x5a\x77\xf2\x0a\xa5\xa0\x61\xd8\x8b\x48\x8d\x3e\xaa\xdc\x31\x65\x9e\xe1\xf6\x3e\x57\x67\xd2\x1e\x01\x06\x04\x0f\x1a\x05\xfa\xe3\x1e\xe4\x35\xcb\x98\xac\x5d\x43\xbb\x48\x20\xed\xbf\x7a\x73\x87\x52\xa5\x6f\x28\xc5\x1a\x86\xf5\x02\xbe\xa2\x08\x00\xa0\x62\xaa\x90\x29\xf6\xc7\x20\x5e\x03\x3a\x29\xe2\xff\x0d\xb3\xa9\x3f\xb1\x74\x94\xc0\x0f\x6b\x1d\x7d\x88\x61\xcc\x69\x83\x15\x1e\x54\xa9\xe4\xb2\x31\x5a\xd8\x93\x70\xd2\xc0\xda\x62\x78\x99\xc0\x07\x9e\xe9\xf6\xfd\x02\xe6\xaf\x8d\xb7\x9e\x12\xda\xa7\x5f\xac\x56\x90\x93\x04\x87\x84\x01\xa5\x89\x72\xe4\x56\x7b\xbe\x2e\xae\x1e\xa6\x24\x19\x86\x06\xb0\x0d\x56\xf0\x9f\x27\x68\x25\xfc\xe5\xd8\x62\x99\x76\x74\x8a\xec\x32\x27\x79\x9a\x7f\xdd\x57\x32\x08\xf1\xfa\x1c\xf7\x9c\xdd\x33\x65\xf5\x68\x68\x01\x2f\x2f\x50\xa1\x56\x69\x3c\x7b\x0f\x73\xd7\x46\xc2\xec\x6b\x25\xc5\x5d\xe4\x80\x12\xd4\xa1\x42\x29\x66\x8b\x28\x34\x2f\x65\x42\x21\x40\xd0\x54\x07\x17\x81\x18\x98\xac\x71\x9c\x12\xcc\xc1\xe2\x99\x40\x69\xb0\x4d\x88\x49\xd7\xe3\x5b\x19\xcd\xd8\xe1\x07\x1b\x36\x2e\xf4\xf7\xd8\x43\x3f\x3d\x8e\xef\xdc\xb2\x51\xb1\xa3\x3a\x54\x30\x98\xbd\xfe\x47\x36\x8b\x1e\xbf\x69\xdf\xb2\x15\xb8\xf4\x82\xe3\xa7\xc7\x9e\x31\x01\x31\xeb\x3b\xce\xb6\x91\xb7\x32\x8f\x2c\x71\xba\x6a\xfa\x08\xf4\x5b\x59\xf1\x87\x0c\x0c\x0d\xf3\x6e\x0a\x36\x91\x5a\x2b\x67\xd4\x8d\x1e\x36\x9e\x0a\x7c\x32\x95\x39\x74\x4a\x70\xe0\xbd\xf4\x77\x7c\x30\xb4\x2e\x88\xe9\xb6\x37\x60\xb7\x7f\x45\xda\xf0\x09\xcb\xf2\x02\x07\x9a\x4e\xe3\x9d\x52\x52\x67\xe2\xa6\xeb\x53\xca\x3b\x57\x95\xbf\xc8\x53\xfd\xee\x20\xae\xcf\xf1\x37\x1e\x7f\x67\x4e\x67\xcd\x94\xaa\x04\x50\xd6\x93\xb7\xa4\x35\xed\x1a\x5d\xa3\x3f\x01\x00\x00\xff\xff\x68\xb8\x5d\xc5\x25\x06\x00\x00" +var _transactionsNftForwardingCreate_forwarderCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x54\x4d\x6f\xe2\x30\x10\xbd\xe7\x57\x8c\x38\xd0\x20\xa5\x70\x47\xdd\x56\x5d\x24\xa4\x3d\x2c\xaa\x5a\xb6\xf7\x21\x19\x12\x6b\x83\x1d\x8d\xc7\x64\xab\x8a\xff\xbe\x32\xf9\x72\xd8\x6c\x73\x32\xf6\xf8\xbd\xe7\x37\x6f\x50\xa7\xca\xb0\xc0\xce\xe8\xad\xd3\xb9\x3a\x94\xb4\x37\xbf\x49\xc3\x91\xcd\x09\x66\xb7\xdb\xb3\xa8\xad\xff\x49\x82\x19\x0a\xbe\x2b\xaa\x6d\x5b\x3c\xda\xeb\x2b\x77\xdb\xfd\xd6\x70\x8d\x9c\x29\x9d\x77\xb0\xe1\xde\x2c\x8a\x56\xab\x15\xec\x0b\x65\x41\x18\xb5\xc5\x54\x94\xd1\xa0\x2c\xd4\x05\x0a\xa0\x06\x4c\x53\xe3\xb4\x40\x6d\x5c\x99\x01\x3b\x0d\x62\xc0\x92\x80\x12\x4b\xe5\x11\x5c\xe5\x37\x8e\x0d\xa4\x67\xb4\xfe\x37\x42\x46\x56\xe5\x1a\x85\x32\x60\x4a\x55\xa5\x48\xcb\x9d\x85\x2b\xdf\x6e\xbb\x5f\x6e\x4c\x59\x52\xc3\x86\xd6\xba\x93\x57\x28\x05\x0d\xc5\x5e\x44\x6a\xf4\x51\xe5\x8e\x29\xf3\x0c\xd7\xf3\x5c\x9d\x49\x7b\x04\x18\x10\x3c\x68\x14\xe8\x8f\x7b\x90\xe7\x2c\x63\xb2\x76\x0d\xed\x22\x81\xb4\xbf\xf5\xe2\x0e\xa5\x4a\x5f\x50\x8a\x35\x0c\xeb\x05\x7c\x46\x11\x00\x40\xc5\x54\x21\x53\xec\x9f\x41\xbc\x06\x74\x52\xc4\xdf\x0d\xb3\xa9\xdf\xb1\x74\x94\xc0\x0f\x6b\x1d\xbd\x89\x61\xcc\x69\x83\x15\x1e\x54\xa9\xe4\x63\x63\xb4\xb0\x27\xe1\xa4\x81\xb5\xc5\x70\x98\xc0\x1b\x9e\xa9\xbd\xff\x4b\x57\xb7\xe7\x0b\x98\x3f\x37\x86\x7b\x1d\xd0\x7e\xfd\x62\xb5\x82\x9c\x24\x78\x39\x0c\x57\x9b\xfe\x8e\x2c\x6c\x1f\xdd\xf5\xb0\x87\x29\x49\x86\xa2\x01\x6c\x83\x15\x7c\xf3\x04\xad\x84\x7f\x6c\x5c\x2c\xd3\x8e\x4e\x91\x5d\xe6\x24\x0f\xf3\xcf\xdb\x9c\x06\x9d\xbd\x3c\xc6\x3d\x67\xf7\x4d\xf9\x3f\x2a\x5a\xc0\xd3\x13\x54\xa8\x55\x1a\xcf\x5e\xc3\x30\x68\x23\x61\x20\x6a\x25\xc5\x4d\x0e\x00\x25\xc8\x48\x85\x52\xcc\x16\x51\x68\x5e\xca\x84\x42\x80\xa0\xa9\x0e\xa6\x83\x18\x98\xac\x71\x9c\x12\xcc\xc1\xe2\x99\x40\x69\xb0\x4d\x67\x93\x2e\xdc\xd7\x84\x9a\xb1\xc3\x77\x36\x8c\x61\xe8\xef\xb1\x87\x7e\xb8\x1f\x0f\xe2\xb2\x51\xb1\xa3\x3a\x54\x30\x98\xbd\xfe\x4f\x6f\x16\x3d\x7e\x13\xc9\x65\x2b\x70\xe9\x05\xc7\x0f\xf7\x3d\x63\x02\x62\xd6\x37\x9c\x6d\x4c\xaf\x09\x1f\x59\xe2\xba\x10\x02\xfd\x51\x56\xfc\x23\x03\x43\xc3\x7e\x37\x01\x9b\xe8\x5a\x2b\x67\x94\x8d\x1e\x36\x9e\x6a\xf8\x64\x57\xe6\xd0\x29\xc1\x81\xf7\xa3\x1f\xfc\xc1\xd0\xba\x20\xa6\xeb\xde\x80\xdd\xfe\x3f\x69\xc3\x27\x2c\xcb\x0f\x38\xd0\x74\x37\x5e\x29\x25\x75\x26\x6e\xb2\x3e\xa5\xbc\x73\x55\xf9\xe9\x9e\xca\x77\x07\x71\x79\x8c\xbf\xf0\xf8\x2b\x73\x3a\x6b\xa6\x54\x25\x80\xb2\x9e\x9c\x92\xd6\xb4\x4b\x74\x89\xfe\x06\x00\x00\xff\xff\xca\x59\xbf\x49\x3a\x06\x00\x00" func transactionsNftForwardingCreate_forwarderCdcBytes() ([]byte, error) { return bindataRead( @@ -304,7 +304,7 @@ func transactionsNftForwardingCreate_forwarderCdc() (*asset, error) { } info := bindataFileInfo{name: "transactions/nft-forwarding/create_forwarder.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x41, 0x10, 0x83, 0x2b, 0x12, 0xd8, 0x6b, 0xb2, 0xd, 0x89, 0xca, 0x4c, 0x6e, 0xb2, 0x9b, 0xa9, 0xd3, 0x53, 0x63, 0x87, 0x39, 0x3, 0x5, 0xde, 0x8c, 0xb4, 0x5, 0xd8, 0xed, 0x40, 0x9d, 0xe0}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x47, 0xcd, 0x9a, 0xe9, 0x55, 0x66, 0xe1, 0x94, 0x74, 0x4d, 0xcd, 0xd1, 0x64, 0xbe, 0x45, 0x10, 0x96, 0x3f, 0xb5, 0xe0, 0x7b, 0xf7, 0xf, 0x62, 0x13, 0x17, 0xa5, 0xf1, 0x80, 0xb0, 0xa2, 0x76}} return a, nil } diff --git a/tests/nft_forwarding_tests.cdc b/tests/nft_forwarding_tests.cdc new file mode 100644 index 00000000..0b8b081d --- /dev/null +++ b/tests/nft_forwarding_tests.cdc @@ -0,0 +1,106 @@ +import Test +import "test_helpers.cdc" + +access(all) let admin = blockchain.createAccount() +access(all) let forwarder = blockchain.createAccount() +access(all) let recipient = blockchain.createAccount() + +access(all) let collectionPublicPath = /public/cadenceExampleNFTCollection + +access(all) fun setup() { + + blockchain.useConfiguration( + Test.Configuration( + addresses: { + "ViewResolver": admin.address, + "NonFungibleToken": admin.address, + "MetadataViews": admin.address, + "MultipleNFT": admin.address, + "ExampleNFT": admin.address, + "NFTForwarding": admin.address + } + ) + ) + + deploy("ViewResolver", admin, "../contracts/ViewResolver.cdc") + deploy("NonFungibleToken", admin, "../contracts/NonFungibleToken-v2.cdc") + deploy("MetadataViews", admin, "../contracts/MetadataViews.cdc") + deploy("MultipleNFT", admin, "../contracts/MultipleNFT.cdc") + deploy("ExampleNFT", admin, "../contracts/ExampleNFT-v2.cdc") + deploy("NFTForwarding", admin, "../contracts/utility/NFTForwarding.cdc") +} + +access(all) fun testCreateForwarderFails() { + + let expectedErrorMessage = "Recipient is not configured with NFT Collection at the given path" + let expectedErrorType = ErrorType.TX_PANIC + + // Create forwarder in forwarding account should fail since recipient doesn't have Collection configured + let forwarderSetupSuccess: Bool = txExecutor( + "nft-forwarding/create_forwarder.cdc", + [forwarder], + [recipient.address, collectionPublicPath], + expectedErrorMessage, + expectedErrorType + ) +} + +access(all) fun testCreateForwarder() { + // Setup Collection in recipient + let recipientSetupSuccess: Bool = txExecutor("setup_account.cdc", [recipient], [], nil, nil) + + // Create forwarder in forwarding account + let forwarderSetupSuccess: Bool = txExecutor( + "nft-forwarding/create_forwarder.cdc", + [forwarder], + [recipient.address, collectionPublicPath], + nil, + nil + ) + + Test.assertEqual(true, recipientSetupSuccess) + Test.assertEqual(true, forwarderSetupSuccess) +} + +access(all) fun testMintNFT() { + + let expectedCollectionLength: Int = 1 + + let royaltySetupSuccess: Bool = txExecutor( + "setup_account_to_receive_royalty.cdc", + [admin], + [/storage/flowTokenVault], + nil, + nil + ) + Test.assertEqual(true, royaltySetupSuccess) + + // Minting to forwarder should forward minted NFT to recipient + let mintSuccess: Bool = txExecutor( + "mint_nft.cdc", + [admin], + [ + forwarder.address, + "NFT Name", + "NFT Description", + "NFT Thumbnail", + [0.05], + ["Creator Royalty"], + [admin.address] + ], + nil, + nil + ) + Test.assertEqual(true, mintSuccess) + + // TODO: Uncomment once TestAccount bug fixed + // let forwardEventType = CompositeType(buildTypeIdentifier(admin, "NFTForwarding", "ForwardedNFTDeposit"))! + // Test.assertEqual(1, blockchain.eventsOfType(forwardEventType).length) + + let actualCollectionLength = scriptExecutor( + "get_collection_length.cdc", + [recipient.address], + ) as! Int? ?? panic("problem retrieving NFT IDs from recipient at expected path") + + Test.assertEqual(expectedCollectionLength, actualCollectionLength) +} diff --git a/transactions/mint_nft.cdc b/transactions/mint_nft.cdc index cc238424..66011f5d 100644 --- a/transactions/mint_nft.cdc +++ b/transactions/mint_nft.cdc @@ -21,7 +21,7 @@ transaction( let minter: &ExampleNFT.NFTMinter /// Reference to the receiver's collection - let recipientCollectionRef: &{NonFungibleToken.Collection} + let recipientCollectionRef: &{NonFungibleToken.Receiver} prepare(signer: auth(BorrowValue) &Account) { @@ -33,7 +33,7 @@ transaction( ?? panic("Account does not store an object at the specified path") // Borrow the recipient's public NFT collection reference - self.recipientCollectionRef = getAccount(recipient).capabilities.borrow<&{NonFungibleToken.Collection}>( + self.recipientCollectionRef = getAccount(recipient).capabilities.borrow<&{NonFungibleToken.Receiver}>( collectionData.publicPath ) ?? panic("Could not get receiver reference to the NFT Collection") } diff --git a/transactions/nft-forwarding/create_forwarder.cdc b/transactions/nft-forwarding/create_forwarder.cdc index b98a4615..81342beb 100644 --- a/transactions/nft-forwarding/create_forwarder.cdc +++ b/transactions/nft-forwarding/create_forwarder.cdc @@ -7,7 +7,7 @@ import NFTForwarding from "NFTForwarding" /// transaction(recipientAddress: Address, collectionPublicPath: PublicPath) { - prepare(signer: auth(BorrowValue, IssueStorageCapabilityController, PublishCapability, SaveValue) &Account) { + prepare(signer: auth(BorrowValue, IssueStorageCapabilityController, PublishCapability, SaveValue, UnpublishCapability) &Account) { // get Collection Capability from the recipientAddress account let recipientCollectionCap = getAccount(recipientAddress).capabilities.get<&{NonFungibleToken.Collection}>(