@flowtyio/flow-contracts 0.1.0-beta.22 → 0.1.0-beta.24
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/dapper/offers/DapperOffersV2.cdc +35 -28
- package/contracts/dapper/offers/OffersV2.cdc +13 -30
- package/contracts/dapper/offers/Resolver.cdc +8 -2
- package/contracts/hybrid-custody/CapabilityDelegator.cdc +2 -3
- package/contracts/hybrid-custody/CapabilityFactory.cdc +3 -4
- package/contracts/hybrid-custody/CapabilityFilter.cdc +6 -7
- package/contracts/hybrid-custody/HybridCustody.cdc +12 -12
- package/contracts/hybrid-custody/factories/FTVaultFactory.cdc +2 -1
- package/contracts/hybrid-custody/factories/{NFTProviderAndCollectionPublicFactory.cdc → NFTProviderAndCollectionFactory.cdc} +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@ import "OffersV2"
|
|
|
2
2
|
import "FungibleToken"
|
|
3
3
|
import "NonFungibleToken"
|
|
4
4
|
import "Resolver"
|
|
5
|
+
import "ViewResolver"
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
// DapperOffersV2
|
|
7
9
|
//
|
|
@@ -12,6 +14,9 @@ import "Resolver"
|
|
|
12
14
|
// get details on Offers contained within it.
|
|
13
15
|
//
|
|
14
16
|
access(all) contract DapperOffersV2 {
|
|
17
|
+
|
|
18
|
+
access(all) entitlement Manager
|
|
19
|
+
access(all) entitlement ProxyManager
|
|
15
20
|
// DapperOffersV2
|
|
16
21
|
// This contract has been deployed.
|
|
17
22
|
// Event consumers can now expect events from this contract.
|
|
@@ -51,7 +56,7 @@ access(all) contract DapperOffersV2 {
|
|
|
51
56
|
//
|
|
52
57
|
access(all) fun addProxyCapability(
|
|
53
58
|
account: Address,
|
|
54
|
-
cap: Capability
|
|
59
|
+
cap: Capability<auth(ProxyManager) &DapperOffer>
|
|
55
60
|
)
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -62,8 +67,8 @@ access(all) contract DapperOffersV2 {
|
|
|
62
67
|
// createOffer
|
|
63
68
|
// Allows the DapperOffer owner to create Offers.
|
|
64
69
|
//
|
|
65
|
-
access(
|
|
66
|
-
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.
|
|
70
|
+
access(Manager) fun createOffer(
|
|
71
|
+
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>,
|
|
67
72
|
nftReceiverCapability: Capability<&{NonFungibleToken.CollectionPublic}>,
|
|
68
73
|
nftType: Type,
|
|
69
74
|
amount: UFix64,
|
|
@@ -76,7 +81,7 @@ access(all) contract DapperOffersV2 {
|
|
|
76
81
|
// removeOffer
|
|
77
82
|
// Allows the DapperOffer owner to remove offers
|
|
78
83
|
//
|
|
79
|
-
access(
|
|
84
|
+
access(Manager | ProxyManager) fun removeOffer(offerId: UInt64)
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
// DapperOfferProxyManager
|
|
@@ -86,11 +91,11 @@ access(all) contract DapperOffersV2 {
|
|
|
86
91
|
// removeOffer
|
|
87
92
|
// Allows the DapperOffer owner to remove offers
|
|
88
93
|
//
|
|
89
|
-
access(
|
|
94
|
+
access(Manager | ProxyManager) fun removeOffer(offerId: UInt64)
|
|
90
95
|
// removeOfferFromProxy
|
|
91
96
|
// Allows the DapperOffer proxy owner to remove offers
|
|
92
97
|
//
|
|
93
|
-
access(
|
|
98
|
+
access(ProxyManager) fun removeOfferFromProxy(account: Address, offerId: UInt64)
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
|
|
@@ -98,18 +103,18 @@ access(all) contract DapperOffersV2 {
|
|
|
98
103
|
// A resource that allows its owner to manage a list of Offers, and anyone to interact with them
|
|
99
104
|
// in order to query their details and accept the Offers for NFTs that they represent.
|
|
100
105
|
//
|
|
101
|
-
access(all) resource DapperOffer :
|
|
106
|
+
access(all) resource DapperOffer :DapperOfferManager, DapperOfferPublic, DapperOfferProxyManager {
|
|
102
107
|
// The dictionary of Address to DapperOfferProxyManager capabilities.
|
|
103
|
-
access(self) var removeOfferCapability: {Address:Capability
|
|
108
|
+
access(self) var removeOfferCapability: {Address:Capability<auth(ProxyManager) &DapperOffer>}
|
|
104
109
|
// The dictionary of Offer uuids to Offer resources.
|
|
105
110
|
access(self) var offers: @{UInt64:OffersV2.Offer}
|
|
106
111
|
|
|
107
112
|
// addProxyCapability
|
|
108
113
|
// Assign proxy capabilities (DapperOfferProxyManager) to an DapperOffer resource.
|
|
109
114
|
//
|
|
110
|
-
access(all) fun addProxyCapability(account: Address, cap: Capability
|
|
115
|
+
access(all) fun addProxyCapability(account: Address, cap: Capability<auth(ProxyManager) &DapperOffer>) {
|
|
111
116
|
pre {
|
|
112
|
-
cap
|
|
117
|
+
cap != nil: "Invalid admin capability"
|
|
113
118
|
}
|
|
114
119
|
self.removeOfferCapability[account] = cap
|
|
115
120
|
}
|
|
@@ -117,23 +122,23 @@ access(all) contract DapperOffersV2 {
|
|
|
117
122
|
// removeOfferFromProxy
|
|
118
123
|
// Allows the DapperOffer proxy owner to remove offers
|
|
119
124
|
//
|
|
120
|
-
access(
|
|
125
|
+
access(ProxyManager) fun removeOfferFromProxy(account: Address, offerId: UInt64) {
|
|
121
126
|
pre {
|
|
122
127
|
self.removeOfferCapability[account] != nil:
|
|
123
128
|
"Cannot remove offers until the token admin has deposited the account registration capability"
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
let adminRef = self.removeOfferCapability[account]
|
|
131
|
+
let adminRef = self.removeOfferCapability[account]!
|
|
127
132
|
|
|
128
|
-
adminRef.removeOffer(offerId: offerId)
|
|
133
|
+
adminRef.borrow()!.removeOffer(offerId: offerId)
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
|
|
132
137
|
// createOffer
|
|
133
138
|
// Allows the DapperOffer owner to create Offers.
|
|
134
139
|
//
|
|
135
|
-
access(
|
|
136
|
-
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.
|
|
140
|
+
access(Manager) fun createOffer(
|
|
141
|
+
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>,
|
|
137
142
|
nftReceiverCapability: Capability<&{NonFungibleToken.CollectionPublic}>,
|
|
138
143
|
nftType: Type,
|
|
139
144
|
amount: UFix64,
|
|
@@ -165,22 +170,28 @@ access(all) contract DapperOffersV2 {
|
|
|
165
170
|
// removeOffer
|
|
166
171
|
// Remove an Offer that has not yet been accepted from the collection and destroy it.
|
|
167
172
|
//
|
|
168
|
-
access(
|
|
169
|
-
|
|
173
|
+
access(Manager | ProxyManager) fun removeOffer(offerId: UInt64) {
|
|
174
|
+
let offer <- self.offers.remove(key: offerId) ?? panic("missing offer")
|
|
175
|
+
// offer.customDestroy()
|
|
176
|
+
destroy offer
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
// getOfferIds
|
|
173
180
|
// Returns an array of the Offer resource IDs that are in the collection
|
|
174
181
|
//
|
|
175
|
-
access(all) fun getOfferIds(): [UInt64] {
|
|
182
|
+
access(all) view fun getOfferIds(): [UInt64] {
|
|
176
183
|
return self.offers.keys
|
|
177
184
|
}
|
|
178
185
|
|
|
179
186
|
// borrowOffer
|
|
180
187
|
// Returns a read-only view of the Offer for the given OfferID if it is contained by this collection.
|
|
181
188
|
//
|
|
182
|
-
access(all) fun borrowOffer(offerId: UInt64): &{OffersV2.OfferPublic}? {
|
|
183
|
-
|
|
189
|
+
access(all) view fun borrowOffer(offerId: UInt64): &{OffersV2.OfferPublic}? {
|
|
190
|
+
if self.offers[offerId] != nil {
|
|
191
|
+
return (&self.offers[offerId] as &{OffersV2.OfferPublic}?)!
|
|
192
|
+
} else {
|
|
193
|
+
return nil
|
|
194
|
+
}
|
|
184
195
|
}
|
|
185
196
|
|
|
186
197
|
// cleanup
|
|
@@ -206,13 +217,9 @@ access(all) contract DapperOffersV2 {
|
|
|
206
217
|
emit DapperOfferInitialized(DapperOfferResourceId: self.uuid)
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// destroy self.offers
|
|
213
|
-
// // Let event consumers know that this storefront exists.
|
|
214
|
-
// emit DapperOfferDestroyed(DapperOfferResourceId: self.uuid)
|
|
215
|
-
// }
|
|
220
|
+
access(all) event ResourceDestroyed(
|
|
221
|
+
id: UInt64 = self.uuid
|
|
222
|
+
)
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
// createDapperOffer
|
|
@@ -231,4 +238,4 @@ access(all) contract DapperOffersV2 {
|
|
|
231
238
|
|
|
232
239
|
emit DapperOffersInitialized()
|
|
233
240
|
}
|
|
234
|
-
}
|
|
241
|
+
}
|
|
@@ -2,10 +2,10 @@ import "FungibleToken"
|
|
|
2
2
|
import "NonFungibleToken"
|
|
3
3
|
import "DapperUtilityCoin"
|
|
4
4
|
import "MetadataViews"
|
|
5
|
-
import "Resolver"
|
|
6
5
|
import "ViewResolver"
|
|
6
|
+
import "Resolver"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/// OffersV2
|
|
9
9
|
//
|
|
10
10
|
// Contract holds the Offer resource and a public method to create them.
|
|
11
11
|
//
|
|
@@ -141,6 +141,10 @@ access(all) contract OffersV2 {
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
access(all) resource Offer: OfferPublic {
|
|
144
|
+
|
|
145
|
+
access(all) event ResourceDestroyed(purchased: Bool = self.details.purchased, offerId: UInt64 = self.details.offerId)
|
|
146
|
+
|
|
147
|
+
|
|
144
148
|
// The OfferDetails struct of the Offer
|
|
145
149
|
access(self) let details: OfferDetails
|
|
146
150
|
// The vault which will handle the payment if the Offer is accepted.
|
|
@@ -151,7 +155,7 @@ access(all) contract OffersV2 {
|
|
|
151
155
|
access(contract) let resolverCapability: Capability<&{Resolver.ResolverPublic}>
|
|
152
156
|
|
|
153
157
|
init(
|
|
154
|
-
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.
|
|
158
|
+
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>,
|
|
155
159
|
nftReceiverCapability: Capability<&{NonFungibleToken.CollectionPublic}>,
|
|
156
160
|
nftType: Type,
|
|
157
161
|
amount: UFix64,
|
|
@@ -252,8 +256,8 @@ access(all) contract OffersV2 {
|
|
|
252
256
|
|
|
253
257
|
// If a DUC vault is being used for payment we must assert that no DUC is leaking from the transactions.
|
|
254
258
|
let isDucVault = self.vaultRefCapability.isInstance(
|
|
255
|
-
Type<Capability<&
|
|
256
|
-
)
|
|
259
|
+
Type<Capability<&DapperUtilityCoin.Vault>>()
|
|
260
|
+
) // todo: check if this is correct
|
|
257
261
|
|
|
258
262
|
if isDucVault {
|
|
259
263
|
assert(self.vaultRefCapability.borrow()!.balance == initalDucSupply, message: "DUC is leaking")
|
|
@@ -279,14 +283,14 @@ access(all) contract OffersV2 {
|
|
|
279
283
|
// getDetails
|
|
280
284
|
// Return Offer details
|
|
281
285
|
//
|
|
282
|
-
access(all) fun getDetails(): OfferDetails {
|
|
286
|
+
access(all) view fun getDetails(): OfferDetails {
|
|
283
287
|
return self.details
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
// getRoyaltyInfo
|
|
287
291
|
// Return royalty details
|
|
288
292
|
//
|
|
289
|
-
access(all) fun getRoyaltyInfo(): {Address:UFix64} {
|
|
293
|
+
access(all) view fun getRoyaltyInfo(): {Address:UFix64} {
|
|
290
294
|
let royaltyInfo: {Address:UFix64} = {}
|
|
291
295
|
|
|
292
296
|
for royalty in self.details.royalties {
|
|
@@ -294,31 +298,11 @@ access(all) contract OffersV2 {
|
|
|
294
298
|
}
|
|
295
299
|
return royaltyInfo;
|
|
296
300
|
}
|
|
297
|
-
|
|
298
|
-
// destroy() {
|
|
299
|
-
// if !self.details.purchased {
|
|
300
|
-
// emit OfferCompleted(
|
|
301
|
-
// purchased: self.details.purchased,
|
|
302
|
-
// acceptingAddress: nil,
|
|
303
|
-
// offerAddress: self.nftReceiverCapability.address,
|
|
304
|
-
// offerId: self.details.offerId,
|
|
305
|
-
// nftType: self.details.nftType,
|
|
306
|
-
// offerAmount: self.details.offerAmount,
|
|
307
|
-
// royalties: self.getRoyaltyInfo(),
|
|
308
|
-
// offerType: self.details.offerParamsString["_type"] ?? "unknown",
|
|
309
|
-
// offerParamsString: self.details.offerParamsString,
|
|
310
|
-
// offerParamsUFix64: self.details.offerParamsUFix64,
|
|
311
|
-
// offerParamsUInt64: self.details.offerParamsUInt64,
|
|
312
|
-
// paymentVaultType: self.details.paymentVaultType,
|
|
313
|
-
// nftId: nil,
|
|
314
|
-
// )
|
|
315
|
-
// }
|
|
316
|
-
// }
|
|
317
301
|
}
|
|
318
302
|
|
|
319
303
|
// makeOffer
|
|
320
304
|
access(all) fun makeOffer(
|
|
321
|
-
vaultRefCapability:
|
|
305
|
+
vaultRefCapability: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>,
|
|
322
306
|
nftReceiverCapability: Capability<&{NonFungibleToken.CollectionPublic}>,
|
|
323
307
|
nftType: Type,
|
|
324
308
|
amount: UFix64,
|
|
@@ -341,5 +325,4 @@ access(all) contract OffersV2 {
|
|
|
341
325
|
)
|
|
342
326
|
return <-newOfferResource
|
|
343
327
|
}
|
|
344
|
-
}
|
|
345
|
-
|
|
328
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import "NonFungibleToken"
|
|
2
2
|
import "MetadataViews"
|
|
3
|
-
import "ViewResolver"
|
|
4
3
|
import "TopShot"
|
|
4
|
+
import "ViewResolver"
|
|
5
5
|
|
|
6
|
+
// Resolver
|
|
7
|
+
//
|
|
8
|
+
// Contract holds the Offer exchange resolution rules.
|
|
9
|
+
//
|
|
10
|
+
// When an Offer is created a ResolverType is included. The ResolverType is also
|
|
11
|
+
// passed into checkOfferResolver() from the Offers contract on exchange validation
|
|
6
12
|
access(all) contract Resolver {
|
|
7
13
|
// Current list of supported resolution rules.
|
|
8
14
|
access(all) enum ResolverType: UInt8 {
|
|
@@ -35,7 +41,7 @@ access(all) contract Resolver {
|
|
|
35
41
|
if offerParamsString["resolver"] == ResolverType.NFT.rawValue.toString() {
|
|
36
42
|
assert(item.id.toString() == offerParamsString["nftId"], message: "item NFT does not have specified ID")
|
|
37
43
|
return true
|
|
38
|
-
}
|
|
44
|
+
} else if offerParamsString["resolver"] == ResolverType.TopShotEdition.rawValue.toString() {
|
|
39
45
|
// // Get the Top Shot specific metadata for this NFT
|
|
40
46
|
let view = item.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
|
|
41
47
|
let metadata = view as! TopShot.TopShotMomentMetadataView
|
|
@@ -15,7 +15,6 @@ access(all) contract CapabilityDelegator {
|
|
|
15
15
|
access(all) let PublicPath: PublicPath
|
|
16
16
|
|
|
17
17
|
access(all) entitlement Get
|
|
18
|
-
access(all) entitlement Owner
|
|
19
18
|
access(all) entitlement Add
|
|
20
19
|
access(all) entitlement Delete
|
|
21
20
|
|
|
@@ -126,7 +125,7 @@ access(all) contract CapabilityDelegator {
|
|
|
126
125
|
/// @param cap: Capability to add
|
|
127
126
|
/// @param isPublic: Whether the Capability should be public or private
|
|
128
127
|
///
|
|
129
|
-
access(
|
|
128
|
+
access(Add) fun addCapability(cap: Capability, isPublic: Bool) {
|
|
130
129
|
pre {
|
|
131
130
|
cap.check<&AnyResource>(): "Invalid Capability provided"
|
|
132
131
|
}
|
|
@@ -142,7 +141,7 @@ access(all) contract CapabilityDelegator {
|
|
|
142
141
|
///
|
|
143
142
|
/// @param cap: Capability to remove
|
|
144
143
|
///
|
|
145
|
-
access(
|
|
144
|
+
access(Delete) fun removeCapability(cap: Capability) {
|
|
146
145
|
if let removedPublic = self.publicCapabilities.remove(key: cap.getType()) {
|
|
147
146
|
emit DelegatorUpdated(id: self.uuid, capabilityType: cap.getType(), isPublic: true, active: false)
|
|
148
147
|
}
|
|
@@ -18,7 +18,6 @@ access(all) contract CapabilityFactory {
|
|
|
18
18
|
access(all) let StoragePath: StoragePath
|
|
19
19
|
access(all) let PublicPath: PublicPath
|
|
20
20
|
|
|
21
|
-
access(all) entitlement Owner
|
|
22
21
|
access(all) entitlement Add
|
|
23
22
|
access(all) entitlement Delete
|
|
24
23
|
|
|
@@ -64,7 +63,7 @@ access(all) contract CapabilityFactory {
|
|
|
64
63
|
/// @param t: Type of Capability the Factory retrieves
|
|
65
64
|
/// @param f: Factory to add
|
|
66
65
|
///
|
|
67
|
-
access(
|
|
66
|
+
access(Add) fun addFactory(_ t: Type, _ f: {CapabilityFactory.Factory}) {
|
|
68
67
|
pre {
|
|
69
68
|
!self.factories.containsKey(t): "Factory of given type already exists"
|
|
70
69
|
}
|
|
@@ -76,7 +75,7 @@ access(all) contract CapabilityFactory {
|
|
|
76
75
|
/// @param t: Type of Capability the Factory retrieves
|
|
77
76
|
/// @param f: Factory to replace existing Factory
|
|
78
77
|
///
|
|
79
|
-
access(
|
|
78
|
+
access(Add) fun updateFactory(_ t: Type, _ f: {CapabilityFactory.Factory}) {
|
|
80
79
|
self.factories[t] = f
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -84,7 +83,7 @@ access(all) contract CapabilityFactory {
|
|
|
84
83
|
///
|
|
85
84
|
/// @param t: Type the Factory is indexed on
|
|
86
85
|
///
|
|
87
|
-
access(
|
|
86
|
+
access(Delete) fun removeFactory(_ t: Type): {CapabilityFactory.Factory}? {
|
|
88
87
|
return self.factories.remove(key: t)
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -13,7 +13,6 @@ access(all) contract CapabilityFilter {
|
|
|
13
13
|
access(all) let StoragePath: StoragePath
|
|
14
14
|
access(all) let PublicPath: PublicPath
|
|
15
15
|
|
|
16
|
-
access(all) entitlement Owner
|
|
17
16
|
access(all) entitlement Add
|
|
18
17
|
access(all) entitlement Delete
|
|
19
18
|
|
|
@@ -42,7 +41,7 @@ access(all) contract CapabilityFilter {
|
|
|
42
41
|
///
|
|
43
42
|
/// @param type: The type to add to the denied types mapping
|
|
44
43
|
///
|
|
45
|
-
access(
|
|
44
|
+
access(Add) fun addType(_ type: Type) {
|
|
46
45
|
self.deniedTypes.insert(key: type, true)
|
|
47
46
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: true)
|
|
48
47
|
}
|
|
@@ -51,7 +50,7 @@ access(all) contract CapabilityFilter {
|
|
|
51
50
|
///
|
|
52
51
|
/// @param type: The type to remove from the denied types mapping
|
|
53
52
|
///
|
|
54
|
-
access(
|
|
53
|
+
access(Delete) fun removeType(_ type: Type) {
|
|
55
54
|
if let removed = self.deniedTypes.remove(key: type) {
|
|
56
55
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: false)
|
|
57
56
|
}
|
|
@@ -59,7 +58,7 @@ access(all) contract CapabilityFilter {
|
|
|
59
58
|
|
|
60
59
|
/// Removes all types from the mapping of denied types
|
|
61
60
|
///
|
|
62
|
-
access(
|
|
61
|
+
access(Delete) fun removeAllTypes() {
|
|
63
62
|
for type in self.deniedTypes.keys {
|
|
64
63
|
self.removeType(type)
|
|
65
64
|
}
|
|
@@ -109,7 +108,7 @@ access(all) contract CapabilityFilter {
|
|
|
109
108
|
///
|
|
110
109
|
/// @param type: The type to add to the allowed types mapping
|
|
111
110
|
///
|
|
112
|
-
access(
|
|
111
|
+
access(Add) fun addType(_ type: Type) {
|
|
113
112
|
self.allowedTypes.insert(key: type, true)
|
|
114
113
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: true)
|
|
115
114
|
}
|
|
@@ -118,7 +117,7 @@ access(all) contract CapabilityFilter {
|
|
|
118
117
|
///
|
|
119
118
|
/// @param type: The type to remove from the denied types mapping
|
|
120
119
|
///
|
|
121
|
-
access(
|
|
120
|
+
access(Delete) fun removeType(_ type: Type) {
|
|
122
121
|
if let removed = self.allowedTypes.remove(key: type) {
|
|
123
122
|
emit FilterUpdated(id: self.uuid, filterType: self.getType(), type: type, active: false)
|
|
124
123
|
}
|
|
@@ -126,7 +125,7 @@ access(all) contract CapabilityFilter {
|
|
|
126
125
|
|
|
127
126
|
/// Removes all types from the mapping of denied types
|
|
128
127
|
///
|
|
129
|
-
access(
|
|
128
|
+
access(Delete) fun removeAllTypes() {
|
|
130
129
|
for type in self.allowedTypes.keys {
|
|
131
130
|
self.removeType(type)
|
|
132
131
|
}
|
|
@@ -115,7 +115,7 @@ access(all) contract HybridCustody {
|
|
|
115
115
|
/// access control are managed through the child account.
|
|
116
116
|
access(Owner) fun publishToParent(
|
|
117
117
|
parentAddress: Address,
|
|
118
|
-
factory: Capability<&
|
|
118
|
+
factory: Capability<&CapabilityFactory.Manager>,
|
|
119
119
|
filter: Capability<&{CapabilityFilter.Filter}>
|
|
120
120
|
) {
|
|
121
121
|
pre {
|
|
@@ -140,7 +140,7 @@ access(all) contract HybridCustody {
|
|
|
140
140
|
// setCapabilityFactoryForParent
|
|
141
141
|
// Override the existing CapabilityFactory Capability for a given parent. This will allow the owner of the
|
|
142
142
|
// account to start managing their own factory of capabilities to be able to retrieve
|
|
143
|
-
access(Owner) fun setCapabilityFactoryForParent(parent: Address, cap: Capability<&
|
|
143
|
+
access(Owner) fun setCapabilityFactoryForParent(parent: Address, cap: Capability<&CapabilityFactory.Manager>) {
|
|
144
144
|
pre {
|
|
145
145
|
cap.check(): "Invalid CapabilityFactory.Getter Capability provided"
|
|
146
146
|
}
|
|
@@ -529,7 +529,7 @@ access(all) contract HybridCustody {
|
|
|
529
529
|
/// account. The CapabilityFactory returns Capabilities which can be casted to their appropriate types once
|
|
530
530
|
/// obtained, but only if the child account has configured their factory to allow it. For instance, a
|
|
531
531
|
/// ChildAccount might choose to expose NonFungibleToken.Provider, but not FungibleToken.Provider
|
|
532
|
-
access(self) var factory: Capability<&
|
|
532
|
+
access(self) var factory: Capability<&CapabilityFactory.Manager>
|
|
533
533
|
|
|
534
534
|
/// The CapabilityFilter is a restriction put at the front of obtaining any non-public Capability. Some wallets
|
|
535
535
|
/// might want to give access to NonFungibleToken.Provider, but only to **some** of the collections it manages,
|
|
@@ -541,7 +541,7 @@ access(all) contract HybridCustody {
|
|
|
541
541
|
/// certain type. When using the CapabilityDelegator, you do not have the ability to specify which path a
|
|
542
542
|
/// capability came from. For instance, Dapper Wallet might choose to expose a Capability to their Full TopShot
|
|
543
543
|
/// collection, but only to the path that the collection exists in.
|
|
544
|
-
access(self) let delegator: Capability<auth(CapabilityDelegator.Get) &
|
|
544
|
+
access(self) let delegator: Capability<auth(CapabilityDelegator.Get) &CapabilityDelegator.Delegator>
|
|
545
545
|
|
|
546
546
|
/// managerCapabilityFilter is a component optionally given to a child account when a manager redeems it. If
|
|
547
547
|
/// this filter is not nil, any Capability returned through the `getCapability` function checks that the
|
|
@@ -580,7 +580,7 @@ access(all) contract HybridCustody {
|
|
|
580
580
|
|
|
581
581
|
/// Sets the CapabiltyFactory.Manager Capability
|
|
582
582
|
///
|
|
583
|
-
access(contract) fun setCapabilityFactory(cap: Capability<&
|
|
583
|
+
access(contract) fun setCapabilityFactory(cap: Capability<&CapabilityFactory.Manager>) {
|
|
584
584
|
self.factory = cap
|
|
585
585
|
}
|
|
586
586
|
|
|
@@ -730,9 +730,9 @@ access(all) contract HybridCustody {
|
|
|
730
730
|
|
|
731
731
|
init(
|
|
732
732
|
_ childCap: Capability<&{BorrowableAccount, OwnedAccountPublic, ViewResolver.Resolver}>,
|
|
733
|
-
_ factory: Capability<&
|
|
733
|
+
_ factory: Capability<&CapabilityFactory.Manager>,
|
|
734
734
|
_ filter: Capability<&{CapabilityFilter.Filter}>,
|
|
735
|
-
_ delegator: Capability<auth(CapabilityDelegator.Get) &
|
|
735
|
+
_ delegator: Capability<auth(CapabilityDelegator.Get) &CapabilityDelegator.Delegator>,
|
|
736
736
|
_ parent: Address
|
|
737
737
|
) {
|
|
738
738
|
pre {
|
|
@@ -853,7 +853,7 @@ access(all) contract HybridCustody {
|
|
|
853
853
|
///
|
|
854
854
|
access(Owner) fun publishToParent(
|
|
855
855
|
parentAddress: Address,
|
|
856
|
-
factory: Capability<&
|
|
856
|
+
factory: Capability<&CapabilityFactory.Manager>,
|
|
857
857
|
filter: Capability<&{CapabilityFilter.Filter}>
|
|
858
858
|
) {
|
|
859
859
|
pre {
|
|
@@ -880,7 +880,7 @@ access(all) contract HybridCustody {
|
|
|
880
880
|
let pubCap = acct.capabilities.storage.issue<&{CapabilityDelegator.GetterPublic}>(capDelegatorStorage)
|
|
881
881
|
acct.capabilities.publish(pubCap, at: capDelegatorPublic)
|
|
882
882
|
|
|
883
|
-
let delegator = acct.capabilities.storage.issue<auth(CapabilityDelegator.Get) &
|
|
883
|
+
let delegator = acct.capabilities.storage.issue<auth(CapabilityDelegator.Get) &CapabilityDelegator.Delegator>(capDelegatorStorage)
|
|
884
884
|
assert(delegator.check(), message: "failed to setup capability delegator for parent address")
|
|
885
885
|
|
|
886
886
|
let borrowableCap = self.borrowAccount().capabilities.storage.issue<&{BorrowableAccount, OwnedAccountPublic, ViewResolver.Resolver}>(
|
|
@@ -1109,7 +1109,7 @@ access(all) contract HybridCustody {
|
|
|
1109
1109
|
///
|
|
1110
1110
|
access(Owner) fun setCapabilityFactoryForParent(
|
|
1111
1111
|
parent: Address,
|
|
1112
|
-
cap: Capability<&
|
|
1112
|
+
cap: Capability<&CapabilityFactory.Manager>
|
|
1113
1113
|
) {
|
|
1114
1114
|
let p = self.borrowChildAccount(parent: parent) ?? panic("could not find parent address")
|
|
1115
1115
|
p.setCapabilityFactory(cap: cap)
|
|
@@ -1124,9 +1124,9 @@ access(all) contract HybridCustody {
|
|
|
1124
1124
|
|
|
1125
1125
|
/// Retrieves a reference to the Delegator associated with the given parent account if one exists.
|
|
1126
1126
|
///
|
|
1127
|
-
access(Owner) fun borrowCapabilityDelegatorForParent(parent: Address): auth(CapabilityDelegator.
|
|
1127
|
+
access(Owner) fun borrowCapabilityDelegatorForParent(parent: Address): auth(CapabilityDelegator.Get, CapabilityDelegator.Add, CapabilityDelegator.Delete) &CapabilityDelegator.Delegator? {
|
|
1128
1128
|
let identifier = HybridCustody.getCapabilityDelegatorIdentifier(parent)
|
|
1129
|
-
return self.borrowAccount().storage.borrow<auth(CapabilityDelegator.
|
|
1129
|
+
return self.borrowAccount().storage.borrow<auth(CapabilityDelegator.Get, CapabilityDelegator.Add, CapabilityDelegator.Delete) &CapabilityDelegator.Delegator>(from: StoragePath(identifier: identifier)!)
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
1132
|
/// Adds the provided Capability to the Delegator associated with the given parent account.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "CapabilityFactory"
|
|
2
2
|
import "NonFungibleToken"
|
|
3
3
|
|
|
4
|
-
access(all) contract
|
|
4
|
+
access(all) contract NFTProviderAndCollectionFactory {
|
|
5
5
|
access(all) struct Factory: CapabilityFactory.Factory {
|
|
6
6
|
access(all) view fun getCapability(acct: auth(Capabilities) &Account, controllerID: UInt64): Capability? {
|
|
7
7
|
if let con = acct.capabilities.storage.getController(byCapabilityID: controllerID) {
|