Skip to content

Commit 57c2912

Browse files
authored
chore: Remove commented code (#1094)
Exactly the same code exists in correct form in `macros/light/src/traits.rs`.
1 parent 77f1d62 commit 57c2912

File tree

1 file changed

+0
-272
lines changed

1 file changed

+0
-272
lines changed

macros/light/src/lib.rs

Lines changed: 0 additions & 272 deletions
Original file line numberDiff line numberDiff line change
@@ -154,278 +154,6 @@ pub fn light_traits_derive(input: TokenStream) -> TokenStream {
154154
}
155155
}
156156

157-
// #[proc_macro_derive(
158-
// LightTraits,
159-
// attributes(self_program, fee_payer, authority, cpi_context)
160-
// )]
161-
// pub fn light_traits_derive(input: TokenStream) -> TokenStream {
162-
// let input = parse_macro_input!(input as DeriveInput);
163-
// let name = &input.ident;
164-
165-
// let trait_impls = match input.data {
166-
// Data::Struct(data_struct) => {
167-
// match data_struct.fields {
168-
// Fields::Named(fields) => {
169-
// let mut self_program_field = None;
170-
// let mut fee_payer_field = None;
171-
// let mut authority_field = None;
172-
// let mut light_system_program_field = None;
173-
// let mut cpi_context_account_field = None;
174-
175-
// // base impl
176-
// let mut registered_program_pda_field = None;
177-
// let mut noop_program_field = None;
178-
// let mut account_compression_authority_field = None;
179-
// let mut account_compression_program_field = None;
180-
// let mut system_program_field = None;
181-
182-
// let compressed_sol_pda_field = fields
183-
// .named
184-
// .iter()
185-
// .find_map(|f| {
186-
// if f.ident
187-
// .as_ref()
188-
// .map(|id| id == "compressed_sol_pda")
189-
// .unwrap_or(false)
190-
// {
191-
// Some(quote! { self.#f.ident.as_ref() })
192-
// } else {
193-
// None
194-
// }
195-
// })
196-
// .unwrap_or(quote! { None });
197-
198-
// let compression_recipient_field = fields
199-
// .named
200-
// .iter()
201-
// .find_map(|f| {
202-
// if f.ident
203-
// .as_ref()
204-
// .map(|id| id == "compression_recipient")
205-
// .unwrap_or(false)
206-
// {
207-
// Some(quote! { self.#f.ident.as_ref() })
208-
// } else {
209-
// None
210-
// }
211-
// })
212-
// .unwrap_or(quote! { None });
213-
214-
// for f in fields.named.iter() {
215-
// for attr in &f.attrs {
216-
// if attr.path.is_ident("self_program") {
217-
// self_program_field = Some(f.ident.as_ref().unwrap());
218-
// }
219-
// if attr.path.is_ident("fee_payer") {
220-
// fee_payer_field = Some(f.ident.as_ref().unwrap());
221-
// }
222-
// if attr.path.is_ident("authority") {
223-
// authority_field = Some(f.ident.as_ref().unwrap());
224-
// }
225-
// if attr.path.is_ident("cpi_context") {
226-
// cpi_context_account_field = Some(f.ident.as_ref().unwrap());
227-
// }
228-
// }
229-
// if f.ident
230-
// .as_ref()
231-
// .map(|id| id == "light_system_program")
232-
// .unwrap_or(false)
233-
// {
234-
// light_system_program_field = Some(f.ident.as_ref().unwrap());
235-
// }
236-
// if f.ident
237-
// .as_ref()
238-
// .map(|id| id == "registered_program_pda")
239-
// .unwrap_or(false)
240-
// {
241-
// registered_program_pda_field = Some(f.ident.as_ref().unwrap());
242-
// }
243-
// if f.ident
244-
// .as_ref()
245-
// .map(|id| id == "noop_program")
246-
// .unwrap_or(false)
247-
// {
248-
// noop_program_field = Some(f.ident.as_ref().unwrap());
249-
// }
250-
// if f.ident
251-
// .as_ref()
252-
// .map(|id| id == "account_compression_authority")
253-
// .unwrap_or(false)
254-
// {
255-
// account_compression_authority_field = Some(f.ident.as_ref().unwrap());
256-
// }
257-
// if f.ident
258-
// .as_ref()
259-
// .map(|id| id == "account_compression_program")
260-
// .unwrap_or(false)
261-
// {
262-
// account_compression_program_field = Some(f.ident.as_ref().unwrap());
263-
// }
264-
// if f.ident
265-
// .as_ref()
266-
// .map(|id| id == "system_program")
267-
// .unwrap_or(false)
268-
// {
269-
// system_program_field = Some(f.ident.as_ref().unwrap());
270-
// }
271-
// }
272-
273-
// // optional: compressed_sol_pda, compression_recipient,
274-
// // cpi_context_account
275-
// let missing_required_fields = [
276-
// if light_system_program_field.is_none() {
277-
// "light_system_program"
278-
// } else {
279-
// ""
280-
// },
281-
// if registered_program_pda_field.is_none() {
282-
// "registered_program_pda"
283-
// } else {
284-
// ""
285-
// },
286-
// if noop_program_field.is_none() {
287-
// "noop_program"
288-
// } else {
289-
// ""
290-
// },
291-
// if account_compression_authority_field.is_none() {
292-
// "account_compression_authority"
293-
// } else {
294-
// ""
295-
// },
296-
// if account_compression_program_field.is_none() {
297-
// "account_compression_program"
298-
// } else {
299-
// ""
300-
// },
301-
// if system_program_field.is_none() {
302-
// "system_program"
303-
// } else {
304-
// ""
305-
// },
306-
// ]
307-
// .iter()
308-
// .filter(|&field| !field.is_empty())
309-
// .cloned()
310-
// .collect::<Vec<_>>();
311-
312-
// let missing_required_attributes = [
313-
// if self_program_field.is_none() {
314-
// "self_program"
315-
// } else {
316-
// ""
317-
// },
318-
// if fee_payer_field.is_none() {
319-
// "fee_payer"
320-
// } else {
321-
// ""
322-
// },
323-
// if authority_field.is_none() {
324-
// "authority"
325-
// } else {
326-
// ""
327-
// },
328-
// ]
329-
// .iter()
330-
// .filter(|&attr| !attr.is_empty())
331-
// .cloned()
332-
// .collect::<Vec<_>>();
333-
334-
// if !missing_required_fields.is_empty()
335-
// || !missing_required_attributes.is_empty()
336-
// {
337-
// let error_message = format!(
338-
// "Error: Missing required fields: [{}], Missing required attributes: [{}]",
339-
// missing_required_fields.join(", "),
340-
// missing_required_attributes.join(", ")
341-
// );
342-
// quote! {
343-
// compile_error!(#error_message);
344-
// }
345-
// } else {
346-
// let base_impls = quote! {
347-
// impl<'info> InvokeCpiAccounts<'info> for #name<'info> {
348-
// fn get_invoking_program(&self) -> &AccountInfo<'info> {
349-
// &self.#self_program_field
350-
// }
351-
// }
352-
// impl<'info> SignerAccounts<'info> for #name<'info> {
353-
// fn get_fee_payer(&self) -> &Signer<'info> {
354-
// &self.#fee_payer_field
355-
// }
356-
// fn get_authority(&self) -> &AccountInfo<'info> {
357-
// &self.#authority_field
358-
// }
359-
// }
360-
// impl<'info> LightSystemAccount<'info> for #name<'info> {
361-
// fn get_light_system_program(&self) -> &Program<'info, LightSystemProgram> {
362-
// &self.#light_system_program_field
363-
// }
364-
// }
365-
// };
366-
// let invoke_accounts_impl = quote! {
367-
// impl<'info> InvokeAccounts<'info> for #name<'info> {
368-
// fn get_registered_program_pda(&self) -> &Account<'info, RegisteredProgram> {
369-
// &self.#registered_program_pda_field
370-
// }
371-
// fn get_noop_program(&self) -> &AccountInfo<'info> {
372-
// &self.#noop_program_field
373-
// }
374-
// fn get_account_compression_authority(&self) -> &AccountInfo<'info> {
375-
// &self.#account_compression_authority_field
376-
// }
377-
// fn get_account_compression_program(&self) -> &Program<'info, AccountCompression> {
378-
// &self.#account_compression_program_field
379-
// }
380-
// fn get_system_program(&self) -> &Program<'info, System> {
381-
// &self.#system_program_field
382-
// }
383-
// fn get_compressed_sol_pda(&self) -> Option<&UncheckedAccount<'info>> {
384-
// #compressed_sol_pda_field
385-
// }
386-
// fn get_compression_recipient(&self) -> Option<&UncheckedAccount<'info>> {
387-
// #compression_recipient_field
388-
// }
389-
// }
390-
// };
391-
// if cpi_context_account_field.is_none() {
392-
// quote! {
393-
// #base_impls
394-
// #invoke_accounts_impl
395-
// impl<'info> InvokeCpiContextAccount<'info> for #name<'info> {
396-
// fn get_cpi_context_account(&self) -> Option<&Account<'info, CpiContextAccount>> {
397-
// None
398-
// }
399-
// }
400-
// }
401-
// } else {
402-
// quote! {
403-
// #base_impls
404-
// #invoke_accounts_impl
405-
// impl<'info> InvokeCpiContextAccount<'info> for #name<'info> {
406-
// fn get_cpi_context_account(&self) -> Option<&Account<'info, CpiContextAccount>> {
407-
// Some(&self.#cpi_context_account_field)
408-
// }
409-
// }
410-
// }
411-
// }
412-
// }
413-
// }
414-
// _ => quote! {
415-
// compile_error!("Error: Expected named fields but found unnamed or no fields.");
416-
// },
417-
// }
418-
// }
419-
// _ => quote! {},
420-
// };
421-
422-
// let expanded = quote! {
423-
// #trait_impls
424-
// };
425-
426-
// TokenStream::from(expanded)
427-
// }
428-
429157
#[proc_macro_derive(LightDiscriminator)]
430158
pub fn light_discriminator(input: TokenStream) -> TokenStream {
431159
let input = parse_macro_input!(input as ItemStruct);

0 commit comments

Comments
 (0)