Cli support compute_unit_price (#26464)

* add compute-unit-price trait to insert compute_budget instruction to set priorization fee

* add clap arg for compute-unit-price

* add compute-unit-price arg to commands that send transactions

* add and update tests
This commit is contained in:
Tao Zhu 2022-08-02 22:23:05 -05:00 committed by GitHub
parent f24de9d254
commit 6892970c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 559 additions and 46 deletions

View File

@ -0,0 +1,15 @@
use {crate::ArgConstant, clap::Arg};
pub const COMPUTE_UNIT_PRICE_ARG: ArgConstant<'static> = ArgConstant {
name: "compute_unit_price",
long: "--with-compute-unit-price",
help: "Set compute unit price for transaction, in increments of 0.000001 lamports per compute unit.",
};
pub fn compute_unit_price_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
.long(COMPUTE_UNIT_PRICE_ARG.long)
.takes_value(true)
.value_name("COMPUTE-UNIT-PRICE")
.help(COMPUTE_UNIT_PRICE_ARG.help)
}

View File

@ -23,6 +23,7 @@ impl std::fmt::Debug for DisplayError {
} }
} }
pub mod compute_unit_price;
pub mod fee_payer; pub mod fee_payer;
pub mod input_parsers; pub mod input_parsers;
pub mod input_validators; pub mod input_validators;

View File

@ -133,6 +133,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
new_authority: Pubkey, new_authority: Pubkey,
compute_unit_price: Option<u64>,
}, },
CreateNonceAccount { CreateNonceAccount {
nonce_account: SignerIndex, nonce_account: SignerIndex,
@ -140,12 +141,14 @@ pub enum CliCommand {
nonce_authority: Option<Pubkey>, nonce_authority: Option<Pubkey>,
memo: Option<String>, memo: Option<String>,
amount: SpendAmount, amount: SpendAmount,
compute_unit_price: Option<u64>,
}, },
GetNonce(Pubkey), GetNonce(Pubkey),
NewNonce { NewNonce {
nonce_account: Pubkey, nonce_account: Pubkey,
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
compute_unit_price: Option<u64>,
}, },
ShowNonceAccount { ShowNonceAccount {
nonce_account_pubkey: Pubkey, nonce_account_pubkey: Pubkey,
@ -157,10 +160,12 @@ pub enum CliCommand {
memo: Option<String>, memo: Option<String>,
destination_account_pubkey: Pubkey, destination_account_pubkey: Pubkey,
lamports: u64, lamports: u64,
compute_unit_price: Option<u64>,
}, },
UpgradeNonceAccount { UpgradeNonceAccount {
nonce_account: Pubkey, nonce_account: Pubkey,
memo: Option<String>, memo: Option<String>,
compute_unit_price: Option<u64>,
}, },
// Program Deployment // Program Deployment
Deploy { Deploy {
@ -188,6 +193,7 @@ pub enum CliCommand {
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
from: SignerIndex, from: SignerIndex,
compute_unit_price: Option<u64>,
}, },
DeactivateStake { DeactivateStake {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -201,6 +207,7 @@ pub enum CliCommand {
memo: Option<String>, memo: Option<String>,
seed: Option<String>, seed: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
DelegateStake { DelegateStake {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -215,6 +222,7 @@ pub enum CliCommand {
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
redelegation_stake_account_pubkey: Option<Pubkey>, redelegation_stake_account_pubkey: Option<Pubkey>,
compute_unit_price: Option<u64>,
}, },
SplitStake { SplitStake {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -229,6 +237,7 @@ pub enum CliCommand {
seed: Option<String>, seed: Option<String>,
lamports: u64, lamports: u64,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
MergeStake { MergeStake {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -241,6 +250,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
ShowStakeHistory { ShowStakeHistory {
use_lamports_unit: bool, use_lamports_unit: bool,
@ -263,6 +273,7 @@ pub enum CliCommand {
fee_payer: SignerIndex, fee_payer: SignerIndex,
custodian: Option<SignerIndex>, custodian: Option<SignerIndex>,
no_wait: bool, no_wait: bool,
compute_unit_price: Option<u64>,
}, },
StakeSetLockup { StakeSetLockup {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -276,6 +287,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
WithdrawStake { WithdrawStake {
stake_account_pubkey: Pubkey, stake_account_pubkey: Pubkey,
@ -291,6 +303,7 @@ pub enum CliCommand {
memo: Option<String>, memo: Option<String>,
seed: Option<String>, seed: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
// Validator Info Commands // Validator Info Commands
GetValidatorInfo(Option<Pubkey>), GetValidatorInfo(Option<Pubkey>),
@ -314,6 +327,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
ShowVoteAccount { ShowVoteAccount {
pubkey: Pubkey, pubkey: Pubkey,
@ -332,6 +346,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
CloseVoteAccount { CloseVoteAccount {
vote_account_pubkey: Pubkey, vote_account_pubkey: Pubkey,
@ -339,6 +354,7 @@ pub enum CliCommand {
withdraw_authority: SignerIndex, withdraw_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
VoteAuthorize { VoteAuthorize {
vote_account_pubkey: Pubkey, vote_account_pubkey: Pubkey,
@ -353,6 +369,7 @@ pub enum CliCommand {
fee_payer: SignerIndex, fee_payer: SignerIndex,
authorized: SignerIndex, authorized: SignerIndex,
new_authorized: Option<SignerIndex>, new_authorized: Option<SignerIndex>,
compute_unit_price: Option<u64>,
}, },
VoteUpdateValidator { VoteUpdateValidator {
vote_account_pubkey: Pubkey, vote_account_pubkey: Pubkey,
@ -365,6 +382,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
VoteUpdateCommission { VoteUpdateCommission {
vote_account_pubkey: Pubkey, vote_account_pubkey: Pubkey,
@ -377,6 +395,7 @@ pub enum CliCommand {
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<String>, memo: Option<String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<u64>,
}, },
// Wallet Commands // Wallet Commands
Address, Address,
@ -416,6 +435,7 @@ pub enum CliCommand {
fee_payer: SignerIndex, fee_payer: SignerIndex,
derived_address_seed: Option<String>, derived_address_seed: Option<String>,
derived_address_program_id: Option<Pubkey>, derived_address_program_id: Option<Pubkey>,
compute_unit_price: Option<u64>,
}, },
StakeMinimumDelegation { StakeMinimumDelegation {
use_lamports_unit: bool, use_lamports_unit: bool,
@ -900,7 +920,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
timeout, timeout,
blockhash, blockhash,
*print_timestamp, *print_timestamp,
compute_unit_price, compute_unit_price.as_ref(),
), ),
CliCommand::Rent { CliCommand::Rent {
data_length, data_length,
@ -969,6 +989,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
new_authority, new_authority,
compute_unit_price,
} => process_authorize_nonce_account( } => process_authorize_nonce_account(
&rpc_client, &rpc_client,
config, config,
@ -976,6 +997,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
new_authority, new_authority,
compute_unit_price.as_ref(),
), ),
// Create nonce account // Create nonce account
CliCommand::CreateNonceAccount { CliCommand::CreateNonceAccount {
@ -984,6 +1006,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
amount, amount,
compute_unit_price,
} => process_create_nonce_account( } => process_create_nonce_account(
&rpc_client, &rpc_client,
config, config,
@ -992,6 +1015,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*amount, *amount,
compute_unit_price.as_ref(),
), ),
// Get the current nonce // Get the current nonce
CliCommand::GetNonce(nonce_account_pubkey) => { CliCommand::GetNonce(nonce_account_pubkey) => {
@ -1002,12 +1026,14 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_account, nonce_account,
nonce_authority, nonce_authority,
memo, memo,
compute_unit_price,
} => process_new_nonce( } => process_new_nonce(
&rpc_client, &rpc_client,
config, config,
nonce_account, nonce_account,
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
compute_unit_price.as_ref(),
), ),
// Show the contents of a nonce account // Show the contents of a nonce account
CliCommand::ShowNonceAccount { CliCommand::ShowNonceAccount {
@ -1026,6 +1052,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo, memo,
destination_account_pubkey, destination_account_pubkey,
lamports, lamports,
compute_unit_price,
} => process_withdraw_from_nonce_account( } => process_withdraw_from_nonce_account(
&rpc_client, &rpc_client,
config, config,
@ -1034,12 +1061,20 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
destination_account_pubkey, destination_account_pubkey,
*lamports, *lamports,
compute_unit_price.as_ref(),
), ),
// Upgrade nonce account out of blockhash domain. // Upgrade nonce account out of blockhash domain.
CliCommand::UpgradeNonceAccount { CliCommand::UpgradeNonceAccount {
nonce_account, nonce_account,
memo, memo,
} => process_upgrade_nonce_account(&rpc_client, config, *nonce_account, memo.as_ref()), compute_unit_price,
} => process_upgrade_nonce_account(
&rpc_client,
config,
*nonce_account,
memo.as_ref(),
compute_unit_price.as_ref(),
),
// Program Deployment // Program Deployment
@ -1082,6 +1117,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo, memo,
fee_payer, fee_payer,
from, from,
compute_unit_price,
} => process_create_stake_account( } => process_create_stake_account(
&rpc_client, &rpc_client,
config, config,
@ -1100,6 +1136,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
*from, *from,
compute_unit_price.as_ref(),
), ),
CliCommand::DeactivateStake { CliCommand::DeactivateStake {
stake_account_pubkey, stake_account_pubkey,
@ -1113,6 +1150,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo, memo,
seed, seed,
fee_payer, fee_payer,
compute_unit_price,
} => process_deactivate_stake_account( } => process_deactivate_stake_account(
&rpc_client, &rpc_client,
config, config,
@ -1127,6 +1165,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
seed.as_ref(), seed.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::DelegateStake { CliCommand::DelegateStake {
stake_account_pubkey, stake_account_pubkey,
@ -1141,6 +1180,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo, memo,
fee_payer, fee_payer,
redelegation_stake_account_pubkey, redelegation_stake_account_pubkey,
compute_unit_price,
} => process_delegate_stake( } => process_delegate_stake(
&rpc_client, &rpc_client,
config, config,
@ -1156,6 +1196,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
redelegation_stake_account_pubkey.as_ref(), redelegation_stake_account_pubkey.as_ref(),
compute_unit_price.as_ref(),
), ),
CliCommand::SplitStake { CliCommand::SplitStake {
stake_account_pubkey, stake_account_pubkey,
@ -1170,6 +1211,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
seed, seed,
lamports, lamports,
fee_payer, fee_payer,
compute_unit_price,
} => process_split_stake( } => process_split_stake(
&rpc_client, &rpc_client,
config, config,
@ -1185,6 +1227,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
seed, seed,
*lamports, *lamports,
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::MergeStake { CliCommand::MergeStake {
stake_account_pubkey, stake_account_pubkey,
@ -1197,6 +1240,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_merge_stake( } => process_merge_stake(
&rpc_client, &rpc_client,
config, config,
@ -1210,6 +1254,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::ShowStakeAccount { CliCommand::ShowStakeAccount {
pubkey: stake_account_pubkey, pubkey: stake_account_pubkey,
@ -1238,6 +1283,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
fee_payer, fee_payer,
custodian, custodian,
no_wait, no_wait,
compute_unit_price,
} => process_stake_authorize( } => process_stake_authorize(
&rpc_client, &rpc_client,
config, config,
@ -1252,6 +1298,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
*no_wait, *no_wait,
compute_unit_price.as_ref(),
), ),
CliCommand::StakeSetLockup { CliCommand::StakeSetLockup {
stake_account_pubkey, stake_account_pubkey,
@ -1265,6 +1312,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_stake_set_lockup( } => process_stake_set_lockup(
&rpc_client, &rpc_client,
config, config,
@ -1279,6 +1327,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::WithdrawStake { CliCommand::WithdrawStake {
stake_account_pubkey, stake_account_pubkey,
@ -1294,6 +1343,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo, memo,
seed, seed,
fee_payer, fee_payer,
compute_unit_price,
} => process_withdraw_stake( } => process_withdraw_stake(
&rpc_client, &rpc_client,
config, config,
@ -1310,6 +1360,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
memo.as_ref(), memo.as_ref(),
seed.as_ref(), seed.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::StakeMinimumDelegation { use_lamports_unit } => { CliCommand::StakeMinimumDelegation { use_lamports_unit } => {
process_stake_minimum_delegation(&rpc_client, config, *use_lamports_unit) process_stake_minimum_delegation(&rpc_client, config, *use_lamports_unit)
@ -1351,6 +1402,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_create_vote_account( } => process_create_vote_account(
&rpc_client, &rpc_client,
config, config,
@ -1367,6 +1419,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::ShowVoteAccount { CliCommand::ShowVoteAccount {
pubkey: vote_account_pubkey, pubkey: vote_account_pubkey,
@ -1391,6 +1444,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_withdraw_from_vote_account( } => process_withdraw_from_vote_account(
&rpc_client, &rpc_client,
config, config,
@ -1405,6 +1459,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::CloseVoteAccount { CliCommand::CloseVoteAccount {
vote_account_pubkey, vote_account_pubkey,
@ -1412,6 +1467,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
destination_account_pubkey, destination_account_pubkey,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_close_vote_account( } => process_close_vote_account(
&rpc_client, &rpc_client,
config, config,
@ -1420,6 +1476,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
destination_account_pubkey, destination_account_pubkey,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::VoteAuthorize { CliCommand::VoteAuthorize {
vote_account_pubkey, vote_account_pubkey,
@ -1434,6 +1491,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
fee_payer, fee_payer,
authorized, authorized,
new_authorized, new_authorized,
compute_unit_price,
} => process_vote_authorize( } => process_vote_authorize(
&rpc_client, &rpc_client,
config, config,
@ -1449,6 +1507,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::VoteUpdateValidator { CliCommand::VoteUpdateValidator {
vote_account_pubkey, vote_account_pubkey,
@ -1461,6 +1520,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_vote_update_validator( } => process_vote_update_validator(
&rpc_client, &rpc_client,
config, config,
@ -1474,6 +1534,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
CliCommand::VoteUpdateCommission { CliCommand::VoteUpdateCommission {
vote_account_pubkey, vote_account_pubkey,
@ -1486,6 +1547,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
nonce_authority, nonce_authority,
memo, memo,
fee_payer, fee_payer,
compute_unit_price,
} => process_vote_update_commission( } => process_vote_update_commission(
&rpc_client, &rpc_client,
config, config,
@ -1499,6 +1561,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*nonce_authority, *nonce_authority,
memo.as_ref(), memo.as_ref(),
*fee_payer, *fee_payer,
compute_unit_price.as_ref(),
), ),
// Wallet Commands // Wallet Commands
@ -1544,6 +1607,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
fee_payer, fee_payer,
derived_address_seed, derived_address_seed,
ref derived_address_program_id, ref derived_address_program_id,
compute_unit_price,
} => process_transfer( } => process_transfer(
&rpc_client, &rpc_client,
config, config,
@ -1561,6 +1625,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*fee_payer, *fee_payer,
derived_address_seed.clone(), derived_address_seed.clone(),
derived_address_program_id.as_ref(), derived_address_program_id.as_ref(),
compute_unit_price.as_ref(),
), ),
} }
} }
@ -2006,6 +2071,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair, &bob_keypair, &identity_keypair]; config.signers = vec![&keypair, &bob_keypair, &identity_keypair];
let result = process_command(&config); let result = process_command(&config);
@ -2048,6 +2114,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}; };
let result = process_command(&vote_config); let result = process_command(&vote_config);
assert!(result.is_ok()); assert!(result.is_ok());
@ -2065,6 +2132,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
let result = process_command(&config); let result = process_command(&config);
assert!(result.is_ok()); assert!(result.is_ok());
@ -2092,6 +2160,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair, &bob_keypair]; config.signers = vec![&keypair, &bob_keypair];
let result = process_command(&config); let result = process_command(&config);
@ -2113,6 +2182,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair]; config.signers = vec![&keypair];
let result = process_command(&config); let result = process_command(&config);
@ -2131,6 +2201,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
let result = process_command(&config); let result = process_command(&config);
assert!(result.is_ok()); assert!(result.is_ok());
@ -2150,6 +2221,7 @@ mod tests {
seed: None, seed: None,
lamports: 30, lamports: 30,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair, &split_stake_account]; config.signers = vec![&keypair, &split_stake_account];
let result = process_command(&config); let result = process_command(&config);
@ -2169,6 +2241,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair, &merge_stake_account]; config.signers = vec![&keypair, &merge_stake_account];
let result = process_command(&config); let result = process_command(&config);
@ -2248,6 +2321,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config.signers = vec![&keypair, &bob_keypair, &identity_keypair]; config.signers = vec![&keypair, &bob_keypair, &identity_keypair];
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
@ -2265,6 +2339,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}; };
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
@ -2279,6 +2354,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
@ -2383,6 +2459,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2410,6 +2487,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2442,6 +2520,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2477,6 +2556,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2520,6 +2600,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![Presigner::new(&from_pubkey, &from_sig).into()], signers: vec![Presigner::new(&from_pubkey, &from_sig).into()],
} }
@ -2564,6 +2645,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2603,6 +2685,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
derived_address_seed: Some(derived_address_seed), derived_address_seed: Some(derived_address_seed),
derived_address_program_id: Some(stake::program::id()), derived_address_program_id: Some(stake::program::id()),
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),],
} }

View File

@ -1,6 +1,7 @@
use { use {
crate::{ crate::{
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
compute_unit_price::WithComputeUnitPrice,
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
}, },
clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand}, clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand},
@ -8,6 +9,7 @@ use {
crossbeam_channel::unbounded, crossbeam_channel::unbounded,
serde::{Deserialize, Serialize}, serde::{Deserialize, Serialize},
solana_clap_utils::{ solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
input_parsers::*, input_parsers::*,
input_validators::*, input_validators::*,
keypair::DefaultSigner, keypair::DefaultSigner,
@ -40,7 +42,6 @@ use {
account_utils::StateMut, account_utils::StateMut,
clock::{self, Clock, Slot}, clock::{self, Clock, Slot},
commitment_config::CommitmentConfig, commitment_config::CommitmentConfig,
compute_budget::ComputeBudgetInstruction,
epoch_schedule::Epoch, epoch_schedule::Epoch,
hash::Hash, hash::Hash,
message::Message, message::Message,
@ -271,13 +272,7 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.default_value("15") .default_value("15")
.help("Wait up to timeout seconds for transaction confirmation"), .help("Wait up to timeout seconds for transaction confirmation"),
) )
.arg( .arg(compute_unit_price_arg())
Arg::with_name("compute_unit_price")
.long("compute-unit-price")
.value_name("MICRO-LAMPORTS")
.takes_value(true)
.help("Set the price in micro-lamports of each transaction compute unit"),
)
.arg(blockhash_arg()), .arg(blockhash_arg()),
) )
.subcommand( .subcommand(
@ -529,7 +524,7 @@ pub fn parse_cluster_ping(
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64)); let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
let blockhash = value_of(matches, BLOCKHASH_ARG.name); let blockhash = value_of(matches, BLOCKHASH_ARG.name);
let print_timestamp = matches.is_present("print_timestamp"); let print_timestamp = matches.is_present("print_timestamp");
let compute_unit_price = value_of(matches, "compute_unit_price"); let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::Ping { command: CliCommand::Ping {
interval, interval,
@ -1396,7 +1391,7 @@ pub fn process_ping(
timeout: &Duration, timeout: &Duration,
fixed_blockhash: &Option<Hash>, fixed_blockhash: &Option<Hash>,
print_timestamp: bool, print_timestamp: bool,
compute_unit_price: &Option<u64>, compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let (signal_sender, signal_receiver) = unbounded(); let (signal_sender, signal_receiver) = unbounded();
ctrlc::set_handler(move || { ctrlc::set_handler(move || {
@ -1436,16 +1431,12 @@ pub fn process_ping(
lamports += 1; lamports += 1;
let build_message = |lamports| { let build_message = |lamports| {
let mut ixs = vec![system_instruction::transfer( let ixs = vec![system_instruction::transfer(
&config.signers[0].pubkey(), &config.signers[0].pubkey(),
&to, &to,
lamports, lamports,
)]; )]
if let Some(compute_unit_price) = compute_unit_price { .with_compute_unit_price(compute_unit_price);
ixs.push(ComputeBudgetInstruction::set_compute_unit_price(
*compute_unit_price,
));
}
Message::new(&ixs, Some(&config.signers[0].pubkey())) Message::new(&ixs, Some(&config.signers[0].pubkey()))
}; };
let (message, _) = resolve_spend_tx_and_check_account_balance( let (message, _) = resolve_spend_tx_and_check_account_balance(

View File

@ -0,0 +1,16 @@
use solana_sdk::{compute_budget::ComputeBudgetInstruction, instruction::Instruction};
pub trait WithComputeUnitPrice {
fn with_compute_unit_price(self, compute_unit_price: Option<&u64>) -> Self;
}
impl WithComputeUnitPrice for Vec<Instruction> {
fn with_compute_unit_price(mut self, compute_unit_price: Option<&u64>) -> Self {
if let Some(compute_unit_price) = compute_unit_price {
self.push(ComputeBudgetInstruction::set_compute_unit_price(
*compute_unit_price,
));
}
self
}
}

View File

@ -27,6 +27,7 @@ pub mod checks;
pub mod clap_app; pub mod clap_app;
pub mod cli; pub mod cli;
pub mod cluster_query; pub mod cluster_query;
pub mod compute_unit_price;
pub mod feature; pub mod feature;
pub mod inflation; pub mod inflation;
pub mod memo; pub mod memo;

View File

@ -5,12 +5,14 @@ use {
log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand, log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand,
CliCommandInfo, CliConfig, CliError, ProcessResult, CliCommandInfo, CliConfig, CliError, ProcessResult,
}, },
compute_unit_price::WithComputeUnitPrice,
feature::get_feature_is_active, feature::get_feature_is_active,
memo::WithMemo, memo::WithMemo,
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
}, },
clap::{App, Arg, ArgMatches, SubCommand}, clap::{App, Arg, ArgMatches, SubCommand},
solana_clap_utils::{ solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
input_parsers::*, input_parsers::*,
input_validators::*, input_validators::*,
keypair::{CliSigners, DefaultSigner, SignerIndex}, keypair::{CliSigners, DefaultSigner, SignerIndex},
@ -63,7 +65,8 @@ impl NonceSubCommands for App<'_, '_> {
"Account to be granted authority of the nonce account. "), "Account to be granted authority of the nonce account. "),
) )
.arg(nonce_authority_arg()) .arg(nonce_authority_arg())
.arg(memo_arg()), .arg(memo_arg())
.arg(compute_unit_price_arg()),
) )
.subcommand( .subcommand(
SubCommand::with_name("create-nonce-account") SubCommand::with_name("create-nonce-account")
@ -99,7 +102,8 @@ impl NonceSubCommands for App<'_, '_> {
.takes_value(true) .takes_value(true)
.help("Seed for address generation; if specified, the resulting account will be at a derived address of the NONCE_ACCOUNT pubkey") .help("Seed for address generation; if specified, the resulting account will be at a derived address of the NONCE_ACCOUNT pubkey")
) )
.arg(memo_arg()), .arg(memo_arg())
.arg(compute_unit_price_arg()),
) )
.subcommand( .subcommand(
SubCommand::with_name("nonce") SubCommand::with_name("nonce")
@ -124,7 +128,8 @@ impl NonceSubCommands for App<'_, '_> {
"Address of the nonce account. "), "Address of the nonce account. "),
) )
.arg(nonce_authority_arg()) .arg(nonce_authority_arg())
.arg(memo_arg()), .arg(memo_arg())
.arg(compute_unit_price_arg()),
) )
.subcommand( .subcommand(
SubCommand::with_name("nonce-account") SubCommand::with_name("nonce-account")
@ -171,7 +176,8 @@ impl NonceSubCommands for App<'_, '_> {
.help("The amount to withdraw from the nonce account, in SOL"), .help("The amount to withdraw from the nonce account, in SOL"),
) )
.arg(nonce_authority_arg()) .arg(nonce_authority_arg())
.arg(memo_arg()), .arg(memo_arg())
.arg(compute_unit_price_arg()),
) )
.subcommand( .subcommand(
SubCommand::with_name("upgrade-nonce-account") SubCommand::with_name("upgrade-nonce-account")
@ -184,7 +190,8 @@ impl NonceSubCommands for App<'_, '_> {
.required(true), .required(true),
"Nonce account to upgrade. "), "Nonce account to upgrade. "),
) )
.arg(memo_arg()), .arg(memo_arg())
.arg(compute_unit_price_arg()),
) )
} }
} }
@ -206,6 +213,7 @@ pub fn parse_authorize_nonce_account(
matches, matches,
wallet_manager, wallet_manager,
)?; )?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::AuthorizeNonceAccount { command: CliCommand::AuthorizeNonceAccount {
@ -213,6 +221,7 @@ pub fn parse_authorize_nonce_account(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
new_authority, new_authority,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -236,6 +245,7 @@ pub fn parse_nonce_create_account(
matches, matches,
wallet_manager, wallet_manager,
)?; )?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::CreateNonceAccount { command: CliCommand::CreateNonceAccount {
@ -244,6 +254,7 @@ pub fn parse_nonce_create_account(
nonce_authority, nonce_authority,
memo, memo,
amount, amount,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -278,12 +289,14 @@ pub fn parse_new_nonce(
matches, matches,
wallet_manager, wallet_manager,
)?; )?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::NewNonce { command: CliCommand::NewNonce {
nonce_account, nonce_account,
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -325,6 +338,7 @@ pub fn parse_withdraw_from_nonce_account(
matches, matches,
wallet_manager, wallet_manager,
)?; )?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::WithdrawFromNonceAccount { command: CliCommand::WithdrawFromNonceAccount {
@ -333,6 +347,7 @@ pub fn parse_withdraw_from_nonce_account(
memo, memo,
destination_account_pubkey, destination_account_pubkey,
lamports, lamports,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -343,10 +358,12 @@ pub(crate) fn parse_upgrade_nonce_account(
) -> Result<CliCommandInfo, CliError> { ) -> Result<CliCommandInfo, CliError> {
let nonce_account = pubkey_of(matches, "nonce_account_pubkey").unwrap(); let nonce_account = pubkey_of(matches, "nonce_account_pubkey").unwrap();
let memo = matches.value_of(MEMO_ARG.name).map(String::from); let memo = matches.value_of(MEMO_ARG.name).map(String::from);
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::UpgradeNonceAccount { command: CliCommand::UpgradeNonceAccount {
nonce_account, nonce_account,
memo, memo,
compute_unit_price,
}, },
signers: CliSigners::default(), signers: CliSigners::default(),
}) })
@ -387,6 +404,7 @@ pub fn process_authorize_nonce_account(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
new_authority: &Pubkey, new_authority: &Pubkey,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let latest_blockhash = rpc_client.get_latest_blockhash()?; let latest_blockhash = rpc_client.get_latest_blockhash()?;
@ -396,7 +414,8 @@ pub fn process_authorize_nonce_account(
&nonce_authority.pubkey(), &nonce_authority.pubkey(),
new_authority, new_authority,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message); let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, latest_blockhash)?; tx.try_sign(&config.signers, latest_blockhash)?;
@ -432,6 +451,7 @@ pub fn process_create_nonce_account(
nonce_authority: Option<Pubkey>, nonce_authority: Option<Pubkey>,
memo: Option<&String>, memo: Option<&String>,
amount: SpendAmount, amount: SpendAmount,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let nonce_account_pubkey = config.signers[nonce_account].pubkey(); let nonce_account_pubkey = config.signers[nonce_account].pubkey();
let nonce_account_address = if let Some(ref seed) = seed { let nonce_account_address = if let Some(ref seed) = seed {
@ -458,6 +478,7 @@ pub fn process_create_nonce_account(
lamports, lamports,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
} else { } else {
create_nonce_account( create_nonce_account(
&config.signers[0].pubkey(), &config.signers[0].pubkey(),
@ -466,6 +487,7 @@ pub fn process_create_nonce_account(
lamports, lamports,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
}; };
Message::new(&ixs, Some(&config.signers[0].pubkey())) Message::new(&ixs, Some(&config.signers[0].pubkey()))
}; };
@ -561,6 +583,7 @@ pub fn process_new_nonce(
nonce_account: &Pubkey, nonce_account: &Pubkey,
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
check_unique_pubkeys( check_unique_pubkeys(
(&config.signers[0].pubkey(), "cli keypair".to_string()), (&config.signers[0].pubkey(), "cli keypair".to_string()),
@ -580,7 +603,8 @@ pub fn process_new_nonce(
nonce_account, nonce_account,
&nonce_authority.pubkey(), &nonce_authority.pubkey(),
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let latest_blockhash = rpc_client.get_latest_blockhash()?; let latest_blockhash = rpc_client.get_latest_blockhash()?;
let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message); let mut tx = Transaction::new_unsigned(message);
@ -646,6 +670,7 @@ pub fn process_withdraw_from_nonce_account(
memo: Option<&String>, memo: Option<&String>,
destination_account_pubkey: &Pubkey, destination_account_pubkey: &Pubkey,
lamports: u64, lamports: u64,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let latest_blockhash = rpc_client.get_latest_blockhash()?; let latest_blockhash = rpc_client.get_latest_blockhash()?;
@ -656,7 +681,8 @@ pub fn process_withdraw_from_nonce_account(
destination_account_pubkey, destination_account_pubkey,
lamports, lamports,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message); let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, latest_blockhash)?; tx.try_sign(&config.signers, latest_blockhash)?;
@ -688,9 +714,12 @@ pub(crate) fn process_upgrade_nonce_account(
config: &CliConfig, config: &CliConfig,
nonce_account: Pubkey, nonce_account: Pubkey,
memo: Option<&String>, memo: Option<&String>,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let latest_blockhash = rpc_client.get_latest_blockhash()?; let latest_blockhash = rpc_client.get_latest_blockhash()?;
let ixs = vec![upgrade_nonce_account(nonce_account)].with_memo(memo); let ixs = vec![upgrade_nonce_account(nonce_account)]
.with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let message = Message::new(&ixs, Some(&config.signers[0].pubkey()));
let mut tx = Transaction::new_unsigned(message); let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, latest_blockhash)?; tx.try_sign(&config.signers, latest_blockhash)?;
@ -774,6 +803,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
new_authority: Pubkey::default(), new_authority: Pubkey::default(),
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -796,6 +826,7 @@ mod tests {
nonce_authority: 1, nonce_authority: 1,
memo: None, memo: None,
new_authority: Pubkey::default(), new_authority: Pubkey::default(),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -820,6 +851,7 @@ mod tests {
nonce_authority: None, nonce_authority: None,
memo: None, memo: None,
amount: SpendAmount::Some(50_000_000_000), amount: SpendAmount::Some(50_000_000_000),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -846,6 +878,7 @@ mod tests {
nonce_authority: Some(nonce_authority_keypair.pubkey()), nonce_authority: Some(nonce_authority_keypair.pubkey()),
memo: None, memo: None,
amount: SpendAmount::Some(50_000_000_000), amount: SpendAmount::Some(50_000_000_000),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -881,6 +914,7 @@ mod tests {
nonce_account: nonce_account.pubkey(), nonce_account: nonce_account.pubkey(),
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -902,6 +936,7 @@ mod tests {
nonce_account: nonce_account.pubkey(), nonce_account: nonce_account.pubkey(),
nonce_authority: 1, nonce_authority: 1,
memo: None, memo: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -948,7 +983,8 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
destination_account_pubkey: nonce_account_pubkey, destination_account_pubkey: nonce_account_pubkey,
lamports: 42_000_000_000 lamports: 42_000_000_000,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -977,7 +1013,8 @@ mod tests {
nonce_authority: 1, nonce_authority: 1,
memo: None, memo: None,
destination_account_pubkey: nonce_account_pubkey, destination_account_pubkey: nonce_account_pubkey,
lamports: 42_000_000_000 lamports: 42_000_000_000,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -998,10 +1035,39 @@ mod tests {
command: CliCommand::UpgradeNonceAccount { command: CliCommand::UpgradeNonceAccount {
nonce_account: nonce_account_pubkey, nonce_account: nonce_account_pubkey,
memo: None, memo: None,
compute_unit_price: None,
}, },
signers: CliSigners::default(), signers: CliSigners::default(),
} }
); );
// Test ComputeUnitPrice Subcommand with authority
let test_authorize_nonce_account = test_commands.clone().get_matches_from(vec![
"test",
"authorize-nonce-account",
&keypair_file,
&Pubkey::default().to_string(),
"--nonce-authority",
&authority_keypair_file,
"--with-compute-unit-price",
"99",
]);
assert_eq!(
parse_command(&test_authorize_nonce_account, &default_signer, &mut None).unwrap(),
CliCommandInfo {
command: CliCommand::AuthorizeNonceAccount {
nonce_account: read_keypair_file(&keypair_file).unwrap().pubkey(),
nonce_authority: 1,
memo: None,
new_authority: Pubkey::default(),
compute_unit_price: Some(99),
},
signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(),
read_keypair_file(&authority_keypair_file).unwrap().into()
],
}
);
} }
#[test] #[test]

View File

@ -5,12 +5,14 @@ use {
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult, ProcessResult,
}, },
compute_unit_price::WithComputeUnitPrice,
memo::WithMemo, memo::WithMemo,
nonce::check_nonce_account, nonce::check_nonce_account,
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
}, },
clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand}, clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand},
solana_clap_utils::{ solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
fee_payer::{fee_payer_arg, FEE_PAYER_ARG}, fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
input_parsers::*, input_parsers::*,
input_validators::*, input_validators::*,
@ -196,6 +198,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("create-stake-account-checked") SubCommand::with_name("create-stake-account-checked")
@ -254,6 +257,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("delegate-stake") SubCommand::with_name("delegate-stake")
@ -284,6 +288,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("redelegate-stake") SubCommand::with_name("redelegate-stake")
@ -367,6 +372,7 @@ impl StakeSubCommands for App<'_, '_> {
.help("Return signature immediately after submitting the transaction, instead of waiting for confirmations"), .help("Return signature immediately after submitting the transaction, instead of waiting for confirmations"),
) )
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("stake-authorize-checked") SubCommand::with_name("stake-authorize-checked")
@ -407,6 +413,7 @@ impl StakeSubCommands for App<'_, '_> {
.help("Return signature immediately after submitting the transaction, instead of waiting for confirmations"), .help("Return signature immediately after submitting the transaction, instead of waiting for confirmations"),
) )
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("deactivate-stake") SubCommand::with_name("deactivate-stake")
@ -438,6 +445,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("split-stake") SubCommand::with_name("split-stake")
@ -480,6 +488,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("merge-stake") SubCommand::with_name("merge-stake")
@ -504,6 +513,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("withdraw-stake") SubCommand::with_name("withdraw-stake")
@ -545,6 +555,7 @@ impl StakeSubCommands for App<'_, '_> {
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(custodian_arg()) .arg(custodian_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("stake-set-lockup") SubCommand::with_name("stake-set-lockup")
@ -593,6 +604,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("stake-set-lockup-checked") SubCommand::with_name("stake-set-lockup-checked")
@ -643,6 +655,7 @@ impl StakeSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("stake-account") SubCommand::with_name("stake-account")
@ -758,6 +771,7 @@ pub fn parse_create_stake_account(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::CreateStakeAccount { command: CliCommand::CreateStakeAccount {
@ -784,6 +798,7 @@ pub fn parse_create_stake_account(
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
from: signer_info.index_of(from_pubkey).unwrap(), from: signer_info.index_of(from_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -818,6 +833,7 @@ pub fn parse_stake_delegate_stake(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::DelegateStake { command: CliCommand::DelegateStake {
@ -833,6 +849,7 @@ pub fn parse_stake_delegate_stake(
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
redelegation_stake_account_pubkey, redelegation_stake_account_pubkey,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -923,6 +940,7 @@ pub fn parse_stake_authorize(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let new_authorizations = new_authorizations let new_authorizations = new_authorizations
.into_iter() .into_iter()
@ -955,6 +973,7 @@ pub fn parse_stake_authorize(
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
custodian: custodian_pubkey.and_then(|_| signer_info.index_of(custodian_pubkey)), custodian: custodian_pubkey.and_then(|_| signer_info.index_of(custodian_pubkey)),
no_wait, no_wait,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -989,6 +1008,7 @@ pub fn parse_split_stake(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::SplitStake { command: CliCommand::SplitStake {
@ -1004,6 +1024,7 @@ pub fn parse_split_stake(
seed, seed,
lamports, lamports,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -1036,6 +1057,7 @@ pub fn parse_merge_stake(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::MergeStake { command: CliCommand::MergeStake {
@ -1049,6 +1071,7 @@ pub fn parse_merge_stake(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -1081,6 +1104,7 @@ pub fn parse_stake_deactivate_stake(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::DeactivateStake { command: CliCommand::DeactivateStake {
@ -1095,6 +1119,7 @@ pub fn parse_stake_deactivate_stake(
memo, memo,
seed, seed,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -1132,6 +1157,7 @@ pub fn parse_stake_withdraw_stake(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::WithdrawStake { command: CliCommand::WithdrawStake {
@ -1148,6 +1174,7 @@ pub fn parse_stake_withdraw_stake(
seed, seed,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
custodian: custodian_pubkey.and_then(|_| signer_info.index_of(custodian_pubkey)), custodian: custodian_pubkey.and_then(|_| signer_info.index_of(custodian_pubkey)),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -1193,6 +1220,7 @@ pub fn parse_stake_set_lockup(
} }
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::StakeSetLockup { command: CliCommand::StakeSetLockup {
@ -1215,6 +1243,7 @@ pub fn parse_stake_set_lockup(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -1283,6 +1312,7 @@ pub fn process_create_stake_account(
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
from: SignerIndex, from: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let stake_account = config.signers[stake_account]; let stake_account = config.signers[stake_account];
let stake_account_address = if let Some(seed) = seed { let stake_account_address = if let Some(seed) = seed {
@ -1339,7 +1369,8 @@ pub fn process_create_stake_account(
lamports, lamports,
), ),
} }
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
if let Some(nonce_account) = &nonce_account { if let Some(nonce_account) = &nonce_account {
Message::new_with_nonce( Message::new_with_nonce(
ixs, ixs,
@ -1431,6 +1462,7 @@ pub fn process_stake_authorize(
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
no_wait: bool, no_wait: bool,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let mut ixs = Vec::new(); let mut ixs = Vec::new();
let custodian = custodian.map(|index| config.signers[index]); let custodian = custodian.map(|index| config.signers[index]);
@ -1497,7 +1529,9 @@ pub fn process_stake_authorize(
)); ));
} }
} }
ixs = ixs.with_memo(memo); ixs = ixs
.with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@ -1565,6 +1599,7 @@ pub fn process_deactivate_stake_account(
memo: Option<&String>, memo: Option<&String>,
seed: Option<&String>, seed: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@ -1643,7 +1678,8 @@ pub fn process_deactivate_stake_account(
let stake_authority = config.signers[stake_authority]; let stake_authority = config.signers[stake_authority];
stake_instruction::deactivate_stake(&stake_account_address, &stake_authority.pubkey()) stake_instruction::deactivate_stake(&stake_account_address, &stake_authority.pubkey())
}] }]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -1707,6 +1743,7 @@ pub fn process_withdraw_stake(
memo: Option<&String>, memo: Option<&String>,
seed: Option<&String>, seed: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let withdraw_authority = config.signers[withdraw_authority]; let withdraw_authority = config.signers[withdraw_authority];
let custodian = custodian.map(|index| config.signers[index]); let custodian = custodian.map(|index| config.signers[index]);
@ -1730,7 +1767,8 @@ pub fn process_withdraw_stake(
lamports, lamports,
custodian.map(|signer| signer.pubkey()).as_ref(), custodian.map(|signer| signer.pubkey()).as_ref(),
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
if let Some(nonce_account) = &nonce_account { if let Some(nonce_account) = &nonce_account {
Message::new_with_nonce( Message::new_with_nonce(
@ -1803,6 +1841,7 @@ pub fn process_split_stake(
split_stake_account_seed: &Option<String>, split_stake_account_seed: &Option<String>,
lamports: u64, lamports: u64,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let split_stake_account = config.signers[split_stake_account]; let split_stake_account = config.signers[split_stake_account];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -1876,6 +1915,7 @@ pub fn process_split_stake(
seed, seed,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
} else { } else {
stake_instruction::split( stake_instruction::split(
stake_account_pubkey, stake_account_pubkey,
@ -1884,6 +1924,7 @@ pub fn process_split_stake(
&split_stake_account_address, &split_stake_account_address,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
}; };
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
@ -1944,6 +1985,7 @@ pub fn process_merge_stake(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -1989,7 +2031,8 @@ pub fn process_merge_stake(
source_stake_account_pubkey, source_stake_account_pubkey,
&stake_authority.pubkey(), &stake_authority.pubkey(),
) )
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
@ -2054,6 +2097,7 @@ pub fn process_stake_set_lockup(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
let custodian = config.signers[custodian]; let custodian = config.signers[custodian];
@ -2063,7 +2107,8 @@ pub fn process_stake_set_lockup(
} else { } else {
stake_instruction::set_lockup(stake_account_pubkey, lockup, &custodian.pubkey()) stake_instruction::set_lockup(stake_account_pubkey, lockup, &custodian.pubkey())
}] }]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -2463,6 +2508,7 @@ pub fn process_delegate_stake(
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
redelegation_stake_account_pubkey: Option<&Pubkey>, redelegation_stake_account_pubkey: Option<&Pubkey>,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
check_unique_pubkeys( check_unique_pubkeys(
(&config.signers[0].pubkey(), "cli keypair".to_string()), (&config.signers[0].pubkey(), "cli keypair".to_string()),
@ -2550,7 +2596,8 @@ pub fn process_delegate_stake(
vote_account_pubkey, vote_account_pubkey,
)] )]
} }
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -2701,6 +2748,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),],
}, },
@ -2749,6 +2797,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2801,6 +2850,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2837,6 +2887,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),],
}, },
@ -2870,6 +2921,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2909,6 +2961,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2945,6 +2998,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),],
}, },
@ -2978,6 +3032,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3017,6 +3072,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: true, no_wait: true,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -3063,6 +3119,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3114,6 +3171,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3167,6 +3225,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3204,6 +3263,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3240,6 +3300,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3280,6 +3341,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3317,6 +3379,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3353,6 +3416,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3393,6 +3457,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: true, no_wait: true,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3434,6 +3499,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -3479,6 +3545,7 @@ mod tests {
fee_payer: 1, fee_payer: 1,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3534,6 +3601,7 @@ mod tests {
fee_payer: 1, fee_payer: 1,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3575,6 +3643,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -3621,6 +3690,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3663,6 +3733,7 @@ mod tests {
fee_payer: 1, fee_payer: 1,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3709,6 +3780,7 @@ mod tests {
fee_payer: 1, fee_payer: 1,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3759,6 +3831,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3799,6 +3872,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3838,6 +3912,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -3910,6 +3985,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
Presigner::new(&offline_pubkey, &offline_sig).into(), Presigner::new(&offline_pubkey, &offline_sig).into(),
@ -3943,6 +4019,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -3975,6 +4052,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4009,6 +4087,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4044,6 +4123,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4074,6 +4154,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4114,6 +4195,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 1, fee_payer: 1,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4163,6 +4245,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 1, fee_payer: 1,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4200,6 +4283,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 1, fee_payer: 1,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4243,6 +4327,7 @@ mod tests {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: Some(redelegation_stake_account_pubkey), redelegation_stake_account_pubkey: Some(redelegation_stake_account_pubkey),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4279,6 +4364,41 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
},
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
}
);
// Test WithdrawStake Subcommand w/ ComputeUnitPrice
let test_withdraw_stake = test_commands.clone().get_matches_from(vec![
"test",
"withdraw-stake",
&stake_account_string,
&stake_account_string,
"42",
"--with-compute-unit-price",
"99",
]);
assert_eq!(
parse_command(&test_withdraw_stake, &default_signer, &mut None).unwrap(),
CliCommandInfo {
command: CliCommand::WithdrawStake {
stake_account_pubkey,
destination_account_pubkey: stake_account_pubkey,
amount: SpendAmount::Some(42_000_000_000),
withdraw_authority: 0,
custodian: None,
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
nonce_authority: 0,
memo: None,
seed: None,
fee_payer: 0,
compute_unit_price: Some(99),
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4312,6 +4432,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4350,6 +4471,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4399,6 +4521,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 1, fee_payer: 1,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&stake_authority_keypair_file) read_keypair_file(&stake_authority_keypair_file)
@ -4430,6 +4553,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4457,6 +4581,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4485,6 +4610,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4523,6 +4649,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4551,6 +4678,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -4589,6 +4717,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 1, fee_payer: 1,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4636,6 +4765,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 1, fee_payer: 1,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4668,6 +4798,7 @@ mod tests {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 1, fee_payer: 1,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4707,6 +4838,7 @@ mod tests {
seed: None, seed: None,
lamports: 50_000_000_000, lamports: 50_000_000_000,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -4773,6 +4905,7 @@ mod tests {
seed: None, seed: None,
lamports: 50_000_000_000, lamports: 50_000_000_000,
fee_payer: 1, fee_payer: 1,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
Presigner::new(&stake_auth_pubkey, &stake_sig).into(), Presigner::new(&stake_auth_pubkey, &stake_sig).into(),
@ -4810,6 +4943,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into(),],
} }

View File

@ -5,6 +5,7 @@ use {
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult, ProcessResult,
}, },
compute_unit_price::WithComputeUnitPrice,
memo::WithMemo, memo::WithMemo,
nonce::check_nonce_account, nonce::check_nonce_account,
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
@ -12,6 +13,7 @@ use {
}, },
clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
solana_clap_utils::{ solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
fee_payer::{fee_payer_arg, FEE_PAYER_ARG}, fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
input_parsers::*, input_parsers::*,
input_validators::*, input_validators::*,
@ -111,6 +113,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-authorize-voter") SubCommand::with_name("vote-authorize-voter")
@ -141,6 +144,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-authorize-withdrawer") SubCommand::with_name("vote-authorize-withdrawer")
@ -171,6 +175,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-authorize-voter-checked") SubCommand::with_name("vote-authorize-voter-checked")
@ -203,6 +208,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-authorize-withdrawer-checked") SubCommand::with_name("vote-authorize-withdrawer-checked")
@ -235,6 +241,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-update-validator") SubCommand::with_name("vote-update-validator")
@ -268,6 +275,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-update-commission") SubCommand::with_name("vote-update-commission")
@ -301,6 +309,7 @@ impl VoteSubCommands for App<'_, '_> {
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg()) .arg(memo_arg())
.arg(compute_unit_price_arg())
) )
.subcommand( .subcommand(
SubCommand::with_name("vote-account") SubCommand::with_name("vote-account")
@ -373,7 +382,8 @@ impl VoteSubCommands for App<'_, '_> {
.offline_args() .offline_args()
.nonce_args(false) .nonce_args(false)
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg() .arg(memo_arg())
.arg(compute_unit_price_arg()
) )
) )
.subcommand( .subcommand(
@ -402,7 +412,8 @@ impl VoteSubCommands for App<'_, '_> {
.help("Authorized withdrawer [default: cli config keypair]"), .help("Authorized withdrawer [default: cli config keypair]"),
) )
.arg(fee_payer_arg()) .arg(fee_payer_arg())
.arg(memo_arg() .arg(memo_arg())
.arg(compute_unit_price_arg()
) )
) )
} }
@ -430,6 +441,7 @@ pub fn parse_create_vote_account(
let (nonce_authority, nonce_authority_pubkey) = let (nonce_authority, nonce_authority_pubkey) =
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?; signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?; let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
if !allow_unsafe { if !allow_unsafe {
if authorized_withdrawer == vote_account_pubkey.unwrap() { if authorized_withdrawer == vote_account_pubkey.unwrap() {
@ -470,6 +482,7 @@ pub fn parse_create_vote_account(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -494,6 +507,7 @@ pub fn parse_vote_authorize(
let (nonce_authority, nonce_authority_pubkey) = let (nonce_authority, nonce_authority_pubkey) =
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?; signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?; let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let mut bulk_signers = vec![fee_payer, authorized]; let mut bulk_signers = vec![fee_payer, authorized];
@ -529,6 +543,7 @@ pub fn parse_vote_authorize(
} else { } else {
None None
}, },
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -554,6 +569,7 @@ pub fn parse_vote_update_validator(
let (nonce_authority, nonce_authority_pubkey) = let (nonce_authority, nonce_authority_pubkey) =
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?; signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?; let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let mut bulk_signers = vec![fee_payer, authorized_withdrawer, new_identity_account]; let mut bulk_signers = vec![fee_payer, authorized_withdrawer, new_identity_account];
if nonce_account.is_some() { if nonce_account.is_some() {
@ -574,6 +590,7 @@ pub fn parse_vote_update_validator(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -598,6 +615,7 @@ pub fn parse_vote_update_commission(
let (nonce_authority, nonce_authority_pubkey) = let (nonce_authority, nonce_authority_pubkey) =
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?; signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?; let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let mut bulk_signers = vec![fee_payer, authorized_withdrawer]; let mut bulk_signers = vec![fee_payer, authorized_withdrawer];
if nonce_account.is_some() { if nonce_account.is_some() {
@ -618,6 +636,7 @@ pub fn parse_vote_update_commission(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -673,6 +692,7 @@ pub fn parse_withdraw_from_vote_account(
let (nonce_authority, nonce_authority_pubkey) = let (nonce_authority, nonce_authority_pubkey) =
signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?; signer_of(matches, NONCE_AUTHORITY_ARG.name, wallet_manager)?;
let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?; let (fee_payer, fee_payer_pubkey) = signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let mut bulk_signers = vec![fee_payer, withdraw_authority]; let mut bulk_signers = vec![fee_payer, withdraw_authority];
if nonce_account.is_some() { if nonce_account.is_some() {
@ -694,6 +714,7 @@ pub fn parse_withdraw_from_vote_account(
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(), nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -719,6 +740,7 @@ pub fn parse_close_vote_account(
wallet_manager, wallet_manager,
)?; )?;
let memo = matches.value_of(MEMO_ARG.name).map(String::from); let memo = matches.value_of(MEMO_ARG.name).map(String::from);
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::CloseVoteAccount { command: CliCommand::CloseVoteAccount {
@ -727,6 +749,7 @@ pub fn parse_close_vote_account(
withdraw_authority: signer_info.index_of(withdraw_authority_pubkey).unwrap(), withdraw_authority: signer_info.index_of(withdraw_authority_pubkey).unwrap(),
memo, memo,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(), fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -749,6 +772,7 @@ pub fn process_create_vote_account(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let vote_account = config.signers[vote_account]; let vote_account = config.signers[vote_account];
let vote_account_pubkey = vote_account.pubkey(); let vote_account_pubkey = vote_account.pubkey();
@ -795,6 +819,7 @@ pub fn process_create_vote_account(
lamports, lamports,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
} else { } else {
vote_instruction::create_account( vote_instruction::create_account(
&config.signers[0].pubkey(), &config.signers[0].pubkey(),
@ -803,6 +828,7 @@ pub fn process_create_vote_account(
lamports, lamports,
) )
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
}; };
if let Some(nonce_account) = &nonce_account { if let Some(nonce_account) = &nonce_account {
Message::new_with_nonce( Message::new_with_nonce(
@ -889,6 +915,7 @@ pub fn process_vote_authorize(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let authorized = config.signers[authorized]; let authorized = config.signers[authorized];
let new_authorized_signer = new_authorized.map(|index| config.signers[index]); let new_authorized_signer = new_authorized.map(|index| config.signers[index]);
@ -950,7 +977,9 @@ pub fn process_vote_authorize(
vote_authorize, // vote or withdraw vote_authorize, // vote or withdraw
) )
}; };
let ixs = vec![vote_ix].with_memo(memo); let ixs = vec![vote_ix]
.with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@ -1013,6 +1042,7 @@ pub fn process_vote_update_validator(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let authorized_withdrawer = config.signers[withdraw_authority]; let authorized_withdrawer = config.signers[withdraw_authority];
let new_identity_account = config.signers[new_identity_account]; let new_identity_account = config.signers[new_identity_account];
@ -1027,7 +1057,8 @@ pub fn process_vote_update_validator(
&authorized_withdrawer.pubkey(), &authorized_withdrawer.pubkey(),
&new_identity_pubkey, &new_identity_pubkey,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -1087,6 +1118,7 @@ pub fn process_vote_update_commission(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let authorized_withdrawer = config.signers[withdraw_authority]; let authorized_withdrawer = config.signers[withdraw_authority];
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@ -1095,7 +1127,8 @@ pub fn process_vote_update_commission(
&authorized_withdrawer.pubkey(), &authorized_withdrawer.pubkey(),
commission, commission,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let nonce_authority = config.signers[nonce_authority]; let nonce_authority = config.signers[nonce_authority];
let fee_payer = config.signers[fee_payer]; let fee_payer = config.signers[fee_payer];
@ -1243,6 +1276,7 @@ pub fn process_withdraw_from_vote_account(
nonce_authority: SignerIndex, nonce_authority: SignerIndex,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let withdraw_authority = config.signers[withdraw_authority]; let withdraw_authority = config.signers[withdraw_authority];
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?; let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
@ -1257,7 +1291,8 @@ pub fn process_withdraw_from_vote_account(
lamports, lamports,
destination_account_pubkey, destination_account_pubkey,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
if let Some(nonce_account) = &nonce_account { if let Some(nonce_account) = &nonce_account {
Message::new_with_nonce( Message::new_with_nonce(
@ -1337,6 +1372,7 @@ pub fn process_close_vote_account(
destination_account_pubkey: &Pubkey, destination_account_pubkey: &Pubkey,
memo: Option<&String>, memo: Option<&String>,
fee_payer: SignerIndex, fee_payer: SignerIndex,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let vote_account_status = let vote_account_status =
rpc_client.get_vote_accounts_with_config(RpcGetVoteAccountsConfig { rpc_client.get_vote_accounts_with_config(RpcGetVoteAccountsConfig {
@ -1371,7 +1407,8 @@ pub fn process_close_vote_account(
current_balance, current_balance,
destination_account_pubkey, destination_account_pubkey,
)] )]
.with_memo(memo); .with_memo(memo)
.with_compute_unit_price(compute_unit_price);
let message = Message::new(&ixs, Some(&fee_payer.pubkey())); let message = Message::new(&ixs, Some(&fee_payer.pubkey()));
let mut tx = Transaction::new_unsigned(message); let mut tx = Transaction::new_unsigned(message);
@ -1450,6 +1487,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -1482,6 +1520,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1516,6 +1555,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1564,6 +1604,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
Presigner::new(&pubkey2, &sig2).into(), Presigner::new(&pubkey2, &sig2).into(),
@ -1600,6 +1641,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: Some(1), new_authorized: Some(1),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1631,6 +1673,7 @@ mod tests {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: Some(2), new_authorized: Some(2),
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1684,6 +1727,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1717,6 +1761,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1757,6 +1802,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1809,6 +1855,7 @@ mod tests {
nonce_authority: 3, nonce_authority: 3,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1851,6 +1898,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1889,6 +1937,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1919,6 +1968,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1949,6 +1999,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -1980,6 +2031,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2008,6 +2060,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2041,6 +2094,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),
@ -2079,6 +2133,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&withdraw_authority_file).unwrap().into()], signers: vec![read_keypair_file(&withdraw_authority_file).unwrap().into()],
} }
@ -2119,6 +2174,7 @@ mod tests {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![Presigner::new(&withdraw_authority.pubkey(), &authorized_sig).into(),], signers: vec![Presigner::new(&withdraw_authority.pubkey(), &authorized_sig).into(),],
} }
@ -2140,6 +2196,7 @@ mod tests {
withdraw_authority: 0, withdraw_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}, },
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()], signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
} }
@ -2166,6 +2223,39 @@ mod tests {
withdraw_authority: 1, withdraw_authority: 1,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
},
signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(),
read_keypair_file(&withdraw_authority_file).unwrap().into()
],
}
);
// Test CloseVoteAccount subcommand with authority w/ ComputeUnitPrice
let withdraw_authority = Keypair::new();
let (withdraw_authority_file, mut tmp_file) = make_tmp_file();
write_keypair(&withdraw_authority, tmp_file.as_file_mut()).unwrap();
let test_close_vote_account = test_commands.clone().get_matches_from(vec![
"test",
"close-vote-account",
&keypair_file,
&pubkey_string,
"--authorized-withdrawer",
&withdraw_authority_file,
"--with-compute-unit-price",
"99",
]);
assert_eq!(
parse_command(&test_close_vote_account, &default_signer, &mut None).unwrap(),
CliCommandInfo {
command: CliCommand::CloseVoteAccount {
vote_account_pubkey: read_keypair_file(&keypair_file).unwrap().pubkey(),
destination_account_pubkey: pubkey,
withdraw_authority: 1,
memo: None,
fee_payer: 0,
compute_unit_price: Some(99),
}, },
signers: vec![ signers: vec![
read_keypair_file(&default_keypair_file).unwrap().into(), read_keypair_file(&default_keypair_file).unwrap().into(),

View File

@ -4,6 +4,7 @@ use {
log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo, log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo,
CliConfig, CliError, ProcessResult, CliConfig, CliError, ProcessResult,
}, },
compute_unit_price::WithComputeUnitPrice,
memo::WithMemo, memo::WithMemo,
nonce::check_nonce_account, nonce::check_nonce_account,
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
@ -11,6 +12,7 @@ use {
clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand},
solana_account_decoder::{UiAccount, UiAccountEncoding}, solana_account_decoder::{UiAccount, UiAccountEncoding},
solana_clap_utils::{ solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
fee_payer::*, fee_payer::*,
input_parsers::*, input_parsers::*,
input_validators::*, input_validators::*,
@ -270,7 +272,8 @@ impl WalletSubCommands for App<'_, '_> {
.offline_args() .offline_args()
.nonce_args(false) .nonce_args(false)
.arg(memo_arg()) .arg(memo_arg())
.arg(fee_payer_arg()), .arg(fee_payer_arg())
.arg(compute_unit_price_arg()),
) )
} }
} }
@ -415,6 +418,7 @@ pub fn parse_transfer(
let signer_info = let signer_info =
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?; default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
let derived_address_seed = matches let derived_address_seed = matches
.value_of("derived_address_seed") .value_of("derived_address_seed")
@ -438,6 +442,7 @@ pub fn parse_transfer(
from: signer_info.index_of(from_pubkey).unwrap(), from: signer_info.index_of(from_pubkey).unwrap(),
derived_address_seed, derived_address_seed,
derived_address_program_id, derived_address_program_id,
compute_unit_price,
}, },
signers: signer_info.signers, signers: signer_info.signers,
}) })
@ -671,6 +676,7 @@ pub fn process_transfer(
fee_payer: SignerIndex, fee_payer: SignerIndex,
derived_address_seed: Option<String>, derived_address_seed: Option<String>,
derived_address_program_id: Option<&Pubkey>, derived_address_program_id: Option<&Pubkey>,
compute_unit_price: Option<&u64>,
) -> ProcessResult { ) -> ProcessResult {
let from = config.signers[from]; let from = config.signers[from];
let mut from_pubkey = from.pubkey(); let mut from_pubkey = from.pubkey();
@ -715,8 +721,11 @@ pub fn process_transfer(
lamports, lamports,
)] )]
.with_memo(memo) .with_memo(memo)
.with_compute_unit_price(compute_unit_price)
} else { } else {
vec![system_instruction::transfer(&from_pubkey, to, lamports)].with_memo(memo) vec![system_instruction::transfer(&from_pubkey, to, lamports)]
.with_memo(memo)
.with_compute_unit_price(compute_unit_price)
}; };
if let Some(nonce_account) = &nonce_account { if let Some(nonce_account) = &nonce_account {

View File

@ -116,6 +116,7 @@ fn full_battery_tests(
nonce_authority: optional_authority, nonce_authority: optional_authority,
memo: None, memo: None,
amount: SpendAmount::Some(sol_to_lamports(1000.0)), amount: SpendAmount::Some(sol_to_lamports(1000.0)),
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -153,6 +154,7 @@ fn full_battery_tests(
nonce_account, nonce_account,
nonce_authority: index, nonce_authority: index,
memo: None, memo: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -173,6 +175,7 @@ fn full_battery_tests(
memo: None, memo: None,
destination_account_pubkey: payee_pubkey, destination_account_pubkey: payee_pubkey,
lamports: sol_to_lamports(100.0), lamports: sol_to_lamports(100.0),
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
check_balance!( check_balance!(
@ -197,6 +200,7 @@ fn full_battery_tests(
nonce_authority: index, nonce_authority: index,
memo: None, memo: None,
new_authority: new_authority.pubkey(), new_authority: new_authority.pubkey(),
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -205,6 +209,7 @@ fn full_battery_tests(
nonce_account, nonce_account,
nonce_authority: index, nonce_authority: index,
memo: None, memo: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap_err(); process_command(&config_payer).unwrap_err();
@ -214,6 +219,7 @@ fn full_battery_tests(
nonce_account, nonce_account,
nonce_authority: 1, nonce_authority: 1,
memo: None, memo: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -224,6 +230,7 @@ fn full_battery_tests(
memo: None, memo: None,
destination_account_pubkey: payee_pubkey, destination_account_pubkey: payee_pubkey,
lamports: sol_to_lamports(100.0), lamports: sol_to_lamports(100.0),
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
check_balance!( check_balance!(
@ -302,6 +309,7 @@ fn test_create_account_with_seed() {
nonce_authority: Some(authority_pubkey), nonce_authority: Some(authority_pubkey),
memo: None, memo: None,
amount: SpendAmount::Some(sol_to_lamports(241.0)), amount: SpendAmount::Some(sol_to_lamports(241.0)),
compute_unit_price: None,
}; };
process_command(&creator_config).unwrap(); process_command(&creator_config).unwrap();
check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address); check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address);
@ -349,6 +357,7 @@ fn test_create_account_with_seed() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
authority_config.output_format = OutputFormat::JsonCompact; authority_config.output_format = OutputFormat::JsonCompact;
let sign_only_reply = process_command(&authority_config).unwrap(); let sign_only_reply = process_command(&authority_config).unwrap();
@ -378,6 +387,7 @@ fn test_create_account_with_seed() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&submit_config).unwrap(); process_command(&submit_config).unwrap();
check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address); check_balance!(sol_to_lamports(241.0), &rpc_client, &nonce_address);

View File

@ -93,6 +93,7 @@ fn test_stake_redelegation() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -113,6 +114,7 @@ fn test_stake_redelegation() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -135,6 +137,7 @@ fn test_stake_redelegation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -153,6 +156,7 @@ fn test_stake_redelegation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -216,6 +220,7 @@ fn test_stake_redelegation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: Some(stake2_keypair.pubkey()), redelegation_stake_account_pubkey: Some(stake2_keypair.pubkey()),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -328,6 +333,7 @@ fn test_stake_delegation_force() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -350,6 +356,7 @@ fn test_stake_delegation_force() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -368,6 +375,7 @@ fn test_stake_delegation_force() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); process_command(&config).unwrap_err();
@ -385,6 +393,7 @@ fn test_stake_delegation_force() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
} }
@ -445,6 +454,7 @@ fn test_seed_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
@ -462,6 +472,7 @@ fn test_seed_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
@ -478,6 +489,7 @@ fn test_seed_stake_delegation_and_deactivation() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
} }
@ -533,6 +545,7 @@ fn test_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
@ -551,6 +564,7 @@ fn test_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
@ -567,6 +581,7 @@ fn test_stake_delegation_and_deactivation() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
} }
@ -646,6 +661,7 @@ fn test_offline_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config_validator).unwrap(); process_command(&config_validator).unwrap();
@ -664,6 +680,7 @@ fn test_offline_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -686,6 +703,7 @@ fn test_offline_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -703,6 +721,7 @@ fn test_offline_stake_delegation_and_deactivation() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
let sign_only = parse_sign_only_reply_string(&sig_response); let sign_only = parse_sign_only_reply_string(&sig_response);
@ -723,6 +742,7 @@ fn test_offline_stake_delegation_and_deactivation() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
} }
@ -776,6 +796,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -788,6 +809,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
nonce_authority: Some(config.signers[0].pubkey()), nonce_authority: Some(config.signers[0].pubkey()),
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -819,6 +841,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
redelegation_stake_account_pubkey: None, redelegation_stake_account_pubkey: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -848,6 +871,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
} }
@ -915,6 +939,7 @@ fn test_stake_authorize() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -939,6 +964,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -980,6 +1006,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1011,6 +1038,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1042,6 +1070,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sign_reply = process_command(&config_offline).unwrap(); let sign_reply = process_command(&config_offline).unwrap();
@ -1066,6 +1095,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1088,6 +1118,7 @@ fn test_stake_authorize() {
nonce_authority: Some(offline_authority_pubkey), nonce_authority: Some(offline_authority_pubkey),
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -1122,6 +1153,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
let sign_reply = process_command(&config_offline).unwrap(); let sign_reply = process_command(&config_offline).unwrap();
let sign_only = parse_sign_only_reply_string(&sign_reply); let sign_only = parse_sign_only_reply_string(&sign_reply);
@ -1150,6 +1182,7 @@ fn test_stake_authorize() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1249,6 +1282,7 @@ fn test_stake_authorize_with_fee_payer() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -1276,6 +1310,7 @@ fn test_stake_authorize_with_fee_payer() {
fee_payer: 1, fee_payer: 1,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
// `config` balance has not changed, despite submitting the TX // `config` balance has not changed, despite submitting the TX
@ -1307,6 +1342,7 @@ fn test_stake_authorize_with_fee_payer() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sign_reply = process_command(&config_offline).unwrap(); let sign_reply = process_command(&config_offline).unwrap();
@ -1331,6 +1367,7 @@ fn test_stake_authorize_with_fee_payer() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
// `config`'s balance again has not changed // `config`'s balance again has not changed
@ -1421,6 +1458,7 @@ fn test_stake_split() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(10 * stake_balance, &rpc_client, &stake_account_pubkey,); check_balance!(10 * stake_balance, &rpc_client, &stake_account_pubkey,);
@ -1437,6 +1475,7 @@ fn test_stake_split() {
nonce_authority: Some(offline_pubkey), nonce_authority: Some(offline_pubkey),
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account.pubkey()); check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account.pubkey());
@ -1468,6 +1507,7 @@ fn test_stake_split() {
seed: None, seed: None,
lamports: 2 * stake_balance, lamports: 2 * stake_balance,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -1491,6 +1531,7 @@ fn test_stake_split() {
seed: None, seed: None,
lamports: 2 * stake_balance, lamports: 2 * stake_balance,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(8 * stake_balance, &rpc_client, &stake_account_pubkey,); check_balance!(8 * stake_balance, &rpc_client, &stake_account_pubkey,);
@ -1577,6 +1618,7 @@ fn test_stake_set_lockup() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(10 * stake_balance, &rpc_client, &stake_account_pubkey,); check_balance!(10 * stake_balance, &rpc_client, &stake_account_pubkey,);
@ -1601,6 +1643,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1637,6 +1680,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -1658,6 +1702,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1691,6 +1736,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -1707,6 +1753,7 @@ fn test_stake_set_lockup() {
nonce_authority: Some(offline_pubkey), nonce_authority: Some(offline_pubkey),
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account_pubkey); check_balance!(minimum_nonce_balance, &rpc_client, &nonce_account_pubkey);
@ -1739,6 +1786,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -1761,6 +1809,7 @@ fn test_stake_set_lockup() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -1834,6 +1883,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
nonce_authority: Some(offline_pubkey), nonce_authority: Some(offline_pubkey),
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -1867,6 +1917,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -1894,6 +1945,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(50_000_000_000, &rpc_client, &stake_pubkey); check_balance!(50_000_000_000, &rpc_client, &stake_pubkey);
@ -1926,6 +1978,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
let sign_only = parse_sign_only_reply_string(&sig_response); let sign_only = parse_sign_only_reply_string(&sig_response);
@ -1948,6 +2001,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
seed: None, seed: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(50_000_000_000, &rpc_client, &recipient_pubkey); check_balance!(50_000_000_000, &rpc_client, &recipient_pubkey);
@ -1981,6 +2035,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
let sign_only = parse_sign_only_reply_string(&sig_response); let sign_only = parse_sign_only_reply_string(&sig_response);
@ -2006,6 +2061,7 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let seed_address = let seed_address =
@ -2061,6 +2117,7 @@ fn test_stake_checked_instructions() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); // unsigned authority should fail process_command(&config).unwrap_err(); // unsigned authority should fail
@ -2081,6 +2138,7 @@ fn test_stake_checked_instructions() {
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
from: 0, from: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -2105,6 +2163,7 @@ fn test_stake_checked_instructions() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); // unsigned authority should fail process_command(&config).unwrap_err(); // unsigned authority should fail
@ -2126,6 +2185,7 @@ fn test_stake_checked_instructions() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -2156,6 +2216,7 @@ fn test_stake_checked_instructions() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); // unsigned authority should fail process_command(&config).unwrap_err(); // unsigned authority should fail
@ -2181,6 +2242,7 @@ fn test_stake_checked_instructions() {
fee_payer: 0, fee_payer: 0,
custodian: None, custodian: None,
no_wait: false, no_wait: false,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();
@ -2212,6 +2274,7 @@ fn test_stake_checked_instructions() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); // unsigned new custodian should fail process_command(&config).unwrap_err(); // unsigned new custodian should fail
@ -2228,6 +2291,7 @@ fn test_stake_checked_instructions() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap(); let stake_account = rpc_client.get_account(&stake_account_pubkey).unwrap();

View File

@ -78,6 +78,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -103,6 +104,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
check_balance!( check_balance!(
@ -141,6 +143,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
offline.output_format = OutputFormat::JsonCompact; offline.output_format = OutputFormat::JsonCompact;
let sign_only_reply = process_command(&offline).unwrap(); let sign_only_reply = process_command(&offline).unwrap();
@ -163,6 +166,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -184,6 +188,7 @@ fn test_transfer() {
nonce_authority: None, nonce_authority: None,
memo: None, memo: None,
amount: SpendAmount::Some(minimum_nonce_balance), amount: SpendAmount::Some(minimum_nonce_balance),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -222,6 +227,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -247,6 +253,7 @@ fn test_transfer() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
new_authority: offline_pubkey, new_authority: offline_pubkey,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -282,6 +289,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
let sign_only_reply = process_command(&offline).unwrap(); let sign_only_reply = process_command(&offline).unwrap();
let sign_only = parse_sign_only_reply_string(&sign_only_reply); let sign_only = parse_sign_only_reply_string(&sign_only_reply);
@ -306,6 +314,7 @@ fn test_transfer() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!( check_balance!(
@ -390,6 +399,7 @@ fn test_transfer_multisession_signing() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
fee_payer_config.output_format = OutputFormat::JsonCompact; fee_payer_config.output_format = OutputFormat::JsonCompact;
let sign_only_reply = process_command(&fee_payer_config).unwrap(); let sign_only_reply = process_command(&fee_payer_config).unwrap();
@ -421,6 +431,7 @@ fn test_transfer_multisession_signing() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
from_config.output_format = OutputFormat::JsonCompact; from_config.output_format = OutputFormat::JsonCompact;
let sign_only_reply = process_command(&from_config).unwrap(); let sign_only_reply = process_command(&from_config).unwrap();
@ -449,6 +460,7 @@ fn test_transfer_multisession_signing() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -513,6 +525,7 @@ fn test_transfer_all() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(0, &rpc_client, &sender_pubkey); check_balance!(0, &rpc_client, &sender_pubkey);
@ -566,6 +579,7 @@ fn test_transfer_unfunded_recipient() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
// Expect failure due to unfunded recipient and the lack of the `allow_unfunded_recipient` flag // Expect failure due to unfunded recipient and the lack of the `allow_unfunded_recipient` flag
@ -632,6 +646,7 @@ fn test_transfer_with_seed() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: Some(derived_address_seed), derived_address_seed: Some(derived_address_seed),
derived_address_program_id: Some(derived_address_program_id), derived_address_program_id: Some(derived_address_program_id),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(sol_to_lamports(1.0) - fee, &rpc_client, &sender_pubkey); check_balance!(sol_to_lamports(1.0) - fee, &rpc_client, &sender_pubkey);

View File

@ -58,6 +58,7 @@ fn test_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let vote_account = rpc_client let vote_account = rpc_client
@ -89,6 +90,7 @@ fn test_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let expected_balance = expected_balance + 10_000; let expected_balance = expected_balance + 10_000;
@ -110,6 +112,7 @@ fn test_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let vote_account = rpc_client let vote_account = rpc_client
@ -135,6 +138,7 @@ fn test_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: Some(1), new_authorized: Some(1),
compute_unit_price: None,
}; };
process_command(&config).unwrap_err(); // unsigned by new authority should fail process_command(&config).unwrap_err(); // unsigned by new authority should fail
config.signers = vec![ config.signers = vec![
@ -155,6 +159,7 @@ fn test_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
authorized: 1, authorized: 1,
new_authorized: Some(2), new_authorized: Some(2),
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let vote_account = rpc_client let vote_account = rpc_client
@ -179,6 +184,7 @@ fn test_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let expected_balance = expected_balance - 1_000; let expected_balance = expected_balance - 1_000;
@ -199,6 +205,7 @@ fn test_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
@ -211,6 +218,7 @@ fn test_vote_authorize_and_withdraw() {
destination_account_pubkey: destination_account, destination_account_pubkey: destination_account,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
check_balance!(0, &rpc_client, &vote_account_pubkey); check_balance!(0, &rpc_client, &vote_account_pubkey);
@ -277,6 +285,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
let vote_account = rpc_client let vote_account = rpc_client
@ -308,6 +317,7 @@ fn test_offline_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
derived_address_seed: None, derived_address_seed: None,
derived_address_program_id: None, derived_address_program_id: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
let expected_balance = expected_balance + 10_000; let expected_balance = expected_balance + 10_000;
@ -329,6 +339,7 @@ fn test_offline_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -351,6 +362,7 @@ fn test_offline_vote_authorize_and_withdraw() {
fee_payer: 0, fee_payer: 0,
authorized: 0, authorized: 0,
new_authorized: None, new_authorized: None,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
let vote_account = rpc_client let vote_account = rpc_client
@ -377,6 +389,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
let sig_response = process_command(&config_offline).unwrap(); let sig_response = process_command(&config_offline).unwrap();
@ -397,6 +410,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
let expected_balance = expected_balance - 1_000; let expected_balance = expected_balance - 1_000;
@ -423,6 +437,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_offline).unwrap(); process_command(&config_offline).unwrap();
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
@ -443,6 +458,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
@ -462,6 +478,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_offline).unwrap(); process_command(&config_offline).unwrap();
config_offline.output_format = OutputFormat::JsonCompact; config_offline.output_format = OutputFormat::JsonCompact;
@ -483,6 +500,7 @@ fn test_offline_vote_authorize_and_withdraw() {
nonce_authority: 0, nonce_authority: 0,
memo: None, memo: None,
fee_payer: 0, fee_payer: 0,
compute_unit_price: None,
}; };
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
check_balance!(0, &rpc_client, &vote_account_pubkey); check_balance!(0, &rpc_client, &vote_account_pubkey);