Skip to content

Commit

Permalink
adding-arguments-to-system
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent committed Jun 18, 2024
1 parent d7d83c9 commit cdfb9fd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cli/src/rust_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ declare_id!("{}");
#[system]
pub mod {} {{
pub fn execute(ctx: Context<Components>, _args_p: Vec<u8>) -> Result<Components> {{
pub fn execute(ctx: Context<Components>, args: Args) -> Result<Components> {{
let position = &mut ctx.accounts.position;
position.x += 1;
position.y += 1;
position.x += args.x;
position.y += args.y;
Ok(ctx.accounts)
}}
Expand All @@ -110,6 +110,11 @@ pub mod {} {{
pub position: Position,
}}
#[arguments]
struct Args {{
pub x: i64,
pub y: i64,
}}
}}
"#,
anchor_cli::rust_template::get_or_create_program_id(name),
Expand Down Expand Up @@ -473,6 +478,9 @@ describe("{}", () => {{
entity: entityPda,
components: [{{ componentId: positionComponent.programId }}],
}}]
}}, {{
x: 1,
y: 1,
}});
const txSign = await provider.sendAndConfirm(applySystem.transaction);
console.log(`Applied a system. Signature: ${{txSign}}`);
Expand Down

0 comments on commit cdfb9fd

Please sign in to comment.