Simple code snippet of workaround for remaining accounts:
#[program]
pub mod t_rem_accs_new {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
#[derive(Accounts)]
struct Foobar<'info> {
#[account(mut)]
foo: AccountInfo<'info>,
#[account(mut)]
bar: AccountInfo<'info>,
}
ctx.remaining_accounts
.chunks_exact(2)
.try_for_each(|mut accounts| -> Result<_> {
Foobar::try_accounts(
&ID,
&mut accounts,
&[],
&mut Default::default(),
&mut Default::default(),
)?;
Ok(())
})?;
Ok(())
}
}
#[derive(Accounts)]
pub struct Initialize {}
I have the following error using anchor 0.31.0, when anchor 0.28.0 build is okay. It's just me or something changed?
--> programs/t_rem_accs_new/src/lib.rs:19:9
|
9 | pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
| ---
| |
| has type `anchor_lang::context::Context<'_, '_, '1, '_, Initialize>`
| has type `anchor_lang::context::Context<'_, '_, '_, '2, Initialize>`
...
19 | / ctx.remaining_accounts
20 | | .chunks_exact(2)
| |____________________________^ argument requires that `'1` must outlive `'2`
Simple code snippet of workaround for remaining accounts:
I have the following error using anchor
0.31.0, when anchor0.28.0build is okay. It's just me or something changed?