dlp_api/args/
delegate_with_actions.rs1use borsh::{BorshDeserialize, BorshSerialize};
2
3use super::DelegateArgs;
4use crate::compact;
5
6#[derive(Debug, BorshSerialize, BorshDeserialize)]
7pub struct DelegateWithActionsArgs {
8 pub delegate: DelegateArgs,
10
11 pub actions: PostDelegationActions,
13}
14
15#[derive(Debug, BorshSerialize, BorshDeserialize)]
47pub struct PostDelegationActions {
48 pub inserted_signers: u8,
49
50 pub inserted_non_signers: u8,
51
52 pub signers: Vec<[u8; 32]>,
53
54 pub non_signers: Vec<MaybeEncryptedPubkey>,
55
56 pub instructions: Vec<MaybeEncryptedInstruction>,
57}
58
59#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
60pub struct MaybeEncryptedInstruction {
61 pub program_id: u8,
62
63 pub accounts: Vec<MaybeEncryptedAccountMeta>,
64
65 pub data: MaybeEncryptedIxData,
66}
67
68#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
69#[cfg_attr(test, derive(PartialEq))]
70pub enum MaybeEncryptedPubkey {
71 ClearText([u8; 32]),
72 Encrypted(EncryptedBuffer),
73}
74
75impl From<[u8; 32]> for MaybeEncryptedPubkey {
76 fn from(pubkey: [u8; 32]) -> Self {
77 Self::ClearText(pubkey)
78 }
79}
80
81impl From<Vec<u8>> for MaybeEncryptedPubkey {
82 fn from(bytes: Vec<u8>) -> Self {
83 Self::Encrypted(bytes.into())
84 }
85}
86
87#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
88pub enum MaybeEncryptedAccountMeta {
89 ClearText(compact::AccountMeta),
90 Encrypted(EncryptedBuffer),
91}
92
93impl From<compact::AccountMeta> for MaybeEncryptedAccountMeta {
94 fn from(account_meta: compact::AccountMeta) -> Self {
95 Self::ClearText(account_meta)
96 }
97}
98
99impl From<Vec<u8>> for MaybeEncryptedAccountMeta {
100 fn from(bytes: Vec<u8>) -> Self {
101 Self::Encrypted(bytes.into())
102 }
103}
104
105#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
106pub struct MaybeEncryptedIxData {
107 pub prefix: Vec<u8>,
108 pub suffix: EncryptedBuffer,
109}
110
111#[derive(Clone, Debug, Default, BorshSerialize, BorshDeserialize)]
112#[cfg_attr(test, derive(PartialEq))]
113pub struct EncryptedBuffer(Vec<u8>);
114
115impl EncryptedBuffer {
116 pub fn new(bytes: Vec<u8>) -> Self {
117 Self(bytes)
118 }
119
120 pub fn as_bytes(&self) -> &[u8] {
121 &self.0
122 }
123
124 pub fn into_inner(self) -> Vec<u8> {
125 self.0
126 }
127}
128
129impl From<Vec<u8>> for EncryptedBuffer {
130 fn from(bytes: Vec<u8>) -> Self {
131 Self(bytes)
132 }
133}