From 9fb7914c5d5a045218b3afad9b25d644d731f388 Mon Sep 17 00:00:00 2001 From: Austin Kline Date: Mon, 30 Jan 2023 10:08:56 -0800 Subject: [PATCH] add a metadata view to designate an nft as a pack --- contracts/MetadataViews.cdc | 22 +++++++++++++++++ docs/MetdataViews/MetadataViews_Pack.md | 32 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 docs/MetdataViews/MetadataViews_Pack.md diff --git a/contracts/MetadataViews.cdc b/contracts/MetadataViews.cdc index 402cdd04..1c733e6e 100644 --- a/contracts/MetadataViews.cdc +++ b/contracts/MetadataViews.cdc @@ -695,6 +695,28 @@ pub contract MetadataViews { } } + // Taken from GaiaPackNFT https://flow-view-source.com/mainnet/account/0xfdae91e14e960079/contract/GaiaPackNFT + // AllDay Packs have a subset of these so it should be safe to use this more verbose set + pub enum PackStatus: UInt8 { + pub case Sealed + pub case RevealRequested + pub case Revealed + pub case OpenRequested + pub case Opened + } + + pub struct Pack { + pub let status: PackStatus + + pub fun isOpen(): Bool { + return self.status == PackStatus.Opened + } + + init(_ status: PackStatus) { + self.status = status + } + } + /// Helper to get Traits view in a typesafe way /// /// @param viewResolver: A reference to the resolver resource diff --git a/docs/MetdataViews/MetadataViews_Pack.md b/docs/MetdataViews/MetadataViews_Pack.md new file mode 100644 index 00000000..9479e77a --- /dev/null +++ b/docs/MetdataViews/MetadataViews_Pack.md @@ -0,0 +1,32 @@ +# Struct `Pack` + +```cadence +pub struct Pack { + pub let status: PackStatus + +} +``` + +View to return the status of an nft if it is a pack. + +NOTE: **This view should only be supported if it is a pack** + +### Initializer + +```cadence +init(_ status: PackStatus) +``` + + +## Functions + +### `isOpened()` + +```cadence +pub fun isOpen(): Bool +``` +Returns a boolean marking whether this pack has been opened or not + +Parameters: None + +---