Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
token metadata: replace IncorrectMintAuthority with `TokenError::Ow…
Browse files Browse the repository at this point in the history
…nerMismatch`
  • Loading branch information
buffalojoec committed Oct 19, 2023
1 parent 1ce94c7 commit eaab1ed
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion token-metadata/example/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
},
spl_pod::optional_keys::OptionalNonZeroPubkey,
spl_token_2022::{
error::TokenError,
extension::{update_authority::check_update_authority, StateWithExtensions},
state::Mint,
},
Expand Down Expand Up @@ -53,7 +54,7 @@ pub fn process_initialize(
return Err(ProgramError::MissingRequiredSignature);
}
if mint.base.mint_authority.as_ref() != COption::Some(mint_authority_info.key) {
return Err(TokenMetadataError::IncorrectMintAuthority.into());
return Err(TokenError::OwnerMismatch.into());
}
}

Expand Down
7 changes: 3 additions & 4 deletions token-metadata/example/tests/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use {
system_instruction,
transaction::{Transaction, TransactionError},
},
spl_token_metadata_interface::{
error::TokenMetadataError, instruction::initialize, state::TokenMetadata,
},
spl_token_2022::error::TokenError,
spl_token_metadata_interface::{instruction::initialize, state::TokenMetadata},
spl_type_length_value::{
error::TlvError,
state::{TlvState, TlvStateBorrowed},
Expand Down Expand Up @@ -265,7 +264,7 @@ async fn fail_incorrect_authority() {
error,
TransactionError::InstructionError(
1,
InstructionError::Custom(TokenMetadataError::IncorrectMintAuthority as u32)
InstructionError::Custom(TokenError::OwnerMismatch as u32)
)
);
}
3 changes: 0 additions & 3 deletions token-metadata/interface/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ pub enum TokenMetadataError {
/// Mint has no mint authority
#[error("Mint has no mint authority")]
MintHasNoMintAuthority,
/// Incorrect mint authority has signed the instruction
#[error("Incorrect mint authority has signed the instruction")]
IncorrectMintAuthority,
/// Incorrect metadata update authority has signed the instruction
#[error("Incorrect metadata update authority has signed the instruction")]
IncorrectUpdateAuthority,
Expand Down
4 changes: 2 additions & 2 deletions token/program-2022-test/tests/token_metadata_initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
},
spl_token_2022::{error::TokenError, extension::BaseStateWithExtensions, processor::Processor},
spl_token_client::token::{ExtensionInitializationParams, TokenError as TokenClientError},
spl_token_metadata_interface::{error::TokenMetadataError, state::TokenMetadata},
spl_token_metadata_interface::state::TokenMetadata,
std::{convert::TryInto, sync::Arc},
};

Expand Down Expand Up @@ -110,7 +110,7 @@ async fn success_initialize() {
TokenClientError::Client(Box::new(TransportError::TransactionError(
TransactionError::InstructionError(
1,
InstructionError::Custom(TokenMetadataError::IncorrectMintAuthority as u32)
InstructionError::Custom(TokenError::OwnerMismatch as u32)
)
)))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn process_initialize(
return Err(ProgramError::MissingRequiredSignature);
}
if mint.base.mint_authority.as_ref() != COption::Some(mint_authority_info.key) {
return Err(TokenMetadataError::IncorrectMintAuthority.into());
return Err(TokenError::OwnerMismatch.into());
}

if mint.get_extension::<MetadataPointer>().is_err() {
Expand Down

0 comments on commit eaab1ed

Please sign in to comment.