Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
49 changes: 20 additions & 29 deletions auction-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ pub enum InstructionError {
UnsupportedSplTokenInstruction(String),
InvalidAssociatedTokenAccountInstruction(String),
UnsupportedAssociatedTokenAccountInstruction(AssociatedTokenAccountInstruction),
UnsupportedProgram(Pubkey),
TransferInstructionNotAllowed,
CloseAccountInstructionNotAllowed,
InvalidTransferInstructionsCount,
InvalidFromAccountTransferInstruction { expected: Pubkey, found: Pubkey },
InvalidUserTransferInstructionsCount { found: usize },
InvalidUserAccountTransferInstruction,
InvalidToAccountTransferInstruction { expected: Pubkey, found: Pubkey },
InvalidAmountTransferInstruction { expected: u64, found: u64 },
InvalidSyncNativeInstructionCount(Pubkey),
Expand All @@ -130,8 +128,9 @@ pub enum InstructionError {
InvalidTokenProgramInCreateAtaInstruction { expected: Pubkey, found: Pubkey },
InvalidSystemProgramInCreateAtaInstruction(Pubkey),
MissingCreateAtaInstruction(Pubkey),
InvalidMemoInstructionCount { expected: usize, found: usize },
InvalidMemoString { expected: String, found: String },
MissingMemoInstruction { expected: String },
UnapprovedProgramId(Pubkey),
RelayerTransferInstructionNotAllowed,
}

impl std::fmt::Display for InstructionError {
Expand All @@ -155,24 +154,17 @@ impl std::fmt::Display for InstructionError {
"Unsupported associated token account instruction {:?}",
instruction
),
InstructionError::UnsupportedProgram(program) => {
write!(f, "Unsupported program {}", program)
}
InstructionError::TransferInstructionNotAllowed => {
write!(f, "Transfer instruction is not allowed")
}
InstructionError::CloseAccountInstructionNotAllowed => {
write!(f, "Close account instruction is not allowed")
}
InstructionError::InvalidTransferInstructionsCount => {
write!(f, "Exactly one sol transfer instruction is required")
InstructionError::InvalidUserTransferInstructionsCount { found } => {
match found {
0 => write!(f, "At least one sol transfer instruction from the user wallet account is required"),
_ => write!(f, "Invalid number ({}) of sol transfer instructions from the user wallet account", found),
}
}
InstructionError::InvalidFromAccountTransferInstruction { expected, found } => {
write!(
f,
"Invalid from account in sol transfer instruction. Expected: {:?} found: {:?}",
expected, found
)
InstructionError::InvalidUserAccountTransferInstruction => {
write!(f, "Invalid sol transfer instruction from the user account.")
}
InstructionError::InvalidToAccountTransferInstruction { expected, found } => {
write!(
Expand Down Expand Up @@ -264,19 +256,18 @@ impl std::fmt::Display for InstructionError {
ata
)
}
InstructionError::InvalidMemoInstructionCount { expected, found } => {
InstructionError::MissingMemoInstruction { expected } => {
write!(
f,
"Invalid memo instruction count. Expected: {:?} found: {:?}",
expected, found
"Missing memo instruction with string: {:?}",
expected,
)
}
InstructionError::InvalidMemoString { expected, found } => {
write!(
f,
"Invalid memo string in memo instruction. Expected: {:?} found: {:?}",
expected, found
)
InstructionError::UnapprovedProgramId(program_id) => {
write!(f, "Instruction has unapproved program id: {:?}", program_id)
}
InstructionError::RelayerTransferInstructionNotAllowed => {
write!(f, "Relayer transfer instruction is not allowed")
}
}
}
Expand Down
Loading
Loading