If I try to create a transaction using declare_program!
for accounts and args and anchor_client
for building the transaction:
use anchor_lang::prelude::*;
declare_program!(my_program);
use my_program::client::accounts::MyInstruction as MyInstructionAccs;
use my_program::client::args::MyInstruction as MyInstructionArgs;
use anchor_client::Program;
use anchor_lang::prelude::*;
use solana_sdk::signer::Signer;
pub fn send_startup_tx<C: Deref<Target = impl Signer> + Clone>(
p: Program<C>,
acc: Pubkey,
param: u32,
) {
let accs = MyInstructionAccs {
acc1: acc,
};
let args = MyInstructionArgs {
arg1: param,
};
let a = p.request().accounts(accs).args(args)
}
This unfortunately doesn't build, with the following error
the trait bound `__client_accounts_my_instruction::MyInstruction: anchor_client::anchor_lang::ToAccountMetas` is not satisfied
If I do cargo expand
, I can also see why: declare_program!
generates an impl for anchor_lang::ToAccountMetas
, but not for anchor_client::anchor_lang::ToAccountMetas
even though these two are the exact same in practice.
I've tried switching my import at the top to use anchor_client::anchor_lang::declare_program;
but it still gives the same error. Any idea on how to fix this?