Smart Contract
KeeprAdmin
A.5eb12ad3d5a99945.KeeprAdmin
1import KeeprNFTStorefront from 0x5eb12ad3d5a99945
2
3access(all) contract KeeprAdmin {
4
5 access(all) let KeeprAdminStoragePath: StoragePath
6 access(all) let KeeprAdminPublicPath: PublicPath
7
8 access(all) event InitAdmin()
9 access(all) event AddedCapability(owner: Address)
10
11 access(all) resource interface AdminStorefrontManagerPublic {
12 access(all) fun addCapability(_ cap: Capability<auth(KeeprNFTStorefront.UpdateListing) &KeeprNFTStorefront.Storefront>, owner: Address)
13 }
14
15 access(all) resource AdminStorefront {
16 access(all) let account: Address
17 access(all) let storefrontCapability: Capability<auth(KeeprNFTStorefront.UpdateListing) &KeeprNFTStorefront.Storefront>
18
19 init(account: Address, storefrontCapability: Capability<auth(KeeprNFTStorefront.UpdateListing) &KeeprNFTStorefront.Storefront>) {
20 self.account = account
21 self.storefrontCapability = storefrontCapability
22 }
23 }
24
25 access(all) resource AdminStorefrontManager: AdminStorefrontManagerPublic {
26 access(self) var storefronts: @{Address: AdminStorefront}
27
28 init() {
29 self.storefronts <- {}
30
31 emit InitAdmin()
32 }
33
34 access(all) fun addCapability(_ cap: Capability<auth(KeeprNFTStorefront.UpdateListing) &KeeprNFTStorefront.Storefront>, owner: Address) {
35 let storefront <- create AdminStorefront(account: owner, storefrontCapability: cap)
36 let oldStorefront <- self.storefronts[owner] <- storefront
37 destroy oldStorefront
38 }
39
40 access(all) fun getCapability(owner: Address): &AdminStorefront? {
41 return &self.storefronts[owner]
42 }
43 }
44
45 access(all) fun createStorefrontManager(): @AdminStorefrontManager {
46 return <-create AdminStorefrontManager()
47 }
48
49 init() {
50 self.KeeprAdminStoragePath = /storage/keepradmin002
51 self.KeeprAdminPublicPath = /public/keepradmin002
52 }
53
54}