@flowtyio/flow-contracts 0.1.0-beta.20 → 0.1.0-beta.22

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.
@@ -1,7 +1,7 @@
1
1
  import "CapabilityFactory"
2
2
  import "NonFungibleToken"
3
3
 
4
- access(all) contract NFTProviderAndCollectionFactory {
4
+ access(all) contract NFTProviderAndCollectionPublicFactory {
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) {
@@ -45,8 +45,12 @@ access(all) contract LostAndFound {
45
45
  access(all) event DepositorTokensAdded(uuid: UInt64, tokens: UFix64, balance: UFix64)
46
46
  access(all) event DepositorTokensWithdrawn(uuid: UInt64, tokens: UFix64, balance: UFix64)
47
47
 
48
+ // Used by the @Depositor resource and controls whether the depositor can be used
49
+ // or not to send resources to the LostAndFound
48
50
  access(all) entitlement Deposit
49
- access(all) entitlement Withdraw
51
+
52
+ // Used by the @Depositor resource to manage settings such as low token threshold
53
+ access(all) entitlement Owner
50
54
 
51
55
  // Placeholder receiver so that any resource can be supported, not just FT and NFT Receivers
52
56
  access(all) resource interface AnyResourceReceiver {
@@ -54,7 +58,7 @@ access(all) contract LostAndFound {
54
58
  }
55
59
 
56
60
  access(all) resource DepositEstimate {
57
- access(Withdraw) var item: @AnyResource?
61
+ access(self) var item: @AnyResource?
58
62
  access(all) let storageFee: UFix64
59
63
 
60
64
  init(item: @AnyResource, storageFee: UFix64) {
@@ -62,7 +66,7 @@ access(all) contract LostAndFound {
62
66
  self.storageFee = storageFee
63
67
  }
64
68
 
65
- access(Withdraw) fun withdraw(): @AnyResource {
69
+ access(all) fun withdraw(): @AnyResource {
66
70
  let item <- self.item <- nil
67
71
  return <-item!
68
72
  }
@@ -140,7 +144,7 @@ access(all) contract LostAndFound {
140
144
  return nil
141
145
  }
142
146
 
143
- access(Withdraw) fun withdraw(receiver: Capability) {
147
+ access(contract) fun withdraw(receiver: Capability) {
144
148
  pre {
145
149
  receiver.address == self.redeemer: "receiver address and redeemer must match"
146
150
  !self.redeemed: "already redeemed"
@@ -344,7 +348,7 @@ access(all) contract LostAndFound {
344
348
  }
345
349
 
346
350
  // Redeem a specific ticket instead of all of a certain type.
347
- access(Withdraw) fun redeem(type: Type, ticketID: UInt64, receiver: Capability) {
351
+ access(all) fun redeem(type: Type, ticketID: UInt64, receiver: Capability) {
348
352
  pre {
349
353
  receiver.address == self.redeemer: "receiver must match the redeemer of this shelf"
350
354
  self.bins.containsKey(type.identifier): "no bin for provided type"
@@ -430,7 +434,7 @@ access(all) contract LostAndFound {
430
434
  storagePayment.getType() == Type<@FlowToken.Vault>(): "storage payment must be in flow tokens"
431
435
  }
432
436
  let receiver = LostAndFound.account
433
- .capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver)!
437
+ .capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver)
434
438
  .borrow()!
435
439
 
436
440
 
@@ -513,11 +517,11 @@ access(all) contract LostAndFound {
513
517
  return false
514
518
  }
515
519
 
516
- access(Mutate) fun setLowBalanceThreshold(threshold: UFix64?) {
520
+ access(Owner) fun setLowBalanceThreshold(threshold: UFix64?) {
517
521
  self.lowBalanceThreshold = threshold
518
522
  }
519
523
 
520
- access(Mutate) fun getLowBalanceThreshold(): UFix64? {
524
+ access(Owner) fun getLowBalanceThreshold(): UFix64? {
521
525
  return self.lowBalanceThreshold
522
526
  }
523
527
 
@@ -528,7 +532,7 @@ access(all) contract LostAndFound {
528
532
  display: MetadataViews.Display?
529
533
  ) : UInt64 {
530
534
  let receiver = LostAndFound.account
531
- .capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver)!
535
+ .capabilities.get<&FlowToken.Vault>(/public/flowTokenReceiver)
532
536
  .borrow()!
533
537
 
534
538
  let storageBeforeShelf = LostAndFound.account.storage.used
@@ -577,7 +581,7 @@ access(all) contract LostAndFound {
577
581
  }
578
582
  }
579
583
 
580
- access(Mutate) fun withdrawTokens(amount: UFix64): @{FungibleToken.Vault} {
584
+ access(Owner) fun withdrawTokens(amount: UFix64): @{FungibleToken.Vault} {
581
585
  let tokens <-self.flowTokenVault.withdraw(amount: amount)
582
586
  emit DepositorTokensWithdrawn(uuid: self.uuid, tokens: amount, balance: self.flowTokenVault.balance)
583
587
  self.checkForLowBalance()
@@ -617,7 +621,7 @@ access(all) contract LostAndFound {
617
621
  }
618
622
 
619
623
  access(all) fun borrowShelfManager(): &LostAndFound.ShelfManager {
620
- return self.account.capabilities.get<&LostAndFound.ShelfManager>(LostAndFound.LostAndFoundPublicPath)!.borrow()!
624
+ return self.account.capabilities.get<&LostAndFound.ShelfManager>(LostAndFound.LostAndFoundPublicPath).borrow()!
621
625
  }
622
626
 
623
627
  access(all) fun borrowAllTicketsByType(addr: Address, type: Type): [&LostAndFound.Ticket] {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowtyio/flow-contracts",
3
- "version": "0.1.0-beta.20",
3
+ "version": "0.1.0-beta.22",
4
4
  "main": "index.json",
5
5
  "description": "An NPM package for common flow contracts",
6
6
  "author": "flowtyio",