Skip to content

Commit

Permalink
Adding supply and decimal checks. (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus authored Jun 29, 2023
1 parent 8e5e190 commit e55f2a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions token-metadata/program/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ pub enum MetadataError {
EditionAlreadyMinted,

/// Printing mint decimals should be zero
#[error("Printing mint decimals should be zero")]
/// This error is unused, but kept for backwards compatibility
#[error("")]
PrintingMintDecimalsShouldBeZero,

/// OneTimePrintingAuthorizationMint mint decimals should be zero
#[error("OneTimePrintingAuthorization mint decimals should be zero")]
/// This error is unused, but kept for backwards compatibility
#[error("")]
OneTimePrintingAuthorizationMintDecimalsShouldBeZero,

/// Edition mint decimals should be zero
Expand Down
5 changes: 4 additions & 1 deletion token-metadata/program/src/processor/metadata/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ fn print_v1(_program_id: &Pubkey, ctx: Context<Print>, args: PrintArgs) -> Progr
)?;
} else {
assert_owned_by(edition_token_account_info, &spl_token::id())?;
let _edition_token_account: spl_token::state::Account =
let edition_token_account: spl_token::state::Account =
assert_initialized(edition_token_account_info)?;
if edition_token_account.amount < 1 {
return Err(MetadataError::NotEnoughTokens.into());
}
}

if ata_program.key != &spl_associated_token_account::ID {
Expand Down
4 changes: 4 additions & 0 deletions token-metadata/program/src/utils/master_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ pub fn mint_limited_edition<'a>(
let me_supply = get_supply_off_master_edition(master_edition_account_info)?;
let mint_authority = get_mint_authority(mint_info)?;
let mint_supply = get_mint_supply(mint_info)?;
let mint_decimals = get_mint_decimals(mint_info)?;
assert_mint_authority_matches_mint(&mint_authority, mint_authority_info)?;

assert_edition_valid(
Expand Down Expand Up @@ -451,6 +452,9 @@ pub fn mint_limited_edition<'a>(
if mint_supply != 1 {
return Err(MetadataError::EditionsMustHaveExactlyOneToken.into());
}
if mint_decimals != 0 {
return Err(MetadataError::EditionMintDecimalsShouldBeZero.into());
}
let master_data = master_metadata.data;
// bundle data into v2
let data_v2 = DataV2 {
Expand Down

0 comments on commit e55f2a8

Please sign in to comment.