diff --git a/clients/cli/src/cli.rs b/clients/cli/src/cli.rs index 7c81829d..9ce50fc2 100644 --- a/clients/cli/src/cli.rs +++ b/clients/cli/src/cli.rs @@ -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), @@ -165,6 +166,7 @@ pub struct DepositCli { #[clap(value_parser = |p: &str| parse_address(p, "stake_account_address"))] pub stake_account_address: Option, + /// 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( diff --git a/clients/cli/src/main.rs b/clients/cli/src/main.rs index 380fd330..4dbbce29 100644 --- a/clients/cli/src/main.rs +++ b/clients/cli/src/main.rs @@ -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::*; @@ -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)) = @@ -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 @@ -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), @@ -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, @@ -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, }, )) diff --git a/clients/js-legacy/src/addresses.ts b/clients/js-legacy/src/addresses.ts index 88d2ae09..76f5e08f 100644 --- a/clients/js-legacy/src/addresses.ts +++ b/clients/js-legacy/src/addresses.ts @@ -66,6 +66,7 @@ export async function findPoolMplAuthorityAddress(programId: PublicKey, poolAddr ); } +/** @deprecated */ export async function findDefaultDepositAccountAddress( poolAddress: PublicKey, userWallet: PublicKey, diff --git a/clients/js/src/addresses.ts b/clients/js/src/addresses.ts index 36d52d5f..5c5f86bf 100644 --- a/clients/js/src/addresses.ts +++ b/clients/js/src/addresses.ts @@ -102,6 +102,7 @@ async function findPda(programId: Address, baseAddress: Address, prefix: string) return pda; } +/** @deprecated */ export async function findDefaultDepositAccountAddress( poolAddress: PoolAddress, userWallet: Address, @@ -113,6 +114,7 @@ export async function findDefaultDepositAccountAddress( }); } +/** @deprecated */ export function defaultDepositAccountSeed(poolAddress: PoolAddress): string { return 'svsp' + poolAddress.slice(0, 28); } diff --git a/clients/js/src/transactions.ts b/clients/js/src/transactions.ts index 8e23cab0..69d846fd 100644 --- a/clients/js/src/transactions.ts +++ b/clients/js/src/transactions.ts @@ -44,6 +44,7 @@ interface DepositParams { pool: PoolAddress; userWallet: Address; userStakeAccount?: Address; + /** @deprecated */ depositFromDefaultAccount?: boolean; userTokenAccount?: Address; userLamportAccount?: Address; @@ -348,6 +349,7 @@ export async function initializeOnRampTransaction( return transaction; } +/** @deprecated */ export async function createAndDelegateUserStakeTransaction( rpc: any, // XXX not exported: Rpc, voteAccount: VoteAccountAddress, diff --git a/program/src/instruction.rs b/program/src/instruction.rs index 8591ce65..84bed446 100644 --- a/program/src/instruction.rs +++ b/program/src/instruction.rs @@ -419,6 +419,13 @@ 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 = "Default deposit helpers will be removed in a future release; these were \ + intended to support a wallet flow that never materialized. To set up a new stake \ + account for deposit, use `instruction::create_account_and_delegate_stake` from \ + `solana-stake-interface` using any normal keypair." +)] pub fn create_and_delegate_user_stake( program_id: &Pubkey, vote_account_address: &Pubkey, diff --git a/program/src/lib.rs b/program/src/lib.rs index a4369d8c..e18c3d3d 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -125,6 +125,13 @@ 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 = "Default deposit helpers will be removed in a future release; these were \ + intended to support a wallet flow that never materialized. To set up a new stake \ + account for deposit, use `instruction::create_account_and_delegate_stake` from \ + `solana-stake-interface` using any normal keypair." +)] pub fn find_default_deposit_account_address( pool_address: &Pubkey, user_wallet_address: &Pubkey, diff --git a/program/tests/deposit.rs b/program/tests/deposit.rs index 97a76643..8a90c764 100644 --- a/program/tests/deposit.rs +++ b/program/tests/deposit.rs @@ -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")] @@ -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(),