@flowtyio/flow-contracts 0.1.0-beta.5 → 0.1.0-beta.7

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,8 +1,5 @@
1
- import "StringUtils"
2
-
3
- pub contract AddressUtils {
4
-
5
- pub fun withoutPrefix(_ input: String): String {
1
+ access(all) contract AddressUtils {
2
+ access(all) fun withoutPrefix(_ input: String): String {
6
3
  var address = input
7
4
 
8
5
  // get rid of 0x
@@ -17,7 +14,7 @@ pub contract AddressUtils {
17
14
  return address
18
15
  }
19
16
 
20
- pub fun parseUInt64(_ input: AnyStruct): UInt64? {
17
+ access(all) fun parseUInt64(_ input: AnyStruct): UInt64? {
21
18
  var stringValue = ""
22
19
 
23
20
  if let string = input as? String {
@@ -25,7 +22,7 @@ pub contract AddressUtils {
25
22
  } else if let address = input as? Address {
26
23
  stringValue = address.toString()
27
24
  } else if let type = input as? Type {
28
- let parts = StringUtils.split(type.identifier, ".")
25
+ let parts = type.identifier.split(separator: ".")
29
26
  if parts.length == 1 {
30
27
  return nil
31
28
  }
@@ -45,14 +42,14 @@ pub contract AddressUtils {
45
42
  return r
46
43
  }
47
44
 
48
- pub fun parseAddress(_ input: AnyStruct): Address? {
45
+ access(all) fun parseAddress(_ input: AnyStruct): Address? {
49
46
  if let parsed = self.parseUInt64(input) {
50
47
  return Address(parsed)
51
48
  }
52
49
  return nil
53
50
  }
54
51
 
55
- pub fun isValidAddress(_ input: AnyStruct, forNetwork: String): Bool {
52
+ access(all) fun isValidAddress(_ input: AnyStruct, forNetwork: String): Bool {
56
53
  let address = self.parseUInt64(input)
57
54
  if address == nil {
58
55
  return false
@@ -61,18 +58,19 @@ pub contract AddressUtils {
61
58
  let codeWords: {String: UInt64} = {
62
59
  "MAINNET" : 0,
63
60
  "TESTNET" : 0x6834ba37b3980209,
61
+ "CRESCENDO" : 0x6834ba37b3980209,
64
62
  "EMULATOR": 0x1cb159857af02018
65
63
  }
66
64
 
67
65
  let parityCheckMatrixColumns: [UInt64] = [
68
- 0x00001, 0x00002, 0x00004, 0x00008, 0x00010, 0x00020, 0x00040, 0x00080,
69
- 0x00100, 0x00200, 0x00400, 0x00800, 0x01000, 0x02000, 0x04000, 0x08000,
70
- 0x10000, 0x20000, 0x40000, 0x7328d, 0x6689a, 0x6112f, 0x6084b, 0x433fd,
71
- 0x42aab, 0x41951, 0x233ce, 0x22a81, 0x21948, 0x1ef60, 0x1deca, 0x1c639,
72
- 0x1bdd8, 0x1a535, 0x194ac, 0x18c46, 0x1632b, 0x1529b, 0x14a43, 0x13184,
73
- 0x12942, 0x118c1, 0x0f812, 0x0e027, 0x0d00e, 0x0c83c, 0x0b01d, 0x0a831,
74
- 0x0982b, 0x07034, 0x0682a, 0x05819, 0x03807, 0x007d2, 0x00727, 0x0068e,
75
- 0x0067c, 0x0059d, 0x004eb, 0x003b4, 0x0036a, 0x002d9, 0x001c7, 0x0003f
66
+ 0x00001, 0x00002, 0x00004, 0x00008, 0x00010, 0x00020, 0x00040, 0x00080,
67
+ 0x00100, 0x00200, 0x00400, 0x00800, 0x01000, 0x02000, 0x04000, 0x08000,
68
+ 0x10000, 0x20000, 0x40000, 0x7328d, 0x6689a, 0x6112f, 0x6084b, 0x433fd,
69
+ 0x42aab, 0x41951, 0x233ce, 0x22a81, 0x21948, 0x1ef60, 0x1deca, 0x1c639,
70
+ 0x1bdd8, 0x1a535, 0x194ac, 0x18c46, 0x1632b, 0x1529b, 0x14a43, 0x13184,
71
+ 0x12942, 0x118c1, 0x0f812, 0x0e027, 0x0d00e, 0x0c83c, 0x0b01d, 0x0a831,
72
+ 0x0982b, 0x07034, 0x0682a, 0x05819, 0x03807, 0x007d2, 0x00727, 0x0068e,
73
+ 0x0067c, 0x0059d, 0x004eb, 0x003b4, 0x0036a, 0x002d9, 0x001c7, 0x0003f
76
74
  ]
77
75
 
78
76
  var parity: UInt64 = 0
@@ -93,8 +91,8 @@ pub contract AddressUtils {
93
91
  return parity == 0 && codeWord == 0
94
92
  }
95
93
 
96
- pub fun getNetworkFromAddress(_ input: AnyStruct): String? {
97
- for network in ["MAINNET", "TESTNET", "EMULATOR"]{
94
+ access(all) fun getNetworkFromAddress(_ input: AnyStruct): String? {
95
+ for network in ["MAINNET", "TESTNET", "EMULATOR"] {
98
96
  if self.isValidAddress(input, forNetwork: network){
99
97
  return network
100
98
  }
@@ -102,8 +100,7 @@ pub contract AddressUtils {
102
100
  return nil
103
101
  }
104
102
 
105
- pub fun currentNetwork(): String {
106
- return self.getNetworkFromAddress(self.account.address)!
103
+ access(all) fun currentNetwork(): String {
104
+ return self.getNetworkFromAddress(self.account.address) ?? panic("unknown network!")
107
105
  }
108
-
109
- }
106
+ }
@@ -1,8 +1,7 @@
1
1
  // Copied from https://github.com/bluesign/flow-utils/blob/dnz/cadence/contracts/ArrayUtils.cdc with minor adjustments
2
2
 
3
- pub contract ArrayUtils {
4
-
5
- pub fun rangeFunc(_ start: Int, _ end: Int, _ f: ((Int): Void)) {
3
+ access(all) contract ArrayUtils {
4
+ access(all) fun rangeFunc(_ start: Int, _ end: Int, _ f: fun (Int): Void) {
6
5
  var current = start
7
6
  while current < end {
8
7
  f(current)
@@ -10,7 +9,7 @@ pub contract ArrayUtils {
10
9
  }
11
10
  }
12
11
 
13
- pub fun range(_ start: Int, _ end: Int): [Int] {
12
+ access(all) fun range(_ start: Int, _ end: Int): [Int] {
14
13
  var res: [Int] = []
15
14
  self.rangeFunc(start, end, fun (i: Int) {
16
15
  res.append(i)
@@ -18,7 +17,7 @@ pub contract ArrayUtils {
18
17
  return res
19
18
  }
20
19
 
21
- pub fun reverse(_ array: [Int]): [Int] {
20
+ access(all) fun reverse(_ array: [Int]): [Int] {
22
21
  var res: [Int] = []
23
22
  var i: Int = array.length - 1
24
23
  while i >= 0 {
@@ -28,13 +27,13 @@ pub contract ArrayUtils {
28
27
  return res
29
28
  }
30
29
 
31
- pub fun transform(_ array: &[AnyStruct], _ f : ((AnyStruct): AnyStruct)){
30
+ access(all) fun transform(_ array: auth(Mutate) &[AnyStruct], _ f : fun (&AnyStruct, auth(Mutate) &[AnyStruct], Int)){
32
31
  for i in self.range(0, array.length){
33
- array[i] = f(array[i])
32
+ f(array[i], array, i)
34
33
  }
35
34
  }
36
35
 
37
- pub fun iterate(_ array: [AnyStruct], _ f : ((AnyStruct): Bool)){
36
+ access(all) fun iterate(_ array: [AnyStruct], _ f : fun (AnyStruct): Bool) {
38
37
  for item in array{
39
38
  if !f(item){
40
39
  break
@@ -42,7 +41,7 @@ pub contract ArrayUtils {
42
41
  }
43
42
  }
44
43
 
45
- pub fun map(_ array: [AnyStruct], _ f : ((AnyStruct): AnyStruct)) : [AnyStruct] {
44
+ access(all) fun map(_ array: [AnyStruct], _ f : fun (AnyStruct): AnyStruct) : [AnyStruct] {
46
45
  var res : [AnyStruct] = []
47
46
  for item in array{
48
47
  res.append(f(item))
@@ -50,7 +49,7 @@ pub contract ArrayUtils {
50
49
  return res
51
50
  }
52
51
 
53
- pub fun mapStrings(_ array: [String], _ f: ((String) : String) ) : [String] {
52
+ access(all) fun mapStrings(_ array: [String], _ f: fun (String) : String) : [String] {
54
53
  var res : [String] = []
55
54
  for item in array{
56
55
  res.append(f(item))
@@ -58,7 +57,7 @@ pub contract ArrayUtils {
58
57
  return res
59
58
  }
60
59
 
61
- pub fun reduce(_ array: [AnyStruct], _ initial: AnyStruct, _ f : ((AnyStruct, AnyStruct): AnyStruct)) : AnyStruct{
60
+ access(all) fun reduce(_ array: [AnyStruct], _ initial: AnyStruct, _ f : fun (AnyStruct, AnyStruct): AnyStruct) : AnyStruct{
62
61
  var res: AnyStruct = f(initial, array[0])
63
62
  for i in self.range(1, array.length){
64
63
  res = f(res, array[i])
@@ -8,14 +8,14 @@ import "StringUtils"
8
8
  //
9
9
  // ScopedProviders are meant to solve the issue of unbounded access FungibleToken vaults
10
10
  // when a provider is called for.
11
- pub contract ScopedFTProviders {
12
- pub struct interface FTFilter {
13
- pub fun canWithdrawAmount(_ amount: UFix64): Bool
14
- pub fun markAmountWithdrawn(_ amount: UFix64)
15
- pub fun getDetails(): {String: AnyStruct}
11
+ access(all) contract ScopedFTProviders {
12
+ access(all) struct interface FTFilter {
13
+ access(all) view fun canWithdrawAmount(_ amount: UFix64): Bool
14
+ access(FungibleToken.Withdraw) fun markAmountWithdrawn(_ amount: UFix64)
15
+ access(all) fun getDetails(): {String: AnyStruct}
16
16
  }
17
17
 
18
- pub struct AllowanceFilter: FTFilter {
18
+ access(all) struct AllowanceFilter: FTFilter {
19
19
  access(self) let allowance: UFix64
20
20
  access(self) var allowanceUsed: UFix64
21
21
 
@@ -24,15 +24,15 @@ pub contract ScopedFTProviders {
24
24
  self.allowanceUsed = 0.0
25
25
  }
26
26
 
27
- pub fun canWithdrawAmount(_ amount: UFix64): Bool {
27
+ access(all) view fun canWithdrawAmount(_ amount: UFix64): Bool {
28
28
  return amount + self.allowanceUsed <= self.allowance
29
29
  }
30
30
 
31
- pub fun markAmountWithdrawn(_ amount: UFix64) {
31
+ access(FungibleToken.Withdraw) fun markAmountWithdrawn(_ amount: UFix64) {
32
32
  self.allowanceUsed = self.allowanceUsed + amount
33
33
  }
34
34
 
35
- pub fun getDetails(): {String: AnyStruct} {
35
+ access(all) fun getDetails(): {String: AnyStruct} {
36
36
  return {
37
37
  "allowance": self.allowance,
38
38
  "allowanceUsed": self.allowanceUsed
@@ -44,31 +44,31 @@ pub contract ScopedFTProviders {
44
44
  //
45
45
  // A ScopedFTProvider is a wrapped FungibleTokenProvider with
46
46
  // filters that can be defined by anyone using the ScopedFTProvider.
47
- pub resource ScopedFTProvider: FungibleToken.Provider {
48
- access(self) let provider: Capability<&{FungibleToken.Provider}>
47
+ access(all) resource ScopedFTProvider: FungibleToken.Provider {
48
+ access(self) let provider: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Provider}>
49
49
  access(self) var filters: [{FTFilter}]
50
50
 
51
51
  // block timestamp that this provider can no longer be used after
52
52
  access(self) let expiration: UFix64?
53
53
 
54
- pub init(provider: Capability<&{FungibleToken.Provider}>, filters: [{FTFilter}], expiration: UFix64?) {
54
+ access(all) init(provider: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Provider}>, filters: [{FTFilter}], expiration: UFix64?) {
55
55
  self.provider = provider
56
56
  self.filters = filters
57
57
  self.expiration = expiration
58
58
  }
59
59
 
60
- pub fun check(): Bool {
60
+ access(all) fun check(): Bool {
61
61
  return self.provider.check()
62
62
  }
63
63
 
64
- pub fun isExpired(): Bool {
64
+ access(all) view fun isExpired(): Bool {
65
65
  if let expiration = self.expiration {
66
66
  return getCurrentBlock().timestamp >= expiration
67
67
  }
68
68
  return false
69
69
  }
70
70
 
71
- pub fun canWithdraw(_ amount: UFix64): Bool {
71
+ access(all) view fun canWithdraw(_ amount: UFix64): Bool {
72
72
  if self.isExpired() {
73
73
  return false
74
74
  }
@@ -82,7 +82,11 @@ pub contract ScopedFTProviders {
82
82
  return true
83
83
  }
84
84
 
85
- pub fun withdraw(amount: UFix64): @FungibleToken.Vault {
85
+ access(all) view fun isAvailableToWithdraw(amount: UFix64): Bool {
86
+ return self.canWithdraw(amount)
87
+ }
88
+
89
+ access(FungibleToken.Withdraw | FungibleToken.Withdraw) fun withdraw(amount: UFix64): @{FungibleToken.Vault} {
86
90
  pre {
87
91
  !self.isExpired(): "provider has expired"
88
92
  }
@@ -100,7 +104,7 @@ pub contract ScopedFTProviders {
100
104
  return <-self.provider.borrow()!.withdraw(amount: amount)
101
105
  }
102
106
 
103
- pub fun getDetails(): [{String: AnyStruct}] {
107
+ access(all) fun getDetails(): [{String: AnyStruct}] {
104
108
  let details: [{String: AnyStruct}] = []
105
109
  for filter in self.filters {
106
110
  details.append(filter.getDetails())
@@ -110,11 +114,12 @@ pub contract ScopedFTProviders {
110
114
  }
111
115
  }
112
116
 
113
- pub fun createScopedFTProvider(
114
- provider: Capability<&{FungibleToken.Provider}>,
117
+ access(all) fun createScopedFTProvider(
118
+ provider: Capability<auth(FungibleToken.Withdraw) &{FungibleToken.Provider}>,
115
119
  filters: [{FTFilter}],
116
120
  expiration: UFix64?
117
121
  ): @ScopedFTProvider {
118
122
  return <- create ScopedFTProvider(provider: provider, filters: filters, expiration: expiration)
119
123
  }
120
124
  }
125
+
@@ -11,14 +11,14 @@ import "StringUtils"
11
11
  //
12
12
  // By using a scoped provider, only a subset of assets can be taken if the provider leaks
13
13
  // instead of the entire nft collection.
14
- pub contract ScopedNFTProviders {
15
- pub struct interface NFTFilter {
16
- pub fun canWithdraw(_ nft: &NonFungibleToken.NFT): Bool
17
- pub fun markWithdrawn(_ nft: &NonFungibleToken.NFT)
18
- pub fun getDetails(): {String: AnyStruct}
14
+ access(all) contract ScopedNFTProviders {
15
+ access(all) struct interface NFTFilter {
16
+ access(all) fun canWithdraw(_ nft: &{NonFungibleToken.NFT}): Bool
17
+ access(NonFungibleToken.Withdraw) fun markWithdrawn(_ nft: &{NonFungibleToken.NFT})
18
+ access(all) fun getDetails(): {String: AnyStruct}
19
19
  }
20
20
 
21
- pub struct NFTIDFilter: NFTFilter {
21
+ access(all) struct NFTIDFilter: NFTFilter {
22
22
  // the ids that are allowed to be withdrawn.
23
23
  // If ids[num] is false, the id cannot be withdrawn anymore
24
24
  access(self) let ids: {UInt64: Bool}
@@ -31,22 +31,22 @@ pub contract ScopedNFTProviders {
31
31
  self.ids = d
32
32
  }
33
33
 
34
- pub fun canWithdraw(_ nft: &NonFungibleToken.NFT): Bool {
34
+ access(all) fun canWithdraw(_ nft: &{NonFungibleToken.NFT}): Bool {
35
35
  return self.ids[nft.id] != nil && self.ids[nft.id] == true
36
36
  }
37
37
 
38
- pub fun markWithdrawn(_ nft: &NonFungibleToken.NFT) {
38
+ access(NonFungibleToken.Withdraw) fun markWithdrawn(_ nft: &{NonFungibleToken.NFT}) {
39
39
  self.ids[nft.id] = false
40
40
  }
41
41
 
42
- pub fun getDetails(): {String: AnyStruct} {
42
+ access(all) fun getDetails(): {String: AnyStruct} {
43
43
  return {
44
44
  "ids": self.ids
45
45
  }
46
46
  }
47
47
  }
48
48
 
49
- pub struct UUIDFilter: NFTFilter {
49
+ access(all) struct UUIDFilter: NFTFilter {
50
50
  // the ids that are allowed to be withdrawn.
51
51
  // If ids[num] is false, the id cannot be withdrawn anymore
52
52
  access(self) let uuids: {UInt64: Bool}
@@ -59,15 +59,15 @@ pub contract ScopedNFTProviders {
59
59
  self.uuids = d
60
60
  }
61
61
 
62
- pub fun canWithdraw(_ nft: &NonFungibleToken.NFT): Bool {
62
+ access(all) fun canWithdraw(_ nft: &{NonFungibleToken.NFT}): Bool {
63
63
  return self.uuids[nft.uuid] != nil && self.uuids[nft.uuid]! == true
64
64
  }
65
65
 
66
- pub fun markWithdrawn(_ nft: &NonFungibleToken.NFT) {
66
+ access(NonFungibleToken.Withdraw) fun markWithdrawn(_ nft: &{NonFungibleToken.NFT}) {
67
67
  self.uuids[nft.uuid] = false
68
68
  }
69
69
 
70
- pub fun getDetails(): {String: AnyStruct} {
70
+ access(all) fun getDetails(): {String: AnyStruct} {
71
71
  return {
72
72
  "uuids": self.uuids
73
73
  }
@@ -77,39 +77,39 @@ pub contract ScopedNFTProviders {
77
77
  // ScopedNFTProvider
78
78
  //
79
79
  // Wrapper around an NFT Provider that is restricted to specific ids.
80
- pub resource ScopedNFTProvider: NonFungibleToken.Provider {
81
- access(self) let provider: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
80
+ access(all) resource ScopedNFTProvider: NonFungibleToken.Provider {
81
+ access(self) let provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
82
82
  access(self) let filters: [{NFTFilter}]
83
83
 
84
84
  // block timestamp that this provider can no longer be used after
85
85
  access(self) let expiration: UFix64?
86
86
 
87
- pub fun isExpired(): Bool {
87
+ access(all) view fun isExpired(): Bool {
88
88
  if let expiration = self.expiration {
89
89
  return getCurrentBlock().timestamp >= expiration
90
90
  }
91
91
  return false
92
92
  }
93
93
 
94
- pub init(provider: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>, filters: [{NFTFilter}], expiration: UFix64?) {
94
+ access(all) init(provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>, filters: [{NFTFilter}], expiration: UFix64?) {
95
95
  self.provider = provider
96
96
  self.expiration = expiration
97
97
  self.filters = filters
98
98
  }
99
99
 
100
- pub fun canWithdraw(_ id: UInt64): Bool {
100
+ access(all) fun canWithdraw(_ id: UInt64): Bool {
101
101
  if self.isExpired() {
102
102
  return false
103
103
  }
104
104
 
105
- let nft = self.provider.borrow()!.borrowNFT(id: id)
105
+ let nft = self.provider.borrow()!.borrowNFT(id)
106
106
  if nft == nil {
107
107
  return false
108
108
  }
109
109
 
110
110
  var i = 0
111
111
  while i < self.filters.length {
112
- if !self.filters[i].canWithdraw(nft) {
112
+ if !self.filters[i].canWithdraw(nft!) {
113
113
  return false
114
114
  }
115
115
  i = i + 1
@@ -117,17 +117,17 @@ pub contract ScopedNFTProviders {
117
117
  return true
118
118
  }
119
119
 
120
- pub fun check(): Bool {
120
+ access(all) fun check(): Bool {
121
121
  return self.provider.check()
122
122
  }
123
123
 
124
- pub fun withdraw(withdrawID: UInt64): @NonFungibleToken.NFT {
124
+ access(NonFungibleToken.Withdraw | NonFungibleToken.Owner) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} {
125
125
  pre {
126
126
  !self.isExpired(): "provider has expired"
127
127
  }
128
128
 
129
129
  let nft <- self.provider.borrow()!.withdraw(withdrawID: withdrawID)
130
- let ref = &nft as &NonFungibleToken.NFT
130
+ let ref = &nft as &{NonFungibleToken.NFT}
131
131
 
132
132
  var i = 0
133
133
  while i < self.filters.length {
@@ -142,7 +142,7 @@ pub contract ScopedNFTProviders {
142
142
  return <-nft
143
143
  }
144
144
 
145
- pub fun getDetails(): [{String: AnyStruct}] {
145
+ access(all) fun getDetails(): [{String: AnyStruct}] {
146
146
  let details: [{String: AnyStruct}] = []
147
147
  for f in self.filters {
148
148
  details.append(f.getDetails())
@@ -152,11 +152,12 @@ pub contract ScopedNFTProviders {
152
152
  }
153
153
  }
154
154
 
155
- pub fun createScopedNFTProvider(
156
- provider: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>,
155
+ access(all) fun createScopedNFTProvider(
156
+ provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>,
157
157
  filters: [{NFTFilter}],
158
158
  expiration: UFix64?
159
159
  ): @ScopedNFTProvider {
160
160
  return <- create ScopedNFTProvider(provider: provider, filters: filters, expiration: expiration)
161
161
  }
162
162
  }
163
+
@@ -1,16 +1,16 @@
1
1
  import "ArrayUtils"
2
2
 
3
- pub contract StringUtils {
4
-
5
- pub fun format(_ s: String, _ args: {String:String}): String{
6
- var formatted = s
7
- for key in args.keys{
8
- formatted = StringUtils.replaceAll(formatted, "{".concat(key).concat("}"), args[key]!)
9
- }
10
- return formatted
3
+ access(all) contract StringUtils {
4
+
5
+ access(all) fun format(_ s: String, _ args: {String:String}): String{
6
+ var formatted = s
7
+ for key in args.keys{
8
+ formatted = StringUtils.replaceAll(formatted, "{".concat(key).concat("}"), args[key]!)
9
+ }
10
+ return formatted
11
11
  }
12
12
 
13
- pub fun explode(_ s: String): [String]{
13
+ access(all) fun explode(_ s: String): [String]{
14
14
  var chars : [String] = []
15
15
  for i in ArrayUtils.range(0, s.length){
16
16
  chars.append(s[i].toString())
@@ -18,7 +18,7 @@ pub contract StringUtils {
18
18
  return chars
19
19
  }
20
20
 
21
- pub fun trimLeft(_ s: String): String{
21
+ access(all) fun trimLeft(_ s: String): String{
22
22
  for i in ArrayUtils.range(0, s.length){
23
23
  if s[i] != " "{
24
24
  return s.slice(from: i, upTo: s.length)
@@ -27,23 +27,23 @@ pub contract StringUtils {
27
27
  return ""
28
28
  }
29
29
 
30
- pub fun trim(_ s: String): String{
30
+ access(all) fun trim(_ s: String): String{
31
31
  return self.trimLeft(s)
32
32
  }
33
33
 
34
- pub fun replaceAll(_ s: String, _ search: String, _ replace: String): String{
35
- return self.join(self.split(s, search), replace)
34
+ access(all) fun replaceAll(_ s: String, _ search: String, _ replace: String): String{
35
+ return s.replaceAll(of: search, with: replace)
36
36
  }
37
37
 
38
- pub fun hasPrefix(_ s: String, _ prefix: String) : Bool{
38
+ access(all) fun hasPrefix(_ s: String, _ prefix: String) : Bool{
39
39
  return s.length >= prefix.length && s.slice(from:0, upTo: prefix.length)==prefix
40
40
  }
41
41
 
42
- pub fun hasSuffix(_ s: String, _ suffix: String) : Bool{
42
+ access(all) fun hasSuffix(_ s: String, _ suffix: String) : Bool{
43
43
  return s.length >= suffix.length && s.slice(from:s.length-suffix.length, upTo: s.length)==suffix
44
44
  }
45
45
 
46
- pub fun index(_ s : String, _ substr : String, _ startIndex: Int): Int?{
46
+ access(all) fun index(_ s : String, _ substr : String, _ startIndex: Int): Int?{
47
47
  for i in ArrayUtils.range(startIndex,s.length-substr.length+1){
48
48
  if s[i]==substr[0] && s.slice(from:i, upTo:i+substr.length) == substr{
49
49
  return i
@@ -52,7 +52,7 @@ pub contract StringUtils {
52
52
  return nil
53
53
  }
54
54
 
55
- pub fun count(_ s: String, _ substr: String): Int{
55
+ access(all) fun count(_ s: String, _ substr: String): Int{
56
56
  var pos = [self.index(s, substr, 0)]
57
57
  while pos[0]!=nil {
58
58
  pos.insert(at:0, self.index(s, substr, pos[0]!+pos.length*substr.length+1))
@@ -60,38 +60,25 @@ pub contract StringUtils {
60
60
  return pos.length-1
61
61
  }
62
62
 
63
- pub fun contains(_ s: String, _ substr: String): Bool {
63
+ access(all) fun contains(_ s: String, _ substr: String): Bool {
64
64
  if let index = self.index(s, substr, 0) {
65
65
  return true
66
66
  }
67
67
  return false
68
68
  }
69
69
 
70
- pub fun substringUntil(_ s: String, _ until: String, _ startIndex: Int): String{
70
+ access(all) fun substringUntil(_ s: String, _ until: String, _ startIndex: Int): String{
71
71
  if let index = self.index( s, until, startIndex){
72
72
  return s.slice(from:startIndex, upTo: index)
73
73
  }
74
74
  return s.slice(from:startIndex, upTo:s.length)
75
75
  }
76
76
 
77
- pub fun split(_ s: String, _ delimiter: String): [String] {
78
- let segments: [String] = []
79
- var p = 0
80
- while p<=s.length{
81
- var preDelimiter = self.substringUntil(s, delimiter, p)
82
- segments.append(preDelimiter)
83
- p = p + preDelimiter.length + delimiter.length
84
- }
85
- return segments
77
+ access(all) fun split(_ s: String, _ delimiter: String): [String] {
78
+ return s.split(separator: delimiter)
86
79
  }
87
80
 
88
- pub fun join(_ strs: [String], _ separator: String): String {
89
- var joinedStr = ""
90
- for s in strs {
91
- joinedStr = joinedStr.concat(s).concat(separator)
92
- }
93
- return joinedStr.slice(from: 0, upTo: joinedStr.length - separator.length)
81
+ access(all) fun join(_ strs: [String], _ separator: String): String {
82
+ return String.join(strs, separator: separator)
94
83
  }
95
-
96
-
97
- }
84
+ }
@@ -125,7 +125,7 @@ access(all) contract LostAndFound {
125
125
  if self.type.isSubtype(of: Type<@{NonFungibleToken.NFT}>()) {
126
126
  let ref = (&self.item as &AnyResource?)!
127
127
  let nft = ref as! &{NonFungibleToken.NFT}
128
- return nft.getID()
128
+ return nft.id
129
129
  }
130
130
  return nil
131
131
  }
@@ -135,7 +135,7 @@ access(all) contract LostAndFound {
135
135
  if self.type.isSubtype(of: Type<@{FungibleToken.Vault}>()) {
136
136
  let ref = (&self.item as &AnyResource?)!
137
137
  let ft = ref as! &{FungibleToken.Vault}
138
- return ft.getBalance()
138
+ return ft.balance
139
139
  }
140
140
  return nil
141
141
  }
@@ -391,8 +391,8 @@ access(all) contract LostAndFound {
391
391
  }
392
392
  }
393
393
 
394
- access(contract) fun getFlowProvider(): auth(FungibleToken.Withdrawable) &FlowToken.Vault {
395
- return self.account.storage.borrow<auth(FungibleToken.Withdrawable) &FlowToken.Vault>(from: /storage/flowTokenVault)!
394
+ access(contract) fun getFlowProvider(): auth(FungibleToken.Withdraw) &FlowToken.Vault {
395
+ return self.account.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)!
396
396
  }
397
397
 
398
398
  // ShelfManager is a light-weight wrapper to get our shelves into storage.
@@ -422,7 +422,7 @@ access(all) contract LostAndFound {
422
422
  item: @AnyResource,
423
423
  memo: String?,
424
424
  display: MetadataViews.Display?,
425
- storagePayment: auth(FungibleToken.Withdrawable) &{FungibleToken.Vault},
425
+ storagePayment: auth(FungibleToken.Withdraw) &{FungibleToken.Vault},
426
426
  flowTokenRepayment: Capability<&FlowToken.Vault>?
427
427
  ) : UInt64 {
428
428
  pre {
@@ -598,7 +598,7 @@ access(all) contract LostAndFound {
598
598
  init(_ flowTokenRepayment: Capability<&FlowToken.Vault>, lowBalanceThreshold: UFix64?) {
599
599
  self.flowTokenRepayment = flowTokenRepayment
600
600
 
601
- let vault <- FlowToken.createEmptyVault()
601
+ let vault <- FlowToken.createEmptyVault(vaultType: Type<@FlowToken.Vault>())
602
602
  self.flowTokenVault <- vault
603
603
  self.lowBalanceThreshold = lowBalanceThreshold
604
604
  }
@@ -713,7 +713,7 @@ access(all) contract LostAndFound {
713
713
  item: @AnyResource,
714
714
  memo: String?,
715
715
  display: MetadataViews.Display?,
716
- storagePayment: auth(FungibleToken.Withdrawable) &{FungibleToken.Vault},
716
+ storagePayment: auth(FungibleToken.Withdraw) &{FungibleToken.Vault},
717
717
  flowTokenRepayment: Capability<&FlowToken.Vault>?
718
718
  ) : UInt64 {
719
719
  pre {
@@ -730,7 +730,7 @@ access(all) contract LostAndFound {
730
730
  cap: Capability,
731
731
  memo: String?,
732
732
  display: MetadataViews.Display?,
733
- storagePayment: auth(FungibleToken.Withdrawable) &{FungibleToken.Vault},
733
+ storagePayment: auth(FungibleToken.Withdraw) &{FungibleToken.Vault},
734
734
  flowTokenRepayment: Capability<&FlowToken.Vault>
735
735
  ) {
736
736
  if cap.check<&{NonFungibleToken.Collection}>() {
@@ -10,10 +10,10 @@ import "MetadataViews"
10
10
  // To make an addition to the catalog you can propose an NFT and provide its metadata.
11
11
  // An Admin can approve a proposal which would add the NFT to the catalog
12
12
 
13
- pub contract NFTCatalog {
13
+ access(all) contract NFTCatalog {
14
14
  // EntryAdded
15
15
  // An NFT collection has been added to the catalog
16
- pub event EntryAdded(
16
+ access(all) event EntryAdded(
17
17
  collectionIdentifier : String,
18
18
  contractName : String,
19
19
  contractAddress : Address,
@@ -30,7 +30,7 @@ pub contract NFTCatalog {
30
30
 
31
31
  // EntryUpdated
32
32
  // An NFT Collection has been updated in the catalog
33
- pub event EntryUpdated(
33
+ access(all) event EntryUpdated(
34
34
  collectionIdentifier : String,
35
35
  contractName : String,
36
36
  contractAddress : Address,
@@ -47,23 +47,23 @@ pub contract NFTCatalog {
47
47
 
48
48
  // EntryRemoved
49
49
  // An NFT Collection has been removed from the catalog
50
- pub event EntryRemoved(collectionIdentifier : String, nftType: Type)
50
+ access(all) event EntryRemoved(collectionIdentifier : String, nftType: Type)
51
51
 
52
52
  // ProposalEntryAdded
53
53
  // A new proposal to make an addtion to the catalog has been made
54
- pub event ProposalEntryAdded(proposalID : UInt64, collectionIdentifier : String, message: String, status: String, proposer : Address)
54
+ access(all) event ProposalEntryAdded(proposalID : UInt64, collectionIdentifier : String, message: String, status: String, proposer : Address)
55
55
 
56
56
  // ProposalEntryUpdated
57
57
  // A proposal has been updated
58
- pub event ProposalEntryUpdated(proposalID : UInt64, collectionIdentifier : String, message: String, status: String, proposer : Address)
58
+ access(all) event ProposalEntryUpdated(proposalID : UInt64, collectionIdentifier : String, message: String, status: String, proposer : Address)
59
59
 
60
60
  // ProposalEntryRemoved
61
61
  // A proposal has been removed from storage
62
- pub event ProposalEntryRemoved(proposalID : UInt64)
62
+ access(all) event ProposalEntryRemoved(proposalID : UInt64)
63
63
 
64
- pub let ProposalManagerStoragePath: StoragePath
64
+ access(all) let ProposalManagerStoragePath: StoragePath
65
65
 
66
- pub let ProposalManagerPublicPath: PublicPath
66
+ access(all) let ProposalManagerPublicPath: PublicPath
67
67
 
68
68
  access(self) let catalog: {String : NFTCatalog.NFTCatalogMetadata} // { collectionIdentifier -> Metadata }
69
69
  access(self) let catalogTypeData: {String : {String : Bool}} // Additional view to go from { NFT Type Identifier -> {Collection Identifier : Bool } }
@@ -75,17 +75,17 @@ pub contract NFTCatalog {
75
75
  // NFTCatalogProposalManager
76
76
  // Used to authenticate proposals made to the catalog
77
77
 
78
- pub resource interface NFTCatalogProposalManagerPublic {
79
- pub fun getCurrentProposalEntry(): String?
78
+ access(all) resource interface NFTCatalogProposalManagerPublic {
79
+ access(all) fun getCurrentProposalEntry(): String?
80
80
  }
81
- pub resource NFTCatalogProposalManager : NFTCatalogProposalManagerPublic {
81
+ access(all) resource NFTCatalogProposalManager : NFTCatalogProposalManagerPublic {
82
82
  access(self) var currentProposalEntry: String?
83
83
 
84
- pub fun getCurrentProposalEntry(): String? {
84
+ access(all) fun getCurrentProposalEntry(): String? {
85
85
  return self.currentProposalEntry
86
86
  }
87
87
 
88
- pub fun setCurrentProposalEntry(identifier: String?) {
88
+ access(all) fun setCurrentProposalEntry(identifier: String?) {
89
89
  self.currentProposalEntry = identifier
90
90
  }
91
91
 
@@ -95,19 +95,19 @@ pub contract NFTCatalog {
95
95
  }
96
96
 
97
97
 
98
- pub resource Snapshot {
99
- pub var catalogSnapshot: {String : NFTCatalogMetadata}
100
- pub var shouldUseSnapshot: Bool
98
+ access(all) resource Snapshot {
99
+ access(all) var catalogSnapshot: {String : NFTCatalogMetadata}
100
+ access(all) var shouldUseSnapshot: Bool
101
101
 
102
- pub fun setPartialSnapshot(_ snapshotKey: String, _ snapshotEntry: NFTCatalogMetadata) {
102
+ access(all) fun setPartialSnapshot(_ snapshotKey: String, _ snapshotEntry: NFTCatalogMetadata) {
103
103
  self.catalogSnapshot[snapshotKey] = snapshotEntry
104
104
  }
105
105
 
106
- pub fun setShouldUseSnapshot(_ shouldUseSnapshot: Bool) {
106
+ access(all) fun setShouldUseSnapshot(_ shouldUseSnapshot: Bool) {
107
107
  self.shouldUseSnapshot = shouldUseSnapshot
108
108
  }
109
109
 
110
- pub fun getCatalogSnapshot(): {String : NFTCatalogMetadata} {
110
+ access(all) fun getCatalogSnapshot(): {String : NFTCatalogMetadata} {
111
111
  return self.catalogSnapshot
112
112
  }
113
113
 
@@ -117,7 +117,7 @@ pub contract NFTCatalog {
117
117
  }
118
118
  }
119
119
 
120
- pub fun createEmptySnapshot(): @Snapshot {
120
+ access(all) fun createEmptySnapshot(): @Snapshot {
121
121
  return <- create Snapshot()
122
122
  }
123
123
 
@@ -125,13 +125,13 @@ pub contract NFTCatalog {
125
125
  // Represents information about an NFT collection resource
126
126
  // Note: Not suing the struct from Metadata standard due to
127
127
  // inability to store functions
128
- pub struct NFTCollectionData {
128
+ access(all) struct NFTCollectionData {
129
129
 
130
- pub let storagePath : StoragePath
131
- pub let publicPath : PublicPath
132
- pub let privatePath: PrivatePath
133
- pub let publicLinkedType: Type
134
- pub let privateLinkedType: Type
130
+ access(all) let storagePath : StoragePath
131
+ access(all) let publicPath : PublicPath
132
+ access(all) let privatePath: PrivatePath
133
+ access(all) let publicLinkedType: Type
134
+ access(all) let privateLinkedType: Type
135
135
 
136
136
  init(
137
137
  storagePath : StoragePath,
@@ -150,12 +150,12 @@ pub contract NFTCatalog {
150
150
 
151
151
  // NFTCatalogMetadata
152
152
  // Represents data about an NFT
153
- pub struct NFTCatalogMetadata {
154
- pub let contractName : String
155
- pub let contractAddress : Address
156
- pub let nftType: Type
157
- pub let collectionData: NFTCollectionData
158
- pub let collectionDisplay: MetadataViews.NFTCollectionDisplay
153
+ access(all) struct NFTCatalogMetadata {
154
+ access(all) let contractName : String
155
+ access(all) let contractAddress : Address
156
+ access(all) let nftType: Type
157
+ access(all) let collectionData: NFTCollectionData
158
+ access(all) let collectionDisplay: MetadataViews.NFTCollectionDisplay
159
159
 
160
160
  init (contractName : String, contractAddress : Address, nftType: Type, collectionData : NFTCollectionData, collectionDisplay : MetadataViews.NFTCollectionDisplay) {
161
161
  self.contractName = contractName
@@ -169,13 +169,13 @@ pub contract NFTCatalog {
169
169
  // NFTCatalogProposal
170
170
  // Represents a proposal to the catalog
171
171
  // Includes data about an NFT
172
- pub struct NFTCatalogProposal {
173
- pub let collectionIdentifier : String
174
- pub let metadata : NFTCatalogMetadata
175
- pub let message : String
176
- pub let status : String
177
- pub let proposer : Address
178
- pub let createdTime : UFix64
172
+ access(all) struct NFTCatalogProposal {
173
+ access(all) let collectionIdentifier : String
174
+ access(all) let metadata : NFTCatalogMetadata
175
+ access(all) let message : String
176
+ access(all) let status : String
177
+ access(all) let proposer : Address
178
+ access(all) let createdTime : UFix64
179
179
 
180
180
  init(collectionIdentifier : String, metadata : NFTCatalogMetadata, message : String, status : String, proposer : Address) {
181
181
  self.collectionIdentifier = collectionIdentifier
@@ -192,8 +192,8 @@ pub contract NFTCatalog {
192
192
  If obtaining all elements from the catalog is essential, please
193
193
  use the getCatalogKeys and forEachCatalogKey methods instead.
194
194
  */
195
- pub fun getCatalog() : {String : NFTCatalogMetadata} {
196
- let snapshot = self.account.borrow<&NFTCatalog.Snapshot>(from: /storage/CatalogSnapshot)
195
+ access(all) fun getCatalog() : {String : NFTCatalogMetadata} {
196
+ let snapshot = self.account.storage.borrow<&NFTCatalog.Snapshot>(from: /storage/CatalogSnapshot)
197
197
  if snapshot != nil {
198
198
  let snapshot = snapshot!
199
199
  if snapshot.shouldUseSnapshot {
@@ -206,23 +206,23 @@ pub contract NFTCatalog {
206
206
  }
207
207
  }
208
208
 
209
- pub fun getCatalogKeys(): [String] {
209
+ access(all) fun getCatalogKeys(): [String] {
210
210
  return self.catalog.keys
211
211
  }
212
212
 
213
- pub fun forEachCatalogKey(_ function: ((String): Bool)) {
213
+ access(all) fun forEachCatalogKey(_ function: fun (String): Bool) {
214
214
  self.catalog.forEachKey(function)
215
215
  }
216
216
 
217
- pub fun getCatalogEntry(collectionIdentifier : String) : NFTCatalogMetadata? {
217
+ access(all) view fun getCatalogEntry(collectionIdentifier : String) : NFTCatalogMetadata? {
218
218
  return self.catalog[collectionIdentifier]
219
219
  }
220
220
 
221
- pub fun getCollectionsForType(nftTypeIdentifier: String) : {String : Bool}? {
221
+ access(all) fun getCollectionsForType(nftTypeIdentifier: String) : {String : Bool}? {
222
222
  return self.catalogTypeData[nftTypeIdentifier]
223
223
  }
224
224
 
225
- pub fun getCatalogTypeData() : {String : {String : Bool}} {
225
+ access(all) fun getCatalogTypeData() : {String : {String : Bool}} {
226
226
  return self.catalogTypeData
227
227
  }
228
228
 
@@ -231,12 +231,10 @@ pub contract NFTCatalog {
231
231
  // @param metadata: The Metadata for the NFT collection that will be stored in the catalog
232
232
  // @param message: A message to the catalog owners
233
233
  // @param proposer: Who is making the proposition(the address needs to be verified)
234
- pub fun proposeNFTMetadata(collectionIdentifier : String, metadata : NFTCatalogMetadata, message : String, proposer : Address) : UInt64 {
235
- let proposerManagerCap = getAccount(proposer).getCapability<&NFTCatalogProposalManager{NFTCatalog.NFTCatalogProposalManagerPublic}>(NFTCatalog.ProposalManagerPublicPath)
236
-
237
- assert(proposerManagerCap.check(), message : "Proposer needs to set up a manager")
238
-
239
- let proposerManagerRef = proposerManagerCap.borrow()!
234
+ access(all) fun proposeNFTMetadata(collectionIdentifier : String, metadata : NFTCatalogMetadata, message : String, proposer : Address) : UInt64 {
235
+ let proposerManagerRef = getAccount(proposer).capabilities.borrow<&NFTCatalogProposalManager>(
236
+ NFTCatalog.ProposalManagerPublicPath
237
+ ) ?? panic("Proposer needs to set up a manager")
240
238
 
241
239
  assert(proposerManagerRef.getCurrentProposalEntry()! == collectionIdentifier, message: "Expected proposal entry does not match entry for the proposer")
242
240
 
@@ -250,41 +248,39 @@ pub contract NFTCatalog {
250
248
 
251
249
  // Withdraw a proposal from the catalog
252
250
  // @param proposalID: The ID of proposal you want to withdraw
253
- pub fun withdrawNFTProposal(proposalID : UInt64) {
251
+ access(all) fun withdrawNFTProposal(proposalID : UInt64) {
254
252
  pre {
255
253
  self.catalogProposals[proposalID] != nil : "Invalid Proposal ID"
256
254
  }
257
255
  let proposal = self.catalogProposals[proposalID]!
258
256
  let proposer = proposal.proposer
259
257
 
260
- let proposerManagerCap = getAccount(proposer).getCapability<&NFTCatalogProposalManager{NFTCatalog.NFTCatalogProposalManagerPublic}>(NFTCatalog.ProposalManagerPublicPath)
261
-
262
- assert(proposerManagerCap.check(), message : "Proposer needs to set up a manager")
263
-
264
- let proposerManagerRef = proposerManagerCap.borrow()!
258
+ let proposerManagerRef = getAccount(proposer).capabilities.borrow<&NFTCatalogProposalManager>(
259
+ NFTCatalog.ProposalManagerPublicPath
260
+ ) ?? panic("Proposer needs to set up a manager")
265
261
 
266
262
  assert(proposerManagerRef.getCurrentProposalEntry()! == proposal.collectionIdentifier, message: "Expected proposal entry does not match entry for the proposer")
267
263
 
268
264
  self.removeCatalogProposal(proposalID : proposalID)
269
265
  }
270
266
 
271
- pub fun getCatalogProposals() : {UInt64 : NFTCatalogProposal} {
267
+ access(all) fun getCatalogProposals() : {UInt64 : NFTCatalogProposal} {
272
268
  return self.catalogProposals
273
269
  }
274
270
 
275
- pub fun getCatalogProposalEntry(proposalID : UInt64) : NFTCatalogProposal? {
271
+ access(all) view fun getCatalogProposalEntry(proposalID : UInt64) : NFTCatalogProposal? {
276
272
  return self.catalogProposals[proposalID]
277
273
  }
278
274
 
279
- pub fun getCatalogProposalKeys() : [UInt64] {
275
+ access(all) fun getCatalogProposalKeys() : [UInt64] {
280
276
  return self.catalogProposals.keys
281
277
  }
282
278
 
283
- pub fun forEachCatalogProposalKey(_ function: ((UInt64): Bool)) {
279
+ access(all) fun forEachCatalogProposalKey(_ function: fun (UInt64): Bool) {
284
280
  self.catalogProposals.forEachKey(function)
285
281
  }
286
282
 
287
- pub fun createNFTCatalogProposalManager(): @NFTCatalogProposalManager {
283
+ access(all) fun createNFTCatalogProposalManager(): @NFTCatalogProposalManager {
288
284
  return <-create NFTCatalogProposalManager()
289
285
  }
290
286
 
@@ -6,11 +6,13 @@ import "NFTCatalog"
6
6
  // a proxy resource to receive a capability that lets you make changes to the NFT Catalog
7
7
  // and manage proposals
8
8
 
9
- pub contract NFTCatalogAdmin {
9
+ access(all) contract NFTCatalogAdmin {
10
+
11
+ access(all) entitlement CatalogActions
10
12
 
11
13
  // AddProposalAccepted
12
14
  // Emitted when a proposal to add a new catalog item has been approved by an admin
13
- pub event AddProposalAccepted(
15
+ access(all) event AddProposalAccepted(
14
16
  proposer: Address,
15
17
  collectionIdentifier : String,
16
18
  contractName : String,
@@ -20,7 +22,7 @@ pub contract NFTCatalogAdmin {
20
22
 
21
23
  // UpdateProposalAccepted
22
24
  // Emitted when a proposal to update a catalog item has been approved by an admin
23
- pub event UpdateProposalAccepted(
25
+ access(all) event UpdateProposalAccepted(
24
26
  proposer: Address,
25
27
  collectionIdentifier : String,
26
28
  contractName : String,
@@ -30,7 +32,7 @@ pub contract NFTCatalogAdmin {
30
32
 
31
33
  // ProposalRejected
32
34
  // Emitted when a proposal to add or update a catalog item has been rejected.
33
- pub event ProposalRejected(
35
+ access(all) event ProposalRejected(
34
36
  proposer: Address,
35
37
  collectionIdentifier : String,
36
38
  contractName : String,
@@ -38,33 +40,33 @@ pub contract NFTCatalogAdmin {
38
40
  displayName : String
39
41
  )
40
42
 
41
- pub let AdminPrivatePath: PrivatePath
42
- pub let AdminStoragePath: StoragePath
43
+ access(all) let AdminPrivatePath: PrivatePath
44
+ access(all) let AdminStoragePath: StoragePath
43
45
 
44
- pub let AdminProxyPublicPath: PublicPath
45
- pub let AdminProxyStoragePath: StoragePath
46
+ access(all) let AdminProxyPublicPath: PublicPath
47
+ access(all) let AdminProxyStoragePath: StoragePath
46
48
 
47
49
  // Admin
48
50
  // Admin resource to manage NFT Catalog
49
- pub resource Admin {
51
+ access(all) resource Admin {
50
52
 
51
- pub fun addCatalogEntry(collectionIdentifier: String, metadata : NFTCatalog.NFTCatalogMetadata) {
53
+ access(CatalogActions) fun addCatalogEntry(collectionIdentifier: String, metadata : NFTCatalog.NFTCatalogMetadata) {
52
54
  NFTCatalog.addCatalogEntry(collectionIdentifier: collectionIdentifier, metadata : metadata)
53
55
  }
54
56
 
55
- pub fun updateCatalogEntry(collectionIdentifier : String , metadata : NFTCatalog.NFTCatalogMetadata) {
57
+ access(CatalogActions) fun updateCatalogEntry(collectionIdentifier : String , metadata : NFTCatalog.NFTCatalogMetadata) {
56
58
  NFTCatalog.updateCatalogEntry(collectionIdentifier: collectionIdentifier, metadata : metadata)
57
59
  }
58
60
 
59
- pub fun removeCatalogEntry(collectionIdentifier : String) {
61
+ access(CatalogActions) fun removeCatalogEntry(collectionIdentifier : String) {
60
62
  NFTCatalog.removeCatalogEntry(collectionIdentifier : collectionIdentifier)
61
63
  }
62
64
 
63
- pub fun removeCatalogEntryUnsafe(collectionIdentifier : String, nftTypeIdentifier: String) {
65
+ access(CatalogActions) fun removeCatalogEntryUnsafe(collectionIdentifier : String, nftTypeIdentifier: String) {
64
66
  NFTCatalog.removeCatalogEntryUnsafe(collectionIdentifier : collectionIdentifier, nftTypeIdentifier: nftTypeIdentifier)
65
67
  }
66
68
 
67
- pub fun approveCatalogProposal(proposalID : UInt64) {
69
+ access(CatalogActions) fun approveCatalogProposal(proposalID : UInt64) {
68
70
  pre {
69
71
  NFTCatalog.getCatalogProposalEntry(proposalID : proposalID) != nil : "Invalid Proposal ID"
70
72
  NFTCatalog.getCatalogProposalEntry(proposalID : proposalID)!.status == "IN_REVIEW" : "Invalid Proposal"
@@ -94,7 +96,7 @@ pub contract NFTCatalogAdmin {
94
96
  }
95
97
  }
96
98
 
97
- pub fun rejectCatalogProposal(proposalID : UInt64) {
99
+ access(CatalogActions) fun rejectCatalogProposal(proposalID : UInt64) {
98
100
  pre {
99
101
  NFTCatalog.getCatalogProposalEntry(proposalID : proposalID) != nil : "Invalid Proposal ID"
100
102
  NFTCatalog.getCatalogProposalEntry(proposalID : proposalID)!.status == "IN_REVIEW" : "Invalid Proposal"
@@ -111,7 +113,7 @@ pub contract NFTCatalogAdmin {
111
113
  )
112
114
  }
113
115
 
114
- pub fun removeCatalogProposal(proposalID : UInt64) {
116
+ access(CatalogActions) fun removeCatalogProposal(proposalID : UInt64) {
115
117
  pre {
116
118
  NFTCatalog.getCatalogProposalEntry(proposalID : proposalID) != nil : "Invalid Proposal ID"
117
119
  }
@@ -125,16 +127,16 @@ pub contract NFTCatalogAdmin {
125
127
  // AdminProxy
126
128
  // A proxy resource that can store
127
129
  // a capability to admin controls
128
- pub resource interface IAdminProxy {
129
- pub fun addCapability(capability : Capability<&Admin>)
130
- pub fun hasCapability() : Bool
130
+ access(all) resource interface IAdminProxy {
131
+ access(all) fun addCapability(capability : Capability<auth(CatalogActions) &Admin>)
132
+ access(all) fun hasCapability() : Bool
131
133
  }
132
134
 
133
- pub resource AdminProxy : IAdminProxy {
135
+ access(all) resource AdminProxy : IAdminProxy {
134
136
 
135
- access(self) var capability : Capability<&Admin>?
137
+ access(self) var capability : Capability<auth(CatalogActions) &Admin>?
136
138
 
137
- pub fun addCapability(capability : Capability<&Admin>) {
139
+ access(all) fun addCapability(capability : Capability<auth(CatalogActions) &Admin>) {
138
140
  pre {
139
141
  capability.check() : "Invalid Admin Capability"
140
142
  self.capability == nil : "Admin Proxy already set"
@@ -142,11 +144,11 @@ pub contract NFTCatalogAdmin {
142
144
  self.capability = capability
143
145
  }
144
146
 
145
- pub fun getCapability() : Capability<&Admin>? {
147
+ access(all) fun getCapability() : Capability<auth(CatalogActions) &Admin>? {
146
148
  return self.capability
147
149
  }
148
150
 
149
- pub fun hasCapability() : Bool {
151
+ access(all) fun hasCapability() : Bool {
150
152
  return self.capability != nil
151
153
  }
152
154
 
@@ -156,7 +158,7 @@ pub contract NFTCatalogAdmin {
156
158
 
157
159
  }
158
160
 
159
- pub fun createAdminProxy() : @AdminProxy {
161
+ access(all) fun createAdminProxy() : @AdminProxy {
160
162
  return <- create AdminProxy()
161
163
  }
162
164
 
@@ -169,7 +171,6 @@ pub contract NFTCatalogAdmin {
169
171
 
170
172
  let admin <- create Admin()
171
173
 
172
- self.account.save(<-admin, to: self.AdminStoragePath)
173
- self.account.link<&Admin>(self.AdminPrivatePath, target: self.AdminStoragePath)
174
+ self.account.storage.save(<-admin, to: self.AdminStoragePath)
174
175
  }
175
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowtyio/flow-contracts",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0-beta.7",
4
4
  "main": "index.json",
5
5
  "description": "An NPM package for common flow contracts",
6
6
  "author": "flowtyio",