Skip to content

Commit

Permalink
Merge pull request #30 from A91y/fix/init,initIfNeeded,close
Browse files Browse the repository at this point in the history
feat: added transpilation instructions to init, close, initIfNeeded
  • Loading branch information
ShrinathNR authored Oct 29, 2024
2 parents 5f2530c + 2591e5d commit 361b505
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/rs_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ impl InstructionAccount {
let name = Ident::new(&self.name, proc_macro2::Span::call_site());
let of_type = &self.of_type;
let constraints: TokenStream;
if self.seeds.is_none() & (self.is_close | self.is_init | self.is_initifneeded) {
panic!(r##"use derive or deriveWithBump while using "init" or "initIfNeeded" or "close" "##);
}
let payer = match &self.payer {
Some(s) => {
let payer = Ident::new(s, proc_macro2::Span::call_site());
Expand Down Expand Up @@ -715,9 +718,7 @@ impl ProgramInstruction {
if chaincall1prop == "init" {
ix.uses_system_program = true;
cur_ix_acc.is_init = true;
if let Some(payer) = &ix.signer {
cur_ix_acc.payer = Some(payer.clone());
}
cur_ix_acc.payer = Some(c.args[0].expr.as_ident().ok_or(PoseidonError::IdentNotFound)?.sym.as_ref().to_case(Case::Snake));
}
else if chaincall1prop == "initIfNeeded" {
ix.uses_system_program = true;
Expand All @@ -739,6 +740,19 @@ impl ProgramInstruction {
cur_ix_acc.has_one = has_one;

}
} else if prop.contains("init") {
ix.uses_system_program = true;
cur_ix_acc.is_init = true;
cur_ix_acc.payer = Some(c.args[0].expr.as_ident().ok_or(PoseidonError::IdentNotFound)?.sym.as_ref().to_case(Case::Snake));
} else if prop.contains("initIfNeeded") {
ix.uses_system_program = true;
cur_ix_acc.is_initifneeded = true;
if let Some(payer) = &ix.signer {
cur_ix_acc.payer = Some(payer.clone());
}
} else if prop.contains("close") {
cur_ix_acc.close = Some(c.args[0].expr.as_ident().ok_or(PoseidonError::IdentNotFound)?.sym.as_ref().to_case(Case::Snake));
cur_ix_acc.is_mut = true;
}
}
if obj == "SystemProgram" {
Expand Down

0 comments on commit 361b505

Please sign in to comment.