atlas_feature_gate_interface/
instruction.rs1#[cfg(feature = "bincode")]
2use {
3 crate::state::Feature,
4 atlas_instruction::{AccountMeta, Instruction},
5 atlas_pubkey::Pubkey,
6 atlas_rent::Rent,
7 atlas_sdk_ids::{feature::id, incinerator, system_program},
8 atlas_system_interface::instruction as system_instruction,
9};
10
11#[cfg(feature = "bincode")]
12pub fn activate(feature_id: &Pubkey, funding_address: &Pubkey, rent: &Rent) -> Vec<Instruction> {
14 activate_with_lamports(
15 feature_id,
16 funding_address,
17 rent.minimum_balance(Feature::size_of()),
18 )
19}
20
21#[cfg(feature = "bincode")]
22pub fn activate_with_lamports(
23 feature_id: &Pubkey,
24 funding_address: &Pubkey,
25 lamports: u64,
26) -> Vec<Instruction> {
27 vec![
28 system_instruction::transfer(funding_address, feature_id, lamports),
29 system_instruction::allocate(feature_id, Feature::size_of() as u64),
30 system_instruction::assign(feature_id, &id()),
31 ]
32}
33
34#[cfg(feature = "bincode")]
36pub fn revoke_pending_activation(feature_id: &Pubkey) -> Instruction {
37 let accounts = vec![
38 AccountMeta::new(*feature_id, true),
39 AccountMeta::new(incinerator::id(), false),
40 AccountMeta::new_readonly(system_program::id(), false),
41 ];
42
43 Instruction {
44 program_id: crate::id(),
45 accounts,
46 data: vec![0],
47 }
48}