Add GetMinimumDelegation stake program instruction (#24020)

This commit is contained in:
Brooks Prumo
2022-04-02 00:11:10 -05:00
committed by GitHub
parent 792bbf75ab
commit 2af6753808
7 changed files with 178 additions and 92 deletions

View File

@ -222,6 +222,15 @@ pub enum StakeInstruction {
/// 1. `[SIGNER]` Lockup authority or withdraw authority
/// 2. Optional: `[SIGNER]` New lockup authority
SetLockupChecked(LockupCheckedArgs),
/// Get the minimum stake delegation, in lamports
///
/// # Account references
/// None
///
/// The minimum delegation will be returned via the transaction context's returndata.
/// Use `get_return_data()` to retrieve the result.
GetMinimumDelegation,
}
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
@ -678,6 +687,14 @@ pub fn set_lockup_checked(
)
}
pub fn get_minimum_delegation() -> Instruction {
Instruction::new_with_bincode(
id(),
&StakeInstruction::GetMinimumDelegation,
Vec::default(),
)
}
#[cfg(test)]
mod tests {
use {super::*, crate::instruction::InstructionError};

View File

@ -6,7 +6,8 @@ pub mod program {
crate::declare_id!("Stake11111111111111111111111111111111111111");
}
/// The minimum stake amount that can be delegated, in lamports.
/// NOTE: This is also used to calculate the minimum balance of a stake account, which is the
/// rent exempt reserve _plus_ the minimum stake delegation.
#[deprecated(
since = "1.10.6",
note = "This constant may be outdated, please use `solana_stake_program::get_minimum_delegation` instead"
)]
pub const MINIMUM_STAKE_DELEGATION: u64 = 1;