@flowtyio/flow-contracts 0.1.0-beta.2 → 0.1.0-beta.21
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/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/MetadataViews.cdc +107 -50
- package/contracts/NonFungibleToken.cdc +110 -60
- package/contracts/TokenForwarding.cdc +19 -11
- package/contracts/ViewResolver.cdc +20 -16
- 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 +36 -40
- package/contracts/dapper/offers/OffersV2.cdc +52 -51
- package/contracts/dapper/offers/Resolver.cdc +13 -12
- package/contracts/emerald-city/FLOAT.cdc +259 -254
- package/contracts/example/ExampleNFT.cdc +419 -0
- package/contracts/example/ExampleToken.cdc +302 -0
- 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/hybrid-custody/CapabilityDelegator.cdc +29 -26
- package/contracts/hybrid-custody/CapabilityFactory.cdc +21 -18
- package/contracts/hybrid-custody/CapabilityFilter.cdc +42 -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 +45 -0
- package/contracts/hybrid-custody/factories/NFTCollectionFactory.cdc +45 -0
- package/contracts/hybrid-custody/factories/NFTCollectionPublicFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/NFTProviderAndCollectionPublicFactory.cdc +16 -4
- package/contracts/hybrid-custody/factories/NFTProviderFactory.cdc +16 -4
- package/contracts/lost-and-found/LostAndFound.cdc +14 -14
- package/contracts/nft-catalog/NFTCatalog.cdc +60 -64
- package/contracts/nft-catalog/NFTCatalogAdmin.cdc +28 -27
- package/flow.json +38 -1
- package/package.json +1 -1
|
@@ -7,48 +7,52 @@
|
|
|
7
7
|
/// private `Delegator` can only be borrowed from the child account when you have access to the full `ChildAccount`
|
|
8
8
|
/// resource.
|
|
9
9
|
///
|
|
10
|
-
|
|
10
|
+
access(all) contract CapabilityDelegator {
|
|
11
11
|
|
|
12
12
|
/* --- Canonical Paths --- */
|
|
13
13
|
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
access(all) let StoragePath: StoragePath
|
|
15
|
+
access(all) let PublicPath: PublicPath
|
|
16
|
+
|
|
17
|
+
access(all) entitlement Get
|
|
18
|
+
access(all) entitlement Owner
|
|
19
|
+
access(all) entitlement Add
|
|
20
|
+
access(all) entitlement Delete
|
|
17
21
|
|
|
18
22
|
/* --- Events --- */
|
|
19
23
|
//
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
access(all) event DelegatorCreated(id: UInt64)
|
|
25
|
+
access(all) event DelegatorUpdated(id: UInt64, capabilityType: Type, isPublic: Bool, active: Bool)
|
|
22
26
|
|
|
23
27
|
/// Private interface for Capability retrieval
|
|
24
28
|
///
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
access(all) resource interface GetterPrivate {
|
|
30
|
+
access(Get) view fun getPrivateCapability(_ type: Type): Capability? {
|
|
27
31
|
post {
|
|
28
32
|
result == nil || type.isSubtype(of: result.getType()): "incorrect returned capability type"
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
access(all) view fun findFirstPrivateType(_ type: Type): Type?
|
|
36
|
+
access(Get) fun getAllPrivate(): [Capability]
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
/// Exposes public Capability retrieval
|
|
36
40
|
///
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
access(all) resource interface GetterPublic {
|
|
42
|
+
access(all) view fun getPublicCapability(_ type: Type): Capability? {
|
|
39
43
|
post {
|
|
40
|
-
result == nil || type.isSubtype(of: result.getType()): "incorrect returned capability type
|
|
44
|
+
result == nil || type.isSubtype(of: result.getType()): "incorrect returned capability type"
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
access(all) view fun findFirstPublicType(_ type: Type): Type?
|
|
49
|
+
access(all) view fun getAllPublic(): [Capability]
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/// This Delegator is used to store Capabilities, partitioned by public and private access with corresponding
|
|
49
53
|
/// GetterPublic and GetterPrivate conformances.AccountCapabilityController
|
|
50
54
|
///
|
|
51
|
-
|
|
55
|
+
access(all) resource Delegator: GetterPublic, GetterPrivate {
|
|
52
56
|
access(self) let privateCapabilities: {Type: Capability}
|
|
53
57
|
access(self) let publicCapabilities: {Type: Capability}
|
|
54
58
|
|
|
@@ -56,7 +60,7 @@ pub contract CapabilityDelegator {
|
|
|
56
60
|
//
|
|
57
61
|
/// Returns the public Capability of the given Type if it exists
|
|
58
62
|
///
|
|
59
|
-
|
|
63
|
+
access(all) view fun getPublicCapability(_ type: Type): Capability? {
|
|
60
64
|
return self.publicCapabilities[type]
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -66,7 +70,7 @@ pub contract CapabilityDelegator {
|
|
|
66
70
|
/// @param type: Type of the Capability to retrieve
|
|
67
71
|
/// @return Capability of the given Type if it exists, nil otherwise
|
|
68
72
|
///
|
|
69
|
-
|
|
73
|
+
access(Get) view fun getPrivateCapability(_ type: Type): Capability? {
|
|
70
74
|
return self.privateCapabilities[type]
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -74,7 +78,7 @@ pub contract CapabilityDelegator {
|
|
|
74
78
|
///
|
|
75
79
|
/// @return List of all public Capabilities
|
|
76
80
|
///
|
|
77
|
-
|
|
81
|
+
access(all) view fun getAllPublic(): [Capability] {
|
|
78
82
|
return self.publicCapabilities.values
|
|
79
83
|
}
|
|
80
84
|
|
|
@@ -82,7 +86,7 @@ pub contract CapabilityDelegator {
|
|
|
82
86
|
///
|
|
83
87
|
/// @return List of all private Capabilities
|
|
84
88
|
///
|
|
85
|
-
|
|
89
|
+
access(Get) fun getAllPrivate(): [Capability] {
|
|
86
90
|
return self.privateCapabilities.values
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -91,7 +95,7 @@ pub contract CapabilityDelegator {
|
|
|
91
95
|
/// @param type: Type to check for subtypes
|
|
92
96
|
/// @return First public Type that is a subtype of the given Type, nil otherwise
|
|
93
97
|
///
|
|
94
|
-
|
|
98
|
+
access(all) view fun findFirstPublicType(_ type: Type): Type? {
|
|
95
99
|
for t in self.publicCapabilities.keys {
|
|
96
100
|
if t.isSubtype(of: type) {
|
|
97
101
|
return t
|
|
@@ -106,7 +110,7 @@ pub contract CapabilityDelegator {
|
|
|
106
110
|
/// @param type: Type to check for subtypes
|
|
107
111
|
/// @return First private Type that is a subtype of the given Type, nil otherwise
|
|
108
112
|
///
|
|
109
|
-
|
|
113
|
+
access(all) view fun findFirstPrivateType(_ type: Type): Type? {
|
|
110
114
|
for t in self.privateCapabilities.keys {
|
|
111
115
|
if t.isSubtype(of: type) {
|
|
112
116
|
return t
|
|
@@ -122,7 +126,7 @@ pub contract CapabilityDelegator {
|
|
|
122
126
|
/// @param cap: Capability to add
|
|
123
127
|
/// @param isPublic: Whether the Capability should be public or private
|
|
124
128
|
///
|
|
125
|
-
|
|
129
|
+
access(Owner | Add) fun addCapability(cap: Capability, isPublic: Bool) {
|
|
126
130
|
pre {
|
|
127
131
|
cap.check<&AnyResource>(): "Invalid Capability provided"
|
|
128
132
|
}
|
|
@@ -138,7 +142,7 @@ pub contract CapabilityDelegator {
|
|
|
138
142
|
///
|
|
139
143
|
/// @param cap: Capability to remove
|
|
140
144
|
///
|
|
141
|
-
|
|
145
|
+
access(Owner | Delete) fun removeCapability(cap: Capability) {
|
|
142
146
|
if let removedPublic = self.publicCapabilities.remove(key: cap.getType()) {
|
|
143
147
|
emit DelegatorUpdated(id: self.uuid, capabilityType: cap.getType(), isPublic: true, active: false)
|
|
144
148
|
}
|
|
@@ -158,7 +162,7 @@ pub contract CapabilityDelegator {
|
|
|
158
162
|
///
|
|
159
163
|
/// @return Newly created Delegator
|
|
160
164
|
///
|
|
161
|
-
|
|
165
|
+
access(all) fun createDelegator(): @Delegator {
|
|
162
166
|
let delegator <- create Delegator()
|
|
163
167
|
emit DelegatorCreated(id: delegator.uuid)
|
|
164
168
|
return <- delegator
|
|
@@ -167,7 +171,6 @@ pub contract CapabilityDelegator {
|
|
|
167
171
|
init() {
|
|
168
172
|
let identifier = "CapabilityDelegator_".concat(self.account.address.toString())
|
|
169
173
|
self.StoragePath = StoragePath(identifier: identifier)!
|
|
170
|
-
self.PrivatePath = PrivatePath(identifier: identifier)!
|
|
171
174
|
self.PublicPath = PublicPath(identifier: identifier)!
|
|
172
175
|
}
|
|
173
176
|
}
|
|
@@ -13,37 +13,41 @@
|
|
|
13
13
|
/// Capabilities is critical to the use case of Hybrid Custody. It's advised to use Factories sparingly and only for
|
|
14
14
|
/// cases where Capabilities must be castable by the caller.
|
|
15
15
|
///
|
|
16
|
-
|
|
16
|
+
access(all) contract CapabilityFactory {
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
access(all) let StoragePath: StoragePath
|
|
19
|
+
access(all) let PublicPath: PublicPath
|
|
20
|
+
|
|
21
|
+
access(all) entitlement Owner
|
|
22
|
+
access(all) entitlement Add
|
|
23
|
+
access(all) entitlement Delete
|
|
21
24
|
|
|
22
25
|
/// Factory structures a common interface for Capability retrieval from a given account at a specified path
|
|
23
26
|
///
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
access(all) struct interface Factory {
|
|
28
|
+
access(all) view fun getCapability(acct: auth(Capabilities) &Account, controllerID: UInt64): Capability?
|
|
29
|
+
access(all) view fun getPublicCapability(acct: &Account, path: PublicPath): Capability?
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
/// Getter defines an interface for retrieval of a Factory if contained within the implementing resource
|
|
29
33
|
///
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
access(all) resource interface Getter {
|
|
35
|
+
access(all) view fun getSupportedTypes(): [Type]
|
|
36
|
+
access(all) view fun getFactory(_ t: Type): {CapabilityFactory.Factory}?
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
/// Manager is a resource that contains Factories and implements the Getter interface for retrieval of contained
|
|
36
40
|
/// Factories
|
|
37
41
|
///
|
|
38
|
-
|
|
42
|
+
access(all) resource Manager: Getter {
|
|
39
43
|
/// Mapping of Factories indexed on Type of Capability they retrieve
|
|
40
|
-
|
|
44
|
+
access(all) let factories: {Type: {CapabilityFactory.Factory}}
|
|
41
45
|
|
|
42
46
|
/// Retrieves a list of Types supported by contained Factories
|
|
43
47
|
///
|
|
44
48
|
/// @return List of Types supported by the Manager
|
|
45
49
|
///
|
|
46
|
-
|
|
50
|
+
access(all) view fun getSupportedTypes(): [Type] {
|
|
47
51
|
return self.factories.keys
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -51,7 +55,7 @@ pub contract CapabilityFactory {
|
|
|
51
55
|
///
|
|
52
56
|
/// @param t: Type the Factory is indexed on
|
|
53
57
|
///
|
|
54
|
-
|
|
58
|
+
access(all) view fun getFactory(_ t: Type): {CapabilityFactory.Factory}? {
|
|
55
59
|
return self.factories[t]
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -60,7 +64,7 @@ pub contract CapabilityFactory {
|
|
|
60
64
|
/// @param t: Type of Capability the Factory retrieves
|
|
61
65
|
/// @param f: Factory to add
|
|
62
66
|
///
|
|
63
|
-
|
|
67
|
+
access(Owner | Add) fun addFactory(_ t: Type, _ f: {CapabilityFactory.Factory}) {
|
|
64
68
|
pre {
|
|
65
69
|
!self.factories.containsKey(t): "Factory of given type already exists"
|
|
66
70
|
}
|
|
@@ -72,7 +76,7 @@ pub contract CapabilityFactory {
|
|
|
72
76
|
/// @param t: Type of Capability the Factory retrieves
|
|
73
77
|
/// @param f: Factory to replace existing Factory
|
|
74
78
|
///
|
|
75
|
-
|
|
79
|
+
access(Owner | Add) fun updateFactory(_ t: Type, _ f: {CapabilityFactory.Factory}) {
|
|
76
80
|
self.factories[t] = f
|
|
77
81
|
}
|
|
78
82
|
|
|
@@ -80,7 +84,7 @@ pub contract CapabilityFactory {
|
|
|
80
84
|
///
|
|
81
85
|
/// @param t: Type the Factory is indexed on
|
|
82
86
|
///
|
|
83
|
-
|
|
87
|
+
access(Owner | Delete) fun removeFactory(_ t: Type): {CapabilityFactory.Factory}? {
|
|
84
88
|
return self.factories.remove(key: t)
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -92,14 +96,13 @@ pub contract CapabilityFactory {
|
|
|
92
96
|
/// Creates a Manager resource
|
|
93
97
|
///
|
|
94
98
|
/// @return Manager resource
|
|
95
|
-
|
|
99
|
+
access(all) fun createFactoryManager(): @Manager {
|
|
96
100
|
return <- create Manager()
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
init() {
|
|
100
104
|
let identifier = "CapabilityFactory_".concat(self.account.address.toString())
|
|
101
105
|
self.StoragePath = StoragePath(identifier: identifier)!
|
|
102
|
-
self.PrivatePath = PrivatePath(identifier: identifier)!
|
|
103
106
|
self.PublicPath = PublicPath(identifier: identifier)!
|
|
104
107
|
}
|
|
105
108
|
}
|
|
@@ -6,29 +6,32 @@
|
|
|
6
6
|
/// - `AllowlistFilter` - A filter which contains a mapping of allowed Types
|
|
7
7
|
/// - `AllowAllFilter` - A passthrough, all requested capabilities are allowed
|
|
8
8
|
///
|
|
9
|
-
|
|
9
|
+
access(all) contract CapabilityFilter {
|
|
10
10
|
|
|
11
11
|
/* --- Canonical Paths --- */
|
|
12
12
|
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
access(all) let StoragePath: StoragePath
|
|
14
|
+
access(all) let PublicPath: PublicPath
|
|
15
|
+
|
|
16
|
+
access(all) entitlement Owner
|
|
17
|
+
access(all) entitlement Add
|
|
18
|
+
access(all) entitlement Delete
|
|
16
19
|
|
|
17
20
|
/* --- Events --- */
|
|
18
21
|
//
|
|
19
|
-
|
|
22
|
+
access(all) event FilterUpdated(id: UInt64, filterType: Type, type: Type, active: Bool)
|
|
20
23
|
|
|
21
24
|
/// `Filter` is a simple interface with methods to determine if a Capability is allowed and retrieve details about
|
|
22
25
|
/// the Filter itself
|
|
23
26
|
///
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
access(all) resource interface Filter {
|
|
28
|
+
access(all) view fun allowed(cap: Capability): Bool
|
|
29
|
+
access(all) view fun getDetails(): AnyStruct
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/// `DenylistFilter` is a `Filter` which contains a mapping of denied Types
|
|
30
33
|
///
|
|
31
|
-
|
|
34
|
+
access(all) resource DenylistFilter: Filter {
|
|
32
35
|
|
|
33
36
|
/// Represents the underlying types which should not ever be returned by a RestrictedChildAccount. The filter
|
|
34
37
|
/// will borrow a requested capability, and make sure that the type it gets back is not in the list of denied
|
|
@@ -39,7 +42,7 @@ pub contract CapabilityFilter {
|
|
|
39
42
|
///
|
|
40
43
|
/// @param type: The type to add to the denied types mapping
|
|
41
44
|
///
|
|
42
|
-
|
|
45
|
+
access(Owner | Add) fun addType(_ type: Type) {
|
|
43
46
|
self.deniedTypes.insert(key: type, true)
|
|
44
47
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: true)
|
|
45
48
|
}
|
|
@@ -48,18 +51,26 @@ pub contract CapabilityFilter {
|
|
|
48
51
|
///
|
|
49
52
|
/// @param type: The type to remove from the denied types mapping
|
|
50
53
|
///
|
|
51
|
-
|
|
54
|
+
access(Owner | Delete) fun removeType(_ type: Type) {
|
|
52
55
|
if let removed = self.deniedTypes.remove(key: type) {
|
|
53
56
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: false)
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
/// Removes all types from the mapping of denied types
|
|
61
|
+
///
|
|
62
|
+
access(Owner | Delete) fun removeAllTypes() {
|
|
63
|
+
for type in self.deniedTypes.keys {
|
|
64
|
+
self.removeType(type)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
/// Determines if a requested capability is allowed by this `Filter`
|
|
58
69
|
///
|
|
59
70
|
/// @param cap: The capability to check
|
|
60
71
|
/// @return: true if the capability is allowed, false otherwise
|
|
61
72
|
///
|
|
62
|
-
|
|
73
|
+
access(all) view fun allowed(cap: Capability): Bool {
|
|
63
74
|
if let item = cap.borrow<&AnyResource>() {
|
|
64
75
|
return !self.deniedTypes.containsKey(item.getType())
|
|
65
76
|
}
|
|
@@ -72,7 +83,7 @@ pub contract CapabilityFilter {
|
|
|
72
83
|
/// @return A struct containing details about this filter including this Filter's Type indexed on the `type`
|
|
73
84
|
/// key as well as types denied indexed on the `deniedTypes` key
|
|
74
85
|
///
|
|
75
|
-
|
|
86
|
+
access(all) view fun getDetails(): AnyStruct {
|
|
76
87
|
return {
|
|
77
88
|
"type": self.getType(),
|
|
78
89
|
"deniedTypes": self.deniedTypes.keys
|
|
@@ -86,7 +97,7 @@ pub contract CapabilityFilter {
|
|
|
86
97
|
|
|
87
98
|
/// `AllowlistFilter` is a `Filter` which contains a mapping of allowed Types
|
|
88
99
|
///
|
|
89
|
-
|
|
100
|
+
access(all) resource AllowlistFilter: Filter {
|
|
90
101
|
// allowedTypes
|
|
91
102
|
// Represents the set of underlying types which are allowed to be
|
|
92
103
|
// returned by a RestrictedChildAccount. The filter will borrow
|
|
@@ -98,7 +109,7 @@ pub contract CapabilityFilter {
|
|
|
98
109
|
///
|
|
99
110
|
/// @param type: The type to add to the allowed types mapping
|
|
100
111
|
///
|
|
101
|
-
|
|
112
|
+
access(Owner | Add) fun addType(_ type: Type) {
|
|
102
113
|
self.allowedTypes.insert(key: type, true)
|
|
103
114
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: true)
|
|
104
115
|
}
|
|
@@ -107,18 +118,26 @@ pub contract CapabilityFilter {
|
|
|
107
118
|
///
|
|
108
119
|
/// @param type: The type to remove from the denied types mapping
|
|
109
120
|
///
|
|
110
|
-
|
|
121
|
+
access(Owner | Delete) fun removeType(_ type: Type) {
|
|
111
122
|
if let removed = self.allowedTypes.remove(key: type) {
|
|
112
123
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: false)
|
|
113
124
|
}
|
|
114
125
|
}
|
|
126
|
+
|
|
127
|
+
/// Removes all types from the mapping of denied types
|
|
128
|
+
///
|
|
129
|
+
access(Owner | Delete) fun removeAllTypes() {
|
|
130
|
+
for type in self.allowedTypes.keys {
|
|
131
|
+
self.removeType(type)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
115
134
|
|
|
116
135
|
/// Determines if a requested capability is allowed by this `Filter`
|
|
117
136
|
///
|
|
118
137
|
/// @param cap: The capability to check
|
|
119
138
|
/// @return: true if the capability is allowed, false otherwise
|
|
120
139
|
///
|
|
121
|
-
|
|
140
|
+
access(all) view fun allowed(cap: Capability): Bool {
|
|
122
141
|
if let item = cap.borrow<&AnyResource>() {
|
|
123
142
|
return self.allowedTypes.containsKey(item.getType())
|
|
124
143
|
}
|
|
@@ -131,7 +150,7 @@ pub contract CapabilityFilter {
|
|
|
131
150
|
/// @return A struct containing details about this filter including this Filter's Type indexed on the `type`
|
|
132
151
|
/// key as well as types allowed indexed on the `allowedTypes` key
|
|
133
152
|
///
|
|
134
|
-
|
|
153
|
+
access(all) view fun getDetails(): AnyStruct {
|
|
135
154
|
return {
|
|
136
155
|
"type": self.getType(),
|
|
137
156
|
"allowedTypes": self.allowedTypes.keys
|
|
@@ -145,13 +164,13 @@ pub contract CapabilityFilter {
|
|
|
145
164
|
|
|
146
165
|
/// AllowAllFilter is a passthrough, all requested capabilities are allowed
|
|
147
166
|
///
|
|
148
|
-
|
|
167
|
+
access(all) resource AllowAllFilter: Filter {
|
|
149
168
|
/// Determines if a requested capability is allowed by this `Filter`
|
|
150
169
|
///
|
|
151
170
|
/// @param cap: The capability to check
|
|
152
171
|
/// @return: true since this filter is a passthrough
|
|
153
172
|
///
|
|
154
|
-
|
|
173
|
+
access(all) view fun allowed(cap: Capability): Bool {
|
|
155
174
|
return true
|
|
156
175
|
}
|
|
157
176
|
|
|
@@ -160,7 +179,7 @@ pub contract CapabilityFilter {
|
|
|
160
179
|
/// @return A struct containing details about this filter including this Filter's Type indexed on the `type`
|
|
161
180
|
/// key
|
|
162
181
|
///
|
|
163
|
-
|
|
182
|
+
access(all) view fun getDetails(): AnyStruct {
|
|
164
183
|
return {
|
|
165
184
|
"type": self.getType()
|
|
166
185
|
}
|
|
@@ -172,7 +191,7 @@ pub contract CapabilityFilter {
|
|
|
172
191
|
/// @param t: The type of `Filter` to create
|
|
173
192
|
/// @return: A new instance of the given `Filter` type
|
|
174
193
|
///
|
|
175
|
-
|
|
194
|
+
access(all) fun createFilter(_ t: Type): @{Filter} {
|
|
176
195
|
post {
|
|
177
196
|
result.getType() == t
|
|
178
197
|
}
|
|
@@ -194,6 +213,5 @@ pub contract CapabilityFilter {
|
|
|
194
213
|
|
|
195
214
|
self.StoragePath = StoragePath(identifier: identifier)!
|
|
196
215
|
self.PublicPath = PublicPath(identifier: identifier)!
|
|
197
|
-
self.PrivatePath = PrivatePath(identifier: identifier)!
|
|
198
216
|
}
|
|
199
|
-
}
|
|
217
|
+
}
|