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

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.
@@ -126,8 +126,32 @@ access(all) contract MetadataViews {
126
126
  }
127
127
  }
128
128
 
129
- /// View to represent a file with an correspoiding mediaType.
130
- ///
129
+ /// A struct to represent a generic URI. May be used to represent the URI of
130
+ /// the NFT where the type of URI is not able to be determined (i.e. HTTP,
131
+ /// IPFS, etc.)
132
+ ///
133
+ access(all) struct URI: File {
134
+ /// The base URI prefix, if any. Not needed for all URIs, but helpful
135
+ /// for some use cases For example, updating a whole NFT collection's
136
+ /// image host easily
137
+ ///
138
+ access(all) let baseURI: String?
139
+ /// The URI string value
140
+ /// NOTE: this is set on init as a concatenation of the baseURI and the
141
+ /// value if baseURI != nil
142
+ ///
143
+ access(self) let value: String
144
+
145
+ access(all) view fun uri(): String {
146
+ return self.value
147
+ }
148
+
149
+ init(baseURI: String?, value: String) {
150
+ self.baseURI = baseURI
151
+ self.value = baseURI != nil ? baseURI!.concat(value) : value
152
+ }
153
+ }
154
+
131
155
  access(all) struct Media {
132
156
 
133
157
  /// File for the media
@@ -185,7 +209,7 @@ access(all) contract MetadataViews {
185
209
  /// Helper to get License in a typesafe way
186
210
  ///
187
211
  /// @param viewResolver: A reference to the resolver resource
188
- /// @return A optional License struct
212
+ /// @return An optional License struct
189
213
  ///
190
214
  access(all) fun getLicense(_ viewResolver: &{ViewResolver.Resolver}) : License? {
191
215
  if let view = viewResolver.resolveView(Type<License>()) {
@@ -212,7 +236,7 @@ access(all) contract MetadataViews {
212
236
  /// Helper to get ExternalURL in a typesafe way
213
237
  ///
214
238
  /// @param viewResolver: A reference to the resolver resource
215
- /// @return A optional ExternalURL struct
239
+ /// @return An optional ExternalURL struct
216
240
  ///
217
241
  access(all) fun getExternalURL(_ viewResolver: &{ViewResolver.Resolver}) : ExternalURL? {
218
242
  if let view = viewResolver.resolveView(Type<ExternalURL>()) {
@@ -665,7 +689,7 @@ access(all) contract MetadataViews {
665
689
  // Square-sized image to represent this collection.
666
690
  access(all) let squareImage: MetadataViews.Media
667
691
 
668
- // Banner-sized image for this collection, recommended to have a size near 1200x630.
692
+ // Banner-sized image for this collection, recommended to have a size near 1400x350.
669
693
  access(all) let bannerImage: MetadataViews.Media
670
694
 
671
695
  // Social links to reach this collection's social homepages.
@@ -703,4 +727,53 @@ access(all) contract MetadataViews {
703
727
  }
704
728
  return nil
705
729
  }
706
- }
730
+ /// This view may be used by Cadence-native projects to define their
731
+ /// contract- and token-level metadata according to EVM-compatible formats.
732
+ /// Several ERC standards (e.g. ERC20, ERC721, etc.) expose name and symbol
733
+ /// values to define assets as well as contract- & token-level metadata view
734
+ /// `tokenURI(uint256)` and `contractURI()` methods. This view enables
735
+ /// Cadence projects to define in their own contracts how they would like
736
+ /// their metadata to be defined when bridged to EVM.
737
+ ///
738
+ access(all) struct EVMBridgedMetadata {
739
+
740
+ /// The name of the asset
741
+ ///
742
+ access(all) let name: String
743
+
744
+ /// The symbol of the asset
745
+ ///
746
+ access(all) let symbol: String
747
+
748
+ /// The URI of the asset - this can either be contract-level or
749
+ /// token-level URI depending on where the metadata is resolved. It
750
+ /// is recommended to reference EVM metadata standards for how to best
751
+ /// prepare your view's formatted value.
752
+ ///
753
+ /// For example, while you may choose to take advantage of onchain
754
+ /// metadata, as is the case for most Cadence NFTs, you may also choose
755
+ /// to represent your asset's metadata in IPFS and assign this value as
756
+ /// an IPFSFile struct pointing to that IPFS file. Alternatively, you
757
+ /// may serialize your NFT's metadata and assign it as a JSON string
758
+ /// data URL representating the NFT's onchain metadata at the time this
759
+ /// view is resolved.
760
+ ///
761
+ access(all) let uri: {File}
762
+
763
+ init(name: String, symbol: String, uri: {File}) {
764
+ self.name = name
765
+ self.symbol = symbol
766
+ self.uri = uri
767
+ }
768
+ }
769
+
770
+ access(all) fun getEVMBridgedMetadata(_ viewResolver: &{ViewResolver.Resolver}) : EVMBridgedMetadata? {
771
+ if let view = viewResolver.resolveView(Type<EVMBridgedMetadata>()) {
772
+ if let v = view as? EVMBridgedMetadata {
773
+ return v
774
+ }
775
+ }
776
+ return nil
777
+ }
778
+
779
+ }
@@ -298,7 +298,7 @@ access(all) contract HybridCustody {
298
298
  /// Adds a ChildAccount Capability to this Manager. If a default Filter is set in the manager, it will also be
299
299
  /// added to the ChildAccount
300
300
  ///
301
- access(Manage | Insert) fun addAccount(cap: Capability<auth(Child) &{AccountPrivate, AccountPublic, ViewResolver.Resolver}>) {
301
+ access(Manage) fun addAccount(cap: Capability<auth(Child) &{AccountPrivate, AccountPublic, ViewResolver.Resolver}>) {
302
302
  pre {
303
303
  self.childAccounts[cap.address] == nil: "There is already a child account with this address"
304
304
  }
@@ -336,7 +336,7 @@ access(all) contract HybridCustody {
336
336
  /// Removes specified child account from the Manager's child accounts. Callbacks to the child account remove
337
337
  /// any associated resources and Capabilities
338
338
  ///
339
- access(Manage | Remove) fun removeChild(addr: Address) {
339
+ access(Manage) fun removeChild(addr: Address) {
340
340
  let cap = self.childAccounts.remove(key: addr)
341
341
  ?? panic("child account not found")
342
342
 
@@ -370,7 +370,7 @@ access(all) contract HybridCustody {
370
370
  /// Adds an owned account to the Manager's list of owned accounts, setting the Manager account as the owner of
371
371
  /// the given account
372
372
  ///
373
- access(Manage | Insert) fun addOwnedAccount(cap: Capability<auth(Owner) &{OwnedAccountPrivate, OwnedAccountPublic, ViewResolver.Resolver}>) {
373
+ access(Manage) fun addOwnedAccount(cap: Capability<auth(Owner) &{OwnedAccountPrivate, OwnedAccountPublic, ViewResolver.Resolver}>) {
374
374
  pre {
375
375
  self.ownedAccounts[cap.address] == nil: "There is already an owned account with this address"
376
376
  }
@@ -424,7 +424,7 @@ access(all) contract HybridCustody {
424
424
  /// Removes specified child account from the Manager's child accounts. Callbacks to the child account remove
425
425
  /// any associated resources and Capabilities
426
426
  ///
427
- access(Manage | Remove) fun removeOwned(addr: Address) {
427
+ access(Manage) fun removeOwned(addr: Address) {
428
428
  if let acct = self.ownedAccounts.remove(key: addr) {
429
429
  if acct.check() {
430
430
  acct.borrow()!.seal()
@@ -954,7 +954,7 @@ access(all) contract HybridCustody {
954
954
  /// configured for the provided parent address. Once done, the parent will not have any valid capabilities with
955
955
  /// which to access the child account.
956
956
  ///
957
- access(Owner | Remove) fun removeParent(parent: Address): Bool {
957
+ access(Owner) fun removeParent(parent: Address): Bool {
958
958
  if self.parents[parent] == nil {
959
959
  return false
960
960
  }
@@ -983,8 +983,8 @@ access(all) contract HybridCustody {
983
983
  emit AccountUpdated(id: self.uuid, child: self.acct.address, parent: parent, active: false)
984
984
 
985
985
  let parentManager = getAccount(parent).capabilities.get<&{ManagerPublic}>(HybridCustody.ManagerPublicPath)
986
- if parentManager?.check() == true {
987
- parentManager!.borrow()?.removeParentCallback(child: acct.address)
986
+ if parentManager.check() {
987
+ parentManager.borrow()?.removeParentCallback(child: acct.address)
988
988
  }
989
989
 
990
990
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowtyio/flow-contracts",
3
- "version": "0.1.0-beta.19",
3
+ "version": "0.1.0-beta.20",
4
4
  "main": "index.json",
5
5
  "description": "An NPM package for common flow contracts",
6
6
  "author": "flowtyio",