Smart Contract
AthleteStudioMintCache
A.27ece19eff91bab0.AthleteStudioMintCache
1/// AthleteStudioMintCache is a utility contract to keep track of Athlete Studio editions
2/// that have been minted in order to prevent duplicate mints.
3///
4/// It should be deployed to the same account as the AthleteStudio contract.
5///
6pub contract AthleteStudioMintCache {
7
8 /// This dictionary indexes editions by their mint ID.
9 ///
10 /// It is populated at mint time and used to prevent duplicate mints.
11 /// The mint ID can be any unique string value,
12 /// for example the hash of the edition metadata.
13 ///
14 access(self) let editionsByMintID: {String: UInt64}
15
16 /// Get an edition ID by its mint ID.
17 ///
18 /// This function returns nil if the edition is not in this index.
19 ///
20 pub fun getEditionByMintID(mintID: String): UInt64? {
21 return AthleteStudioMintCache.editionsByMintID[mintID]
22 }
23
24 /// Insert an edition mint ID into the index.
25 ///
26 /// This function can only be called by other contracts deployed to this account.
27 /// It is intended to be called by the AthleteStudio contract when
28 /// creating new editions.
29 ///
30 access(account) fun insertEditionMintID(mintID: String, editionID: UInt64) {
31 AthleteStudioMintCache.editionsByMintID[mintID] = editionID
32 }
33
34 init() {
35 self.editionsByMintID = {}
36 }
37}
38