Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dlp-api/src/v2/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum DlpV2Instruction {
/// InitStateBuffer takes more arguments and AppendStateBuffer takes as less as
/// possible.
WriteStateBuffer = 107,
/// Applies an approved v2 commitment to the delegated account.
FinalizeCommitment = 108,
}

impl DlpV2Instruction {
Expand Down
62 changes: 62 additions & 0 deletions dlp-api/src/v2/instruction_builder/finalize_commitment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
use solana_sdk_ids::system_program;

use crate::{
compat::{Compatize, Modernize},
pda::{
delegation_metadata_pda_from_delegated_account,
delegation_record_pda_from_delegated_account,
},
v2::{
pda::{pending_commitment_pda, state_buffer_pda},
DlpV2Instruction,
},
};

/// Builds the instruction that finalizes one approved v2 commitment.
pub fn finalize_commitment(
operator: Pubkey,
account: Pubkey,
commit_id: u64,
) -> Instruction {
Instruction {
program_id: crate::id().modernize(),
accounts: vec![
AccountMeta::new(operator, true),
AccountMeta::new(
pending_commitment_pda(&account.compatize(), commit_id)
.modernize(),
false,
),
AccountMeta::new(account, false),
AccountMeta::new(
delegation_record_pda_from_delegated_account(
&account.compatize(),
)
.modernize(),
false,
),
AccountMeta::new(
delegation_metadata_pda_from_delegated_account(
&account.compatize(),
)
.modernize(),
false,
),
AccountMeta::new_readonly(
state_buffer_pda(
&account.compatize(),
commit_id,
&operator.compatize(),
)
.modernize(),
false,
),
AccountMeta::new_readonly(system_program::id(), false),
],
data: DlpV2Instruction::FinalizeCommitment.to_vec(),
}
}
2 changes: 2 additions & 0 deletions dlp-api/src/v2/instruction_builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod approve_commitment;
mod finalize_commitment;
mod init_protocol_config;
mod post_commitment;
mod register_operator;
Expand All @@ -8,6 +9,7 @@ mod update_verifier_registry;
mod write_state_buffer;

pub use approve_commitment::*;
pub use finalize_commitment::*;
pub use init_protocol_config::*;
pub use post_commitment::*;
pub use register_operator::*;
Expand Down
Loading
Loading