Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(token-metadata): add burn_print_edition handler #684

Merged
merged 27 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
681652d
feat(token-metadata): add burn_print_edition handler
samuelvanderwaal Aug 19, 2022
8cb4b4f
Merge branch 'master' into feat/burn-print-editions
samuelvanderwaal Aug 19, 2022
fed8698
fix(burn-print-edition): clippy lints
samuelvanderwaal Aug 23, 2022
e949d4e
fix: clippy lints
samuelvanderwaal Aug 23, 2022
a20d4fc
tests(token-metadata): add more tests
samuelvanderwaal Aug 23, 2022
5f3d0cb
chore(token-metadata): generate JS code for burn_edition_nft
samuelvanderwaal Aug 23, 2022
8d62056
Merge branch 'master' into feat/burn-print-editions
samuelvanderwaal Aug 24, 2022
ea15701
test(burn_edition_nft): only holder of print edition can burn
samuelvanderwaal Aug 24, 2022
836937a
test(token-metadata/burn_edition_nft): reprint burned nft
samuelvanderwaal Aug 25, 2022
e0fb85e
chore(token-metadata): merge master into branch
samuelvanderwaal Aug 25, 2022
b9a4b0c
test(token-metadata) refactor burn_edition_nft tests a little
samuelvanderwaal Aug 25, 2022
455c745
test(token-metdata): make mask check more complex
samuelvanderwaal Aug 25, 2022
2ec0b82
fix: clippy lints
samuelvanderwaal Aug 25, 2022
ded9c23
refactor: fix supply account; decrement max_supply
samuelvanderwaal Aug 31, 2022
3ffe8a8
chore: merge master into branch
samuelvanderwaal Aug 31, 2022
662c5e7
Merge branch 'master' into feat/burn-print-editions
samuelvanderwaal Sep 8, 2022
4f19f68
finish spec implementation; update tests
samuelvanderwaal Sep 14, 2022
da20c43
Merge branch 'master' into feat/burn-print-editions
samuelvanderwaal Sep 14, 2022
72257b1
refactor: update tests for new supply accounting; remove unused fn
samuelvanderwaal Sep 14, 2022
ce68d7e
chore: generate JS lib for token metadata
samuelvanderwaal Sep 14, 2022
a836cbc
chore: clean up tests
samuelvanderwaal Sep 14, 2022
c657d1c
fix: decrement max supply correctly
samuelvanderwaal Sep 14, 2022
cdfebb8
add missing check; regnerate JS api
samuelvanderwaal Sep 16, 2022
6307d9a
refactor: address review comments
samuelvanderwaal Sep 19, 2022
b92e489
add tests checking invalid master & print derivations
samuelvanderwaal Sep 19, 2022
6aefd85
tests: add a few more tests
samuelvanderwaal Sep 19, 2022
3326dd1
chore(token-metadata/js): generate JS lib
samuelvanderwaal Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(token-metadata): merge master into branch
  • Loading branch information
samuelvanderwaal committed Aug 25, 2022
commit e0fb85e5cf14872831395ee14183fb3dd54b4b8f
4 changes: 2 additions & 2 deletions token-metadata/program/src/deprecated_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ use solana_program::{

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct MintPrintingTokensViaTokenArgs {
pub supply: u64,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct SetReservationListArgs {
/// If set, means that no more than this number of editions can ever be minted. This is immutable.
pub reservations: Vec<Reservation>,
Expand Down
20 changes: 10 additions & 10 deletions token-metadata/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
/// Args for update call
pub struct UpdateMetadataAccountArgs {
pub data: Option<Data>,
Expand All @@ -34,7 +34,7 @@ pub struct UpdateMetadataAccountArgs {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
/// Args for update call
pub struct UpdateMetadataAccountArgsV2 {
pub data: Option<DataV2>,
Expand All @@ -49,7 +49,7 @@ pub struct UpdateMetadataAccountArgsV2 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
/// Args for create call
pub struct CreateMetadataAccountArgs {
/// Note that unique metadatas are disabled for now.
Expand All @@ -60,7 +60,7 @@ pub struct CreateMetadataAccountArgs {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
/// Args for create call
pub struct CreateMetadataAccountArgsV2 {
/// Note that unique metadatas are disabled for now.
Expand All @@ -71,7 +71,7 @@ pub struct CreateMetadataAccountArgsV2 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
/// Args for create call
pub struct CreateMetadataAccountArgsV3 {
/// Note that unique metadatas are disabled for now.
Expand All @@ -84,36 +84,36 @@ pub struct CreateMetadataAccountArgsV3 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct CreateMasterEditionArgs {
/// If set, means that no more than this number of editions can ever be minted. This is immutable.
pub max_supply: Option<u64>,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct MintNewEditionFromMasterEditionViaTokenArgs {
pub edition: u64,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct ApproveUseAuthorityArgs {
pub number_of_uses: u64,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct UtilizeArgs {
pub number_of_uses: u64,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct SetCollectionSizeArgs {
pub size: u64,
}
Expand Down
38 changes: 19 additions & 19 deletions token-metadata/program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ where {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, Copy)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, Copy)]
pub enum Key {
Uninitialized,
EditionV1,
Expand All @@ -141,7 +141,7 @@ pub enum Key {
}
#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Default, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, Default, PartialEq, Eq, Debug, Clone)]
pub struct Data {
/// The name of the asset
pub name: String,
Expand All @@ -157,7 +157,7 @@ pub struct Data {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct DataV2 {
/// The name of the asset
pub name: String,
Expand Down Expand Up @@ -190,7 +190,7 @@ impl DataV2 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub enum UseMethod {
Burn,
Multiple,
Expand All @@ -199,14 +199,14 @@ pub enum UseMethod {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub enum CollectionDetails {
V1 { size: u64 },
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct Uses {
// 17 bytes + Option byte
pub use_method: UseMethod, //1
Expand All @@ -216,7 +216,7 @@ pub struct Uses {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub enum TokenStandard {
NonFungible, // This is a master edition
FungibleAsset, // A token with metadata that can also have attrributes
Expand All @@ -226,7 +226,7 @@ pub enum TokenStandard {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, ShankAccount)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
pub struct UseAuthorityRecord {
pub key: Key, //1
pub allowed_uses: u64, //8
Expand Down Expand Up @@ -267,7 +267,7 @@ impl UseAuthorityRecord {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, ShankAccount)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
pub struct CollectionAuthorityRecord {
pub key: Key, //1
pub bump: u8, //1
Expand Down Expand Up @@ -305,15 +305,15 @@ impl CollectionAuthorityRecord {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct Collection {
pub verified: bool,
pub key: Pubkey,
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(Clone, BorshSerialize, Debug, Eq, PartialEq, ShankAccount)]
#[derive(Clone, BorshSerialize, Debug, PartialEq, Eq, ShankAccount)]
pub struct Metadata {
pub key: Key,
pub update_authority: Pubkey,
Expand Down Expand Up @@ -402,7 +402,7 @@ pub fn get_master_edition(account: &AccountInfo) -> Result<Box<dyn MasterEdition

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq, BorshSerialize, BorshDeserialize, ShankAccount)]
#[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize, ShankAccount)]
pub struct MasterEditionV2 {
pub key: Key,

Expand Down Expand Up @@ -456,7 +456,7 @@ impl MasterEdition for MasterEditionV2 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq, BorshSerialize, BorshDeserialize, ShankAccount)]
#[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize, ShankAccount)]
pub struct MasterEditionV1 {
pub key: Key,

Expand Down Expand Up @@ -515,7 +515,7 @@ impl MasterEdition for MasterEditionV1 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq, BorshSerialize, BorshDeserialize, ShankAccount)]
#[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize, ShankAccount)]
/// All Editions should never have a supply greater than 1.
/// To enforce this, a transfer mint authority instruction will happen when
/// a normal token is turned into an Edition, and in order for a Metadata update authority
Expand Down Expand Up @@ -608,7 +608,7 @@ pub fn get_reservation_list(

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, ShankAccount)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
pub struct ReservationListV2 {
pub key: Key,
/// Present for reverse lookups
Expand Down Expand Up @@ -728,7 +728,7 @@ impl ReservationList for ReservationListV2 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct Reservation {
pub address: Pubkey,
pub spots_remaining: u64,
Expand All @@ -738,7 +738,7 @@ pub struct Reservation {
// Legacy Reservation List with u8s
#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, ShankAccount)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
pub struct ReservationListV1 {
pub key: Key,
/// Present for reverse lookups
Expand Down Expand Up @@ -829,7 +829,7 @@ impl ReservationList for ReservationListV1 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct ReservationV1 {
pub address: Pubkey,
pub spots_remaining: u8,
Expand All @@ -838,7 +838,7 @@ pub struct ReservationV1 {

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone, ShankAccount)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
pub struct EditionMarker {
pub key: Key,
pub ledger: [u8; 31],
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.