-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
anchorImproves conversion from Anchor IDLImproves conversion from Anchor IDLv2Something to look into when updating the Codama standard to v2Something to look into when updating the Codama standard to v2
Description
solana-program/create-solana-program#108
if you have an Anchor program like the following
#[program]
mod drp_test_scaffold {
use super::*;
pub fn create(ctx: Context<Create>, name: String, authority: Pubkey) -> Result<()> {
let counter = &mut ctx.accounts.counter;
counter.name = name;
counter.authority = authority;
counter.count = 0;
Ok(())
}
}
#[derive(Accounts)]
#[instruction(name: String)]
pub struct Create<'info> {
#[account(
init,
seeds = [name.as_bytes()],
bump,
payer = payer, space = 8 + Counter::INIT_SPACE
)]
pub counter: Account<'info, Counter>,
#[account(mut)]
pub payer: Signer<'info>,
pub system_program: Program<'info, System>,
}the generated Encoder for the seeds is incorrect.
it generates the following snippet for resolving the counter account if not provided
// Resolve default values.
if (!accounts.counter.value) {
accounts.counter.value = await getProgramDerivedAddress({
programAddress,
seeds: [
addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()).encode(
expectSome(args.name)
),
],
});
}it should be using
getUtf8Encoder().encode(
expectSome(args.name)
),Metadata
Metadata
Assignees
Labels
anchorImproves conversion from Anchor IDLImproves conversion from Anchor IDLv2Something to look into when updating the Codama standard to v2Something to look into when updating the Codama standard to v2