use cow_settlement_interface::{
pda::{buffer::find_buffer_pda, state::find_state_pda},
token_program::TokenProgram,
Instruction, Pubkey,
};
pub struct ReclaimBuffer<'a> {
pub program_id: Pubkey,
pub reclaim_authority: Pubkey,
pub reclaim_recipient: Pubkey,
pub token_program: TokenProgram,
pub mints: &'a [Pubkey],
}
impl From<ReclaimBuffer<'_>> for Instruction {
fn from(builder: ReclaimBuffer<'_>) -> Self {
let (state_pda, _bump) = find_state_pda(&builder.program_id);
let buffers: Vec<(Pubkey, Pubkey)> = builder
.mints
.iter()
.map(|mint| {
let (buffer_pda, _bump) = find_buffer_pda(&builder.program_id, mint);
(buffer_pda, *mint)
})
.collect();
cow_settlement_interface::instruction::reclaim_buffer::ReclaimBuffer {
program_id: builder.program_id,
state_pda,
reclaim_authority: builder.reclaim_authority,
reclaim_recipient: builder.reclaim_recipient,
token_program: builder.token_program.address(),
buffers: &buffers,
}
.into()
}
}