0

Im trying to update my program to be able to transfer pnfts from the payer wallet to another wallet but facing errors:

"11111111111111111111111111111111's signer privilege escalated",
'Program f37PsdsiyhLuDLUc2HpSEFJCdav1n5ibzKe92HDFmiP consumed 37923 of 200000 compute units',
'Program f37PsdsiyhLuDLUc2HpSEFJCdav1n5ibzKe92HDFmiP failed: Cross-program invocation with unauthorized signer or writable account'

My Function looks like this:

                    transferPNFT(
                        ctx.accounts.nft_account.to_account_info(),
                        ctx.accounts.nft_metadata.to_account_info(),
                        ctx.accounts.nft_mint.to_account_info(),
                        ctx.accounts.destination.to_account_info(),
                        ctx.accounts.destination_ata.to_account_info(),
                        ctx.accounts.spl_ata_program.to_account_info(),
                        ctx.accounts.authority.to_account_info(),
                        ctx.accounts.admin.to_account_info(),
                        ctx.accounts.system_program.to_account_info(),
                        ctx.accounts.sysvar_instructions.to_account_info(),
                        ctx.accounts.spl_token_program.to_account_info(),
                        ctx.accounts.nft_master_edition.to_account_info(),
                        ctx.accounts.owner_token_record.to_account_info(),
                        ctx.accounts.destination_token_record.to_account_info(),
                        ctx.accounts.auth_rules_program.to_account_info(),
                        ctx.accounts.auth_rules.to_account_info(),
                        false,
                        None,
                        None,
                    );

pub fn transferPNFT<'info>( nft_account: AccountInfo<'info>, nft_metadata: AccountInfo<'info>, nft_mint: AccountInfo<'info>, destination: AccountInfo<'info>, destination_ata: AccountInfo<'info>, spl_ata_program: AccountInfo<'info>, authority: AccountInfo<'info>, payer: AccountInfo<'info>, system_program: AccountInfo<'info>, sysvar_instructions: AccountInfo<'info>, spl_token_program: AccountInfo<'info>, nft_master_edition: AccountInfo<'info>, owner_token_record: AccountInfo<'info>, destination_token_record: AccountInfo<'info>, auth_rules_program: AccountInfo<'info>, auth_rules: AccountInfo<'info>, escrow: bool, entrants: Option, bump: Option, ) -> Result<()> { let mut transfer_builder = TransferBuilder::new();

transfer_builder
    .token(nft_account.key())
    .token_owner(authority.key())
    .destination(destination_ata.key())
    .destination_owner(destination.key())
    .mint(nft_mint.key())
    .metadata(nft_metadata.key())
    .authority(authority.key())
    .payer(payer.key());

let mut transfer_infos = vec![
    nft_account.to_account_info(),
    authority.to_account_info(),
    authority.to_account_info(),
    destination_ata.to_account_info(),
    destination.to_account_info(),
    nft_mint.to_account_info(),
    nft_metadata.to_account_info(),
    system_program.to_account_info(),
    sysvar_instructions.to_account_info(),
    spl_token_program.to_account_info(),
    spl_ata_program.to_account_info(),
];

let metadata: Metadata = Metadata::from_account_info(&nft_metadata)?;

if matches!(
    metadata.token_standard,
    Some(TokenStandard::ProgrammableNonFungible)
) {
    transfer_builder
        .edition(nft_master_edition.key())
        .owner_token_record(owner_token_record.key())
        .destination_token_record(destination_token_record.key());

    transfer_infos.push(nft_master_edition.to_account_info());
    transfer_infos.push(owner_token_record.to_account_info());
    transfer_infos.push(destination_token_record.to_account_info());

    // if let Some(ProgrammableConfig::V1 { rule_set: Some(_) }) =
    //     metadata.programmable_config
    // {

    transfer_builder
        .authorization_rules_program(auth_rules_program.key())
        .authorization_rules(auth_rules.key());
    transfer_infos.push(auth_rules_program.to_account_info());

    transfer_infos.push(auth_rules.to_account_info());
    // }
}
let transfer_ix = transfer_builder
    .build(TransferArgs::V1 {
        amount: 1,
        authorization_data: None,
    }).map_err(|_| DegenDropError::InstructionBuilderFailed)?
    .instruction();
if !escrow {
    invoke(&transfer_ix, &transfer_infos)?;
} else {
    let entrants = match entrants {
        Some(entrants) => entrants,
        None => return Err(DegenDropError::AccountNotfound.into()),
    };

    let bump = match bump {
        Some(bump) => bump,
        None => return Err(DegenDropError::AccountNotfound.into()),
    };

    invoke_signed(
        &transfer_ix,
        &transfer_infos,
        &[&[b"raffle".as_ref(), entrants.as_ref(), &[bump]]],
    )?;
}

Ok(())

}

and my context looks like this:

#[derive(Accounts)] pub struct AdminCallbackPNFT<'info> { #[account(mut, address = global_account.authority @ DegenDropError::AccessDenied)] pub admin: Signer<'info>,

#[account(
    mut,
    seeds = [GLOBAL_VAULT.as_bytes()],
    bump = global_account.bump,
)]
pub global_account:  Box<Account<'info, GlobalState>>,

/// CHECK:Initialize Treasury
#[account(mut, address = admin.key() @ DegenDropError::InvalidFeePool, signer)]
pub treasury_account: AccountInfo<'info>,
#[account(
    mut,
    seeds = [PLAYER_ACCOUNT.as_bytes(), player.key().as_ref()],
    bump = player_account.bump,
)]
pub player_account:  Box<Account<'info, BoxPlay>>,
/// CHECK: callback player's account
#[account(mut, address=player_account.wallet_address)]
pub player: AccountInfo<'info>,

#[account(
    mut,
    token::authority = admin.key(),
    token::mint = spl_mint.key()
)]
pub spl_treasury_account: Box<Account<'info, TokenAccount>>,

#[account(mut)]
/// CHECK:Initialize Treasury
pub spl_mint: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub nft_account: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub nft_metadata: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub nft_mint: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub authority: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub destination: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub destination_ata: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub spl_ata_program: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub spl_token_program: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub sysvar_instructions: AccountInfo<'info>,
/// CHECK:Initialize Treasury
pub nft_master_edition: UncheckedAccount<'info>,
/// CHECK:Initialize Treasury
pub owner_token_record: UncheckedAccount<'info>,
/// CHECK:Initialize Treasury
pub destination_token_record: UncheckedAccount<'info>,
/// CHECK:Initialize Treasury
pub auth_rules_program: UncheckedAccount<'info>,
/// CHECK:Initialize Treasury
pub auth_rules: UncheckedAccount<'info>,
/// CHECK:Initialize Treasury
pub token_program: Program<'info, Token>,

#[account(
    mut,
    constraint = player_mint_ata.owner == player.key() && player_mint_ata.mint == spl_mint.key()
)]
pub player_mint_ata:  Box<Account<'info, TokenAccount>>,
pub system_program: Program<'info, System>,

}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.