From 4d07d2f20a2a8c3520706c96e72ba52fedd32b68 Mon Sep 17 00:00:00 2001 From: bucurdavid Date: Fri, 25 Oct 2024 14:21:04 +0300 Subject: [PATCH] fix: leaf check --- .../src/instructions/bond.rs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/programs/core-sol-bond-stake-sc/src/instructions/bond.rs b/programs/core-sol-bond-stake-sc/src/instructions/bond.rs index 377e8e8..9f8c07c 100644 --- a/programs/core-sol-bond-stake-sc/src/instructions/bond.rs +++ b/programs/core-sol-bond-stake-sc/src/instructions/bond.rs @@ -161,23 +161,23 @@ pub fn bond<'a, 'b, 'c: 'info, 'info>( // check leaf owner here let asset_id = get_asset_id(&ctx.accounts.merkle_tree.key(), nonce); - // let leaf = LeafSchema::V1 { - // id: asset_id, - // owner: ctx.accounts.authority.key(), - // delegate: ctx.accounts.authority.key(), - // nonce, - // data_hash, - // creator_hash, - // }; - // let cpi_ctx = CpiContext::new( - // ctx.accounts.compression_program.to_account_info(), - // spl_account_compression::cpi::accounts::VerifyLeaf { - // merkle_tree: ctx.accounts.merkle_tree.to_account_info(), - // }, - // ) - // .with_remaining_accounts(ctx.remaining_accounts.to_vec()); - - // spl_account_compression::cpi::verify_leaf(cpi_ctx, root, leaf.hash(), nonce as u32)?; + let leaf = LeafSchema::V1 { + id: asset_id, + owner: ctx.accounts.authority.key(), + delegate: ctx.accounts.authority.key(), + nonce, + data_hash, + creator_hash, + }; + let cpi_ctx = CpiContext::new( + ctx.accounts.compression_program.to_account_info(), + spl_account_compression::cpi::accounts::VerifyLeaf { + merkle_tree: ctx.accounts.merkle_tree.to_account_info(), + }, + ) + .with_remaining_accounts(ctx.remaining_accounts.to_vec()); + + spl_account_compression::cpi::verify_leaf(cpi_ctx, root, leaf.hash(), nonce as u32)?; let current_timestamp = get_current_timestamp()?; @@ -220,4 +220,4 @@ pub fn bond<'a, 'b, 'c: 'info, 'info>( }); Ok(()) -} \ No newline at end of file +}