diff --git a/sdk/src/native_program.rs b/sdk/src/native_program.rs index 03b7ea9ab1..815de12cd2 100644 --- a/sdk/src/native_program.rs +++ b/sdk/src/native_program.rs @@ -28,3 +28,24 @@ macro_rules! solana_entrypoint( } ) ); + +/// Reasons a program might have rejected an instruction. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum ProgramError { + /// Contract's transactions resulted in an account with a negative balance + /// The difference from InsufficientFundsForFee is that the transaction was executed by the + /// contract + ResultWithNegativeTokens, + + /// The program returned an error + GenericError, + + /// Program's instruction token balance does not equal the balance after the instruction + UnbalancedInstruction, + + /// Program modified an account's program id + ModifiedProgramId, + + /// Program spent the tokens of an account that doesn't belong to it + ExternalAccountTokenSpend, +} diff --git a/src/bank.rs b/src/bank.rs index a0d600304b..9c6e8b27ee 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -19,12 +19,12 @@ use native_loader; use payment_plan::Payment; use poh_recorder::PohRecorder; use poh_service::NUM_TICKS_PER_SECOND; -use program::ProgramError; use rayon::prelude::*; use rpc::RpcSignatureStatus; use runtime::{self, RuntimeError}; use solana_sdk::account::Account; use solana_sdk::hash::{hash, Hash}; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::Keypair; use solana_sdk::signature::Signature; diff --git a/src/budget_program.rs b/src/budget_program.rs index f9b375e62e..e2184ae5e3 100644 --- a/src/budget_program.rs +++ b/src/budget_program.rs @@ -4,8 +4,8 @@ use budget_expr::BudgetExpr; use budget_instruction::Instruction; use chrono::prelude::{DateTime, Utc}; use payment_plan::Witness; -use program::ProgramError; use solana_sdk::account::Account; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::transaction::Transaction; use std::io; diff --git a/src/lib.rs b/src/lib.rs index b07bb1a83f..ee8bc54187 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,6 @@ pub mod payment_plan; pub mod poh; pub mod poh_recorder; pub mod poh_service; -pub mod program; pub mod recvmmsg; pub mod replicate_stage; pub mod replicator; diff --git a/src/program.rs b/src/program.rs deleted file mode 100644 index 5804d5f73d..0000000000 --- a/src/program.rs +++ /dev/null @@ -1,20 +0,0 @@ -/// Reasons a program might have rejected an instruction. -#[derive(Debug, PartialEq, Eq, Clone)] -pub enum ProgramError { - /// Contract's transactions resulted in an account with a negative balance - /// The difference from InsufficientFundsForFee is that the transaction was executed by the - /// contract - ResultWithNegativeTokens, - - /// The program returned an error - GenericError, - - /// Program's instruction token balance does not equal the balance after the instruction - UnbalancedInstruction, - - /// Program modified an account's program id - ModifiedProgramId, - - /// Program spent the tokens of an account that doesn't belong to it - ExternalAccountTokenSpend, -} diff --git a/src/runtime.rs b/src/runtime.rs index 2cdd90e722..0eb0e33110 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -1,7 +1,7 @@ use budget_program; use native_loader; -use program::ProgramError; use solana_sdk::account::{create_keyed_accounts, Account, KeyedAccount}; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::transaction::Transaction; use storage_program; diff --git a/src/storage_program.rs b/src/storage_program.rs index 24f15af57c..9b6e2f4cf3 100644 --- a/src/storage_program.rs +++ b/src/storage_program.rs @@ -3,9 +3,9 @@ //! and give reward for good proofs. use bincode::deserialize; -use program::ProgramError; use solana_sdk::account::Account; use solana_sdk::hash::Hash; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::transaction::Transaction; diff --git a/src/system_program.rs b/src/system_program.rs index 829e1f0563..5fb547ced1 100644 --- a/src/system_program.rs +++ b/src/system_program.rs @@ -1,8 +1,8 @@ //! system program use bincode::deserialize; -use program::ProgramError; use solana_sdk::account::Account; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::system_instruction::{SystemInstruction, SYSTEM_PROGRAM_ID}; use solana_sdk::transaction::Transaction; diff --git a/src/vote_program.rs b/src/vote_program.rs index 77a0eb5720..909a00aa0d 100644 --- a/src/vote_program.rs +++ b/src/vote_program.rs @@ -3,8 +3,8 @@ use bincode::{deserialize, serialize}; use byteorder::{ByteOrder, LittleEndian}; -use program::ProgramError; use solana_sdk::account::Account; +use solana_sdk::native_program::ProgramError; use solana_sdk::pubkey::Pubkey; use solana_sdk::transaction::Transaction; use std;