Skip to content

Commit

Permalink
Deprecate MomentCollectionPublic
Browse files Browse the repository at this point in the history
  • Loading branch information
fkenji committed Aug 8, 2024
1 parent e412417 commit 767238a
Show file tree
Hide file tree
Showing 29 changed files with 222 additions and 228 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ prepare(acct: AuthAccount) {
execute {
// Set Top Shot NFT Owner collection ref
let owner = getAccount(0x179b6b1cb6755e31)
let collectionRef = owner.getCapability(/public/MomentCollection).borrow<&{TopShot.MomentCollectionPublic}>()
let collectionRef = owner.getCapability(/public/MomentCollection).borrow<&TopShot.Collection>()
?? panic("Could not reference owner's moment collection")
let nftRef = collectionRef.borrowNFT(id: 1)
Expand Down
12 changes: 1 addition & 11 deletions contracts/TopShot.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,17 +1040,7 @@ access(all) contract TopShot: NonFungibleToken {
// to allow others to deposit Moments into their Collection. It also allows for reading
// the IDs of Moments in the Collection.
/// Deprecated: This is no longer used for defining access control anymore.
access(all) resource interface MomentCollectionPublic : NonFungibleToken.CollectionPublic {
access(all) fun batchDeposit(tokens: @{NonFungibleToken.Collection})
access(all) fun borrowMoment(id: UInt64): &TopShot.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 reference: The ID of the returned reference is incorrect"
}
}
}
access(all) resource interface MomentCollectionPublic : NonFungibleToken.CollectionPublic {}

// Collection is a resource that every user who owns NFTs
// will store in their account to manage their NFTS
Expand Down
34 changes: 18 additions & 16 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

352 changes: 177 additions & 175 deletions lib/go/templates/internal/assets/assets.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion transactions/admin/batch_mint_moment.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ transaction(setID: UInt32, playID: UInt32, quantity: UInt64, recipientAddr: Addr
let recipient = getAccount(recipientAddr)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's collection")

// deposit the NFT in the receivers collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/admin/batch_mint_moment_with_subedition.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ transaction(setID: UInt32, playID: UInt32, quantity: UInt64, subeditionID: UInt3
let recipient = getAccount(recipientAddr)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's collection")

// deposit the NFT in the receivers collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/admin/fulfill_pack.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ transaction(recipientAddr: Address, momentIDs: [UInt64]) {
let recipient = getAccount(recipientAddr)

// borrow a reference to the recipient's moment collection
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's collection")


Expand Down
2 changes: 1 addition & 1 deletion transactions/admin/mark_moment_unlockable.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ transaction(ownerAddress: Address, id: UInt64) {
// Set Top Shot NFT Owner collection ref
let owner = getAccount(ownerAddress)

let collectionRef = owner.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = owner.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not reference owner's moment collection")

// borrow the nft reference
Expand Down
2 changes: 1 addition & 1 deletion transactions/admin/mint_moment.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ transaction(setID: UInt32, playID: UInt32, recipientAddr: Address) {

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's moment collection")

// deposit the NFT in the receivers collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/admin/mint_moment_with_subedition.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ transaction(setID: UInt32, playID: UInt32, subeditionID: UInt32, recipientAddr:
let recipient = getAccount(recipientAddr)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's moment collection")

// deposit the NFT in the receivers collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_collection_ids.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ access(all) fun main(account: Address): [UInt64] {

let acct = getAccount(account)

let collectionRef = acct.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let collectionRef = acct.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

log(collectionRef.getIDs())

Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_id_in_Collection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): Bool {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

return collectionRef.borrowNFT(id) != nil
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_metadata.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ access(all) fun main(account: Address, id: UInt64): {String: String} {

// get the public capability for the owner's moment collection
// and borrow a reference to it
let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

// Borrow a reference to the specified moment
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_metadata_field.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, momentID: UInt64, fieldToSearch: String): String {

// borrow a public reference to the owner's moment collection
let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

// borrow a reference to the specified moment in the collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_isLocked.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TopShotLocking from 0xTOPSHOTLOCKINGADDRESS
access(all) fun main(account: Address, id: UInt64): Bool {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let nftRef = collectionRef.borrowNFT(id)!
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_lockExpiry.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TopShotLocking from 0xTOPSHOTLOCKINGADDRESS
access(all) fun main(account: Address, id: UInt64): UFix64 {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let nftRef = collectionRef.borrowNFT(id)!
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_playID.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): UInt32 {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let token = collectionRef.borrowMoment(id: id)
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_serialNum.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): UInt32 {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let token = collectionRef.borrowMoment(id: id)
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_series.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): UInt32 {

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let token = collectionRef.borrowMoment(id: id)
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_setID.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): UInt32 {

// borrow a public reference to the owner's moment collection
let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

// borrow a reference to the specified moment in the collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/collections/get_moment_setName.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import TopShot from 0xTOPSHOTADDRESS
access(all) fun main(account: Address, id: UInt64): String {

// borrow a public reference to the owner's moment collection
let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

// borrow a reference to the specified moment in the collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ access(all) fun main(account: Address, setIDs: [UInt32], playIDs: [UInt32]): Boo
message: "set and play ID arrays have mismatched lengths"
)

let collectionRef = getAccount(account).capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let collectionRef = getAccount(account).capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Could not get public moment collection reference")

let momentIDs = collectionRef.getIDs()
Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/get_nft_metadata.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ access(all) struct NFT {
access(all) fun main(address: Address, id: UInt64): NFT {
let account = getAccount(address)

let collectionRef = account.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let collectionRef = account.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

let nft = collectionRef.borrowMoment(id: id)!

Expand Down
2 changes: 1 addition & 1 deletion transactions/scripts/get_topshot_metadata.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MetadataViews from 0xMETADATAVIEWSADDRESS
access(all) fun main(address: Address, id: UInt64): TopShot.TopShotMomentMetadataView {
let account = getAccount(address)

let collectionRef = account.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let collectionRef = account.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

let nft = collectionRef.borrowMoment(id: id)!

Expand Down
2 changes: 1 addition & 1 deletion transactions/shardedCollection/batch_from_sharded.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ transaction(recipient: Address, momentIDs: [UInt64]) {
let recipient = getAccount(recipient)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

// deposit the NFT in the receivers collection
receiverRef.batchDeposit(tokens: <-self.transferTokens)
Expand Down
2 changes: 1 addition & 1 deletion transactions/shardedCollection/transfer_from_sharded.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ transaction(recipient: Address, momentID: UInt64) {
let recipient = getAccount(recipient)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

// deposit the NFT in the receivers collection
receiverRef.deposit(token: <-self.transferToken)
Expand Down
2 changes: 1 addition & 1 deletion transactions/user/batch_transfer.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ transaction(recipientAddress: Address, momentIDs: [UInt64]) {
let recipient = getAccount(recipientAddress)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)
?? panic("Cannot borrow a reference to the recipient's collection")

// deposit the NFT in the receivers collection
Expand Down
2 changes: 1 addition & 1 deletion transactions/user/transfer_moment.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ transaction(recipient: Address, withdrawID: UInt64) {
let recipient = getAccount(recipient)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

// deposit the NFT in the receivers collection
receiverRef.deposit(token: <-self.transferToken)
Expand Down
2 changes: 1 addition & 1 deletion transactions/user/transfer_moment_v3_sale.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ transaction(recipient: Address, withdrawID: UInt64) {
let recipient = getAccount(recipient)

// get the Collection reference for the receiver
let receiverRef = recipient.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)!
let receiverRef = recipient.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection)!

// deposit the NFT in the receivers collection
receiverRef.deposit(token: <-self.transferToken)
Expand Down

0 comments on commit 767238a

Please sign in to comment.