Make redelegate signer more optional (#30734)
This commit is contained in:
parent
f8abc8df8d
commit
0cdb315b5b
|
@ -214,7 +214,7 @@ pub enum CliCommand {
|
|||
nonce_authority: SignerIndex,
|
||||
memo: Option<String>,
|
||||
fee_payer: SignerIndex,
|
||||
redelegation_stake_account_pubkey: Option<Pubkey>,
|
||||
redelegation_stake_account: Option<SignerIndex>,
|
||||
compute_unit_price: Option<u64>,
|
||||
},
|
||||
SplitStake {
|
||||
|
@ -1172,7 +1172,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||
nonce_authority,
|
||||
memo,
|
||||
fee_payer,
|
||||
redelegation_stake_account_pubkey,
|
||||
redelegation_stake_account,
|
||||
compute_unit_price,
|
||||
} => process_delegate_stake(
|
||||
&rpc_client,
|
||||
|
@ -1188,7 +1188,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||
*nonce_authority,
|
||||
memo.as_ref(),
|
||||
*fee_payer,
|
||||
redelegation_stake_account_pubkey.as_ref(),
|
||||
*redelegation_stake_account,
|
||||
compute_unit_price.as_ref(),
|
||||
),
|
||||
CliCommand::SplitStake {
|
||||
|
|
|
@ -828,10 +828,13 @@ pub fn parse_stake_delegate_stake(
|
|||
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 mut bulk_signers = vec![stake_authority, fee_payer, redelegation_stake_account];
|
||||
let mut bulk_signers = vec![stake_authority, fee_payer];
|
||||
if nonce_account.is_some() {
|
||||
bulk_signers.push(nonce_authority);
|
||||
}
|
||||
if redelegation_stake_account.is_some() {
|
||||
bulk_signers.push(redelegation_stake_account);
|
||||
}
|
||||
let signer_info =
|
||||
default_signer.generate_unique_signers(bulk_signers, matches, wallet_manager)?;
|
||||
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
|
||||
|
@ -849,7 +852,8 @@ pub fn parse_stake_delegate_stake(
|
|||
nonce_authority: signer_info.index_of(nonce_authority_pubkey).unwrap(),
|
||||
memo,
|
||||
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
|
||||
redelegation_stake_account_pubkey,
|
||||
redelegation_stake_account: redelegation_stake_account_pubkey
|
||||
.and_then(|_| signer_info.index_of(redelegation_stake_account_pubkey)),
|
||||
compute_unit_price,
|
||||
},
|
||||
signers: signer_info.signers,
|
||||
|
@ -2488,25 +2492,26 @@ pub fn process_delegate_stake(
|
|||
nonce_authority: SignerIndex,
|
||||
memo: Option<&String>,
|
||||
fee_payer: SignerIndex,
|
||||
redelegation_stake_account_pubkey: Option<&Pubkey>,
|
||||
redelegation_stake_account: Option<SignerIndex>,
|
||||
compute_unit_price: Option<&u64>,
|
||||
) -> ProcessResult {
|
||||
check_unique_pubkeys(
|
||||
(&config.signers[0].pubkey(), "cli keypair".to_string()),
|
||||
(stake_account_pubkey, "stake_account_pubkey".to_string()),
|
||||
)?;
|
||||
if let Some(redelegation_stake_account_pubkey) = &redelegation_stake_account_pubkey {
|
||||
let redelegation_stake_account = redelegation_stake_account.map(|index| config.signers[index]);
|
||||
if let Some(redelegation_stake_account) = &redelegation_stake_account {
|
||||
check_unique_pubkeys(
|
||||
(stake_account_pubkey, "stake_account_pubkey".to_string()),
|
||||
(
|
||||
redelegation_stake_account_pubkey,
|
||||
&redelegation_stake_account.pubkey(),
|
||||
"redelegation_stake_account".to_string(),
|
||||
),
|
||||
)?;
|
||||
check_unique_pubkeys(
|
||||
(&config.signers[0].pubkey(), "cli keypair".to_string()),
|
||||
(
|
||||
redelegation_stake_account_pubkey,
|
||||
&redelegation_stake_account.pubkey(),
|
||||
"redelegation_stake_account".to_string(),
|
||||
),
|
||||
)?;
|
||||
|
@ -2561,12 +2566,12 @@ pub fn process_delegate_stake(
|
|||
|
||||
let recent_blockhash = blockhash_query.get_blockhash(rpc_client, config.commitment)?;
|
||||
|
||||
let ixs = if let Some(redelegation_stake_account_pubkey) = &redelegation_stake_account_pubkey {
|
||||
let ixs = if let Some(redelegation_stake_account) = &redelegation_stake_account {
|
||||
stake_instruction::redelegate(
|
||||
stake_account_pubkey,
|
||||
&stake_authority.pubkey(),
|
||||
vote_account_pubkey,
|
||||
redelegation_stake_account_pubkey,
|
||||
&redelegation_stake_account.pubkey(),
|
||||
)
|
||||
} else {
|
||||
vec![stake_instruction::delegate_stake(
|
||||
|
@ -3997,7 +4002,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
|
||||
|
@ -4030,7 +4035,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![
|
||||
|
@ -4065,7 +4070,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
|
||||
|
@ -4101,7 +4106,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
|
||||
|
@ -4132,7 +4137,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![read_keypair_file(&default_keypair_file).unwrap().into()],
|
||||
|
@ -4173,7 +4178,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 1,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![
|
||||
|
@ -4223,7 +4228,7 @@ mod tests {
|
|||
nonce_authority: 2,
|
||||
memo: None,
|
||||
fee_payer: 1,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![
|
||||
|
@ -4261,7 +4266,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 1,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![
|
||||
|
@ -4281,7 +4286,6 @@ mod tests {
|
|||
redelegation_stake_account_tmp_file.as_file_mut(),
|
||||
)
|
||||
.unwrap();
|
||||
let redelegation_stake_account_pubkey = redelegation_stake_account_keypair.pubkey();
|
||||
|
||||
let test_redelegate_stake = test_commands.clone().get_matches_from(vec![
|
||||
"test",
|
||||
|
@ -4305,7 +4309,7 @@ mod tests {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: Some(redelegation_stake_account_pubkey),
|
||||
redelegation_stake_account: Some(1),
|
||||
compute_unit_price: None,
|
||||
},
|
||||
signers: vec![
|
||||
|
|
|
@ -152,7 +152,7 @@ fn test_stake_redelegation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config).unwrap();
|
||||
|
@ -216,7 +216,7 @@ fn test_stake_redelegation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: Some(stake2_keypair.pubkey()),
|
||||
redelegation_stake_account: Some(1),
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config).unwrap();
|
||||
|
@ -371,7 +371,7 @@ fn test_stake_delegation_force() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config).unwrap_err();
|
||||
|
@ -389,7 +389,7 @@ fn test_stake_delegation_force() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config).unwrap();
|
||||
|
@ -468,7 +468,7 @@ fn test_seed_stake_delegation_and_deactivation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config_validator).unwrap();
|
||||
|
@ -560,7 +560,7 @@ fn test_stake_delegation_and_deactivation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config_validator).unwrap();
|
||||
|
@ -676,7 +676,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
config_offline.output_format = OutputFormat::JsonCompact;
|
||||
|
@ -699,7 +699,7 @@ fn test_offline_stake_delegation_and_deactivation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config_payer).unwrap();
|
||||
|
@ -837,7 +837,7 @@ fn test_nonced_stake_delegation_and_deactivation() {
|
|||
nonce_authority: 0,
|
||||
memo: None,
|
||||
fee_payer: 0,
|
||||
redelegation_stake_account_pubkey: None,
|
||||
redelegation_stake_account: None,
|
||||
compute_unit_price: None,
|
||||
};
|
||||
process_command(&config).unwrap();
|
||||
|
|
Loading…
Reference in New Issue