Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling contract enforces seeds/bump using the calling contracts program id. #1

Open
yornaath opened this issue May 29, 2024 · 1 comment

Comments

@yornaath
Copy link

Implementing this example(cp-swap-cpi) locally I ran into errors where seed constraints for accounts like authority are violated, probably since the account::seeds macro checks if the account passed mathches the seed discriminator + the calling programm:id. But it should be seed desicriminator + raydium_cp_swap:programId.

Omitting the seeds and the bump fixes the problem for me and I am able to cpi into the raydium contract and init a pool.

/// CHECK: pool vault and lp mint authority
#[account(mut)]
pub authority: UncheckedAccount<'info>,

I think this is fine since the underlying raydium contract enforces the correct seed?

@0x777A
Copy link
Collaborator

0x777A commented Jun 12, 2024

I have add a seeds::program constraint to fix it.

#[derive(Accounts)]
pub struct ProxyInitialize<'info> {
    pub cp_swap_program: Program<'info, RaydiumCpSwap>,
    /// Address paying to create the pool. Can be anyone
    #[account(mut)]
    pub creator: Signer<'info>,

    /// Which config the pool belongs to.
    pub amm_config: Box<Account<'info, AmmConfig>>,

    /// CHECK: pool vault and lp mint authority
    #[account(
        seeds = [
            raydium_cp_swap::AUTH_SEED.as_bytes(),
        ],
        seeds::program = cp_swap_program,
        bump,
    )]
    pub authority: UncheckedAccount<'info>,
    .....
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants