Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastbreak(cadence): upgrade #272

Merged
merged 11 commits into from
Jan 15, 2025
Merged
21 changes: 19 additions & 2 deletions contracts/FastBreakV1.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -417,13 +418,21 @@ access(all) contract FastBreakV1: NonFungibleToken {
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 hasMarketV1 = marketV1CollectionRef != nil && marketV1CollectionRef!.borrowMoment(id: flowId) != nil
if !hasMarketPlaceV3 && !hasMarketV1{
panic("Top shot not owned in any collection with flowId: ".concat(flowId.toString()))
}
}
}

let fastBreakGame = (&FastBreakV1.fastBreakGameByID[fastBreakGameID] as &FastBreakV1.FastBreakGame?)
Expand Down Expand Up @@ -487,13 +496,21 @@ access(all) contract FastBreakV1: NonFungibleToken {
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 hasMarketV1 = marketV1CollectionRef != nil && marketV1CollectionRef!.borrowMoment(id: flowId) != nil
if !hasMarketPlaceV3 && !hasMarketV1{
panic("Top shot not owned in any collection with flowId: ".concat(flowId.toString()))
}
}
}

let fastBreakGame = (&FastBreakV1.fastBreakGameByID[fastBreakGameID] as &FastBreakV1.FastBreakGame?)
Expand Down
Loading
Loading