Skip to content

Commit ed27155

Browse files
committed
generalize to allow non approve program calls that dont invoke user + docs
1 parent 8680311 commit ed27155

File tree

2 files changed

+123
-308
lines changed

2 files changed

+123
-308
lines changed

auction-server/src/api.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ pub enum InstructionError {
111111
UnsupportedSplTokenInstruction(String),
112112
InvalidAssociatedTokenAccountInstruction(String),
113113
UnsupportedAssociatedTokenAccountInstruction(AssociatedTokenAccountInstruction),
114-
TransferInstructionNotAllowed,
115114
CloseAccountInstructionNotAllowed,
116-
InvalidTransferInstructionsCount,
117-
InvalidFromAccountTransferInstruction { expected: Pubkey, found: Pubkey },
115+
InvalidUserTransferInstructionsCount { found: usize },
116+
InvalidUserAccountTransferInstruction,
118117
InvalidToAccountTransferInstruction { expected: Pubkey, found: Pubkey },
119118
InvalidAmountTransferInstruction { expected: u64, found: u64 },
120119
InvalidSyncNativeInstructionCount(Pubkey),
@@ -129,8 +128,7 @@ pub enum InstructionError {
129128
InvalidTokenProgramInCreateAtaInstruction { expected: Pubkey, found: Pubkey },
130129
InvalidSystemProgramInCreateAtaInstruction(Pubkey),
131130
MissingCreateAtaInstruction(Pubkey),
132-
InvalidMemoInstructionCount { expected: usize, found: usize },
133-
InvalidMemoString { expected: String, found: String },
131+
MissingMemoInstruction { expected: String },
134132
UnapprovedProgramId(Pubkey),
135133
}
136134

@@ -155,21 +153,17 @@ impl std::fmt::Display for InstructionError {
155153
"Unsupported associated token account instruction {:?}",
156154
instruction
157155
),
158-
InstructionError::TransferInstructionNotAllowed => {
159-
write!(f, "Transfer instruction is not allowed")
160-
}
161156
InstructionError::CloseAccountInstructionNotAllowed => {
162157
write!(f, "Close account instruction is not allowed")
163158
}
164-
InstructionError::InvalidTransferInstructionsCount => {
165-
write!(f, "Exactly one sol transfer instruction is required")
159+
InstructionError::InvalidUserTransferInstructionsCount { found } => {
160+
match found {
161+
0 => write!(f, "At least one sol transfer instruction from the user wallet account is required"),
162+
_ => write!(f, "Invalid number ({}) of sol transfer instructions from the user wallet account", found),
163+
}
166164
}
167-
InstructionError::InvalidFromAccountTransferInstruction { expected, found } => {
168-
write!(
169-
f,
170-
"Invalid from account in sol transfer instruction. Expected: {:?} found: {:?}",
171-
expected, found
172-
)
165+
InstructionError::InvalidUserAccountTransferInstruction => {
166+
write!(f, "Invalid sol transfer instruction from the user account.")
173167
}
174168
InstructionError::InvalidToAccountTransferInstruction { expected, found } => {
175169
write!(
@@ -261,18 +255,11 @@ impl std::fmt::Display for InstructionError {
261255
ata
262256
)
263257
}
264-
InstructionError::InvalidMemoInstructionCount { expected, found } => {
258+
InstructionError::MissingMemoInstruction { expected } => {
265259
write!(
266260
f,
267-
"Invalid memo instruction count. Expected: {:?} found: {:?}",
268-
expected, found
269-
)
270-
}
271-
InstructionError::InvalidMemoString { expected, found } => {
272-
write!(
273-
f,
274-
"Invalid memo string in memo instruction. Expected: {:?} found: {:?}",
275-
expected, found
261+
"Missing memo instruction with string: {:?}",
262+
expected,
276263
)
277264
}
278265
InstructionError::UnapprovedProgramId(program_id) => {

0 commit comments

Comments
 (0)