Smart Contract
ICryptoys
A.ca63ce22f0d6bdba.ICryptoys
1import NonFungibleToken from 0x1d7e57aa55817448
2
3
4access(all)
5contract interface ICryptoys{
6
7 access(all)
8 struct interface Royalty{
9 access(all)
10 let name: String
11
12 access(all)
13 let address: Address
14
15 access(all)
16 let fee: UFix64
17 }
18
19 access(all)
20 struct interface Display{
21 access(all)
22 let image: String
23
24 access(all)
25 let video: String
26 }
27 access(all)
28 resource interface INFT{
29 access(all)
30 let id: UInt64
31
32 access(account)
33 let metadata:{ String: String}
34
35 access(account)
36 let royalties: [String]
37
38 access(account)
39 let bucket: @{String:{ UInt64:{ INFT}}}
40
41 access(all)
42 fun getMetadata():{ String: String}
43
44 access(account)
45 fun withdrawBucketItem(_ key: String, _ itemUuid: UInt64): @{ICryptoys.INFT}{
46 pre{
47 self.owner != nil:
48 "withdrawBucketItem() failed: nft resource must be in a collection"
49 }
50 post{
51 result == nil || result.uuid == itemUuid:
52 "Cannot withdraw bucket Cryptoy reference: The ID of the returned reference is incorrect"
53 }
54 }
55
56 access(all)
57 fun addToBucket(_ key: String, _ nft: @{INFT}){
58 pre{
59 self.owner != nil:
60 "addToBucket() failed: nft resource must be in a collection"
61 }
62 }
63
64 access(all)
65 fun getBucketKeys(): [String]
66
67 access(all)
68 fun getBucketResourceIdsByKey(_ key: String): [UInt64]
69
70 access(all)
71 fun borrowBucketResourcesByKey(_ key: String): &{UInt64:{ ICryptoys.INFT}}?
72
73 access(all)
74 fun borrowBucket(): &{String:{ UInt64:{ ICryptoys.INFT}}}
75
76 access(all)
77 fun borrowBucketItem(_ key: String, _ itemUuid: UInt64): &{INFT}{
78 post{
79 result == nil || result.uuid == itemUuid:
80 "Cannot borrow bucket Cryptoy reference: The ID of the returned reference is incorrect"
81 }
82 }
83
84 access(all)
85 fun resolveView(_ view: Type): AnyStruct?
86 }
87
88 access(all)
89 resource interface CryptoysCollectionPublic{
90 access(all)
91 fun borrowCryptoy(id: UInt64): &{INFT}{
92 // If the result isn't nil, the id of the returned reference
93 // should be the same as the argument to the function
94 post{
95 result == nil || result.id == id:
96 "Cannot borrow Cryptoy reference: The ID of the returned reference is incorrect"
97 }
98 }
99
100 access(all)
101 fun borrowBucketItem(_ id: UInt64, _ key: String, _ itemUuid: UInt64): &{ICryptoys.INFT}{
102 post{
103 result == nil || result.uuid == itemUuid:
104 "Cannot borrow bucket Cryptoy reference: The ID of the returned reference is incorrect"
105 }
106 }
107 }
108
109 access(all)
110 resource interface Collection{
111 access(all)
112 fun withdrawBucketItem(parentId: UInt64, key: String, itemUuid: UInt64): @{ICryptoys.INFT}
113 }
114}
115