Handle Invalid Instructions

Change-Id: I8a6a15b7744e69c7eab88ef50295480bc5fb96ae
This commit is contained in:
Reisen 2021-07-23 14:13:47 +00:00 committed by Hendrik Hofstadt
parent 28c0c3c195
commit db4c0f8f74
2 changed files with 16 additions and 3 deletions

View File

@ -45,6 +45,9 @@ pub enum SolitaireError {
/// Account has already been initialized
AlreadyInitialized(Pubkey),
/// An instruction that wasn't recognised was sent.
UnknownInstruction,
Custom(u64),
}

View File

@ -34,14 +34,24 @@ macro_rules! solitaire {
{ $($row:ident($kind:ty) => $fn:ident),+ $(,)* } => {
pub mod instruction {
use super::*;
use borsh::{BorshDeserialize, BorshSerialize};
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use solana_program::{
account_info::AccountInfo,
entrypoint::ProgramResult,
program_error::ProgramError,
pubkey::Pubkey,
};
use solitaire::{ExecutionContext, FromAccounts, Persist, Result, trace, SolitaireError};
use solitaire::{
trace,
ExecutionContext,
FromAccounts,
Persist,
Result,
SolitaireError,
};
/// Generated:
/// This Instruction contains a 1-1 mapping for each enum variant to function call. The
@ -69,7 +79,7 @@ macro_rules! solitaire {
)*
_ => {
Ok(())
Err(SolitaireError::UnknownInstruction)
}
}
}