Smart Contract
MarketplaceBlacklist
A.88dd257fcf26d3cc.MarketplaceBlacklist
1pub contract MarketplaceBlacklist {
2
3 // listingId : nftId
4 pub let blacklist: {UInt64: UInt64}
5
6 pub event MarketplaceBlacklistAdd(listingId: UInt64, nftId: UInt64)
7
8 pub event MarketplaceBlacklistRemove(listingId: UInt64, nftId: UInt64)
9
10 init () {
11 self.blacklist = {}
12 }
13
14 pub fun exist(listingId: UInt64): Bool {
15 return self.blacklist.containsKey(listingId)
16 }
17
18 pub fun add(listingId: UInt64, nftId: UInt64) {
19 self.blacklist[listingId] = nftId
20 emit MarketplaceBlacklistAdd(listingId: listingId, nftId: nftId)
21 }
22
23 pub fun remove(listingId: UInt64) {
24 pre {
25 self.blacklist[listingId] != nil: "listingId not exist"
26 }
27 let nftId = self.blacklist.remove(key: listingId)
28 if let unwrappedNftId = nftId {
29 emit MarketplaceBlacklistRemove(listingId: listingId, nftId: unwrappedNftId)
30 }
31 assert(nftId != nil, message: "Not been removed successfully!")
32 }
33
34}
35