github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/nba/transactions/admin/create_set.cdc (about)

     1  import TopShot from 0xf8d6e0586b0a20c7
     2  
     3  // This transaction is for the admin to create a new set resource
     4  // and store it in the top shot smart contract
     5  
     6  // Parameters:
     7  //
     8  // setName: the name of a new Set to be created
     9  
    10  transaction(setName: String) {
    11      
    12      // Local variable for the topshot Admin object
    13      let adminRef: &TopShot.Admin
    14      let currSetID: UInt32
    15  
    16      prepare(acct: AuthAccount) {
    17  
    18          // borrow a reference to the Admin resource in storage
    19          self.adminRef = acct.borrow<&TopShot.Admin>(from: /storage/TopShotAdmin)
    20              ?? panic("Could not borrow a reference to the Admin resource")
    21          self.currSetID = TopShot.nextSetID;
    22      }
    23  
    24      execute {
    25          
    26          // Create a set with the specified name
    27          self.adminRef.createSet(name: setName)
    28      }
    29  
    30      post {
    31          
    32          TopShot.getSetName(setID: self.currSetID) == setName:
    33            "Could not find the specified set"
    34      }
    35  }