Smart Contract

PackRestrictions

A.8f9231920da9af6d.PackRestrictions

Deployed

1d ago
Feb 26, 2026, 10:18:21 PM UTC

Dependents

0 imports
1access(all) contract PackRestrictions {
2    access(all) let restrictedIds: [UInt64]
3
4    access(all) event PackIdAdded(id: UInt64)
5    access(all) event PackIdRemoved(id: UInt64)
6
7    access(all) view fun getAllRestrictedIds(): [UInt64] {
8        return PackRestrictions.restrictedIds
9    }
10
11    access(all) view fun isRestricted(id: UInt64): Bool {
12        return PackRestrictions.restrictedIds.contains(id)
13    }
14
15    access(all) view fun accessCheck(id: UInt64) {
16        assert(!PackRestrictions.restrictedIds.contains(id), message: "Pack opening is restricted")
17    }
18
19    access(account) fun addPackId(id: UInt64) {
20        pre {
21            !PackRestrictions.restrictedIds.contains(id): "Pack id already restricted"
22        }
23        PackRestrictions.restrictedIds.append(id)
24        emit PackIdAdded(id: id)
25    }
26
27    access(account) fun removePackId(id: UInt64) {
28        pre {
29            PackRestrictions.restrictedIds.contains(id): "Pack id not restricted"
30        }
31        let index: Int? = PackRestrictions.restrictedIds.firstIndex(of: id)
32        if index != nil {
33            PackRestrictions.restrictedIds.remove(at: index!)
34            emit PackIdRemoved(id: id)
35        }
36    }
37
38    init() {
39        self.restrictedIds = [] 
40    }
41}