Skip to content

Commit

Permalink
remove 'info lifetime if accounts list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrinathNR committed Oct 29, 2024
1 parent ff71c6f commit 1ae1673
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/rs_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)*
}
}
Expand Down

0 comments on commit 1ae1673

Please sign in to comment.