Smart Contract

Admin

A.7620acf6d7f2468a.Admin

Deployed

16h ago
Feb 28, 2026, 02:31:19 AM UTC

Dependents

0 imports
1import FungibleToken from 0xf233dcee88fe0abe
2import FUSD from 0x3c5959b568896393
3import NonFungibleToken from 0x1d7e57aa55817448
4import Debug from 0x7620acf6d7f2468a
5import Clock from 0x7620acf6d7f2468a
6import Bl0x from 0x7620acf6d7f2468a
7import Bl0xPack from 0x7620acf6d7f2468a
8import MetadataViews from 0x1d7e57aa55817448
9
10pub contract Admin {
11
12	//store the proxy for the admin
13	pub let AdminProxyPublicPath: PublicPath
14	pub let AdminProxyStoragePath: StoragePath
15	pub let AdminServerStoragePath: StoragePath
16	pub let AdminServerPrivatePath: PrivatePath
17
18
19	// This is just an empty resource to signal that you can control the admin, more logic can be added here or changed later if you want to
20	pub resource Server {
21
22	}
23
24	/// ===================================================================================
25	// Admin things
26	/// ===================================================================================
27
28	//Admin client to use for capability receiver pattern
29	pub fun createAdminProxyClient() : @AdminProxy {
30		return <- create AdminProxy()
31	}
32
33	//interface to use for capability receiver pattern
34	pub resource interface AdminProxyClient {
35		pub fun addCapability(_ cap: Capability<&Server>)
36	}
37
38
39	//admin proxy with capability receiver 
40	pub resource AdminProxy: AdminProxyClient {
41
42		access(self) var capability: Capability<&Server>?
43
44		pub fun addCapability(_ cap: Capability<&Server>) {
45			pre {
46				cap.check() : "Invalid server capablity"
47				self.capability == nil : "Server already set"
48			}
49			self.capability = cap
50		}
51
52
53		pub fun registerTrait(_ trait: Bl0x.Trait) {
54			pre {
55				self.capability != nil: "Cannot create Admin, capability is not set"
56			}
57			Bl0x.addTrait(trait)
58		}
59
60		pub fun mintBl0x( 
61			recipient: &{NonFungibleToken.Receiver}, 
62			serial:UInt64,
63			rootHash:String,
64			season:UInt64,
65			traits: {String: UInt64}
66		){
67
68			pre {
69				self.capability != nil: "Cannot create Admin, capability is not set"
70			}
71
72			Bl0x.mintNFT(recipient:recipient, 
73			serial:serial,
74			rootHash:rootHash,
75			season:season,
76			traits: traits)
77		}
78
79		pub fun advanceClock(_ time: UFix64) {
80			pre {
81				self.capability != nil: "Cannot create Admin, capability is not set"
82			}
83			Debug.enable(true)
84			Clock.enable()
85			Clock.tick(time)
86		}
87
88
89		pub fun debug(_ value: Bool) {
90			pre {
91				self.capability != nil: "Cannot create Admin, capability is not set"
92			}
93			Debug.enable(value)
94		}
95
96		pub fun registerPackMetadata(typeId:UInt64, metadata:Bl0xPack.Metadata) {
97			pre {
98				self.capability != nil: "Cannot create Admin, capability is not set"
99			}
100			Bl0xPack.registerMetadata(typeId: typeId, metadata: metadata)
101		}
102
103
104		pub fun batchMintPacks(typeId: UInt64, hashes:[String]) {
105			pre {
106				self.capability != nil: "Cannot create Admin, capability is not set"
107			}
108
109			let recipient=Admin.account.getCapability<&{NonFungibleToken.Receiver}>(Bl0xPack.CollectionPublicPath).borrow()!
110			for hash in  hashes {
111				Bl0xPack.mintNFT(recipient:recipient, typeId: typeId, hash: hash)
112			}
113		}
114
115		pub fun requeue(packId:UInt64) {
116				pre {
117				self.capability != nil: "Cannot create Admin, capability is not set"
118			}
119
120			let cap= Admin.account.borrow<&Bl0xPack.Collection>(from: Bl0xPack.DLQCollectionStoragePath)!
121			cap.requeue(packId: packId)
122		}
123
124		pub fun fulfill(packId: UInt64, rewardIds:[UInt64], salt:String) {
125			pre {
126				self.capability != nil: "Cannot create Admin, capability is not set"
127			}
128			Bl0xPack.fulfill(packId: packId, rewardIds: rewardIds, salt: salt)
129		}
130
131		//THis cap here could be the server really in this case
132		pub fun getProviderCap(): Capability<&{NonFungibleToken.Provider, MetadataViews.ResolverCollection}> {
133			pre {
134				self.capability != nil: "Cannot create Admin, capability is not set"
135			}
136			return Admin.account.getCapability<&{NonFungibleToken.Provider, MetadataViews.ResolverCollection}>(Bl0x.CollectionPrivatePath)	
137		}
138
139		pub fun addRoyaltycut(_ cutInfo: MetadataViews.Royalty) {
140			Bl0x.addRoyaltycut(cutInfo)
141		}
142
143		init() {
144			self.capability = nil
145		}
146
147	}
148
149	init() {
150
151		self.AdminProxyPublicPath= /public/bl0xAdminProxy
152		self.AdminProxyStoragePath=/storage/bl0xAdminProxy
153
154		//create a dummy server for now, if we have a resource later we want to use instead of server we can change to that
155		self.AdminServerPrivatePath=/private/bl0xAdminServer
156		self.AdminServerStoragePath=/storage/bl0xAdminServer
157		self.account.save(<- create Server(), to: self.AdminServerStoragePath)
158		self.account.link<&Server>( self.AdminServerPrivatePath, target: self.AdminServerStoragePath)
159	}
160
161}
162