github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/float/transactions/create_group.cdc (about) 1 import FLOAT from 0xf8d6e0586b0a20c7 2 import FLOATVerifiers from 0xf8d6e0586b0a20c7 3 import NonFungibleToken from 0xf8d6e0586b0a20c7 4 import MetadataViews from 0xf8d6e0586b0a20c7 5 import GrantedAccountAccess from 0xf8d6e0586b0a20c7 6 7 transaction(groupName: String, image: String, description: String) { 8 9 let FLOATEvents: &FLOAT.FLOATEvents 10 11 prepare(acct: AuthAccount) { 12 // SETUP COLLECTION 13 if acct.borrow<&FLOAT.Collection>(from: FLOAT.FLOATCollectionStoragePath) == nil { 14 acct.save(<- FLOAT.createEmptyCollection(), to: FLOAT.FLOATCollectionStoragePath) 15 acct.link<&FLOAT.Collection{NonFungibleToken.Receiver, NonFungibleToken.CollectionPublic, MetadataViews.ResolverCollection, FLOAT.CollectionPublic}> 16 (FLOAT.FLOATCollectionPublicPath, target: FLOAT.FLOATCollectionStoragePath) 17 } 18 19 // SETUP FLOATEVENTS 20 if acct.borrow<&FLOAT.FLOATEvents>(from: FLOAT.FLOATEventsStoragePath) == nil { 21 acct.save(<- FLOAT.createEmptyFLOATEventCollection(), to: FLOAT.FLOATEventsStoragePath) 22 acct.link<&FLOAT.FLOATEvents{FLOAT.FLOATEventsPublic, MetadataViews.ResolverCollection}> 23 (FLOAT.FLOATEventsPublicPath, target: FLOAT.FLOATEventsStoragePath) 24 } 25 26 // SETUP SHARED MINTING 27 if acct.borrow<&GrantedAccountAccess.Info>(from: GrantedAccountAccess.InfoStoragePath) == nil { 28 acct.save(<- GrantedAccountAccess.createInfo(), to: GrantedAccountAccess.InfoStoragePath) 29 acct.link<&GrantedAccountAccess.Info{GrantedAccountAccess.InfoPublic}> 30 (GrantedAccountAccess.InfoPublicPath, target: GrantedAccountAccess.InfoStoragePath) 31 } 32 33 self.FLOATEvents = acct.borrow<&FLOAT.FLOATEvents>(from: FLOAT.FLOATEventsStoragePath) 34 ?? panic("Could not borrow the FLOATEvents from the signer.") 35 36 } 37 38 execute { 39 self.FLOATEvents.createGroup(groupName: groupName, image: image, description: description) 40 log("Created a new Group.") 41 } 42 43 }