Skip to content

Commit

Permalink
feat: add JsonSchema derives to NFT exposed types (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinabell authored Aug 29, 2022
1 parent ac75737 commit dbaf969
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions near-contract-standards/src/non_fungible_token/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub const NFT_METADATA_SPEC: &str = "nft-1.0.0";

/// Metadata for the NFT contract itself.
#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "abi", derive(schemars::JsonSchema))]
#[serde(crate = "near_sdk::serde")]
pub struct NFTContractMetadata {
pub spec: String, // required, essentially a version like "nft-1.0.0"
Expand All @@ -21,6 +22,7 @@ pub struct NFTContractMetadata {

/// Metadata on the individual token level.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, BorshDeserialize, BorshSerialize)]
#[cfg_attr(feature = "abi", derive(schemars::JsonSchema))]
#[serde(crate = "near_sdk::serde")]
pub struct TokenMetadata {
pub title: Option<String>, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055"
Expand Down
1 change: 1 addition & 0 deletions near-contract-standards/src/non_fungible_token/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub type TokenId = String;

/// In this implementation, the Token struct takes two extensions standards (metadata and approval) as optional fields, as they are frequently used in modern NFTs.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "abi", derive(schemars::JsonSchema))]
#[serde(crate = "near_sdk::serde")]
pub struct Token {
pub token_id: TokenId,
Expand Down

0 comments on commit dbaf969

Please sign in to comment.