Skip to main content

rialo_feature_management_interface/
instruction.rs

1// Copyright (c) Subzero Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Instruction types for the Feature Management Program
5
6extern crate alloc;
7use alloc::{string::String, vec::Vec};
8
9use borsh::{BorshDeserialize, BorshSerialize};
10use rialo_s_pubkey::Pubkey;
11
12/// Instructions supported by the Feature Management Program
13#[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
14pub enum FeatureManagementInstruction {
15    /// Upsert features (add or modify)
16    ///
17    /// This instruction requires a valid signature from the authority.
18    ///
19    /// Accounts expected:
20    /// 0. `[writable]` Storage account (PDA)
21    /// 1. `[signer]` The authority account
22    Upsert {
23        /// Name of the feature
24        name: String,
25        /// Start time (Unix timestamp in seconds)
26        start_time: u64,
27        /// End time (Unix timestamp in seconds)
28        end_time: u64,
29    },
30
31    /// Update the authority
32    ///
33    /// This instruction requires a valid signature from the current authority.
34    ///
35    /// Accounts expected:
36    /// 0. `[writable]` Storage account (PDA)
37    /// 1. `[signer]` The current authority account
38    UpdateAuthority {
39        /// The new authority that will control the feature management system
40        new_authority: Pubkey,
41    },
42}
43
44#[cfg(not(target_os = "solana"))]
45impl FeatureManagementInstruction {
46    /// Serialize instruction data
47    pub fn serialize(&self) -> Result<Vec<u8>, borsh::io::Error> {
48        borsh::to_vec(self)
49    }
50
51    /// Deserialize instruction data
52    pub fn deserialize(data: &[u8]) -> Result<Self, borsh::io::Error> {
53        borsh::from_slice(data)
54    }
55}