backport #448 to v2
This commit is contained in:
parent
4f5e70684a
commit
51dc1ae267
|
@ -34,9 +34,6 @@ pub enum TokenError {
|
||||||
/// Invalid number of required signers.
|
/// Invalid number of required signers.
|
||||||
#[error("Invalid number of required signers")]
|
#[error("Invalid number of required signers")]
|
||||||
InvalidNumberOfRequiredSigners,
|
InvalidNumberOfRequiredSigners,
|
||||||
/// State is uninitialized.
|
|
||||||
#[error("State is unititialized")]
|
|
||||||
UninitializedState,
|
|
||||||
/// Instruction does not support native tokens
|
/// Instruction does not support native tokens
|
||||||
#[error("Instruction does not support native tokens")]
|
#[error("Instruction does not support native tokens")]
|
||||||
NativeNotSupported,
|
NativeNotSupported,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! State transition types
|
//! State transition types
|
||||||
|
|
||||||
use crate::error::TokenError;
|
|
||||||
use solana_sdk::program_error::ProgramError;
|
use solana_sdk::program_error::ProgramError;
|
||||||
|
|
||||||
/// Check is a token state is initialized
|
/// Check is a token state is initialized
|
||||||
|
@ -35,7 +34,7 @@ pub trait Pack: Sealed {
|
||||||
if value.is_initialized() {
|
if value.is_initialized() {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
} else {
|
} else {
|
||||||
Err(TokenError::UninitializedState.into())
|
Err(ProgramError::UninitializedAccount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -754,7 +754,6 @@ impl PrintProgramError for TokenError {
|
||||||
TokenError::InvalidNumberOfRequiredSigners => {
|
TokenError::InvalidNumberOfRequiredSigners => {
|
||||||
info!("Error: Invalid number of required signers")
|
info!("Error: Invalid number of required signers")
|
||||||
}
|
}
|
||||||
TokenError::UninitializedState => info!("Error: State is uninitialized"),
|
|
||||||
TokenError::NativeNotSupported => {
|
TokenError::NativeNotSupported => {
|
||||||
info!("Error: Instruction does not support native tokens")
|
info!("Error: Instruction does not support native tokens")
|
||||||
}
|
}
|
||||||
|
@ -2511,7 +2510,7 @@ mod tests {
|
||||||
|
|
||||||
// invalid account
|
// invalid account
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Err(TokenError::UninitializedState.into()),
|
Err(ProgramError::UninitializedAccount),
|
||||||
do_process_instruction(
|
do_process_instruction(
|
||||||
set_authority(
|
set_authority(
|
||||||
&program_id,
|
&program_id,
|
||||||
|
@ -3063,7 +3062,7 @@ mod tests {
|
||||||
|
|
||||||
// uninitialized destination account
|
// uninitialized destination account
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Err(TokenError::UninitializedState.into()),
|
Err(ProgramError::UninitializedAccount),
|
||||||
do_process_instruction(
|
do_process_instruction(
|
||||||
mint_to(
|
mint_to(
|
||||||
&program_id,
|
&program_id,
|
||||||
|
@ -4218,7 +4217,7 @@ mod tests {
|
||||||
|
|
||||||
// uninitialized
|
// uninitialized
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Err(TokenError::UninitializedState.into()),
|
Err(ProgramError::UninitializedAccount),
|
||||||
do_process_instruction(
|
do_process_instruction(
|
||||||
close_account(&program_id, &account_key, &account3_key, &owner2_key, &[]).unwrap(),
|
close_account(&program_id, &account_key, &account3_key, &owner2_key, &[]).unwrap(),
|
||||||
vec![
|
vec![
|
||||||
|
|
Loading…
Reference in New Issue