Smart Contract
AFLAdmin
A.8f9231920da9af6d.AFLAdmin
1import AFLNFT from 0x8f9231920da9af6d
2import AFLBurnExchange from 0x8f9231920da9af6d
3import AFLBurnRegistry from 0x8f9231920da9af6d
4import NonFungibleToken from 0x1d7e57aa55817448
5import PackRestrictions from 0x8f9231920da9af6d
6
7access(all) contract AFLAdmin {
8
9 // Admin
10 // the admin resource is defined so that only the admin account
11 // can have this resource. It possesses the ability to open packs
12 // given a user's Pack Collection and Card Collection reference.
13 // It can also create a new pack type and mint Packs.
14 //
15 access(all) resource Admin {
16
17 access(all) fun createTemplate(maxSupply:UInt64, immutableData:{String: AnyStruct}): UInt64 {
18 return AFLNFT.createTemplate(maxSupply:maxSupply, immutableData:immutableData)
19 }
20
21 access(all) fun updateImmutableData(templateID:UInt64, immutableData:{String: AnyStruct}){
22 let templateRef: &AFLNFT.Template? = AFLNFT.borrowTemplate(id: templateID) // ) &AFLNFT.allTemplates[templateID]
23 templateRef?.updateImmutableData(immutableData) ?? panic("Template does not exist")
24 }
25
26 access(all) fun updateMaxSupply(templateId: UInt64, maxSupply: UInt64){
27 let templateRef: &AFLNFT.Template? = AFLNFT.borrowTemplate(id: templateId)
28 templateRef?.updateMaxSupply(maxSupply) ?? panic("Template does not exist")
29 }
30
31 access(all) fun addRestrictedPack(id: UInt64) {
32 PackRestrictions.addPackId(id: id)
33 }
34
35 access(all) fun removeRestrictedPack(id: UInt64) {
36 PackRestrictions.removePackId(id: id)
37 }
38
39 access(all) fun openPack(templateInfo: {String: UInt64}, account: Address){
40 AFLNFT.mintNFT(templateInfo:templateInfo, account:account)
41 }
42
43 access(all) fun mintNFT(templateInfo: {String: UInt64}): @{NonFungibleToken.NFT} {
44 return <- AFLNFT.mintAndReturnNFT(templateInfo:templateInfo)
45 }
46
47 access(all) fun addTokenForExchange(nftId: UInt64, token: @{NonFungibleToken.NFT}) {
48 AFLBurnExchange.addTokenForExchange(nftId: nftId, token: <- token)
49 }
50
51 access(all) fun withdrawTokenFromBurnExchange(nftId: UInt64): @{NonFungibleToken.NFT} {
52 return <- AFLBurnExchange.withdrawToken(nftId: nftId)
53 }
54
55 access(all) fun registerMultipleBurns(templateId: UInt64, count: UInt64) {
56 AFLBurnRegistry.burnMultiple(templateId: templateId, count: count)
57 }
58
59 access(all) fun setTotalBurns(templateId: UInt64, count: UInt64) {
60 AFLBurnRegistry.setTotalBurns(templateId: templateId, total: count)
61 }
62
63 // createAdmin
64 // only an admin can ever create
65 // a new Admin resource
66 //
67 access(all) fun createAdmin(): @Admin {
68 return <- create Admin()
69 }
70
71 init() {
72
73 }
74 }
75
76 init() {
77 self.account.storage.save(<- create Admin(), to: /storage/AFLAdmin)
78 }
79}