@flowtyio/flow-contracts 0.1.0-beta.8 → 0.1.0

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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/contracts/FungibleTokenSwitchboard.cdc +360 -0
  3. package/contracts/MetadataViews.cdc +79 -6
  4. package/contracts/NonFungibleToken.cdc +17 -10
  5. package/contracts/TokenForwarding.cdc +19 -11
  6. package/contracts/capability-cache/CapabilityCache.cdc +97 -0
  7. package/contracts/dapper/TopShot.cdc +323 -259
  8. package/contracts/dapper/TopShotLocking.cdc +41 -15
  9. package/contracts/dapper/offers/DapperOffersV2.cdc +46 -43
  10. package/contracts/dapper/offers/OffersV2.cdc +40 -56
  11. package/contracts/dapper/offers/Resolver.cdc +20 -13
  12. package/contracts/emerald-city/FLOAT.cdc +259 -254
  13. package/contracts/example/ExampleNFT.cdc +2 -2
  14. package/contracts/find/FindViews.cdc +357 -353
  15. package/contracts/flow-utils/ScopedFTProviders.cdc +5 -2
  16. package/contracts/flow-utils/ScopedNFTProviders.cdc +6 -2
  17. package/contracts/flowty-drops/ContractManager.cdc +73 -0
  18. package/contracts/flowty-drops/DropFactory.cdc +75 -0
  19. package/contracts/flowty-drops/DropTypes.cdc +282 -0
  20. package/contracts/flowty-drops/FlowtyActiveCheckers.cdc +113 -0
  21. package/contracts/flowty-drops/FlowtyAddressVerifiers.cdc +64 -0
  22. package/contracts/flowty-drops/FlowtyDrops.cdc +461 -0
  23. package/contracts/flowty-drops/FlowtyPricers.cdc +48 -0
  24. package/contracts/flowty-drops/initializers/ContractBorrower.cdc +14 -0
  25. package/contracts/flowty-drops/initializers/ContractInitializer.cdc +7 -0
  26. package/contracts/flowty-drops/initializers/OpenEditionInitializer.cdc +57 -0
  27. package/contracts/flowty-drops/nft/BaseCollection.cdc +97 -0
  28. package/contracts/flowty-drops/nft/BaseNFT.cdc +107 -0
  29. package/contracts/flowty-drops/nft/ContractFactory.cdc +13 -0
  30. package/contracts/flowty-drops/nft/ContractFactoryTemplate.cdc +48 -0
  31. package/contracts/flowty-drops/nft/NFTMetadata.cdc +140 -0
  32. package/contracts/flowty-drops/nft/OpenEditionNFT.cdc +42 -0
  33. package/contracts/flowty-drops/nft/OpenEditionTemplate.cdc +54 -0
  34. package/contracts/flowty-drops/nft/UniversalCollection.cdc +29 -0
  35. package/contracts/fungible-token-router/FungibleTokenRouter.cdc +103 -0
  36. package/contracts/hybrid-custody/CapabilityDelegator.cdc +28 -26
  37. package/contracts/hybrid-custody/CapabilityFactory.cdc +20 -18
  38. package/contracts/hybrid-custody/CapabilityFilter.cdc +41 -24
  39. package/contracts/hybrid-custody/HybridCustody.cdc +303 -242
  40. package/contracts/hybrid-custody/factories/FTAllFactory.cdc +16 -4
  41. package/contracts/hybrid-custody/factories/FTBalanceFactory.cdc +16 -4
  42. package/contracts/hybrid-custody/factories/FTProviderFactory.cdc +17 -5
  43. package/contracts/hybrid-custody/factories/FTReceiverBalanceFactory.cdc +16 -4
  44. package/contracts/hybrid-custody/factories/FTReceiverFactory.cdc +16 -4
  45. package/contracts/hybrid-custody/factories/FTVaultFactory.cdc +46 -0
  46. package/contracts/hybrid-custody/factories/NFTCollectionFactory.cdc +45 -0
  47. package/contracts/hybrid-custody/factories/NFTCollectionPublicFactory.cdc +16 -4
  48. package/contracts/hybrid-custody/factories/NFTProviderAndCollectionFactory.cdc +22 -0
  49. package/contracts/hybrid-custody/factories/NFTProviderFactory.cdc +16 -4
  50. package/contracts/lost-and-found/LostAndFound.cdc +21 -17
  51. package/flow.json +181 -7
  52. package/package.json +1 -1
  53. package/contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc +0 -10
@@ -0,0 +1,97 @@
1
+ /*
2
+ https://github.com/Flowtyio/capability-cache
3
+
4
+ CapabilityCache helps manage capabilities which are issued but are not in public paths.
5
+ Rather than looping through all capabilities under a storage path and finding one that
6
+ matches the Capability type you want, the cache can be used to retrieve them
7
+ */
8
+ access(all) contract CapabilityCache {
9
+
10
+ access(all) let basePathIdentifier: String
11
+
12
+ access(all) event CapabilityAdded(owner: Address?, cacheUuid: UInt64, namespace: String, resourceType: Type, capabilityType: Type, capabilityID: UInt64)
13
+ access(all) event CapabilityRemoved(owner: Address?, cacheUuid: UInt64, namespace: String, resourceType: Type, capabilityType: Type, capabilityID: UInt64)
14
+
15
+ // Add to a namespace
16
+ access(all) entitlement Add
17
+
18
+ // Remove from a namespace
19
+ access(all) entitlement Delete
20
+
21
+ // Retrieve a cap from the namespace
22
+ access(all) entitlement Get
23
+
24
+ // Resource that manages capabilities for a provided namespace. Only one capability is permitted per type.
25
+ access(all) resource Cache {
26
+ // A dictionary of resourceType -> CapabilityType -> Capability
27
+ // For example, one might store a Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}> for the @TopShot.NFT resource.
28
+ // Note that the resource type is not necessarily the type that the borrowed capability is an instance of. This is because some resource definitions
29
+ // might be reused.
30
+ access(self) let caps: {Type: {Type: Capability}}
31
+
32
+ // who is this capability cache maintained by? e.g. flowty, dapper, find?
33
+ access(all) let namespace: String
34
+
35
+ // Remove a capability, if it exists,
36
+ access(Delete) fun removeCapabilityByType(resourceType: Type, capabilityType: Type): Capability? {
37
+ if let ref = &self.caps[resourceType] as auth(Mutate) &{Type: Capability}? {
38
+ let cap = ref.remove(key: capabilityType)
39
+ if cap != nil {
40
+ emit CapabilityRemoved(owner: self.owner?.address, cacheUuid: self.uuid, namespace: self.namespace, resourceType: resourceType, capabilityType: capabilityType, capabilityID: cap!.id)
41
+ }
42
+ }
43
+
44
+ return nil
45
+ }
46
+
47
+ // Adds a capability to the cache. If there is already an entry for the given type,
48
+ // it will be returned
49
+ access(Add) fun addCapability(resourceType: Type, cap: Capability): Capability? {
50
+ pre {
51
+ cap.id != 0: "cannot add a capability with id 0"
52
+ }
53
+
54
+ let capType = cap.getType()
55
+ emit CapabilityAdded(owner: self.owner?.address, cacheUuid: self.uuid, namespace: self.namespace, resourceType: resourceType, capabilityType: capType, capabilityID: cap.id)
56
+ if let ref = &self.caps[resourceType] as auth(Mutate) &{Type: Capability}? {
57
+ return ref.insert(key: capType, cap)
58
+ }
59
+
60
+ self.caps[resourceType] = {
61
+ capType: cap
62
+ }
63
+
64
+ return nil
65
+ }
66
+
67
+ // Retrieve a capability key'd by a given type.
68
+ access(Get) fun getCapabilityByType(resourceType: Type, capabilityType: Type): Capability? {
69
+ if let tmp = self.caps[resourceType] {
70
+ return tmp[capabilityType]
71
+ }
72
+
73
+ return nil
74
+ }
75
+
76
+ init(namespace: String) {
77
+ self.caps = {}
78
+
79
+ self.namespace = namespace
80
+ }
81
+ }
82
+
83
+ // There is no uniform storage path for the Capability Cache. Instead, each platform which issues capabilities
84
+ // should manage their own cache, and can generate the storage path to store it in with this helper method
85
+ access(all) fun getPathForCache(_ namespace: String): StoragePath {
86
+ return StoragePath(identifier: self.basePathIdentifier.concat(namespace))
87
+ ?? panic("invalid namespace value")
88
+ }
89
+
90
+ access(all) fun createCache(namespace: String): @Cache {
91
+ return <- create Cache(namespace: namespace)
92
+ }
93
+
94
+ init() {
95
+ self.basePathIdentifier = "CapabilityCache_".concat(self.account.address.toString()).concat("_")
96
+ }
97
+ }