1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::collections::HashMap;
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};
use crate::{json::Base64VecU8, AccountId};
pub type TokenId = String;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize, BorshSerialize)]
pub struct NFTContractMetadata {
pub spec: String, // required, essentially a version like "nft-1.0.0"
pub name: String, // required, ex. "Mosaics"
pub symbol: String, // required, ex. "MOSAIC"
pub icon: Option<String>, // Data URL
pub base_uri: Option<String>, // Centralized gateway known to have reliable access to decentralized storage assets referenced by `reference` or `media` URLs
pub reference: Option<String>, // URL to a JSON file with more info
pub reference_hash: Option<Base64VecU8>, // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included.
}
#[derive(
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize, BorshSerialize,
)]
pub struct TokenMetadata {
pub title: Option<String>, // ex. "Arch Nemesis: Mail Carrier" or "Parcel #5055"
pub description: Option<String>, // free-form description
pub media: Option<String>, // URL to associated media, preferably to decentralized, content-addressed storage
pub media_hash: Option<Base64VecU8>, // Base64-encoded sha256 hash of content referenced by the `media` field. Required if `media` is included.
pub copies: Option<u64>, // number of copies of this set of metadata in existence when token was minted.
pub issued_at: Option<String>, // ISO 8601 datetime when token was issued or minted
pub expires_at: Option<String>, // ISO 8601 datetime when token expires
pub starts_at: Option<String>, // ISO 8601 datetime when token starts being valid
pub updated_at: Option<String>, // ISO 8601 datetime when token was last updated
pub extra: Option<String>, // anything extra the NFT wants to store on-chain. Can be stringified JSON.
pub reference: Option<String>, // URL to an off-chain JSON file with more info.
pub reference_hash: Option<Base64VecU8>, // Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included.
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, BorshDeserialize, BorshSerialize)]
pub struct Token {
pub token_id: TokenId,
pub owner_id: AccountId,
pub metadata: Option<TokenMetadata>,
pub approved_account_ids: Option<HashMap<AccountId, u64>>,
}