From 1ae16733f920a1857074b5d951547ad0484c42e7 Mon Sep 17 00:00:00 2001 From: ShrinathNR Date: Wed, 30 Oct 2024 05:08:34 +0530 Subject: [PATCH] remove 'info lifetime if accounts list is empty --- src/rs_types.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rs_types.rs b/src/rs_types.rs index be38082..abfe03c 100644 --- a/src/rs_types.rs +++ b/src/rs_types.rs @@ -10,9 +10,7 @@ use std::{ }; use swc_common::{util::move_map::MoveMap, TypeEq}; use swc_ecma_ast::{ - BindingIdent, CallExpr, Callee, ClassExpr, ClassMethod, Expr, ExprOrSpread, Lit, MemberExpr, - NewExpr, Stmt, TsExprWithTypeArgs, TsInterfaceDecl, TsKeywordTypeKind, TsType, - TsTypeParamInstantiation, TsTypeRef, + BindingIdent, CallExpr, Callee, ClassExpr, ClassMethod, Expr, ExprOrSpread, Lit, MemberExpr, NewExpr, Stmt, TsExprWithTypeArgs, TsInterfaceDecl, TsKeywordTypeKind, TsType, TsTypeParamInstantiation, TsTypeRef }; use swc_ecma_parser::token::Token; @@ -1641,10 +1639,14 @@ impl ProgramInstruction { pub system_program: Program<'info, System>, }) } + let info_token_stream = match accounts.is_empty() { + true => quote!{}, + false => quote!{<'info>} + }; quote! { #[derive(Accounts)] #ix_attributes - pub struct #ctx_name<'info> { + pub struct #ctx_name #info_token_stream { #(#accounts)* } }