Skip to content

Commit

Permalink
fastbreak(cadence): upgrade
Browse files Browse the repository at this point in the history
* Revert.
* Add grace period.
  • Loading branch information
chumeston committed Dec 5, 2024
1 parent 380af7d commit ef916ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contracts/FastBreakV1.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,20 @@ access(all) contract FastBreakV1: NonFungibleToken {
/// Submit a Fast Break
///
access(contract) fun submitFastBreak(submission: FastBreakV1.FastBreakSubmission) {
pre {
FastBreakV1.isValidSubmission(submissionDeadline: self.submissionDeadline) : "Submission missed deadline"
}

self.submissions[submission.playerId] = submission
}

/// Update a Fast Break with new topshot moments
///
access(contract) fun updateFastBreakTopshots(playerId: UInt64, topshotMoments: [UInt64]) {
pre {
FastBreakV1.isValidSubmission(submissionDeadline: self.submissionDeadline) : "Submission update missed deadline"
}

let submission = &self.submissions[playerId] as &FastBreakV1.FastBreakSubmission?
?? panic("Could not find submission for playerId: ".concat(playerId.toString()))

Expand Down Expand Up @@ -285,6 +293,12 @@ access(all) contract FastBreakV1: NonFungibleToken {
}
}

/// Validate Fast Break Submission
///
access(all) view fun isValidSubmission(submissionDeadline: UInt64): Bool {
return submissionDeadline > UInt64(getCurrentBlock().timestamp) + 60
}

/// Get a Fast Break Game by Id
///
access(all) view fun getFastBreakGame(id: String): FastBreakV1.FastBreakGame? {
Expand Down

0 comments on commit ef916ff

Please sign in to comment.