Skip to content

Commit

Permalink
add mint and operate entitlements
Browse files Browse the repository at this point in the history
  • Loading branch information
Deewai committed Aug 2, 2024
1 parent 076d2d9 commit d16fcbf
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 41 deletions.
43 changes: 20 additions & 23 deletions laliga/contracts/Golazos.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -780,17 +780,8 @@ access(all) contract Golazos: NonFungibleToken {
/// A public collection interface that allows Moment NFTs to be borrowed
///
access(all) resource interface MomentNFTCollectionPublic : NonFungibleToken.CollectionPublic {
access(all) fun batchDeposit(tokens: @{NonFungibleToken.Collection})
access(all) fun borrowMomentNFT(id: UInt64): &Golazos.NFT? {
// If the result isn't nil, the id of the returned reference
// should be the same as the argument to the function
post {
(result == nil) || (result?.id == id):
"Cannot borrow Moment NFT reference: The ID of the returned reference is incorrect"
}
}
}
/// Deprecated: This is no longer used for defining access control anymore.
access(all) resource interface MomentNFTCollectionPublic : NonFungibleToken.CollectionPublic {}

/// An NFT Collection
///
Expand Down Expand Up @@ -916,6 +907,12 @@ access(all) contract Golazos: NonFungibleToken {
// Admin
//------------------------------------------------------------
/// Entitlement that grants the ability to mint Golazos NFTs
access(all) entitlement Mint

/// Entitlement that grants the ability to operate admin functions
access(all) entitlement Operate

/// An interface containing the Admin function that allows minting NFTs
///
/// This is no longer used for defining access control anymore.
Expand All @@ -928,7 +925,7 @@ access(all) contract Golazos: NonFungibleToken {
access(all) resource Admin: NFTMinter {
/// Borrow a Series
///
access(all) view fun borrowSeries(id: UInt64): &Golazos.Series {
access(self) view fun borrowSeries(id: UInt64): &Golazos.Series {
pre {
Golazos.seriesByID[id] != nil: "Cannot borrow series, no such id"
}
Expand All @@ -938,7 +935,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Borrow a Set
///
access(all) view fun borrowSet(id: UInt64): &Golazos.Set {
access(self) view fun borrowSet(id: UInt64): &Golazos.Set {
pre {
Golazos.setByID[id] != nil: "Cannot borrow Set, no such id"
}
Expand All @@ -948,7 +945,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Borrow a Play
///
access(all) view fun borrowPlay(id: UInt64): &Golazos.Play {
access(self) view fun borrowPlay(id: UInt64): &Golazos.Play {
pre {
Golazos.playByID[id] != nil: "Cannot borrow Play, no such id"
}
Expand All @@ -958,7 +955,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Borrow an Edition
///
access(all) view fun borrowEdition(id: UInt64): &Golazos.Edition {
access(self) view fun borrowEdition(id: UInt64): &Golazos.Edition {
pre {
Golazos.editionByID[id] != nil: "Cannot borrow edition, no such id"
}
Expand All @@ -968,7 +965,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Create a Series
///
access(all) fun createSeries(name: String): UInt64 {
access(Operate) fun createSeries(name: String): UInt64 {
// Create and store the new series
let series <- create Golazos.Series(
name: name,
Expand All @@ -982,7 +979,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Close a Series
///
access(all) fun closeSeries(id: UInt64): UInt64 {
access(Operate) fun closeSeries(id: UInt64): UInt64 {
if let series = &Golazos.seriesByID[id] as &Golazos.Series? {
series.close()
return series.id
Expand All @@ -992,7 +989,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Create a Set
///
access(all) fun createSet(name: String): UInt64 {
access(Operate) fun createSet(name: String): UInt64 {
// Create and store the new set
let set <- create Golazos.Set(
name: name,
Expand All @@ -1006,7 +1003,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Locks a Set
///
access(all) fun lockSet(id: UInt64): UInt64 {
access(Operate) fun lockSet(id: UInt64): UInt64 {
if let set = &Golazos.setByID[id] as &Golazos.Set? {
set.lock()
return set.id
Expand All @@ -1016,7 +1013,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Create a Play
///
access(all) fun createPlay(classification: String, metadata: {String: String}): UInt64 {
access(Operate) fun createPlay(classification: String, metadata: {String: String}): UInt64 {
// Create and store the new play
let play <- create Golazos.Play(
classification: classification,
Expand All @@ -1031,7 +1028,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Create an Edition
///
access(all) fun createEdition(
access(Operate) fun createEdition(
seriesID: UInt64,
setID: UInt64,
playID: UInt64,
Expand All @@ -1052,7 +1049,7 @@ access(all) contract Golazos: NonFungibleToken {

/// Close an Edition
///
access(all) fun closeEdition(id: UInt64): UInt64 {
access(Operate) fun closeEdition(id: UInt64): UInt64 {
if let edition = &Golazos.editionByID[id] as &Golazos.Edition? {
edition.close()
return edition.id
Expand All @@ -1063,7 +1060,7 @@ access(all) contract Golazos: NonFungibleToken {
/// Mint a single NFT
/// The Edition for the given ID must already exist
///
access(all) fun mintNFT(editionID: UInt64): @Golazos.NFT {
access(Mint) fun mintNFT(editionID: UInt64): @Golazos.NFT {
pre {
// Make sure the edition we are creating this NFT in exists
Golazos.editionByID.containsKey(editionID): "No such EditionID"
Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/editions/close_edition.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Golazos from "Golazos"

transaction(editionID: UInt64) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/editions/create_edition.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ transaction(
maxMintSize: UInt64?,
) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/nfts/mint_moment_nft.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Golazos from "Golazos"
transaction(recipientAddress: Address, editionID: UInt64) {

// local variable for storing the minter reference
let minter: &Golazos.Admin
let minter: auth(Golazos.Mint) &Golazos.Admin
let recipient: &Golazos.Collection

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the NFTMinter resource in storage
self.minter = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.minter = signer.storage.borrow<auth(Golazos.Mint) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the NFT minter")

// get the recipients public account object
Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/nfts/mint_moment_nfts_multi.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Golazos from "Golazos"
transaction(recipientAddress: Address, editionIDs: [UInt64], counts: [UInt64]) {

// local variable for storing the minter reference
let minter: &Golazos.Admin
let minter: auth(Golazos.Mint) &Golazos.Admin
let recipient: &Golazos.Collection

prepare(signer: auth(BorrowValue) &Account) {
Expand All @@ -15,7 +15,7 @@ transaction(recipientAddress: Address, editionIDs: [UInt64], counts: [UInt64]) {
let recipientAccount = getAccount(recipientAddress)

// borrow a public reference to the receivers collection
self.recipient = recipientAccount.capabilities.borrow<&Golazos.Collection>(Golazos.CollectionPublicPath)
self.recipient = recipientAccount.capabilities.borrow<auth(Golazos.Mint) &Golazos.Collection>(Golazos.CollectionPublicPath)
?? panic("Could not borrow a reference to the collection receiver")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/plays/create_play.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ transaction(
metadata: {String: String}
) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/series/close_series.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Golazos from "Golazos"

transaction(seriesID: UInt64) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/series/create_series.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Golazos from "Golazos"

transaction(name: String) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/sets/create_set.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Golazos from "Golazos"

transaction(name: String) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down
4 changes: 2 additions & 2 deletions laliga/transactions/admin/sets/lock_set.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Golazos from "Golazos"

transaction(setID: UInt64) {
// local variable for the admin reference
let admin: &Golazos.Admin
let admin: auth(Golazos.Operate) &Golazos.Admin

prepare(signer: auth(BorrowValue) &Account) {
// borrow a reference to the Admin resource
self.admin = signer.storage.borrow<&Golazos.Admin>(from: Golazos.AdminStoragePath)
self.admin = signer.storage.borrow<auth(Golazos.Operate) &Golazos.Admin>(from: Golazos.AdminStoragePath)
?? panic("Could not borrow a reference to the Golazos Admin capability")
}

Expand Down

0 comments on commit d16fcbf

Please sign in to comment.