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

is_signer field doesn't pass through CPI for UncheckedAccounts #1899

Open
blockiosaurus opened this issue May 16, 2022 · 2 comments
Open

is_signer field doesn't pass through CPI for UncheckedAccounts #1899

blockiosaurus opened this issue May 16, 2022 · 2 comments

Comments

@blockiosaurus
Copy link

When making a CPI call with an UncheckedAccount as signer, the is_signer field doesn't carry through the CPI and so the invoked instruction has no signer.

The current functioning workaround is to replace the CPI call with an invoke and manually copying the is_signer field to the passed-in account metas.

let ix = solana_program::instruction::Instruction {
        program_id: cpi_program.key(),
        accounts: cpi_accounts
            .to_account_metas(None)
            .into_iter()
            .zip(cpi_accounts.to_account_infos())
            .map(|mut pair| {
                pair.0.is_signer = pair.1.is_signer;
                pair.0
            })
            .collect(),
        data: ix_data.data(),
    };

    invoke(&ix, &cpi_accounts.to_account_infos())?;
@armaniferrante
Copy link
Member

What about if you decorate it with #[account(signer)] ?

@blockiosaurus
Copy link
Author

blockiosaurus commented May 16, 2022

That works in most situations but doesn't cover the edge cases where there are multiple potential signers or optional signers.

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

3 participants
@armaniferrante @blockiosaurus and others