From a99dda54e11656a2231f89c70fdf0ce39c9f8ab2 Mon Sep 17 00:00:00 2001 From: Bjarte Stien Karlsen Date: Mon, 26 Apr 2021 20:35:27 +0200 Subject: [PATCH] reset Art paths and add cacheKey to art since blocto wants it --- contracts/Art.cdc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/contracts/Art.cdc b/contracts/Art.cdc index e5590e0..ad635c3 100644 --- a/contracts/Art.cdc +++ b/contracts/Art.cdc @@ -30,6 +30,8 @@ pub contract Art: NonFungibleToken { pub fun content() : String? pub let royalty: {String: Royalty} + pub fun cacheKey() : String + } pub struct Metadata { @@ -103,6 +105,13 @@ pub contract Art: NonFungibleToken { self.description=metadata.description } + pub fun cacheKey() : String { + if self.url != nil { + return self.url! + } + return self.contentId!.toString() + } + //return the content for this NFT pub fun content() : String { if self.url != nil { @@ -200,9 +209,11 @@ pub contract Art: NonFungibleToken { pub struct ArtData { pub let metadata: Art.Metadata pub let id: UInt64 - init(metadata: Art.Metadata, id: UInt64) { + pub let cacheKey: String + init(metadata: Art.Metadata, id: UInt64, cacheKey: String) { self.metadata= metadata self.id=id + self.cacheKey=cacheKey } } @@ -228,7 +239,8 @@ pub contract Art: NonFungibleToken { var art=artCollection.borrowArt(id: id) artData.append(ArtData( metadata: art!.metadata, - id: id)) + id: id, + cacheKey: art!.cacheKey())) } } return artData @@ -329,8 +341,8 @@ pub contract Art: NonFungibleToken { init() { // Initialize the total supply self.totalSupply = 0 - self.CollectionPublicPath=/public/versusArtCollection3 - self.CollectionStoragePath=/storage/versusArtCollection3 + self.CollectionPublicPath=/public/versusArtCollection + self.CollectionStoragePath=/storage/versusArtCollection self.account.save<@NonFungibleToken.Collection>(<- Art.createEmptyCollection(), to: Art.CollectionStoragePath) self.account.link<&{Art.CollectionPublic}>(Art.CollectionPublicPath, target: Art.CollectionStoragePath)