@flowtyio/flow-contracts 0.1.0-beta.3 → 0.1.0-beta.30
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/Burner.cdc +44 -0
- package/contracts/FlowStorageFees.cdc +15 -15
- package/contracts/FlowToken.cdc +29 -78
- package/contracts/FungibleToken.cdc +80 -53
- package/contracts/FungibleTokenMetadataViews.cdc +13 -25
- package/contracts/FungibleTokenSwitchboard.cdc +360 -0
- package/contracts/MetadataViews.cdc +107 -50
- package/contracts/NonFungibleToken.cdc +110 -60
- package/contracts/TokenForwarding.cdc +19 -11
- package/contracts/ViewResolver.cdc +20 -16
- package/contracts/capability-cache/CapabilityCache.cdc +97 -0
- package/contracts/dapper/DapperUtilityCoin.cdc +106 -39
- package/contracts/dapper/FlowUtilityToken.cdc +107 -40
- 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/example/ExampleNFT.cdc +18 -21
- package/contracts/example/ExampleToken.cdc +68 -1
- package/contracts/find/FindViews.cdc +357 -353
- package/contracts/flow-utils/AddressUtils.cdc +20 -23
- package/contracts/flow-utils/ArrayUtils.cdc +10 -11
- package/contracts/flow-utils/ScopedFTProviders.cdc +27 -19
- package/contracts/flow-utils/ScopedNFTProviders.cdc +31 -26
- package/contracts/flow-utils/StringUtils.cdc +24 -37
- package/contracts/flowty-drops/ContractManager.cdc +47 -0
- package/contracts/flowty-drops/DropFactory.cdc +75 -0
- package/contracts/flowty-drops/DropTypes.cdc +278 -0
- package/contracts/flowty-drops/FlowtyAddressVerifiers.cdc +64 -0
- package/contracts/flowty-drops/FlowtyDrops.cdc +431 -0
- package/contracts/flowty-drops/FlowtyPricers.cdc +48 -0
- package/contracts/flowty-drops/FlowtySwitchers.cdc +113 -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 +58 -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 +119 -0
- package/contracts/flowty-drops/nft/OpenEditionNFT.cdc +41 -0
- package/contracts/flowty-drops/nft/OpenEditionTemplate.cdc +52 -0
- package/contracts/flowty-drops/nft/UniversalCollection.cdc +23 -0
- package/contracts/fungible-token-router/FungibleTokenRouter.cdc +105 -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 +29 -25
- package/contracts/nft-catalog/NFTCatalog.cdc +60 -64
- package/contracts/nft-catalog/NFTCatalogAdmin.cdc +28 -27
- package/flow.json +189 -5
- package/package.json +1 -1
- package/contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc +0 -10
|
@@ -110,10 +110,8 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
110
110
|
return MetadataViews.NFTCollectionData(
|
|
111
111
|
storagePath: ExampleNFT.CollectionStoragePath,
|
|
112
112
|
publicPath: ExampleNFT.CollectionPublicPath,
|
|
113
|
-
providerPath: /private/exampleNFTCollection,
|
|
114
113
|
publicCollection: Type<&ExampleNFT.Collection>(),
|
|
115
114
|
publicLinkedType: Type<&ExampleNFT.Collection>(),
|
|
116
|
-
providerLinkedType: Type<auth(NonFungibleToken.Withdrawable) &ExampleNFT.Collection>(),
|
|
117
115
|
createEmptyCollectionFunction: (fun (): @{NonFungibleToken.Collection} {
|
|
118
116
|
return <-ExampleNFT.createEmptyCollection()
|
|
119
117
|
})
|
|
@@ -145,6 +143,10 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
145
143
|
}
|
|
146
144
|
return nil
|
|
147
145
|
}
|
|
146
|
+
|
|
147
|
+
access(all) fun createEmptyCollection(): @{NonFungibleToken.Collection} {
|
|
148
|
+
return <- ExampleNFT.createEmptyCollection()
|
|
149
|
+
}
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
access(all) resource interface ExampleNFTCollectionPublic: NonFungibleToken.Collection {
|
|
@@ -162,7 +164,7 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
162
164
|
|
|
163
165
|
// dictionary of NFT conforming tokens
|
|
164
166
|
// NFT is a resource type with an `UInt64` ID field
|
|
165
|
-
access(
|
|
167
|
+
access(all) var ownedNFTs: @{UInt64: {NonFungibleToken.NFT}}
|
|
166
168
|
|
|
167
169
|
init () {
|
|
168
170
|
self.ownedNFTs <- {}
|
|
@@ -187,6 +189,14 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
access(all) view fun getIDs(): [UInt64] {
|
|
193
|
+
return self.ownedNFTs.keys
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
|
|
197
|
+
return &self.ownedNFTs[id]
|
|
198
|
+
}
|
|
199
|
+
|
|
190
200
|
access(all) view fun isSupportedNFTType(type: Type): Bool {
|
|
191
201
|
return type == Type<@ExampleNFT.NFT>()
|
|
192
202
|
}
|
|
@@ -196,10 +206,10 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
// withdraw removes an NFT from the collection and moves it to the caller
|
|
199
|
-
access(NonFungibleToken.
|
|
209
|
+
access(NonFungibleToken.Withdraw) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} {
|
|
200
210
|
let token <- self.ownedNFTs.remove(key: withdrawID) ?? panic("missing NFT")
|
|
201
211
|
|
|
202
|
-
emit Withdraw(id: token.
|
|
212
|
+
emit Withdraw(id: token.id, from: self.owner?.address)
|
|
203
213
|
|
|
204
214
|
return <-token
|
|
205
215
|
}
|
|
@@ -218,17 +228,6 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
218
228
|
|
|
219
229
|
destroy oldToken
|
|
220
230
|
}
|
|
221
|
-
|
|
222
|
-
// getIDs returns an array of the IDs that are in the collection
|
|
223
|
-
access(all) view fun getIDs(): [UInt64] {
|
|
224
|
-
return self.ownedNFTs.keys
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// borrowNFT gets a reference to an NFT in the collection
|
|
228
|
-
// so that the caller can read its metadata and call its methods
|
|
229
|
-
access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
|
|
230
|
-
return &self.ownedNFTs[id]
|
|
231
|
-
}
|
|
232
231
|
|
|
233
232
|
access(all) fun borrowExampleNFT(id: UInt64): &ExampleNFT.NFT? {
|
|
234
233
|
if self.ownedNFTs[id] != nil {
|
|
@@ -345,16 +344,14 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
345
344
|
/// @param view: The Type of the desired view.
|
|
346
345
|
/// @return A structure representing the requested view.
|
|
347
346
|
///
|
|
348
|
-
access(all)
|
|
349
|
-
switch
|
|
347
|
+
access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
|
|
348
|
+
switch viewType {
|
|
350
349
|
case Type<MetadataViews.NFTCollectionData>():
|
|
351
350
|
return MetadataViews.NFTCollectionData(
|
|
352
351
|
storagePath: ExampleNFT.CollectionStoragePath,
|
|
353
352
|
publicPath: ExampleNFT.CollectionPublicPath,
|
|
354
|
-
providerPath: /private/exampleNFTCollection,
|
|
355
353
|
publicCollection: Type<&ExampleNFT.Collection>(),
|
|
356
354
|
publicLinkedType: Type<&ExampleNFT.Collection>(),
|
|
357
|
-
providerLinkedType: Type<auth(NonFungibleToken.Withdrawable) &ExampleNFT.Collection>(),
|
|
358
355
|
createEmptyCollectionFunction: (fun (): @{NonFungibleToken.Collection} {
|
|
359
356
|
return <-ExampleNFT.createEmptyCollection()
|
|
360
357
|
})
|
|
@@ -385,7 +382,7 @@ access(all) contract ExampleNFT: ViewResolver {
|
|
|
385
382
|
/// @return An array of Types defining the implemented views. This value will be used by
|
|
386
383
|
/// developers to know which parameter to pass to the resolveView() method.
|
|
387
384
|
///
|
|
388
|
-
access(all) view fun
|
|
385
|
+
access(all) view fun getContractViews(resourceType: Type?): [Type] {
|
|
389
386
|
return [
|
|
390
387
|
Type<MetadataViews.NFTCollectionData>(),
|
|
391
388
|
Type<MetadataViews.NFTCollectionDisplay>()
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "FungibleToken"
|
|
2
|
+
import "FungibleTokenMetadataViews"
|
|
3
|
+
import "MetadataViews"
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
// THIS CONTRACT IS FOR TESTING PURPOSES ONLY!
|
|
@@ -80,6 +82,20 @@ access(all) contract ExampleToken {
|
|
|
80
82
|
return /public/exampleTokenPublic
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
access(all) view fun isAvailableToWithdraw(amount: UFix64): Bool {
|
|
86
|
+
return self.balance >= amount
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// Same as getViews above, but on a specific NFT instead of a contract
|
|
90
|
+
access(all) view fun getViews(): [Type] {
|
|
91
|
+
return ExampleToken.getContractViews(resourceType: nil)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/// Same as resolveView above, but on a specific NFT instead of a contract
|
|
95
|
+
access(all) fun resolveView(_ view: Type): AnyStruct? {
|
|
96
|
+
return ExampleToken.resolveContractView(resourceType: nil, viewType: view)
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
/// withdraw
|
|
84
100
|
///
|
|
85
101
|
/// Function that takes an amount as an argument
|
|
@@ -90,7 +106,7 @@ access(all) contract ExampleToken {
|
|
|
90
106
|
/// created Vault to the context that called so it can be deposited
|
|
91
107
|
/// elsewhere.
|
|
92
108
|
///
|
|
93
|
-
access(FungibleToken.
|
|
109
|
+
access(FungibleToken.Withdraw) fun withdraw(amount: UFix64): @{FungibleToken.Vault} {
|
|
94
110
|
self.balance = self.balance - amount
|
|
95
111
|
emit TokensWithdrawn(amount: amount, from: self.owner?.address)
|
|
96
112
|
return <-create Vault(balance: amount)
|
|
@@ -211,6 +227,57 @@ access(all) contract ExampleToken {
|
|
|
211
227
|
}
|
|
212
228
|
}
|
|
213
229
|
|
|
230
|
+
access(all) view fun getContractViews(resourceType: Type?): [Type] {
|
|
231
|
+
return [Type<FungibleTokenMetadataViews.FTView>(),
|
|
232
|
+
Type<FungibleTokenMetadataViews.FTDisplay>(),
|
|
233
|
+
Type<FungibleTokenMetadataViews.FTVaultData>(),
|
|
234
|
+
Type<FungibleTokenMetadataViews.TotalSupply>()]
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
|
|
238
|
+
switch viewType {
|
|
239
|
+
case Type<FungibleTokenMetadataViews.FTView>():
|
|
240
|
+
return FungibleTokenMetadataViews.FTView(
|
|
241
|
+
ftDisplay: self.resolveContractView(resourceType: nil, viewType: Type<FungibleTokenMetadataViews.FTDisplay>()) as! FungibleTokenMetadataViews.FTDisplay?,
|
|
242
|
+
ftVaultData: self.resolveContractView(resourceType: nil, viewType: Type<FungibleTokenMetadataViews.FTVaultData>()) as! FungibleTokenMetadataViews.FTVaultData?
|
|
243
|
+
)
|
|
244
|
+
case Type<FungibleTokenMetadataViews.FTDisplay>():
|
|
245
|
+
let media = MetadataViews.Media(
|
|
246
|
+
file: MetadataViews.HTTPFile(
|
|
247
|
+
url: "https://example.com"
|
|
248
|
+
),
|
|
249
|
+
mediaType: "image/svg+xml"
|
|
250
|
+
)
|
|
251
|
+
let medias = MetadataViews.Medias([media])
|
|
252
|
+
return FungibleTokenMetadataViews.FTDisplay(
|
|
253
|
+
name: "Example Token",
|
|
254
|
+
symbol: "EXAMPLE",
|
|
255
|
+
description: "",
|
|
256
|
+
externalURL: MetadataViews.ExternalURL("https://flow.com"),
|
|
257
|
+
logos: medias,
|
|
258
|
+
socials: {
|
|
259
|
+
"twitter": MetadataViews.ExternalURL("https://twitter.com/flow_blockchain")
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
case Type<FungibleTokenMetadataViews.FTVaultData>():
|
|
263
|
+
let vaultRef = ExampleToken.account.storage.borrow<auth(FungibleToken.Withdraw) &ExampleToken.Vault>(from: /storage/exampleTokenVault)
|
|
264
|
+
?? panic("Could not borrow reference to the contract's Vault!")
|
|
265
|
+
return FungibleTokenMetadataViews.FTVaultData(
|
|
266
|
+
storagePath: /storage/exampleTokenVault,
|
|
267
|
+
receiverPath: /public/exampleTokenReceiver,
|
|
268
|
+
metadataPath: /public/exampleTokenBalance,
|
|
269
|
+
receiverLinkedType: Type<&{FungibleToken.Receiver, FungibleToken.Vault}>(),
|
|
270
|
+
metadataLinkedType: Type<&{FungibleToken.Balance, FungibleToken.Vault}>(),
|
|
271
|
+
createEmptyVaultFunction: (fun (): @{FungibleToken.Vault} {
|
|
272
|
+
return <-vaultRef.createEmptyVault()
|
|
273
|
+
})
|
|
274
|
+
)
|
|
275
|
+
case Type<FungibleTokenMetadataViews.TotalSupply>():
|
|
276
|
+
return FungibleTokenMetadataViews.TotalSupply(totalSupply: ExampleToken.totalSupply)
|
|
277
|
+
}
|
|
278
|
+
return nil
|
|
279
|
+
}
|
|
280
|
+
|
|
214
281
|
init() {
|
|
215
282
|
self.totalSupply = 1000.0
|
|
216
283
|
|