@flowtyio/flow-contracts 0.1.0-beta.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/contracts/FungibleTokenSwitchboard.cdc +360 -0
- package/contracts/MetadataViews.cdc +79 -6
- package/contracts/NonFungibleToken.cdc +17 -10
- package/contracts/capability-cache/CapabilityCache.cdc +97 -0
- package/contracts/dapper/TopShot.cdc +323 -259
- package/contracts/dapper/TopShotLocking.cdc +41 -15
- package/contracts/dapper/offers/DapperOffersV2.cdc +46 -43
- package/contracts/dapper/offers/OffersV2.cdc +40 -56
- package/contracts/dapper/offers/Resolver.cdc +20 -13
- package/contracts/emerald-city/FLOAT.cdc +259 -254
- package/contracts/evm/CrossVMNFT.cdc +50 -0
- package/contracts/evm/EVM.cdc +851 -0
- package/contracts/evm/FlowEVMBridgeConfig.cdc +454 -0
- package/contracts/evm/FlowEVMBridgeHandlerInterfaces.cdc +163 -0
- package/contracts/evm/FlowEVMBridgeHandlers.cdc +230 -0
- package/contracts/evm/FlowEVMBridgeUtils.cdc +1303 -0
- package/contracts/evm/IBridgePermissions.cdc +19 -0
- package/contracts/evm/ICrossVM.cdc +12 -0
- package/contracts/evm/ICrossVMAsset.cdc +19 -0
- package/contracts/evm/Serialize.cdc +141 -0
- package/contracts/evm/SerializeMetadata.cdc +221 -0
- package/contracts/example/ExampleNFT.cdc +2 -2
- package/contracts/find/FindViews.cdc +357 -353
- package/contracts/flow-utils/ScopedFTProviders.cdc +5 -2
- package/contracts/flow-utils/ScopedNFTProviders.cdc +6 -2
- package/contracts/flowty-drops/ContractManager.cdc +73 -0
- package/contracts/flowty-drops/DropFactory.cdc +75 -0
- package/contracts/flowty-drops/DropTypes.cdc +282 -0
- package/contracts/flowty-drops/FlowtyActiveCheckers.cdc +113 -0
- package/contracts/flowty-drops/FlowtyAddressVerifiers.cdc +64 -0
- package/contracts/flowty-drops/FlowtyDrops.cdc +461 -0
- package/contracts/flowty-drops/FlowtyPricers.cdc +48 -0
- package/contracts/flowty-drops/initializers/ContractBorrower.cdc +14 -0
- package/contracts/flowty-drops/initializers/ContractInitializer.cdc +7 -0
- package/contracts/flowty-drops/initializers/OpenEditionInitializer.cdc +57 -0
- package/contracts/flowty-drops/nft/BaseCollection.cdc +97 -0
- package/contracts/flowty-drops/nft/BaseNFT.cdc +107 -0
- package/contracts/flowty-drops/nft/ContractFactory.cdc +13 -0
- package/contracts/flowty-drops/nft/ContractFactoryTemplate.cdc +48 -0
- package/contracts/flowty-drops/nft/NFTMetadata.cdc +140 -0
- package/contracts/flowty-drops/nft/OpenEditionNFT.cdc +42 -0
- package/contracts/flowty-drops/nft/OpenEditionTemplate.cdc +54 -0
- package/contracts/flowty-drops/nft/UniversalCollection.cdc +29 -0
- package/contracts/fungible-token-router/FungibleTokenRouter.cdc +103 -0
- package/contracts/hybrid-custody/CapabilityDelegator.cdc +28 -26
- package/contracts/hybrid-custody/CapabilityFactory.cdc +20 -18
- package/contracts/hybrid-custody/CapabilityFilter.cdc +41 -24
- package/contracts/hybrid-custody/HybridCustody.cdc +303 -242
- package/contracts/hybrid-custody/factories/FTAllFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/FTBalanceFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/FTProviderFactory.cdc +17 -5
- package/contracts/hybrid-custody/factories/FTReceiverBalanceFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/FTReceiverFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/FTVaultFactory.cdc +46 -0
- package/contracts/hybrid-custody/factories/NFTCollectionFactory.cdc +45 -0
- package/contracts/hybrid-custody/factories/NFTCollectionPublicFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/NFTProviderAndCollectionFactory.cdc +22 -0
- package/contracts/hybrid-custody/factories/NFTProviderFactory.cdc +16 -4
- package/contracts/lost-and-found/LostAndFound.cdc +21 -17
- package/contracts/tokens/USDCFlow.cdc +232 -0
- package/flow.json +278 -7
- package/package.json +1 -1
- package/contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc +0 -10
|
@@ -1,67 +1,64 @@
|
|
|
1
1
|
import "NonFungibleToken"
|
|
2
2
|
import "FungibleToken"
|
|
3
3
|
import "MetadataViews"
|
|
4
|
+
import "ViewResolver"
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
pub struct SharedMedia : MetadataViews.File {
|
|
24
|
-
pub let mediaType: String
|
|
25
|
-
pub let pointer: ViewReadPointer
|
|
26
|
-
pub let protocol: String
|
|
27
|
-
|
|
28
|
-
init(pointer: ViewReadPointer, mediaType: String) {
|
|
29
|
-
self.pointer=pointer
|
|
30
|
-
self.mediaType=mediaType
|
|
31
|
-
self.protocol="shared"
|
|
32
|
-
|
|
33
|
-
if pointer.resolveView(Type<OnChainFile>()) == nil {
|
|
34
|
-
panic("Cannot create shared media if the pointer does not contain StringMedia")
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pub fun uri(): String {
|
|
39
|
-
let media = self.pointer.resolveView(Type<OnChainFile>())
|
|
40
|
-
if media == nil {
|
|
41
|
-
return ""
|
|
42
|
-
}
|
|
43
|
-
return (media as! OnChainFile).uri()
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
pub resource interface VaultViews {
|
|
48
|
-
pub var balance: UFix64
|
|
49
|
-
|
|
50
|
-
pub fun getViews() : [Type]
|
|
51
|
-
pub fun resolveView(_ view: Type): AnyStruct?
|
|
6
|
+
access(all) contract FindViews {
|
|
7
|
+
|
|
8
|
+
access(all) struct OnChainFile : MetadataViews.File{
|
|
9
|
+
access(all) let content: String
|
|
10
|
+
access(all) let mediaType: String
|
|
11
|
+
access(all) let protocol: String
|
|
12
|
+
|
|
13
|
+
init(content:String, mediaType: String) {
|
|
14
|
+
self.content=content
|
|
15
|
+
self.protocol="onChain"
|
|
16
|
+
self.mediaType=mediaType
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
access(all) view fun uri(): String {
|
|
20
|
+
return "data:".concat(self.mediaType).concat(",").concat(self.content)
|
|
21
|
+
}
|
|
52
22
|
}
|
|
53
23
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
24
|
+
access(all) struct SharedMedia : MetadataViews.File {
|
|
25
|
+
access(all) let mediaType: String
|
|
26
|
+
access(all) let pointer: ViewReadPointer
|
|
27
|
+
access(all) let protocol: String
|
|
28
|
+
|
|
29
|
+
init(pointer: ViewReadPointer, mediaType: String) {
|
|
30
|
+
self.pointer=pointer
|
|
31
|
+
self.mediaType=mediaType
|
|
32
|
+
self.protocol="shared"
|
|
33
|
+
|
|
34
|
+
if pointer.resolveView(Type<OnChainFile>()) == nil {
|
|
35
|
+
panic("Cannot create shared media if the pointer does not contain StringMedia")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// todo: this is not working so we have a workaround in the contract
|
|
40
|
+
access(all) view fun uri(): String {
|
|
41
|
+
return "data:".concat(self.mediaType).concat(",").concat(self.protocol)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
access(all) resource interface VaultViews {
|
|
46
|
+
access(all) var balance: UFix64
|
|
47
|
+
access(all) view fun getViews() : [Type]
|
|
48
|
+
access(all) fun resolveView(_ view: Type): AnyStruct?
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
access(all) struct FTVaultData {
|
|
52
|
+
access(all) let tokenAlias: String
|
|
53
|
+
access(all) let storagePath: StoragePath
|
|
54
|
+
access(all) let receiverPath: PublicPath
|
|
55
|
+
access(all) let balancePath: PublicPath
|
|
56
|
+
access(all) let providerPath: PrivatePath
|
|
57
|
+
access(all) let vaultType: Type
|
|
58
|
+
access(all) let receiverType: Type
|
|
59
|
+
access(all) let balanceType: Type
|
|
60
|
+
access(all) let providerType: Type
|
|
61
|
+
access(all) let createEmptyVault: (fun(): @{FungibleToken.Vault})
|
|
65
62
|
|
|
66
63
|
init(
|
|
67
64
|
tokenAlias: String,
|
|
@@ -73,11 +70,11 @@ pub contract FindViews {
|
|
|
73
70
|
receiverType: Type,
|
|
74
71
|
balanceType: Type,
|
|
75
72
|
providerType: Type,
|
|
76
|
-
createEmptyVault: ((): @FungibleToken.Vault)
|
|
73
|
+
createEmptyVault: (fun(): @{FungibleToken.Vault})
|
|
77
74
|
) {
|
|
78
75
|
pre {
|
|
79
76
|
receiverType.isSubtype(of: Type<&{FungibleToken.Receiver}>()): "Receiver type must include FungibleToken.Receiver interfaces."
|
|
80
|
-
balanceType.isSubtype(of: Type<&{FungibleToken.
|
|
77
|
+
balanceType.isSubtype(of: Type<&{FungibleToken.Vault}>()): "Balance type must include FungibleToken.Vault interfaces."
|
|
81
78
|
providerType.isSubtype(of: Type<&{FungibleToken.Provider}>()): "Provider type must include FungibleToken.Provider interface."
|
|
82
79
|
}
|
|
83
80
|
self.tokenAlias=tokenAlias
|
|
@@ -93,300 +90,307 @@ pub contract FindViews {
|
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
93
|
+
// This is an example taken from Versus
|
|
94
|
+
access(all) struct CreativeWork {
|
|
95
|
+
access(all) let artist: String
|
|
96
|
+
access(all) let name: String
|
|
97
|
+
access(all) let description: String
|
|
98
|
+
access(all) let type: String
|
|
99
|
+
|
|
100
|
+
init(artist: String, name: String, description: String, type: String) {
|
|
101
|
+
self.artist=artist
|
|
102
|
+
self.name=name
|
|
103
|
+
self.description=description
|
|
104
|
+
self.type=type
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// A basic pointer that can resolve data and get owner/id/uuid and gype
|
|
109
|
+
access(all) struct interface Pointer {
|
|
110
|
+
access(all) let id: UInt64
|
|
111
|
+
access(all) fun resolveView(_ type: Type) : AnyStruct?
|
|
112
|
+
access(all) fun getUUID() :UInt64
|
|
113
|
+
access(all) fun getViews() : [Type]
|
|
114
|
+
access(all) fun owner() : Address
|
|
115
|
+
access(all) fun valid() : Bool
|
|
116
|
+
access(all) fun getItemType() : Type
|
|
117
|
+
access(all) fun getViewResolver() : &{ViewResolver.Resolver}
|
|
118
|
+
|
|
119
|
+
//There are just convenience functions for shared views in the standard
|
|
120
|
+
access(all) fun getRoyalty() : MetadataViews.Royalties
|
|
121
|
+
access(all) fun getTotalRoyaltiesCut() : UFix64
|
|
122
|
+
|
|
123
|
+
//Requred views
|
|
124
|
+
access(all) fun getDisplay() : MetadataViews.Display
|
|
125
|
+
access(all) fun getNFTCollectionData() : MetadataViews.NFTCollectionData
|
|
126
|
+
|
|
127
|
+
access(all) fun checkSoulBound() : Bool
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//An interface to say that this pointer can withdraw
|
|
132
|
+
access(all) struct interface AuthPointer {
|
|
133
|
+
access(all) fun withdraw() : @AnyResource
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
access(all) struct ViewReadPointer : Pointer {
|
|
137
|
+
access(self) let cap: Capability<&{ViewResolver.ResolverCollection}>
|
|
138
|
+
access(all) let id: UInt64
|
|
139
|
+
access(all) let uuid: UInt64
|
|
140
|
+
access(all) let itemType: Type
|
|
141
|
+
|
|
142
|
+
init(cap: Capability<&{ViewResolver.ResolverCollection}>, id: UInt64) {
|
|
143
|
+
self.cap=cap
|
|
144
|
+
self.id=id
|
|
145
|
+
|
|
146
|
+
if !self.cap.check() {
|
|
147
|
+
panic("The capability is not valid.")
|
|
148
|
+
}
|
|
149
|
+
let viewResolver=self.cap.borrow()!.borrowViewResolver(id: self.id)!
|
|
150
|
+
let display = MetadataViews.getDisplay(viewResolver) ?? panic("MetadataViews Display View is not implemented on this NFT.")
|
|
151
|
+
let nftCollectionData = MetadataViews.getNFTCollectionData(viewResolver) ?? panic("MetadataViews NFTCollectionData View is not implemented on this NFT.")
|
|
152
|
+
self.uuid=viewResolver.uuid
|
|
153
|
+
self.itemType=viewResolver.getType()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
access(all) fun resolveView(_ type: Type) : AnyStruct? {
|
|
157
|
+
return self.getViewResolver().resolveView(type)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
access(all) fun getUUID() :UInt64{
|
|
161
|
+
return self.uuid
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
access(all) fun getViews() : [Type]{
|
|
165
|
+
return self.getViewResolver().getViews()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
access(all) fun owner() : Address {
|
|
169
|
+
return self.cap.address
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
access(all) fun getTotalRoyaltiesCut() :UFix64 {
|
|
173
|
+
var total=0.0
|
|
174
|
+
for royalty in self.getRoyalty().getRoyalties() {
|
|
175
|
+
total = total + royalty.cut
|
|
176
|
+
}
|
|
177
|
+
return total
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
access(all) fun getRoyalty() : MetadataViews.Royalties {
|
|
181
|
+
if let v = MetadataViews.getRoyalties(self.getViewResolver()) {
|
|
182
|
+
return v
|
|
183
|
+
}
|
|
184
|
+
return MetadataViews.Royalties([])
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
access(all) fun valid() : Bool {
|
|
188
|
+
if !self.cap.check() || self.cap.borrow()!.borrowViewResolver(id: self.id) == nil {
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
return true
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
access(all) fun getItemType() : Type {
|
|
195
|
+
return self.itemType
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
access(all) fun getViewResolver() : &{ViewResolver.Resolver} {
|
|
199
|
+
let nft=self.cap.borrow()!.borrowViewResolver(id: self.id) ?? panic("The capability of view pointer is not linked.")
|
|
200
|
+
return nft
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
access(all) fun getDisplay() : MetadataViews.Display {
|
|
205
|
+
if let v = MetadataViews.getDisplay(self.getViewResolver()) {
|
|
206
|
+
return v
|
|
207
|
+
}
|
|
208
|
+
panic("MetadataViews Display View is not implemented on this NFT.")
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
access(all) fun getNFTCollectionData() : MetadataViews.NFTCollectionData {
|
|
212
|
+
if let v = MetadataViews.getNFTCollectionData(self.getViewResolver()) {
|
|
213
|
+
return v
|
|
214
|
+
}
|
|
215
|
+
panic("MetadataViews NFTCollectionData View is not implemented on this NFT.")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
access(all) fun checkSoulBound() : Bool {
|
|
219
|
+
return FindViews.checkSoulBound(self.getViewResolver())
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
access(all) fun getNounce(_ viewResolver: &{ViewResolver.Resolver}) : UInt64 {
|
|
225
|
+
if let nounce = viewResolver.resolveView(Type<FindViews.Nounce>()) {
|
|
226
|
+
if let v = nounce as? FindViews.Nounce {
|
|
227
|
+
return v.nounce
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return 0
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
access(all) struct AuthNFTPointer : Pointer, AuthPointer{
|
|
234
|
+
access(self) let cap: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.CollectionPublic, NonFungibleToken.Provider, ViewResolver.ResolverCollection}>
|
|
235
|
+
access(all) let id: UInt64
|
|
236
|
+
access(all) let nounce: UInt64
|
|
237
|
+
access(all) let uuid: UInt64
|
|
238
|
+
access(all) let itemType: Type
|
|
239
|
+
|
|
240
|
+
init(cap: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection, NonFungibleToken.Provider, ViewResolver.ResolverCollection}>, id: UInt64) {
|
|
241
|
+
self.cap=cap
|
|
242
|
+
self.id=id
|
|
243
|
+
|
|
244
|
+
if !self.cap.check() {
|
|
245
|
+
panic("The capability is not valid.")
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let collection = self.cap.borrow() ?? panic("could not find collection")
|
|
249
|
+
let viewResolver=collection.borrowNFT(self.id) ?? panic("could not borrow nft")
|
|
250
|
+
let display = MetadataViews.getDisplay(viewResolver) ?? panic("MetadataViews Display View is not implemented on this NFT.")
|
|
251
|
+
let nftCollectionData = MetadataViews.getNFTCollectionData(viewResolver) ?? panic("MetadataViews NFTCollectionData View is not implemented on this NFT.")
|
|
252
|
+
self.nounce=FindViews.getNounce(viewResolver)
|
|
253
|
+
self.uuid=viewResolver.uuid
|
|
254
|
+
self.itemType=viewResolver.getType()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
access(all) fun getViewResolver() : &{ViewResolver.Resolver} {
|
|
258
|
+
let cap = self.cap.borrow()!
|
|
259
|
+
let viewResolver = cap.borrowNFT(self.id) ?? panic("The capability of view pointer is not linked.")
|
|
260
|
+
return viewResolver
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
access(all) fun resolveView(_ type: Type) : AnyStruct? {
|
|
264
|
+
return self.getViewResolver().resolveView(type)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
access(all) fun getUUID() :UInt64{
|
|
268
|
+
return self.uuid
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
access(all) fun getViews() : [Type]{
|
|
272
|
+
return self.getViewResolver().getViews()
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
access(all) fun valid() : Bool {
|
|
276
|
+
if !self.cap.check() {
|
|
277
|
+
return false
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
let nft= self.cap.borrow()!.borrowNFT(self.id)
|
|
281
|
+
|
|
282
|
+
if nft ==nil {
|
|
283
|
+
return false
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if let nounce = nft!.resolveView(Type<FindViews.Nounce>()) {
|
|
287
|
+
if let v = nounce as? FindViews.Nounce {
|
|
288
|
+
return v.nounce==self.nounce
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return true
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
access(all) fun getTotalRoyaltiesCut() :UFix64 {
|
|
295
|
+
var total=0.0
|
|
296
|
+
for royalty in self.getRoyalty().getRoyalties() {
|
|
297
|
+
total = total + royalty.cut
|
|
298
|
+
}
|
|
299
|
+
return total
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
access(all) fun getRoyalty() : MetadataViews.Royalties {
|
|
303
|
+
if let v = MetadataViews.getRoyalties(self.getViewResolver()) {
|
|
304
|
+
return v
|
|
305
|
+
}
|
|
306
|
+
return MetadataViews.Royalties([])
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
access(all) fun getDisplay() : MetadataViews.Display {
|
|
310
|
+
if let v = MetadataViews.getDisplay(self.getViewResolver()) {
|
|
311
|
+
return v
|
|
312
|
+
}
|
|
313
|
+
panic("MetadataViews Display View is not implemented on this NFT.")
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
access(all) fun getNFTCollectionData() : MetadataViews.NFTCollectionData {
|
|
317
|
+
if let v = MetadataViews.getNFTCollectionData(self.getViewResolver()) {
|
|
318
|
+
return v
|
|
319
|
+
}
|
|
320
|
+
panic("MetadataViews NFTCollectionData View is not implemented on this NFT.")
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
access(all) fun withdraw() :@{NonFungibleToken.NFT} {
|
|
324
|
+
if !self.cap.check() {
|
|
325
|
+
panic("The pointer capability is invalid.")
|
|
326
|
+
}
|
|
327
|
+
return <- self.cap.borrow()!.withdraw(withdrawID: self.id)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
access(all) fun deposit(_ nft: @{NonFungibleToken.NFT}){
|
|
327
331
|
if !self.cap.check(){
|
|
328
332
|
panic("The pointer capablity is invalid.")
|
|
329
333
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
334
|
+
self.cap.borrow()!.deposit(token: <- nft)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
access(all) fun owner() : Address {
|
|
338
|
+
return self.cap.address
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
access(all) fun getItemType() : Type {
|
|
342
|
+
return self.itemType
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
access(all) fun checkSoulBound() : Bool {
|
|
346
|
+
return FindViews.checkSoulBound(self.getViewResolver())
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
access(all) fun createViewReadPointer(address:Address, path:PublicPath, id:UInt64) : ViewReadPointer {
|
|
351
|
+
let cap= getAccount(address).capabilities.get<&{ViewResolver.ResolverCollection}>(path)!
|
|
352
|
+
let pointer= FindViews.ViewReadPointer(cap: cap, id: id)
|
|
353
|
+
return pointer
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
access(all) struct Nounce {
|
|
357
|
+
access(all) let nounce: UInt64
|
|
358
|
+
|
|
359
|
+
init(_ nounce: UInt64) {
|
|
360
|
+
self.nounce=nounce
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
access(all) struct SoulBound {
|
|
365
|
+
|
|
366
|
+
access(all) let message: String
|
|
367
|
+
|
|
368
|
+
init(_ message:String) {
|
|
369
|
+
self.message=message
|
|
370
|
+
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
access(all) fun checkSoulBound(_ viewResolver: &{ViewResolver.Resolver}) : Bool {
|
|
375
|
+
if let soulBound = viewResolver.resolveView(Type<FindViews.SoulBound>()) {
|
|
376
|
+
if let v = soulBound as? FindViews.SoulBound {
|
|
377
|
+
return true
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return false
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
access(all) fun getDapperAddress(): Address {
|
|
384
|
+
switch FindViews.account.address.toString() {
|
|
385
|
+
case "0x097bafa4e0b48eef":
|
|
386
|
+
//mainnet
|
|
387
|
+
return 0xead892083b3e2c6c
|
|
388
|
+
case "0x35717efbbce11c74":
|
|
389
|
+
//testnet
|
|
390
|
+
return 0x82ec283f88a62e65
|
|
391
|
+
default:
|
|
392
|
+
//emulator
|
|
393
|
+
return 0x01cf0e2f2f715450
|
|
394
|
+
}
|
|
395
|
+
}
|
|
392
396
|
}
|