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)]
16pub struct PostDelegationActions {
17 pub inserted_signers: u8,
18
19 pub inserted_non_signers: u8,
20
21 pub signers: Vec<[u8; 32]>,
22
23 pub non_signers: Vec<MaybeEncryptedPubkey>,
24
25 pub instructions: Vec<MaybeEncryptedInstruction>,
26}
27
28#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
29pub struct MaybeEncryptedInstruction {
30 pub program_id: u8,
31
32 pub accounts: Vec<MaybeEncryptedAccountMeta>,
33
34 pub data: MaybeEncryptedIxData,
35}
36
37#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
38#[cfg_attr(test, derive(PartialEq))]
39pub enum MaybeEncryptedPubkey {
40 ClearText([u8; 32]),
41 Encrypted(EncryptedBuffer),
42}
43
44impl From<[u8; 32]> for MaybeEncryptedPubkey {
45 fn from(pubkey: [u8; 32]) -> Self {
46 Self::ClearText(pubkey)
47 }
48}
49
50impl From<Vec<u8>> for MaybeEncryptedPubkey {
51 fn from(bytes: Vec<u8>) -> Self {
52 Self::Encrypted(bytes.into())
53 }
54}
55
56#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
57pub enum MaybeEncryptedAccountMeta {
58 ClearText(compact::AccountMeta),
59 Encrypted(EncryptedBuffer),
60}
61
62impl From<compact::AccountMeta> for MaybeEncryptedAccountMeta {
63 fn from(account_meta: compact::AccountMeta) -> Self {
64 Self::ClearText(account_meta)
65 }
66}
67
68impl From<Vec<u8>> for MaybeEncryptedAccountMeta {
69 fn from(bytes: Vec<u8>) -> Self {
70 Self::Encrypted(bytes.into())
71 }
72}
73
74#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
75pub struct MaybeEncryptedIxData {
76 pub prefix: Vec<u8>,
77 pub suffix: EncryptedBuffer,
78}
79
80#[derive(Clone, Debug, Default, BorshSerialize, BorshDeserialize)]
81#[cfg_attr(test, derive(PartialEq))]
82pub struct EncryptedBuffer(Vec<u8>);
83
84impl EncryptedBuffer {
85 pub fn new(bytes: Vec<u8>) -> Self {
86 Self(bytes)
87 }
88
89 pub fn as_bytes(&self) -> &[u8] {
90 &self.0
91 }
92
93 pub fn into_inner(self) -> Vec<u8> {
94 self.0
95 }
96}
97
98impl From<Vec<u8>> for EncryptedBuffer {
99 fn from(bytes: Vec<u8>) -> Self {
100 Self(bytes)
101 }
102}