mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 23:16:48 +00:00
37 lines
1020 B
Rust
37 lines
1020 B
Rust
use steel::*;
|
|
|
|
use crate::{
|
|
consts::*,
|
|
state::{Config, Treasury},
|
|
};
|
|
|
|
pub trait OreAccountInfoValidation {
|
|
fn is_bus(&self) -> Result<&Self, ProgramError>;
|
|
fn is_config(&self) -> Result<&Self, ProgramError>;
|
|
fn is_treasury(&self) -> Result<&Self, ProgramError>;
|
|
fn is_treasury_tokens(&self) -> Result<&Self, ProgramError>;
|
|
}
|
|
|
|
impl OreAccountInfoValidation for AccountInfo<'_> {
|
|
fn is_bus(&self) -> Result<&Self, ProgramError> {
|
|
if !BUS_ADDRESSES.contains(self.key) {
|
|
return Err(ProgramError::InvalidSeeds);
|
|
}
|
|
Ok(self)
|
|
}
|
|
|
|
fn is_config(&self) -> Result<&Self, ProgramError> {
|
|
self.has_address(&CONFIG_ADDRESS)?
|
|
.is_type::<Config>(&crate::ID)
|
|
}
|
|
|
|
fn is_treasury(&self) -> Result<&Self, ProgramError> {
|
|
self.has_address(&TREASURY_ADDRESS)?
|
|
.is_type::<Treasury>(&crate::ID)
|
|
}
|
|
|
|
fn is_treasury_tokens(&self) -> Result<&Self, ProgramError> {
|
|
self.has_address(&TREASURY_TOKENS_ADDRESS)
|
|
}
|
|
}
|