From 974bec8453032668c800c18159986d7f28d0f508 Mon Sep 17 00:00:00 2001 From: chumeston Date: Mon, 9 Dec 2024 17:35:26 -0600 Subject: [PATCH] fastbreak(cadence): upgrade * Check all collections. --- contracts/FastBreakV1.cdc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/contracts/FastBreakV1.cdc b/contracts/FastBreakV1.cdc index 489a053..5bd6483 100644 --- a/contracts/FastBreakV1.cdc +++ b/contracts/FastBreakV1.cdc @@ -13,6 +13,7 @@ import NonFungibleToken from 0xNFTADDRESS import TopShot from 0xTOPSHOTADDRESS import MetadataViews from 0xMETADATAVIEWSADDRESS +import TopShotMarketV3, Market from 0xMARKETV3ADDRESS /// Game & Oracle Contract for Fast Break V1 /// @@ -413,17 +414,25 @@ access(all) contract FastBreakV1: NonFungibleToken { FastBreakV1.accountPlayerMapping[ownerAddress] = self.id } - /// Validate Top Shots + /// Validate Top Shots let acct = getAccount(self.owner?.address!) let collectionRef = acct.capabilities.borrow<&TopShot.Collection>(/public/MomentCollection) ?? panic("Player does not have top shot collection") + let marketV3CollectionRef = acct.capabilities.borrow<&TopShotMarketV3.SaleCollection>(/public/topshotSalev3Collection) + let marketV1CollectionRef = acct.capabilities.borrow<&Market.SaleCollection>(/public/topshotSaleCollection) /// Must own Top Shots to play Fast Break /// more efficient to borrow ref than to loop /// for flowId in topShots { let topShotRef = collectionRef.borrowMoment(id: flowId) - ?? panic("Top shot not owned in collection with flowId: ".concat(flowId.toString())) + if topShotRef == nil { + let hasMarketPlaceV3 = marketV3CollectionRef != nil && marketV3CollectionRef.borrowMoment(id: flowId) != nil + let hasMartketV1 = marketV1CollectionRef != nil && marketV1CollectionRef.borrowMoment(id: flowId) + if !hasMarketPlaceV3 && !hasMartketV1{ + panic("does not own") + } + } } let fastBreakGame = (&FastBreakV1.fastBreakGameByID[fastBreakGameID] as &FastBreakV1.FastBreakGame?)