2020-10-16 10:38:12 -07:00
|
|
|
//! Instruction types
|
|
|
|
|
|
|
|
#![allow(clippy::too_many_arguments)]
|
|
|
|
|
2021-02-22 15:28:06 -08:00
|
|
|
use {
|
|
|
|
solana_program::{
|
|
|
|
instruction::{AccountMeta, Instruction},
|
|
|
|
program_error::ProgramError,
|
|
|
|
pubkey::Pubkey,
|
|
|
|
sysvar,
|
|
|
|
},
|
|
|
|
std::mem::size_of,
|
|
|
|
};
|
2020-10-16 10:38:12 -07:00
|
|
|
|
|
|
|
/// Fee rate as a ratio
|
|
|
|
/// Fee is minted on deposit
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Fee {
|
|
|
|
/// denominator of the fee ratio
|
|
|
|
pub denominator: u64,
|
|
|
|
/// numerator of the fee ratio
|
|
|
|
pub numerator: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Inital values for the Stake Pool
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct InitArgs {
|
|
|
|
/// Fee paid to the owner in pool tokens
|
|
|
|
pub fee: Fee,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Instructions supported by the StakePool program.
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub enum StakePoolInstruction {
|
|
|
|
/// Initializes a new StakePool.
|
|
|
|
///
|
|
|
|
/// 0. `[w]` New StakePool to create.
|
2021-02-10 08:42:28 -08:00
|
|
|
/// 1. `[s]` Owner
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// 2. `[w]` Uninitialized validator stake list storage account
|
|
|
|
/// 3. `[]` pool token Mint. Must be non zero, owned by withdraw authority.
|
|
|
|
/// 4. `[]` Pool Account to deposit the generated fee for owner.
|
2021-02-10 08:42:28 -08:00
|
|
|
/// 5. `[]` Clock sysvar
|
|
|
|
/// 6. `[]` Rent sysvar
|
|
|
|
/// 7. `[]` Token program id
|
2020-10-16 10:38:12 -07:00
|
|
|
Initialize(InitArgs),
|
|
|
|
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// Creates new program account for accumulating stakes for a particular validator
|
|
|
|
///
|
|
|
|
/// 0. `[]` Stake pool account this stake will belong to
|
|
|
|
/// 1. `[ws]` Funding account (must be a system account)
|
|
|
|
/// 2. `[w]` Stake account to be created
|
|
|
|
/// 3. `[]` Validator this stake account will vote for
|
|
|
|
/// 4. `[]` Stake authority for the new stake account
|
|
|
|
/// 5. `[]` Withdraw authority for the new stake account
|
|
|
|
/// 6. `[]` Rent sysvar
|
|
|
|
/// 7. `[]` System program
|
|
|
|
/// 8. `[]` Stake program
|
|
|
|
CreateValidatorStakeAccount,
|
|
|
|
|
|
|
|
/// Adds validator stake account to the pool
|
|
|
|
///
|
|
|
|
/// 0. `[w]` Stake pool
|
|
|
|
/// 1. `[s]` Owner
|
|
|
|
/// 2. `[]` Stake pool deposit authority
|
|
|
|
/// 3. `[]` Stake pool withdraw authority
|
|
|
|
/// 4. `[w]` Validator stake list storage account
|
|
|
|
/// 5. `[w]` Stake account to add to the pool, its withdraw authority should be set to stake pool deposit
|
|
|
|
/// 6. `[w]` User account to receive pool tokens
|
|
|
|
/// 7. `[w]` Pool token mint account
|
|
|
|
/// 8. `[]` Clock sysvar (required)
|
2021-02-10 08:42:28 -08:00
|
|
|
/// 9. '[]' Sysvar stake history account
|
|
|
|
/// 10. `[]` Pool token program id,
|
|
|
|
/// 11. `[]` Stake program id,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AddValidatorStakeAccount,
|
|
|
|
|
|
|
|
/// Removes validator stake account from the pool
|
|
|
|
///
|
|
|
|
/// 0. `[w]` Stake pool
|
|
|
|
/// 1. `[s]` Owner
|
|
|
|
/// 2. `[]` Stake pool withdraw authority
|
|
|
|
/// 3. `[]` New withdraw/staker authority to set in the stake account
|
|
|
|
/// 4. `[w]` Validator stake list storage account
|
|
|
|
/// 5. `[w]` Stake account to remove from the pool
|
|
|
|
/// 6. `[w]` User account with pool tokens to burn from
|
|
|
|
/// 7. `[w]` Pool token mint account
|
|
|
|
/// 8. '[]' Sysvar clock account (required)
|
|
|
|
/// 9. `[]` Pool token program id
|
|
|
|
/// 10. `[]` Stake program id,
|
|
|
|
RemoveValidatorStakeAccount,
|
|
|
|
|
|
|
|
/// Updates balances of validator stake accounts in the pool
|
2021-02-22 15:28:06 -08:00
|
|
|
///
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// 0. `[w]` Validator stake list storage account
|
|
|
|
/// 1. `[]` Sysvar clock account
|
|
|
|
/// 2. ..2+N ` [] N validator stake accounts to update balances
|
|
|
|
UpdateListBalance,
|
|
|
|
|
|
|
|
/// Updates total pool balance based on balances in validator stake account list storage
|
|
|
|
///
|
|
|
|
/// 0. `[w]` Stake pool
|
|
|
|
/// 1. `[]` Validator stake list storage account
|
|
|
|
/// 2. `[]` Sysvar clock account
|
|
|
|
UpdatePoolBalance,
|
|
|
|
|
2020-10-16 10:38:12 -07:00
|
|
|
/// Deposit some stake into the pool. The output is a "pool" token representing ownership
|
|
|
|
/// into the pool. Inputs are converted to the current ratio.
|
|
|
|
///
|
2020-10-20 12:02:05 -07:00
|
|
|
/// 0. `[w]` Stake pool
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// 1. `[w]` Validator stake list storage account
|
|
|
|
/// 2. `[]` Stake pool deposit authority
|
|
|
|
/// 3. `[]` Stake pool withdraw authority
|
|
|
|
/// 4. `[w]` Stake account to join the pool (withdraw should be set to stake pool deposit)
|
|
|
|
/// 5. `[w]` Validator stake account for the stake account to be merged with
|
|
|
|
/// 6. `[w]` User account to receive pool tokens
|
|
|
|
/// 7. `[w]` Account to receive pool fee tokens
|
|
|
|
/// 8. `[w]` Pool token mint account
|
|
|
|
/// 9. '[]' Sysvar clock account (required)
|
|
|
|
/// 10. '[]' Sysvar stake history account
|
|
|
|
/// 11. `[]` Pool token program id,
|
|
|
|
/// 12. `[]` Stake program id,
|
2020-10-16 10:38:12 -07:00
|
|
|
Deposit,
|
|
|
|
|
|
|
|
/// Withdraw the token from the pool at the current ratio.
|
|
|
|
/// The amount withdrawn is the MIN(u64, stake size)
|
|
|
|
///
|
2020-10-20 12:02:05 -07:00
|
|
|
/// 0. `[w]` Stake pool
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// 1. `[w]` Validator stake list storage account
|
|
|
|
/// 2. `[]` Stake pool withdraw authority
|
|
|
|
/// 3. `[w]` Validator stake account to split
|
|
|
|
/// 4. `[w]` Unitialized stake account to receive withdrawal
|
|
|
|
/// 5. `[]` User account to set as a new withdraw authority
|
|
|
|
/// 6. `[w]` User account with pool tokens to burn from
|
|
|
|
/// 7. `[w]` Pool token mint account
|
|
|
|
/// 8. '[]' Sysvar clock account (required)
|
|
|
|
/// 9. `[]` Pool token program id
|
|
|
|
/// 10. `[]` Stake program id,
|
2020-10-16 10:38:12 -07:00
|
|
|
/// userdata: amount to withdraw
|
|
|
|
Withdraw(u64),
|
|
|
|
|
|
|
|
/// Update the staking pubkey for a stake
|
|
|
|
///
|
|
|
|
/// 0. `[w]` StakePool
|
|
|
|
/// 1. `[s]` Owner
|
|
|
|
/// 2. `[]` withdraw authority
|
|
|
|
/// 3. `[w]` Stake to update the staking pubkey
|
|
|
|
/// 4. '[]` Staking pubkey.
|
2020-11-02 13:03:54 -08:00
|
|
|
/// 5. '[]' Sysvar clock account (reserved for future use)
|
|
|
|
/// 6. `[]` Stake program id,
|
2020-10-16 10:38:12 -07:00
|
|
|
SetStakingAuthority,
|
|
|
|
|
|
|
|
/// Update owner
|
|
|
|
///
|
|
|
|
/// 0. `[w]` StakePool
|
|
|
|
/// 1. `[s]` Owner
|
|
|
|
/// 2. '[]` New owner pubkey
|
|
|
|
/// 3. '[]` New owner fee account
|
|
|
|
SetOwner,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl StakePoolInstruction {
|
|
|
|
/// Deserializes a byte buffer into an [StakePoolInstruction](enum.StakePoolInstruction.html).
|
|
|
|
/// TODO efficient unpacking here
|
|
|
|
pub fn deserialize(input: &[u8]) -> Result<Self, ProgramError> {
|
|
|
|
if input.len() < size_of::<u8>() {
|
|
|
|
return Err(ProgramError::InvalidAccountData);
|
|
|
|
}
|
|
|
|
Ok(match input[0] {
|
|
|
|
0 => {
|
|
|
|
let val: &InitArgs = unpack(input)?;
|
|
|
|
Self::Initialize(*val)
|
|
|
|
}
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
1 => Self::CreateValidatorStakeAccount,
|
|
|
|
2 => Self::AddValidatorStakeAccount,
|
|
|
|
3 => Self::RemoveValidatorStakeAccount,
|
|
|
|
4 => Self::UpdateListBalance,
|
|
|
|
5 => Self::UpdatePoolBalance,
|
|
|
|
6 => Self::Deposit,
|
|
|
|
7 => {
|
2020-10-16 10:38:12 -07:00
|
|
|
let val: &u64 = unpack(input)?;
|
|
|
|
Self::Withdraw(*val)
|
|
|
|
}
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
8 => Self::SetStakingAuthority,
|
|
|
|
9 => Self::SetOwner,
|
2020-10-16 10:38:12 -07:00
|
|
|
_ => return Err(ProgramError::InvalidAccountData),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Serializes an [StakePoolInstruction](enum.StakePoolInstruction.html) into a byte buffer.
|
|
|
|
/// TODO efficient packing here
|
|
|
|
pub fn serialize(&self) -> Result<Vec<u8>, ProgramError> {
|
|
|
|
let mut output = vec![0u8; size_of::<StakePoolInstruction>()];
|
|
|
|
match self {
|
|
|
|
Self::Initialize(init) => {
|
|
|
|
output[0] = 0;
|
|
|
|
#[allow(clippy::cast_ptr_alignment)]
|
|
|
|
let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut InitArgs) };
|
|
|
|
*value = *init;
|
|
|
|
}
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
Self::CreateValidatorStakeAccount => {
|
2020-10-16 10:38:12 -07:00
|
|
|
output[0] = 1;
|
|
|
|
}
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
Self::AddValidatorStakeAccount => {
|
2020-10-16 10:38:12 -07:00
|
|
|
output[0] = 2;
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
}
|
|
|
|
Self::RemoveValidatorStakeAccount => {
|
|
|
|
output[0] = 3;
|
|
|
|
}
|
|
|
|
Self::UpdateListBalance => {
|
|
|
|
output[0] = 4;
|
|
|
|
}
|
|
|
|
Self::UpdatePoolBalance => {
|
|
|
|
output[0] = 5;
|
|
|
|
}
|
|
|
|
Self::Deposit => {
|
|
|
|
output[0] = 6;
|
|
|
|
}
|
|
|
|
Self::Withdraw(val) => {
|
|
|
|
output[0] = 7;
|
2020-10-16 10:38:12 -07:00
|
|
|
#[allow(clippy::cast_ptr_alignment)]
|
|
|
|
let value = unsafe { &mut *(&mut output[1] as *mut u8 as *mut u64) };
|
|
|
|
*value = *val;
|
|
|
|
}
|
2020-10-20 12:02:05 -07:00
|
|
|
Self::SetStakingAuthority => {
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
output[0] = 8;
|
2020-10-16 10:38:12 -07:00
|
|
|
}
|
2020-10-20 12:02:05 -07:00
|
|
|
Self::SetOwner => {
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
output[0] = 9;
|
2020-10-20 12:02:05 -07:00
|
|
|
}
|
2020-10-16 10:38:12 -07:00
|
|
|
}
|
|
|
|
Ok(output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Unpacks a reference from a bytes buffer.
|
|
|
|
pub fn unpack<T>(input: &[u8]) -> Result<&T, ProgramError> {
|
|
|
|
if input.len() < size_of::<u8>() + size_of::<T>() {
|
|
|
|
return Err(ProgramError::InvalidAccountData);
|
|
|
|
}
|
|
|
|
#[allow(clippy::cast_ptr_alignment)]
|
|
|
|
let val: &T = unsafe { &*(&input[1] as *const u8 as *const T) };
|
|
|
|
Ok(val)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates an 'initialize' instruction.
|
|
|
|
pub fn initialize(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
owner: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
validator_stake_list: &Pubkey,
|
2020-10-16 10:38:12 -07:00
|
|
|
pool_mint: &Pubkey,
|
|
|
|
owner_pool_account: &Pubkey,
|
|
|
|
token_program_id: &Pubkey,
|
|
|
|
init_args: InitArgs,
|
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let init_data = StakePoolInstruction::Initialize(init_args);
|
|
|
|
let data = init_data.serialize()?;
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, true),
|
2021-02-10 08:42:28 -08:00
|
|
|
AccountMeta::new_readonly(*owner, true),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new(*validator_stake_list, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*pool_mint, false),
|
|
|
|
AccountMeta::new_readonly(*owner_pool_account, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
2021-02-10 08:42:28 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::rent::id(), false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*token_program_id, false),
|
2020-10-16 10:38:12 -07:00
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
2020-10-21 05:21:54 -07:00
|
|
|
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// Creates `CreateValidatorStakeAccount` instruction (create new stake account for the validator)
|
|
|
|
pub fn create_validator_stake_account(
|
2020-10-21 05:21:54 -07:00
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
funder: &Pubkey,
|
|
|
|
stake_account: &Pubkey,
|
|
|
|
validator: &Pubkey,
|
|
|
|
stake_authority: &Pubkey,
|
|
|
|
withdraw_authority: &Pubkey,
|
|
|
|
system_program_id: &Pubkey,
|
|
|
|
stake_program_id: &Pubkey,
|
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new_readonly(*stake_pool, false),
|
|
|
|
AccountMeta::new(*funder, true),
|
|
|
|
AccountMeta::new(*stake_account, false),
|
|
|
|
AccountMeta::new_readonly(*validator, false),
|
|
|
|
AccountMeta::new_readonly(*stake_authority, false),
|
|
|
|
AccountMeta::new_readonly(*withdraw_authority, false),
|
|
|
|
AccountMeta::new_readonly(sysvar::rent::id(), false),
|
|
|
|
AccountMeta::new_readonly(*system_program_id, false),
|
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data: StakePoolInstruction::CreateValidatorStakeAccount.serialize()?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates `AddValidatorStakeAccount` instruction (add new validator stake account to the pool)
|
|
|
|
pub fn add_validator_stake_account(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
owner: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
stake_pool_deposit: &Pubkey,
|
|
|
|
stake_pool_withdraw: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
validator_stake_list: &Pubkey,
|
|
|
|
stake_account: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
pool_tokens_to: &Pubkey,
|
|
|
|
pool_mint: &Pubkey,
|
|
|
|
token_program_id: &Pubkey,
|
2020-11-02 13:03:54 -08:00
|
|
|
stake_program_id: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new_readonly(*owner, true),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_pool_deposit, false),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_withdraw, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new(*validator_stake_list, false),
|
|
|
|
AccountMeta::new(*stake_account, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
AccountMeta::new(*pool_tokens_to, false),
|
|
|
|
AccountMeta::new(*pool_mint, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
2021-02-10 08:42:28 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::stake_history::id(), false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*token_program_id, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
data: StakePoolInstruction::AddValidatorStakeAccount.serialize()?,
|
2020-10-21 05:21:54 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// Creates `RemoveValidatorStakeAccount` instruction (remove validator stake account from the pool)
|
|
|
|
pub fn remove_validator_stake_account(
|
2020-10-21 05:21:54 -07:00
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
owner: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
stake_pool_withdraw: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
new_stake_authority: &Pubkey,
|
|
|
|
validator_stake_list: &Pubkey,
|
|
|
|
stake_account: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
burn_from: &Pubkey,
|
|
|
|
pool_mint: &Pubkey,
|
|
|
|
token_program_id: &Pubkey,
|
2020-11-02 13:03:54 -08:00
|
|
|
stake_program_id: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new_readonly(*owner, true),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_pool_withdraw, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new_readonly(*new_stake_authority, false),
|
|
|
|
AccountMeta::new(*validator_stake_list, false),
|
|
|
|
AccountMeta::new(*stake_account, false),
|
2020-11-10 06:36:05 -08:00
|
|
|
AccountMeta::new(*burn_from, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
AccountMeta::new(*pool_mint, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*token_program_id, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
];
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data: StakePoolInstruction::RemoveValidatorStakeAccount.serialize()?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates `UpdateListBalance` instruction (update validator stake account balances)
|
|
|
|
pub fn update_list_balance(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
validator_stake_list_storage: &Pubkey,
|
2021-02-26 15:57:38 -08:00
|
|
|
validator_stake_list: &[Pubkey],
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let mut accounts: Vec<AccountMeta> = validator_stake_list
|
|
|
|
.iter()
|
2021-02-26 15:57:38 -08:00
|
|
|
.map(|pubkey| AccountMeta::new_readonly(*pubkey, false))
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
.collect();
|
|
|
|
accounts.insert(0, AccountMeta::new(*validator_stake_list_storage, false));
|
|
|
|
accounts.insert(1, AccountMeta::new_readonly(sysvar::clock::id(), false));
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data: StakePoolInstruction::UpdateListBalance.serialize()?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates `UpdatePoolBalance` instruction (pool balance from the stake account list balances)
|
|
|
|
pub fn update_pool_balance(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
validator_stake_list_storage: &Pubkey,
|
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
|
|
|
AccountMeta::new(*validator_stake_list_storage, false),
|
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data: StakePoolInstruction::UpdatePoolBalance.serialize()?,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a 'Deposit' instruction.
|
|
|
|
pub fn deposit(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
validator_stake_list_storage: &Pubkey,
|
|
|
|
stake_pool_deposit: &Pubkey,
|
|
|
|
stake_pool_withdraw: &Pubkey,
|
|
|
|
stake_to_join: &Pubkey,
|
|
|
|
validator_stake_accont: &Pubkey,
|
|
|
|
pool_tokens_to: &Pubkey,
|
|
|
|
pool_fee_to: &Pubkey,
|
|
|
|
pool_mint: &Pubkey,
|
|
|
|
token_program_id: &Pubkey,
|
|
|
|
stake_program_id: &Pubkey,
|
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let args = StakePoolInstruction::Deposit;
|
|
|
|
let data = args.serialize()?;
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
|
|
|
AccountMeta::new(*validator_stake_list_storage, false),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_deposit, false),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_withdraw, false),
|
|
|
|
AccountMeta::new(*stake_to_join, false),
|
|
|
|
AccountMeta::new(*validator_stake_accont, false),
|
|
|
|
AccountMeta::new(*pool_tokens_to, false),
|
|
|
|
AccountMeta::new(*pool_fee_to, false),
|
|
|
|
AccountMeta::new(*pool_mint, false),
|
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
|
|
|
AccountMeta::new_readonly(sysvar::stake_history::id(), false),
|
|
|
|
AccountMeta::new_readonly(*token_program_id, false),
|
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
|
|
|
];
|
2020-10-21 05:21:54 -07:00
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
/// Creates a 'withdraw' instruction.
|
|
|
|
pub fn withdraw(
|
2020-10-21 05:21:54 -07:00
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
validator_stake_list_storage: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
stake_pool_withdraw: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
stake_to_split: &Pubkey,
|
|
|
|
stake_to_receive: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
user_withdrawer: &Pubkey,
|
|
|
|
burn_from: &Pubkey,
|
|
|
|
pool_mint: &Pubkey,
|
|
|
|
token_program_id: &Pubkey,
|
2020-11-02 13:03:54 -08:00
|
|
|
stake_program_id: &Pubkey,
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
amount: u64,
|
2020-10-21 05:21:54 -07:00
|
|
|
) -> Result<Instruction, ProgramError> {
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
let args = StakePoolInstruction::Withdraw(amount);
|
2020-10-21 05:21:54 -07:00
|
|
|
let data = args.serialize()?;
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new(*validator_stake_list_storage, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_pool_withdraw, false),
|
Stake pool: adding pool balance confirmation (Redo of #960) (#1116)
* Added validator stake account list storage, deprecated old tests
* Added join and leave stake pool instructions, error messages refactoring
* Stake pool tests refactoring, tests for join and leave pool added
* Added validator stake account creation instruction, join/leave pool instructions renamed, version field added
* Formatting fixes
* Added update list/pool instructions (no tests yet), updated deposit instruction logic, claim instruction removed, refactoring
* Updated deposit logic and tests, updated withdraw logic and added tests, refactoring
* Stake pool CLI updated to work with new deposit/withdraw instructions, claim usage removed
* Added validator stake account management and balance update commands to the stake pool CLI, updated dependency versions, updated devnet program address
* Merge conflicts fixed
* Removed deprecated tests
* Fixes for review comments
* Additional program id checks across the code
* Formatting errors fixed
* Changed minimum stake balance in CLI, removed deprecated tests, removed check for stake history id
* Added TODO for stake account warmup status check
* Cargo.lock conflict fix
* Formatting fixed
* Update Cargo lock file for CI
* Pin themis version of subtle
Co-authored-by: Yuriy Savchenko <yuriy.savchenko@gmail.com>
2021-01-21 05:48:46 -08:00
|
|
|
AccountMeta::new(*stake_to_split, false),
|
|
|
|
AccountMeta::new(*stake_to_receive, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*user_withdrawer, false),
|
2020-11-10 06:36:05 -08:00
|
|
|
AccountMeta::new(*burn_from, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
AccountMeta::new(*pool_mint, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*token_program_id, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a 'set staking authority' instruction.
|
|
|
|
pub fn set_staking_authority(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
stake_pool_owner: &Pubkey,
|
|
|
|
stake_pool_withdraw: &Pubkey,
|
|
|
|
stake_account_to_update: &Pubkey,
|
|
|
|
stake_account_new_authority: &Pubkey,
|
2020-11-02 13:03:54 -08:00
|
|
|
stake_program_id: &Pubkey,
|
2020-10-21 05:21:54 -07:00
|
|
|
) -> Result<Instruction, ProgramError> {
|
|
|
|
let args = StakePoolInstruction::SetStakingAuthority;
|
|
|
|
let data = args.serialize()?;
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_pool_owner, true),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_withdraw, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
AccountMeta::new(*stake_account_to_update, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_account_new_authority, false),
|
2020-11-02 13:03:54 -08:00
|
|
|
AccountMeta::new_readonly(sysvar::clock::id(), false),
|
|
|
|
AccountMeta::new_readonly(*stake_program_id, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a 'set owner' instruction.
|
|
|
|
pub fn set_owner(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
stake_pool: &Pubkey,
|
|
|
|
stake_pool_owner: &Pubkey,
|
|
|
|
stake_pool_new_owner: &Pubkey,
|
|
|
|
stake_pool_new_fee_receiver: &Pubkey,
|
|
|
|
) -> Result<Instruction, ProgramError> {
|
2020-11-04 04:34:25 -08:00
|
|
|
let args = StakePoolInstruction::SetOwner;
|
2020-10-21 05:21:54 -07:00
|
|
|
let data = args.serialize()?;
|
|
|
|
let accounts = vec![
|
|
|
|
AccountMeta::new(*stake_pool, false),
|
2020-10-23 05:25:53 -07:00
|
|
|
AccountMeta::new_readonly(*stake_pool_owner, true),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_new_owner, false),
|
|
|
|
AccountMeta::new_readonly(*stake_pool_new_fee_receiver, false),
|
2020-10-21 05:21:54 -07:00
|
|
|
];
|
|
|
|
Ok(Instruction {
|
|
|
|
program_id: *program_id,
|
|
|
|
accounts,
|
|
|
|
data,
|
|
|
|
})
|
|
|
|
}
|