Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clients/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub enum Command {
/// tokens to burn or the ALL keyword to burn all.
Withdraw(WithdrawCli),

/// WARNING: This command is DEPRECATED and will be removed in a future release.
/// Create and delegate a new stake account to a given validator, using a
/// default address linked to the intended depository pool
CreateDefaultStake(CreateStakeCli),
Expand Down Expand Up @@ -165,6 +166,7 @@ pub struct DepositCli {
#[clap(value_parser = |p: &str| parse_address(p, "stake_account_address"))]
pub stake_account_address: Option<Pubkey>,

/// WARNING: This flag is DEPRECATED and will be removed in a future release.
/// Instead of using a stake account by address, use the user's default
/// account for a specified pool
#[clap(
Expand Down
47 changes: 31 additions & 16 deletions clients/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ use {
solana_transaction::Transaction,
solana_vote_program::{self as vote_program, vote_state::VoteState},
spl_single_pool::{
self, find_default_deposit_account_address, find_pool_address, find_pool_mint_address,
find_pool_onramp_address, find_pool_stake_address, instruction::SinglePoolInstruction,
state::SinglePool,
self, find_pool_address, find_pool_mint_address, find_pool_onramp_address,
find_pool_stake_address, instruction::SinglePoolInstruction, state::SinglePool,
},
spl_token_client::token::Token,
std::{rc::Rc, sync::Arc},
};

#[allow(deprecated)]
use spl_single_pool::find_default_deposit_account_address;

mod config;
use config::*;

Expand Down Expand Up @@ -247,15 +249,21 @@ async fn command_deposit(
});

// from there we can determine the stake account address
let stake_account_address =
if let Some(stake_account_address) = command_config.stake_account_address {
stake_account_address
} else if let Some(pool_address) = provided_pool_address {
assert!(command_config.default_stake_account);
find_default_deposit_account_address(&pool_address, &stake_authority.pubkey())
} else {
unreachable!()
};
let stake_account_address = if let Some(stake_account_address) =
command_config.stake_account_address
{
stake_account_address
} else if let Some(pool_address) = provided_pool_address {
assert!(command_config.default_stake_account);
eprintln_display(
config,
"WARNING: This flag is DEPRECATED and will be removed in a future release.".to_string(),
);
#[allow(deprecated)]
find_default_deposit_account_address(&pool_address, &stake_authority.pubkey())
} else {
unreachable!()
};

// now we validate the stake account and definitively resolve the pool address
let (pool_address, user_stake_active) = if let Some((meta, stake)) =
Expand Down Expand Up @@ -702,6 +710,11 @@ async fn command_update_metadata(

// create default stake account
async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -> CommandResult {
eprintln_display(
config,
"WARNING: This command is DEPRECATED and will be removed in a future release.".to_string(),
);

let payer = config.fee_payer()?;
let owner = config.default_signer()?;
let stake_authority_address = command_config
Expand All @@ -713,6 +726,10 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
command_config.vote_account_address,
);

#[allow(deprecated)]
let stake_account_address =
find_default_deposit_account_address(&pool_address, &stake_authority_address);

println_display(
config,
format!("Creating default stake account for pool {}\n", pool_address),
Expand Down Expand Up @@ -744,6 +761,7 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
);
}

#[allow(deprecated)]
let instructions = spl_single_pool::instruction::create_and_delegate_user_stake(
&spl_single_pool::id(),
&vote_account_address,
Expand All @@ -766,10 +784,7 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
"CreateDefaultStake".to_string(),
CreateStakeOutput {
pool_address,
stake_account_address: find_default_deposit_account_address(
&pool_address,
&stake_authority_address,
),
stake_account_address,
signature,
},
))
Expand Down
1 change: 1 addition & 0 deletions clients/js-legacy/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export async function findPoolMplAuthorityAddress(programId: PublicKey, poolAddr
);
}

/** @deprecated */
export async function findDefaultDepositAccountAddress(
poolAddress: PublicKey,
userWallet: PublicKey,
Expand Down
2 changes: 2 additions & 0 deletions clients/js/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async function findPda(programId: Address, baseAddress: Address, prefix: string)
return pda;
}

/** @deprecated */
export async function findDefaultDepositAccountAddress(
poolAddress: PoolAddress,
userWallet: Address,
Expand All @@ -113,6 +114,7 @@ export async function findDefaultDepositAccountAddress(
});
}

/** @deprecated */
export function defaultDepositAccountSeed(poolAddress: PoolAddress): string {
return 'svsp' + poolAddress.slice(0, 28);
}
Expand Down
2 changes: 2 additions & 0 deletions clients/js/src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface DepositParams {
pool: PoolAddress;
userWallet: Address;
userStakeAccount?: Address;
/** @deprecated */
depositFromDefaultAccount?: boolean;
userTokenAccount?: Address;
userLamportAccount?: Address;
Expand Down Expand Up @@ -348,6 +349,7 @@ export async function initializeOnRampTransaction(
return transaction;
}

/** @deprecated */
export async function createAndDelegateUserStakeTransaction(
rpc: any, // XXX not exported: Rpc<???>,
voteAccount: VoteAccountAddress,
Expand Down
4 changes: 4 additions & 0 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ pub fn withdraw_stake(
/// combination to make it easier to find for deposits. This is an optional
/// helper function; deposits can come from any owned stake account without
/// lockup.
#[deprecated(
since = "3.0.0",
note = "Will be removed in a future release; this was intended to support a wallet flow that never materialized."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can this provide the preferred alternative of creating and delegating a stake account?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)]
pub fn create_and_delegate_user_stake(
program_id: &Pubkey,
vote_account_address: &Pubkey,
Expand Down
4 changes: 4 additions & 0 deletions program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ pub fn find_pool_mpl_authority_address(program_id: &Pubkey, pool_address: &Pubke

/// Find the address of the default intermediate account that holds activating
/// user stake before deposit.
#[deprecated(
since = "3.0.0",
note = "Will be removed in a future release; this was intended to support a wallet flow that never materialized."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here, can this give the alternative of using any new stake account address instead?

)]
pub fn find_default_deposit_account_address(
pool_address: &Pubkey,
user_wallet_address: &Pubkey,
Expand Down
9 changes: 6 additions & 3 deletions program/tests/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use {
solana_stake_interface::state::{Authorized, Lockup},
solana_system_interface::instruction as system_instruction,
spl_associated_token_account_client::address as atoken,
spl_single_pool::{
error::SinglePoolError, find_default_deposit_account_address, id, instruction,
},
spl_single_pool::{error::SinglePoolError, id, instruction},
test_case::test_case,
};

#[allow(deprecated)]
use spl_single_pool::find_default_deposit_account_address;

#[test_case(true, 0, 0, false, false, false; "activated::minimum_disabled")]
#[test_case(true, 0, 0, false, false, true; "activated::minimum_disabled::small")]
#[test_case(true, 0, 0, false, true, false; "activated::minimum_enabled")]
Expand Down Expand Up @@ -204,9 +205,11 @@ async fn success_with_seed(activate: bool, enable_minimum_delegation: bool, smal
let accounts = SinglePoolAccounts::default();
let rent = context.banks_client.get_rent().await.unwrap();
let minimum_stake = accounts.initialize(&mut context).await;
#[allow(deprecated)]
let alice_default_stake =
find_default_deposit_account_address(&accounts.pool, &accounts.alice.pubkey());

#[allow(deprecated)]
let instructions = instruction::create_and_delegate_user_stake(
&id(),
&accounts.vote_account.pubkey(),
Expand Down