-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprocess_refund_proposal_deposit.rs
More file actions
42 lines (32 loc) · 1.29 KB
/
process_refund_proposal_deposit.rs
File metadata and controls
42 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Program state processor
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
pubkey::Pubkey,
};
use spl_governance_tools::account::dispose_account;
use crate::state::{
proposal::get_proposal_data,
proposal_deposit::get_proposal_deposit_data_for_proposal_and_deposit_payer,
};
/// Processes RefundProposalDeposit instruction
pub fn process_refund_proposal_deposit(
program_id: &Pubkey,
accounts: &[AccountInfo],
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let proposal_info = next_account_info(account_info_iter)?; // 0
let proposal_deposit_info = next_account_info(account_info_iter)?; // 1
let proposal_deposit_payer_info = next_account_info(account_info_iter)?; // 2
let proposal_data = get_proposal_data(program_id, proposal_info)?;
proposal_data.assert_can_refund_proposal_deposit()?;
// Assert we are disposing a deposit which belongs to the Proposal and the deposit payer
let _proposal_deposit_data = get_proposal_deposit_data_for_proposal_and_deposit_payer(
program_id,
proposal_deposit_info,
proposal_info.key,
proposal_deposit_payer_info.key,
)?;
dispose_account(proposal_deposit_info, proposal_deposit_payer_info)?;
Ok(())
}