magicblock_magic_program_api/
args.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4pub struct ActionArgs {
5    pub escrow_index: u8,
6    pub data: Vec<u8>,
7}
8
9#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
10pub struct BaseActionArgs {
11    pub args: ActionArgs,
12    pub compute_units: u32, // compute units your action will use
13    pub escrow_authority: u8, // index of account authorizing action on actor pda
14    pub destination_program: u8, // index of the account
15    pub accounts: Vec<u8>,    // indices of account
16}
17
18#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
19pub enum CommitTypeArgs {
20    Standalone(Vec<u8>), // indices on accounts
21    WithBaseActions {
22        committed_accounts: Vec<u8>, // indices of accounts
23        base_actions: Vec<BaseActionArgs>,
24    },
25}
26
27impl CommitTypeArgs {
28    pub fn committed_accounts_indices(&self) -> &Vec<u8> {
29        match self {
30            Self::Standalone(value) => value,
31            Self::WithBaseActions {
32                committed_accounts, ..
33            } => committed_accounts,
34        }
35    }
36}
37
38#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
39pub enum UndelegateTypeArgs {
40    Standalone,
41    WithBaseActions { base_actions: Vec<BaseActionArgs> },
42}
43
44#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
45pub struct CommitAndUndelegateArgs {
46    pub commit_type: CommitTypeArgs,
47    pub undelegate_type: UndelegateTypeArgs,
48}
49
50impl CommitAndUndelegateArgs {
51    pub fn committed_accounts_indices(&self) -> &Vec<u8> {
52        self.commit_type.committed_accounts_indices()
53    }
54}
55
56#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
57pub enum MagicBaseIntentArgs {
58    BaseActions(Vec<BaseActionArgs>),
59    Commit(CommitTypeArgs),
60    CommitAndUndelegate(CommitAndUndelegateArgs),
61}