Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single-pool: rename program to spl_single_pool #5560

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion single-pool/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ solana-vote-program = "=1.16.16"
spl-token = { version = "4.0", path="../../token/program", features = [ "no-entrypoint" ] }
spl-token-client = { version = "0.7", path="../../token/client" }
spl-associated-token-account = { version = "2.0", path="../../associated-token-account/program", features = [ "no-entrypoint" ] }
spl-single-validator-pool = { version = "1.0.0", path="../program", features = [ "no-entrypoint" ] }
spl-single-pool = { version = "1.0.0", path="../program", features = [ "no-entrypoint" ] }

[dev-dependencies]
solana-test-validator = "=1.16.16"
Expand Down
6 changes: 3 additions & 3 deletions single-pool/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use {
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{pubkey::Pubkey, signer::Signer},
spl_single_validator_pool::{self as single_pool, find_pool_address},
spl_single_pool::{self, find_pool_address},
std::{str::FromStr, sync::Arc},
};

Expand Down Expand Up @@ -90,7 +90,7 @@ pub enum Command {
/// linked to the intended depository pool
CreateDefaultStake(CreateStakeCli),

/// Display info for one or all single single-validator stake pool(s)
/// Display info for one or all single-validator stake pool(s)
Display(DisplayCli),
}

Expand Down Expand Up @@ -355,7 +355,7 @@ pub fn pool_address_from_args(maybe_pool: Option<Pubkey>, maybe_vote: Option<Pub
if let Some(pool_address) = maybe_pool {
pool_address
} else if let Some(vote_account_address) = maybe_vote {
find_pool_address(&single_pool::id(), &vote_account_address)
find_pool_address(&spl_single_pool::id(), &vote_account_address)
} else {
unreachable!()
}
Expand Down
57 changes: 29 additions & 28 deletions single-pool/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ use {
transaction::Transaction,
},
solana_vote_program::{self as vote_program, vote_state::VoteState},
spl_single_validator_pool::{
self as single_pool, find_default_deposit_account_address, find_pool_address,
find_pool_mint_address, find_pool_stake_address, instruction::SinglePoolInstruction,
state::SinglePool,
spl_single_pool::{
self, find_default_deposit_account_address, find_pool_address, find_pool_mint_address,
find_pool_stake_address, instruction::SinglePoolInstruction, state::SinglePool,
},
spl_token_client::token::Token,
};
Expand Down Expand Up @@ -106,7 +105,7 @@ async fn command_initialize(config: &Config, command_config: InitializeCli) -> C
return Err(format!("{} is not a valid vote account", vote_account_address,).into());
}

let pool_address = find_pool_address(&single_pool::id(), &vote_account_address);
let pool_address = find_pool_address(&spl_single_pool::id(), &vote_account_address);

// check if the pool has already been initialized
if config
Expand All @@ -122,8 +121,8 @@ async fn command_initialize(config: &Config, command_config: InitializeCli) -> C
.into());
}

let mut instructions = single_pool::instruction::initialize(
&single_pool::id(),
let mut instructions = spl_single_pool::instruction::initialize(
&spl_single_pool::id(),
&vote_account_address,
&payer.pubkey(),
&quarantine::get_rent(config).await?,
Expand Down Expand Up @@ -190,7 +189,7 @@ async fn command_reactivate_pool_stake(
// the only reason this check is skippable is for testing, otherwise theres no reason
if !command_config.skip_deactivation_check {
let current_epoch = config.rpc_client.get_epoch_info().await?.epoch;
let pool_stake_address = find_pool_stake_address(&single_pool::id(), &pool_address);
let pool_stake_address = find_pool_stake_address(&spl_single_pool::id(), &pool_address);
let pool_stake_deactivated = quarantine::get_stake_info(config, &pool_stake_address)
.await?
.unwrap()
Expand All @@ -204,8 +203,10 @@ async fn command_reactivate_pool_stake(
}
}

let instruction =
single_pool::instruction::reactivate_pool_stake(&single_pool::id(), &vote_account_address);
let instruction = spl_single_pool::instruction::reactivate_pool_stake(
&spl_single_pool::id(),
&vote_account_address,
);
let transaction = Transaction::new_signed_with_payer(
&[instruction],
Some(&payer.pubkey()),
Expand Down Expand Up @@ -240,7 +241,7 @@ async fn command_deposit(config: &Config, command_config: DepositCli) -> Command
let provided_pool_address = command_config.pool_address.or_else(|| {
command_config
.vote_account_address
.map(|address| find_pool_address(&single_pool::id(), &address))
.map(|address| find_pool_address(&spl_single_pool::id(), &address))
});

// from there we can determine the stake account address
Expand All @@ -259,7 +260,7 @@ async fn command_deposit(config: &Config, command_config: DepositCli) -> Command
quarantine::get_stake_info(config, &stake_account_address).await?
{
let derived_pool_address =
find_pool_address(&single_pool::id(), &stake.delegation.voter_pubkey);
find_pool_address(&spl_single_pool::id(), &stake.delegation.voter_pubkey);

if let Some(provided_pool_address) = provided_pool_address {
if provided_pool_address != derived_pool_address {
Expand Down Expand Up @@ -314,7 +315,7 @@ async fn command_deposit(config: &Config, command_config: DepositCli) -> Command
return Err(format!("Pool {} has not been initialized", pool_address).into());
}

let pool_stake_address = find_pool_stake_address(&single_pool::id(), &pool_address);
let pool_stake_address = find_pool_stake_address(&spl_single_pool::id(), &pool_address);
let pool_stake_active = quarantine::get_stake_info(config, &pool_stake_address)
.await?
.unwrap()
Expand All @@ -327,7 +328,7 @@ async fn command_deposit(config: &Config, command_config: DepositCli) -> Command
return Err("Activation status mismatch; try again next epoch".into());
}

let pool_mint_address = find_pool_mint_address(&single_pool::id(), &pool_address);
let pool_mint_address = find_pool_mint_address(&spl_single_pool::id(), &pool_address);
let token = Token::new(
config.program_client.clone(),
&spl_token::id(),
Expand All @@ -352,8 +353,8 @@ async fn command_deposit(config: &Config, command_config: DepositCli) -> Command
.base
.amount;

let instructions = single_pool::instruction::deposit(
&single_pool::id(),
let instructions = spl_single_pool::instruction::deposit(
&spl_single_pool::id(),
&pool_address,
&stake_account_address,
&token_account_address,
Expand Down Expand Up @@ -423,7 +424,7 @@ async fn command_withdraw(config: &Config, command_config: WithdrawCli) -> Comma
}

// now all the mint and token info
let pool_mint_address = find_pool_mint_address(&single_pool::id(), &pool_address);
let pool_mint_address = find_pool_mint_address(&spl_single_pool::id(), &pool_address);
let token = Token::new(
config.program_client.clone(),
&spl_token::id(),
Expand Down Expand Up @@ -484,8 +485,8 @@ async fn command_withdraw(config: &Config, command_config: WithdrawCli) -> Comma
];

// perform the withdrawal
instructions.extend(single_pool::instruction::withdraw(
&single_pool::id(),
instructions.extend(spl_single_pool::instruction::withdraw(
&spl_single_pool::id(),
&pool_address,
&stake_account_address,
&stake_authority_address,
Expand Down Expand Up @@ -570,8 +571,8 @@ async fn command_create_metadata(

// and... i guess thats it?

let instruction = single_pool::instruction::create_token_metadata(
&single_pool::id(),
let instruction = spl_single_pool::instruction::create_token_metadata(
&spl_single_pool::id(),
&pool_address,
&payer.pubkey(),
);
Expand Down Expand Up @@ -641,8 +642,8 @@ async fn command_update_metadata(
unreachable!();
}

let instruction = single_pool::instruction::update_token_metadata(
&single_pool::id(),
let instruction = spl_single_pool::instruction::update_token_metadata(
&spl_single_pool::id(),
&vote_account_address,
&authorized_withdrawer.pubkey(),
command_config.token_name,
Expand Down Expand Up @@ -717,8 +718,8 @@ async fn command_create_stake(config: &Config, command_config: CreateStakeCli) -
);
}

let instructions = single_pool::instruction::create_and_delegate_user_stake(
&single_pool::id(),
let instructions = spl_single_pool::instruction::create_and_delegate_user_stake(
&spl_single_pool::id(),
&vote_account_address,
&stake_authority_address,
&quarantine::get_rent(config).await?,
Expand Down Expand Up @@ -755,7 +756,7 @@ async fn command_display(config: &Config, command_config: DisplayCli) -> Command
let pools = config
.rpc_client
.get_program_accounts_with_config(
&single_pool::id(),
&spl_single_pool::id(),
RpcProgramAccountsConfig {
filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new_raw_bytes(
0,
Expand Down Expand Up @@ -813,15 +814,15 @@ async fn get_pool_display(
return Err(format!("Pool {} does not exist", pool_address).into());
};

let pool_stake_address = find_pool_stake_address(&single_pool::id(), &pool_address);
let pool_stake_address = find_pool_stake_address(&spl_single_pool::id(), &pool_address);
let available_stake =
if let Some((_, stake)) = quarantine::get_stake_info(config, &pool_stake_address).await? {
stake.delegation.stake - quarantine::get_minimum_delegation(config).await?
} else {
unreachable!()
};

let pool_mint_address = find_pool_mint_address(&single_pool::id(), &pool_address);
let pool_mint_address = find_pool_mint_address(&spl_single_pool::id(), &pool_address);
let token_supply = config
.rpc_client
.get_token_supply(&pool_mint_address)
Expand Down
17 changes: 10 additions & 7 deletions single-pool/cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use {
serde_with::{serde_as, DisplayFromStr},
solana_cli_output::{display::writeln_name_value, QuietDisplay, VerboseDisplay},
solana_sdk::{pubkey::Pubkey, signature::Signature},
spl_single_validator_pool::{
self as single_pool, find_pool_mint_address, find_pool_mint_authority_address,
spl_single_pool::{
self, find_pool_mint_address, find_pool_mint_authority_address,
find_pool_mpl_authority_address, find_pool_stake_address,
find_pool_stake_authority_address,
},
Expand Down Expand Up @@ -113,27 +113,30 @@ impl VerboseDisplay for StakePoolOutput {
writeln_name_value(
w,
" Pool stake address:",
&find_pool_stake_address(&single_pool::id(), &self.pool_address).to_string(),
&find_pool_stake_address(&spl_single_pool::id(), &self.pool_address).to_string(),
)?;
writeln_name_value(
w,
" Pool mint address:",
&find_pool_mint_address(&single_pool::id(), &self.pool_address).to_string(),
&find_pool_mint_address(&spl_single_pool::id(), &self.pool_address).to_string(),
)?;
writeln_name_value(
w,
" Pool stake authority address:",
&find_pool_stake_authority_address(&single_pool::id(), &self.pool_address).to_string(),
&find_pool_stake_authority_address(&spl_single_pool::id(), &self.pool_address)
.to_string(),
)?;
writeln_name_value(
w,
" Pool mint authority address:",
&find_pool_mint_authority_address(&single_pool::id(), &self.pool_address).to_string(),
&find_pool_mint_authority_address(&spl_single_pool::id(), &self.pool_address)
.to_string(),
)?;
writeln_name_value(
w,
" Pool MPL authority address:",
&find_pool_mpl_authority_address(&single_pool::id(), &self.pool_address).to_string(),
&find_pool_mpl_authority_address(&spl_single_pool::id(), &self.pool_address)
.to_string(),
)?;

writeln_name_value(w, " Available stake:", &self.available_stake.to_string())?;
Expand Down
5 changes: 2 additions & 3 deletions single-pool/cli/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use {
vote_instruction::{self, CreateVoteAccountConfig},
vote_state::{VoteInit, VoteState, VoteStateVersions},
},
spl_single_validator_pool::{self as single_pool},
spl_token_client::client::{ProgramClient, ProgramRpcClient, ProgramRpcClientSendTransaction},
std::{path::PathBuf, process::Command, str::FromStr, sync::Arc, time::Duration},
tempfile::NamedTempFile,
Expand Down Expand Up @@ -122,9 +121,9 @@ async fn start_validator() -> (TestValidator, Keypair) {
upgrade_authority: Pubkey::default(),
},
UpgradeableProgramInfo {
program_id: single_pool::id(),
program_id: spl_single_pool::id(),
loader: bpf_loader_upgradeable::id(),
program_path: PathBuf::from("../../target/deploy/spl_single_validator_pool.so"),
program_path: PathBuf::from("../../target/deploy/spl_single_pool.so"),
upgrade_authority: Pubkey::default(),
},
]);
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion single-pool/js/packages/classic/tests/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function startWithContext(authorizedWithdrawer?: PublicKey) {

return await start(
[
{ name: 'spl_single_validator_pool', programId: SinglePoolProgram.programId },
{ name: 'spl_single_pool', programId: SinglePoolProgram.programId },
{ name: 'mpl_token_metadata', programId: MPL_METADATA_PROGRAM_ID },
],
[
Expand Down
2 changes: 1 addition & 1 deletion single-pool/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "spl-single-validator-pool"
name = "spl-single-pool"
version = "1.0.0"
description = "Solana Program Library Single-Validator Stake Pool"
authors = ["Solana Labs Maintainers <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion single-pool/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use {
#[repr(C)]
#[derive(Clone, Debug, PartialEq, BorshSerialize, BorshDeserialize)]
pub enum SinglePoolInstruction {
/// Initialize the mint and stake account for a new single-validator pool.
/// Initialize the mint and stake account for a new single-validator stake pool.
/// The pool stake account must contain the rent-exempt minimum plus the minimum delegation.
/// No tokens will be minted: to deposit more, use `Deposit` after `InitializeStake`.
///
Expand Down
2 changes: 1 addition & 1 deletion single-pool/program/tests/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
instruction::Instruction, program_error::ProgramError, pubkey::Pubkey, signature::Signer,
stake, system_program, transaction::Transaction,
},
spl_single_validator_pool::{
spl_single_pool::{
error::SinglePoolError,
id,
instruction::{self, SinglePoolInstruction},
Expand Down
Loading
Loading