Skip to content

Commit be71de0

Browse files
authored
interface: deprecate default deposit addresses (#390)
1 parent 8c66e21 commit be71de0

File tree

8 files changed

+58
-19
lines changed

8 files changed

+58
-19
lines changed

clients/cli/src/cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub enum Command {
8787
/// tokens to burn or the ALL keyword to burn all.
8888
Withdraw(WithdrawCli),
8989

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

169+
/// WARNING: This flag is DEPRECATED and will be removed in a future release.
168170
/// Instead of using a stake account by address, use the user's default
169171
/// account for a specified pool
170172
#[clap(

clients/cli/src/main.rs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ use {
1717
solana_transaction::Transaction,
1818
solana_vote_program::{self as vote_program, vote_state::VoteState},
1919
spl_single_pool::{
20-
self, find_default_deposit_account_address, find_pool_address, find_pool_mint_address,
21-
find_pool_onramp_address, find_pool_stake_address, instruction::SinglePoolInstruction,
22-
state::SinglePool,
20+
self, find_pool_address, find_pool_mint_address, find_pool_onramp_address,
21+
find_pool_stake_address, instruction::SinglePoolInstruction, state::SinglePool,
2322
},
2423
spl_token_client::token::Token,
2524
std::{rc::Rc, sync::Arc},
2625
};
2726

27+
#[allow(deprecated)]
28+
use spl_single_pool::find_default_deposit_account_address;
29+
2830
mod config;
2931
use config::*;
3032

@@ -247,15 +249,21 @@ async fn command_deposit(
247249
});
248250

249251
// from there we can determine the stake account address
250-
let stake_account_address =
251-
if let Some(stake_account_address) = command_config.stake_account_address {
252-
stake_account_address
253-
} else if let Some(pool_address) = provided_pool_address {
254-
assert!(command_config.default_stake_account);
255-
find_default_deposit_account_address(&pool_address, &stake_authority.pubkey())
256-
} else {
257-
unreachable!()
258-
};
252+
let stake_account_address = if let Some(stake_account_address) =
253+
command_config.stake_account_address
254+
{
255+
stake_account_address
256+
} else if let Some(pool_address) = provided_pool_address {
257+
assert!(command_config.default_stake_account);
258+
eprintln_display(
259+
config,
260+
"WARNING: This flag is DEPRECATED and will be removed in a future release.".to_string(),
261+
);
262+
#[allow(deprecated)]
263+
find_default_deposit_account_address(&pool_address, &stake_authority.pubkey())
264+
} else {
265+
unreachable!()
266+
};
259267

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

703711
// create default stake account
704712
async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -> CommandResult {
713+
eprintln_display(
714+
config,
715+
"WARNING: This command is DEPRECATED and will be removed in a future release.".to_string(),
716+
);
717+
705718
let payer = config.fee_payer()?;
706719
let owner = config.default_signer()?;
707720
let stake_authority_address = command_config
@@ -713,6 +726,10 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
713726
command_config.vote_account_address,
714727
);
715728

729+
#[allow(deprecated)]
730+
let stake_account_address =
731+
find_default_deposit_account_address(&pool_address, &stake_authority_address);
732+
716733
println_display(
717734
config,
718735
format!("Creating default stake account for pool {}\n", pool_address),
@@ -744,6 +761,7 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
744761
);
745762
}
746763

764+
#[allow(deprecated)]
747765
let instructions = spl_single_pool::instruction::create_and_delegate_user_stake(
748766
&spl_single_pool::id(),
749767
&vote_account_address,
@@ -766,10 +784,7 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
766784
"CreateDefaultStake".to_string(),
767785
CreateStakeOutput {
768786
pool_address,
769-
stake_account_address: find_default_deposit_account_address(
770-
&pool_address,
771-
&stake_authority_address,
772-
),
787+
stake_account_address,
773788
signature,
774789
},
775790
))

clients/js-legacy/src/addresses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export async function findPoolMplAuthorityAddress(programId: PublicKey, poolAddr
6666
);
6767
}
6868

69+
/** @deprecated */
6970
export async function findDefaultDepositAccountAddress(
7071
poolAddress: PublicKey,
7172
userWallet: PublicKey,

clients/js/src/addresses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ async function findPda(programId: Address, baseAddress: Address, prefix: string)
102102
return pda;
103103
}
104104

105+
/** @deprecated */
105106
export async function findDefaultDepositAccountAddress(
106107
poolAddress: PoolAddress,
107108
userWallet: Address,
@@ -113,6 +114,7 @@ export async function findDefaultDepositAccountAddress(
113114
});
114115
}
115116

117+
/** @deprecated */
116118
export function defaultDepositAccountSeed(poolAddress: PoolAddress): string {
117119
return 'svsp' + poolAddress.slice(0, 28);
118120
}

clients/js/src/transactions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface DepositParams {
4444
pool: PoolAddress;
4545
userWallet: Address;
4646
userStakeAccount?: Address;
47+
/** @deprecated */
4748
depositFromDefaultAccount?: boolean;
4849
userTokenAccount?: Address;
4950
userLamportAccount?: Address;
@@ -348,6 +349,7 @@ export async function initializeOnRampTransaction(
348349
return transaction;
349350
}
350351

352+
/** @deprecated */
351353
export async function createAndDelegateUserStakeTransaction(
352354
rpc: any, // XXX not exported: Rpc<???>,
353355
voteAccount: VoteAccountAddress,

program/src/instruction.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ pub fn withdraw_stake(
421421
/// combination to make it easier to find for deposits. This is an optional
422422
/// helper function; deposits can come from any owned stake account without
423423
/// lockup.
424+
#[deprecated(
425+
since = "3.0.0",
426+
note = "Default deposit helpers will be removed in a future release; these were \
427+
intended to support a wallet flow that never materialized. To set up a new stake \
428+
account for deposit, use `instruction::create_account_and_delegate_stake` from \
429+
`solana-stake-interface` using any normal keypair."
430+
)]
424431
pub fn create_and_delegate_user_stake(
425432
program_id: &Pubkey,
426433
vote_account_address: &Pubkey,

program/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ pub fn find_pool_mpl_authority_address(program_id: &Pubkey, pool_address: &Pubke
125125

126126
/// Find the address of the default intermediate account that holds activating
127127
/// user stake before deposit.
128+
#[deprecated(
129+
since = "3.0.0",
130+
note = "Default deposit helpers will be removed in a future release; these were \
131+
intended to support a wallet flow that never materialized. To set up a new stake \
132+
account for deposit, use `instruction::create_account_and_delegate_stake` from \
133+
`solana-stake-interface` using any normal keypair."
134+
)]
128135
pub fn find_default_deposit_account_address(
129136
pool_address: &Pubkey,
130137
user_wallet_address: &Pubkey,

program/tests/deposit.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ use {
99
solana_stake_interface::state::{Authorized, Lockup},
1010
solana_system_interface::instruction as system_instruction,
1111
spl_associated_token_account_client::address as atoken,
12-
spl_single_pool::{
13-
error::SinglePoolError, find_default_deposit_account_address, id, instruction,
14-
},
12+
spl_single_pool::{error::SinglePoolError, id, instruction},
1513
test_case::test_case,
1614
};
1715

16+
#[allow(deprecated)]
17+
use spl_single_pool::find_default_deposit_account_address;
18+
1819
#[test_case(true, 0, 0, false, false, false; "activated::minimum_disabled")]
1920
#[test_case(true, 0, 0, false, false, true; "activated::minimum_disabled::small")]
2021
#[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
204205
let accounts = SinglePoolAccounts::default();
205206
let rent = context.banks_client.get_rent().await.unwrap();
206207
let minimum_stake = accounts.initialize(&mut context).await;
208+
#[allow(deprecated)]
207209
let alice_default_stake =
208210
find_default_deposit_account_address(&accounts.pool, &accounts.alice.pubkey());
209211

212+
#[allow(deprecated)]
210213
let instructions = instruction::create_and_delegate_user_stake(
211214
&id(),
212215
&accounts.vote_account.pubkey(),

0 commit comments

Comments
 (0)