#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use rialo_s_pubkey::Pubkey;
pub mod error;
pub mod features;
pub mod instruction;
pub mod state;
rialo_s_pubkey::declare_id!("Feature1111111111111111111111111111111111111");
pub const STORAGE_ACCOUNT_SEED: &[u8] = b"features_storage";
pub fn get_storage_account_address() -> (rialo_s_pubkey::Pubkey, u8) {
rialo_s_pubkey::Pubkey::find_program_address(&[STORAGE_ACCOUNT_SEED], &id())
}
pub const MAX_FEATURE_NAME_LENGTH: usize = 512;
pub const MAX_FEATURE_COUNT: usize = 10000;
pub const MAX_FEATURES_STATE_SIZE: usize = 100 * 1024;
pub fn validate_feature_name(name: &str) -> bool {
!name.is_empty()
&& name.len() <= MAX_FEATURE_NAME_LENGTH
&& name
.chars()
.all(|c| c.is_alphanumeric() || c == '_' || c == '-')
&& !name.starts_with(char::is_whitespace)
&& !name.ends_with(char::is_whitespace)
}
pub fn genesis_storage(authority: Pubkey) -> Vec<u8> {
use state::FeaturesState;
let state = FeaturesState::new(authority);
state
.serialize()
.expect("Failed to serialize genesis state")
}