I am facing an error on adding line Vec<String>,
type or String
type.
Error:
#[derive(Accounts)]
pub struct ModifyLedger<'info> {
#[account(mut)]
pub ledger_account: Account<'info, Ledger>,
#[account(mut)]
pub wallet: Signer<'info>,
}
program function:
pub fn add_limited_list(
ctx: Context<ModifyLedger>,
limited_pk_list: Vec<String>,
) -> Result<()> {
for each_limited_pk in limited_pk_list.iter() {
if ctx
.accounts
.ledger_account
.limited_stage_list
.iter()
.find(|&pk | pk == each_limited_pk)
== None
{
ctx.accounts
.ledger_account
.limited_stage_list
.push(each_limited_pk.to_string());
}
}
Ok(())
}
Account:
#[account]
pub struct Ledger {
pub limited_stage_list: Vec<String>,
pub timebound_stage_list: Vec<String>,
pub public_stage_list: Vec<String>,
//pub uri: String,
}
space = 82
to the account. The code breaks down if I changes this number. Code works for all typesu8
,u32
,u64
,i64
but not forString
andvec<String>
Code Snippet:#[account( init_if_needed, payer = wallet, space = 82, seeds = [ b"new_seed", ], bump )] pub ledger_account: Account<'info, Ledger>