Skip to content

Instantly share code, notes, and snippets.

@vl-dev
Created October 24, 2023 14:36
Show Gist options
  • Save vl-dev/d9aedb8dbd8a1f694b3f8c26bf289eb0 to your computer and use it in GitHub Desktop.
Save vl-dev/d9aedb8dbd8a1f694b3f8c26bf289eb0 to your computer and use it in GitHub Desktop.
Failing Anchor CPI to Bubblegum
use anchor_lang::prelude::*;
use mpl_bubblegum::program::Bubblegum;
use solana_program::pubkey::Pubkey;
use spl_account_compression::{
Noop, program::SplAccountCompression,
};
declare_id!("BtuqD66LQtfASw12jDfKGNUSf5g3GwNk9jZFnMwXFruC");
#[program]
pub mod cnft_vault {
use super::*;
pub fn create_merkle_tree<'info>(ctx: Context<'_, '_, '_, 'info, CreateMerkleTree<'info>>) -> Result<()> {
msg!("creating merkle tree");
mpl_bubblegum::cpi::create_tree(
CpiContext::new(
ctx.accounts.bubblegum_program.to_account_info(),
mpl_bubblegum::cpi::accounts::CreateTree {
tree_authority: ctx.accounts.tree_authority.to_account_info(),
merkle_tree: ctx.accounts.merkle_tree.to_account_info(),
payer: ctx.accounts.payer.to_account_info(),
tree_creator: ctx.accounts.tree_creator.to_account_info(),
log_wrapper: ctx.accounts.log_wrapper.to_account_info(),
compression_program: ctx.accounts.compression_program.to_account_info(),
system_program: ctx.accounts.system_program.to_account_info(),
}), 3, 8, None,
)
}
}
#[derive(Accounts)]
pub struct CreateMerkleTree<'info> {
/// CHECK: Initialized by the CPI
#[account(mut)]
pub tree_authority: UncheckedAccount<'info>,
/// CHECK:
#[account(mut)]
pub merkle_tree: UncheckedAccount<'info>,
#[account(mut)]
pub payer: Signer<'info>,
pub tree_creator: Signer<'info>,
pub log_wrapper: Program<'info, Noop>,
pub compression_program: Program<'info, SplAccountCompression>,
pub bubblegum_program: Program<'info, Bubblegum>,
pub system_program: Program<'info, System>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment