1use tape_api::prelude::*;
2use steel::*;
3
4pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
5 let [
6 signer_info,
7 miner_info,
8 system_program_info,
9 ] = accounts else {
10 return Err(ProgramError::NotEnoughAccountKeys);
11 };
12
13 signer_info.is_signer()?;
14
15 miner_info
16 .is_writable()?
17 .as_account::<Miner>(&tape_api::ID)?
18 .assert_err(
19 |p| p.authority == *signer_info.key,
20 ProgramError::MissingRequiredSignature,
21 )?
22 .assert(|p| p.unclaimed_rewards == 0)?;
23
24 system_program_info
25 .is_program(&system_program::ID)?;
26
27 miner_info.close(signer_info)?;
29
30 Ok(())
31}