TransactionSEALED
□□@█^╲▫╲░╲█◇□▒#◇▓#●●$*□■╱░□▒!@╲▒$!%*○◇█!@@■▪&░&◇▒$#*@▒▒╱▫&@╳~◇!●
Transaction ID
Transaction Summary
Contract CallCalled FungibleToken, TopShotMarketV3, TopShot +2 more
Script Arguments
Cadence Script
1import FungibleToken from 0xf233dcee88fe0abe
2import TopShotMarketV3 from 0xc1e4f4f4c4257510
3import TopShot from 0x0b2a3299cc857e29
4import Market from 0xc1e4f4f4c4257510
5import NonFungibleToken from 0x1d7e57aa55817448
6
7transaction() {
8
9 prepare(acct: auth(Storage, Capabilities) &Account) {
10
11 // check if moment is currently listed
12 var listed = false
13 if let marketV3CollectionRef = acct.capabilities.borrow<&TopShotMarketV3.SaleCollection>(/public/topshotSalev3Collection) {
14
15 let salePrice = marketV3CollectionRef.getPrice(tokenID: UInt64(48446809))
16
17 if salePrice != nil {
18 listed = true
19 }
20 } else if let marketV1CollectionRef = acct.capabilities.borrow<&Market.SaleCollection>(/public/topshotSaleCollection) {
21
22 let salePrice = marketV1CollectionRef.getPrice(tokenID: UInt64(48446809))
23
24 if salePrice != nil {
25 listed = true
26 }
27 }
28 if listed {
29 panic("moment is already listed for sale")
30 }
31
32 // check to see if a v3 sale collection already exists
33 if acct.storage.borrow<&TopShotMarketV3.SaleCollection>(from: TopShotMarketV3.marketStoragePath) == nil {
34 // get the fungible token capabilities for the owner and beneficiary
35 let ownerCapability = acct.capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
36 if !ownerCapability.check() {
37 panic("Could not get the owner's FungibleToken.Receiver capability from /public/dapperUtilityCoinReceiver")
38 }
39 let beneficiaryCapability = getAccount(0xfaf0cc52c6e3acaf).capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
40 if !beneficiaryCapability.check() {
41 panic("Could not get the beneficiary's FungibleToken.Receiver capability from /public/dapperUtilityCoinReceiver")
42 }
43
44 var ownerCollection = acct.storage.copy<Capability<auth(NonFungibleToken.Withdraw, NonFungibleToken.Update) &TopShot.Collection>>(from: /storage/MomentCollectionCap)
45 if ownerCollection == nil {
46 ownerCollection = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw, NonFungibleToken.Update) &TopShot.Collection>(/storage/MomentCollection)
47 acct.storage.save(ownerCollection, to: /storage/MomentCollectionCap)
48 }
49
50 // get a capability for the v1 collection
51 var v1SaleCollection = acct.storage.copy<Capability<auth(Market.Create, NonFungibleToken.Withdraw, Market.Update) &Market.SaleCollection>>(from: /storage/topshotSaleCollectionCap)
52 if v1SaleCollection == nil {
53 if acct.storage.borrow<auth(Market.Create) &Market.SaleCollection>(from: /storage/topshotSaleCollection) != nil {
54 // If they have a V1 Sale Collection, issue a capability for it
55 // and store it in storage
56 v1SaleCollection = acct.capabilities.storage.issue<auth(Market.Create, NonFungibleToken.Withdraw, Market.Update) &Market.SaleCollection>(/storage/topshotSaleCollection)
57 acct.storage.save(v1SaleCollection, to: /storage/topshotSaleCollectionCap)
58 }
59 }
60
61 // create a new sale collection
62 let topshotV3SaleCollection <- TopShotMarketV3.createSaleCollection(ownerCollection: ownerCollection!,
63 ownerCapability: ownerCapability,
64 beneficiaryCapability: beneficiaryCapability,
65 cutPercentage: 0.050000,
66 marketV1Capability: v1SaleCollection)
67
68 // save it to storage
69 acct.storage.save(<-topshotV3SaleCollection, to: TopShotMarketV3.marketStoragePath)
70
71 // create a public link to the sale collection
72 acct.capabilities.publish(
73 acct.capabilities.storage.issue<&TopShotMarketV3.SaleCollection>(TopShotMarketV3.marketStoragePath),
74 at: TopShotMarketV3.marketPublicPath
75 )
76 }
77
78 // borrow a reference to the sale
79 let topshotSaleCollection = acct.storage.borrow<auth(TopShotMarketV3.Create) &TopShotMarketV3.SaleCollection>(from: TopShotMarketV3.marketStoragePath)
80 ?? panic("Could not borrow from sale in storage")
81
82 // put the moment up for sale
83 topshotSaleCollection.listForSale(tokenID: 48446809, price: UFix64(1))
84
85 }
86}