Skip to content

Instantly share code, notes, and snippets.

@bhgames
Created January 8, 2022 01:14
Show Gist options
  • Save bhgames/26c5423b6446d7160d8befe9441d04df to your computer and use it in GitHub Desktop.
Save bhgames/26c5423b6446d7160d8befe9441d04df to your computer and use it in GitHub Desktop.
Rough idea
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub enum CollectionStatus {
Unverified,
Verified,
CollectionMasterEdition,
}
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub enum UseType {
Burn,
Multiple,
Single,
}
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub enum TokenType {
NonFungible,
SemiFungible,
Fungible,
Edition,
}
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct Uses {
pub use_type: UseType,
pub uses: u64,
pub available_uses: u64,
}
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct Collection {
pub status: CollectionStatus,
pub collection_key: Pubkey,
}
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct DataV2 {
/// The name of the asset
pub name: String,
/// The symbol for the asset
pub symbol: String,
/// URI pointing to JSON representing the asset
pub uri: String,
/// Royalty basis points that goes to creators in secondary sales (0-10000)
pub seller_fee_basis_points: u16,
/// Array of creators, optional
pub creators: Option<Vec<Creator>>,
/// Collection
pub collection: Option<Collection>,
/// Uses
pub uses: Option<Uses>,
}
#[repr(C)]
#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)]
pub struct Metadata {
pub key: Key,
pub update_authority: Pubkey,
pub mint: Pubkey,
pub data: Data,
// Immutable, once flipped, all sales of this metadata are considered secondary.
pub primary_sale_happened: bool,
// Whether or not the data struct is mutable, default is not
pub is_mutable: bool,
/// nonce for easy calculation of editions, if present
pub edition_nonce: Option<u8>,
/// Since we cannot easily change Metadata, we add the new DataV2 fields here at the end.
/// Collection
pub collection: Option<Collection>,
/// Uses
pub uses: Option<Uses>,
/// Token type is deterministic and will change from SemiFungible to NonFungible if
/// you call the create master edition call and it succeeds.
pub token_type: Option<TokenType>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment