Anchor 0.30.0 added the declare_program!
macro which generates rust bindings from an anchor idl. I was able to find examples on how to use this for CPIs, but not for how to do this for client-side rust similar to how it works with typescript. If I have an instruction called MyInstruction
as part of my_program
, I can do:
use anchor_lang::prelude::*;
declare_program!(my_program);
use my_program::client::accounts::MyInstruction as MyInstructionAccs;
use my_program::client::args::MyInstruction as MyInstructionArgs;
let accs = MyInstructionAccs {
acc1: someAccount,
};
let args = MyInstructionArgs {
arg1: someArg,
};
Is there anything else Anchor can do for me from here to actually build & send this transaction and invoke MyInstruction
in my_program
?
Edit: I'm not asking how to generate a client program for Rust in general, as there's already a number of tools for this. Judging from this issue the idea behind declare_program!
was to remove the need for external crates to do this, which is why I'm asking.