1use borsh::{BorshDeserialize, BorshSerialize};
2use shank::{ShankContext, ShankInstruction};
3
4pub use crate::generated::{
5 types::{DelegateRole, ExtensionType, Standard},
6 *,
7};
8
9#[derive(BorshDeserialize, BorshSerialize, Clone, Debug, ShankInstruction, ShankContext)]
10#[rustfmt::skip]
11pub enum Interface {
12 #[account(0, signer, writable, name="buffer", desc = "The unitialized buffer account")]
16 #[account(1, writable, name="recipient", desc = "The account receiving refunded rent")]
17 Close,
18
19 #[account(0, signer, writable, name="asset", desc = "Asset account")]
21 #[account(1, signer, writable, name="signer", desc = "The owner or burn delegate of the asset")]
22 #[account(2, optional, writable, name="recipient", desc = "The account receiving refunded rent")]
23 #[account(3, optional, writable, name="group", desc = "Asset account of the group")]
24 Burn,
25
26 #[account(0, signer, writable, name="asset", desc = "Asset account")]
28 #[account(1, optional_signer, name="authority", desc = "The authority of the asset")]
29 #[account(2, name="owner", desc = "The owner of the asset")]
30 #[account(3, optional, writable, name="group", desc = "Asset account of the group")]
31 #[account(4, optional, signer, name="group_authority", desc = "The delegate authority for minting assets into a group")]
32 #[account(5, optional, signer, writable, name="payer", desc = "The account paying for the storage fees")]
33 #[account(6, optional, name="system_program", desc = "The system program")]
34 Create(MetadataInput),
35
36 #[account(0, signer, writable, name="asset", desc = "Asset account")]
38 #[account(1, signer, name="owner", desc = "The owner of the asset")]
39 #[account(2, name="delegate", desc = "The delegate account")]
40 Approve(DelegateInput),
41
42 #[account(0, signer, writable, name="asset", desc = "Asset account")]
44 #[account(1, optional, signer, writable, name="payer", desc = "The account paying for the storage fees")]
45 #[account(2, optional, name="system_program", desc = "The system program")]
46 Allocate(AllocateInput),
47
48 #[account(0, signer, writable, name="asset", desc = "Asset account")]
50 #[account(1, signer, name="signer", desc = "Delegate or owner account")]
51 Lock,
52
53 #[account(0, signer, writable, name="asset", desc = "Asset account")]
55 #[account(1, signer, name="signer", desc = "Current owner of the asset or delegate")]
56 Revoke(DelegateInput),
57
58 #[account(0, signer, writable, name="asset", desc = "Asset account")]
60 #[account(1, signer, name="signer", desc = "Current owner of the asset or transfer delegate")]
61 #[account(2, name="recipient", desc = "The recipient of the asset")]
62 #[account(3, optional, name="group", desc = "The asset defining the group, if applicable")]
63 Transfer,
64
65 #[account(0, signer, writable, name="asset", desc = "Asset account")]
67 #[account(1, signer, name="signer", desc = "Delegate or owner account")]
68 Unlock,
69
70 #[account(0, signer, writable, name="asset", desc = "Asset account")]
72 #[account(1, signer, name="creator", desc = "Creator account to unverify")]
73 Unverify,
74
75 #[account(0, signer, writable, name="asset", desc = "Asset account")]
77 #[account(1, signer, name="authority", desc = "The authority of the asset")]
78 #[account(2, optional, writable, name="buffer", desc = "Extension (asset) buffer account")]
79 #[account(3, optional, name="group", desc = "The asset defining the group, if applicable")]
80 #[account(4, optional, signer, writable, name="payer", desc = "The account paying for the storage fees")]
81 #[account(5, optional, name="system_program", desc = "The system program")]
82 Update(UpdateInput),
83
84 #[account(0, signer, writable, name="asset", desc = "Asset account")]
86 #[account(1, signer, name="creator", desc = "Creator account to verify")]
87 Verify,
88
89 #[account(0, signer, writable, name="asset", desc = "Asset account")]
91 #[account(1, signer, writable, name="payer", desc = "The account paying for the storage fees")]
92 #[account(2, name="system_program", desc = "The system program")]
93 Write(DataInput),
94
95 #[account(0, signer, writable, name="asset", desc = "Asset account")]
97 #[account(1, writable, name="group", desc = "Asset account of the group")]
98 #[account(2, signer, name="authority", desc = "The authority of the assets")]
99 Group,
100
101 #[account(0, signer, writable, name="asset", desc = "Asset account")]
103 #[account(1, writable, name="group", desc = "Asset account of the group")]
104 #[account(2, signer, name="authority", desc = "The authority of the assets")]
105 Ungroup,
106
107 #[account(0, signer, writable, name="asset", desc = "Asset account")]
109 #[account(1, signer, name="authority", desc = "The authority of the asset")]
110 #[account(2, signer, name="new_authority", desc = "The new authority of the asset")]
111 Handover,
112
113 #[account(0, signer, writable, name="asset", desc = "Asset account")]
115 #[account(1, signer, name="authority", desc = "The authority of the asset")]
116 #[account(2, optional, name="group", desc = "The asset defining the group, if applicable")]
117 #[account(3, writable, name="recipient", desc = "The account receiving refunded rent")]
118 Remove(ExtensionType),
119
120 #[account(0, signer, writable, name="asset", desc = "Asset account")]
122 #[account(1, signer, name="authority", desc = "The authority of the asset")]
123 #[account(2, optional_signer, writable, name="payer", desc = "The account paying for the storage fees")]
124 #[account(3, optional, name="system_program", desc = "The system program")]
125 Resize(Strategy),
126}
127
128#[repr(C)]
129#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
130pub struct AllocateInput {
131 pub extension: ExtensionInput,
133}
134
135#[repr(C)]
136#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
137pub enum DelegateInput {
138 All,
139 Some { roles: Vec<DelegateRole> },
140}
141
142#[repr(C)]
143#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
144pub struct DataInput {
145 pub overwrite: bool,
147
148 pub bytes: Vec<u8>,
150}
151
152#[repr(C)]
153#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
154pub struct ExtensionInput {
155 pub extension_type: ExtensionType,
157
158 pub length: u32,
160
161 pub data: Option<Vec<u8>>,
163}
164
165#[repr(C)]
166#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
167pub struct MetadataInput {
168 pub name: String,
170
171 pub standard: Standard,
173
174 pub mutable: bool,
176
177 pub extensions: Option<Vec<ExtensionInput>>,
179}
180
181#[repr(C)]
182#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)]
183pub struct UpdateInput {
184 pub name: Option<String>,
186
187 pub mutable: Option<bool>,
191
192 pub extension: Option<ExtensionInput>,
194}
195
196#[repr(C)]
198#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
199pub enum Strategy {
200 Trim,
205
206 Extend { value: u16 },
208}