From on-chain program, calling a normal third-party program (without source code, but has IDL) instruction would be like this:
let accounts_meta = vec![
// ...
];
let ix = &solana_program::instruction::Instruction::new_with_bytes(
target_program.key()
&ix_data, // Passing instructions through
accounts_meta, // Just the required account for the other program
);
let accounts_info = vec![
// ...
];
solana_program::program::invoke(
&ix,
&accounts_info,
)?;
However, now I got a third-party program, who's instruction require caller to pass in some accounts through 'remaining_accounts' parameter.
Info about third-party close-source program:
- IDL file is available
- They give a JS demo that
const tx = await xxxProgram.methods
.xxxMethod({ ... })
.accounts({ ... })
.remainingAccounts(moreAccountMetas)
.rpc();
I know well how to pass remaining_accounts
if invoke from JS client.
But, I need to call it from my on-chain program, how can I pass this remaining_accounts
when do CPI call with solana_program::program::invoke
? Or any other method instead of using invoke
?