Smart Contract

MFLAdmin

A.8ebcbfd516b1da27.MFLAdmin

Valid From

116,806,162

Deployed

1w ago
Feb 19, 2026, 09:40:23 PM UTC

Dependents

23 imports
1/**
2  This contract contains the MFL Admin logic.The idea is that any account can create an adminProxy,
3  but only an AdminRoot in possession of Claims can share them with that admin proxy (using private capabilities).
4**/
5
6access(all)
7contract MFLAdmin {
8
9	access(all)
10	entitlement AdminProxyAction
11
12	access(all)
13	entitlement AdminRootAction
14
15	// Events
16	access(all)
17	event ContractInitialized()
18
19	access(all)
20	event AdminRootCreated(by: Address?)
21
22	// Named Paths
23	access(all)
24	let AdminRootStoragePath: StoragePath
25
26	access(all)
27	let AdminProxyStoragePath: StoragePath
28
29	access(all)
30	let AdminProxyPublicPath: PublicPath
31
32	// MFL Royalty Address
33	access(all)
34	view fun royaltyAddress(): Address {
35		return 0x15e71a9f7fe7d53d
36	}
37
38	access(all)
39	view fun imageHostUrl(): String {
40		return "https://d13e14gtps4iwl.cloudfront.net"
41	}
42
43	// Deprecated: Only here for backward compatibility.
44	access(all)
45	resource interface AdminProxyPublic {}
46
47	access(all)
48	resource AdminProxy: AdminProxyPublic {
49
50		// Dictionary of all Claims Capabilities stored in an AdminProxy
51		access(self)
52		let claimsCapabilities: {String: Capability}
53
54		access(contract)
55		fun setClaimCapability(name: String, capability: Capability) {
56			self.claimsCapabilities[name] = capability
57		}
58
59		access(AdminProxyAction)
60		view fun getClaimCapability(name: String): Capability? {
61			return self.claimsCapabilities[name]
62		}
63
64		init() {
65			self.claimsCapabilities = {}
66		}
67	}
68
69	// Anyone can create an AdminProxy, but can't do anything without Claims capabilities,
70	// and only an AdminRoot can provide that.
71	access(all)
72	fun createAdminProxy(): @AdminProxy {
73		return <-create AdminProxy()
74	}
75
76	// Resource that an admin owns to be able to create new AdminRoot or to set Claims
77	access(all)
78	resource AdminRoot {
79
80		// Create a new AdminRoot resource and returns it
81		// Only if really needed ! One AdminRoot should be enough for all the logic in MFL
82		access(AdminRootAction)
83		fun createNewAdminRoot(): @AdminRoot {
84			emit AdminRootCreated(by: self.owner?.address)
85			return <-create AdminRoot()
86		}
87
88		// Set a Claim capabability for a given AdminProxy
89		access(AdminRootAction)
90		fun setAdminProxyClaimCapability(
91			name: String,
92			adminProxyRef: &MFLAdmin.AdminProxy,
93			newCapability: Capability
94		) {
95			adminProxyRef.setClaimCapability(name: name, capability: newCapability)
96		}
97	}
98
99	init() {
100		// Set our named paths
101		self.AdminRootStoragePath = /storage/MFLAdminRoot
102		self.AdminProxyStoragePath = /storage/MFLAdminProxy
103		self.AdminProxyPublicPath = /public/MFLAdminProxy
104
105		// Create an AdminRoot resource and save it to storage
106		let adminRoot <- create AdminRoot()
107		self.account.storage.save(<-adminRoot, to: self.AdminRootStoragePath)
108		emit ContractInitialized()
109	}
110}
111