@@ -86,21 +86,26 @@ impl SigningAuthority {
 | 
				
			|||||||
        matches: &ArgMatches<'_>,
 | 
					        matches: &ArgMatches<'_>,
 | 
				
			||||||
        name: &str,
 | 
					        name: &str,
 | 
				
			||||||
        signers: Option<&[(Pubkey, Signature)]>,
 | 
					        signers: Option<&[(Pubkey, Signature)]>,
 | 
				
			||||||
    ) -> Result<Self, CliError> {
 | 
					    ) -> Result<Option<Self>, CliError> {
 | 
				
			||||||
        keypair_of(matches, name)
 | 
					        if matches.is_present(name) {
 | 
				
			||||||
            .map(|keypair| keypair.into())
 | 
					            keypair_of(matches, name)
 | 
				
			||||||
            .or_else(|| {
 | 
					                .map(|keypair| keypair.into())
 | 
				
			||||||
                pubkey_of(matches, name)
 | 
					                .or_else(|| {
 | 
				
			||||||
                    .filter(|pubkey| {
 | 
					                    pubkey_of(matches, name)
 | 
				
			||||||
                        signers
 | 
					                        .filter(|pubkey| {
 | 
				
			||||||
                            .and_then(|signers| {
 | 
					                            signers
 | 
				
			||||||
                                signers.iter().find(|(signer, _sig)| *signer == *pubkey)
 | 
					                                .and_then(|signers| {
 | 
				
			||||||
                            })
 | 
					                                    signers.iter().find(|(signer, _sig)| *signer == *pubkey)
 | 
				
			||||||
                            .is_some()
 | 
					                                })
 | 
				
			||||||
                    })
 | 
					                                .is_some()
 | 
				
			||||||
                    .map(|pubkey| pubkey.into())
 | 
					                        })
 | 
				
			||||||
            })
 | 
					                        .map(|pubkey| pubkey.into())
 | 
				
			||||||
            .ok_or_else(|| CliError::BadParameter("Invalid authority".to_string()))
 | 
					                })
 | 
				
			||||||
 | 
					                .ok_or_else(|| CliError::BadParameter("Invalid authority".to_string()))
 | 
				
			||||||
 | 
					                .map(Some)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Ok(None)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn keypair(&self) -> &Keypair {
 | 
					    pub fn keypair(&self) -> &Keypair {
 | 
				
			||||||
@@ -609,15 +614,11 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
 | 
				
			|||||||
            let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
 | 
					            let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
 | 
				
			||||||
            let blockhash_query = BlockhashQuery::new_from_matches(&matches);
 | 
					            let blockhash_query = BlockhashQuery::new_from_matches(&matches);
 | 
				
			||||||
            let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
					            let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
				
			||||||
            let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					            let nonce_authority = SigningAuthority::new_from_matches(
 | 
				
			||||||
                Some(SigningAuthority::new_from_matches(
 | 
					                &matches,
 | 
				
			||||||
                    &matches,
 | 
					                NONCE_AUTHORITY_ARG.name,
 | 
				
			||||||
                    NONCE_AUTHORITY_ARG.name,
 | 
					                signers.as_deref(),
 | 
				
			||||||
                    signers.as_deref(),
 | 
					            )?;
 | 
				
			||||||
                )?)
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                None
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Ok(CliCommandInfo {
 | 
					            Ok(CliCommandInfo {
 | 
				
			||||||
                command: CliCommand::Pay(PayCommand {
 | 
					                command: CliCommand::Pay(PayCommand {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -234,15 +234,8 @@ impl NonceSubCommands for App<'_, '_> {
 | 
				
			|||||||
pub fn parse_authorize_nonce_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
 | 
					pub fn parse_authorize_nonce_account(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
 | 
				
			||||||
    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
					    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
				
			||||||
    let new_authority = pubkey_of(matches, "new_authority").unwrap();
 | 
					    let new_authority = pubkey_of(matches, "new_authority").unwrap();
 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					    let nonce_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, None)?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            None,
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::AuthorizeNonceAccount {
 | 
					        command: CliCommand::AuthorizeNonceAccount {
 | 
				
			||||||
@@ -282,15 +275,8 @@ pub fn parse_get_nonce(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliEr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn parse_new_nonce(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
 | 
					pub fn parse_new_nonce(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
 | 
				
			||||||
    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
					    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					    let nonce_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, None)?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            None,
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::NewNonce {
 | 
					        command: CliCommand::NewNonce {
 | 
				
			||||||
@@ -320,15 +306,8 @@ pub fn parse_withdraw_from_nonce_account(
 | 
				
			|||||||
    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
					    let nonce_account = pubkey_of(matches, "nonce_account_keypair").unwrap();
 | 
				
			||||||
    let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
 | 
					    let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
 | 
				
			||||||
    let lamports = required_lamports_from(matches, "amount", "unit")?;
 | 
					    let lamports = required_lamports_from(matches, "amount", "unit")?;
 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					    let nonce_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, None)?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            None,
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::WithdrawFromNonceAccount {
 | 
					        command: CliCommand::WithdrawFromNonceAccount {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -354,24 +354,10 @@ pub fn parse_stake_delegate_stake(matches: &ArgMatches<'_>) -> Result<CliCommand
 | 
				
			|||||||
    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
					    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
				
			||||||
    let require_keypair = signers.is_none();
 | 
					    let require_keypair = signers.is_none();
 | 
				
			||||||
    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
					    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
				
			||||||
    let stake_authority = if matches.is_present(STAKE_AUTHORITY_ARG.name) {
 | 
					    let stake_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, STAKE_AUTHORITY_ARG.name, signers.as_deref())?;
 | 
				
			||||||
            &matches,
 | 
					    let nonce_authority =
 | 
				
			||||||
            STAKE_AUTHORITY_ARG.name,
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, signers.as_deref())?;
 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::DelegateStake {
 | 
					        command: CliCommand::DelegateStake {
 | 
				
			||||||
@@ -401,26 +387,12 @@ pub fn parse_stake_authorize(
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
    let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
 | 
					    let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
 | 
				
			||||||
    let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
 | 
					    let signers = pubkeys_sigs_of(&matches, SIGNER_ARG.name);
 | 
				
			||||||
    let authority = if matches.is_present(authority_flag) {
 | 
					    let authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, authority_flag, signers.as_deref())?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            authority_flag,
 | 
					 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
					    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
				
			||||||
    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
					    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					    let nonce_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, signers.as_deref())?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::StakeAuthorize {
 | 
					        command: CliCommand::StakeAuthorize {
 | 
				
			||||||
@@ -445,24 +417,10 @@ pub fn parse_stake_deactivate_stake(matches: &ArgMatches<'_>) -> Result<CliComma
 | 
				
			|||||||
    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
					    let blockhash_query = BlockhashQuery::new_from_matches(matches);
 | 
				
			||||||
    let require_keypair = signers.is_none();
 | 
					    let require_keypair = signers.is_none();
 | 
				
			||||||
    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
					    let nonce_account = pubkey_of(&matches, NONCE_ARG.name);
 | 
				
			||||||
    let stake_authority = if matches.is_present(STAKE_AUTHORITY_ARG.name) {
 | 
					    let stake_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, STAKE_AUTHORITY_ARG.name, signers.as_deref())?;
 | 
				
			||||||
            &matches,
 | 
					    let nonce_authority =
 | 
				
			||||||
            STAKE_AUTHORITY_ARG.name,
 | 
					        SigningAuthority::new_from_matches(&matches, NONCE_AUTHORITY_ARG.name, signers.as_deref())?;
 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    let nonce_authority = if matches.is_present(NONCE_AUTHORITY_ARG.name) {
 | 
					 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            NONCE_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            signers.as_deref(),
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::DeactivateStake {
 | 
					        command: CliCommand::DeactivateStake {
 | 
				
			||||||
@@ -482,15 +440,8 @@ pub fn parse_stake_withdraw_stake(matches: &ArgMatches<'_>) -> Result<CliCommand
 | 
				
			|||||||
    let stake_account_pubkey = pubkey_of(matches, "stake_account_pubkey").unwrap();
 | 
					    let stake_account_pubkey = pubkey_of(matches, "stake_account_pubkey").unwrap();
 | 
				
			||||||
    let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
 | 
					    let destination_account_pubkey = pubkey_of(matches, "destination_account_pubkey").unwrap();
 | 
				
			||||||
    let lamports = required_lamports_from(matches, "amount", "unit")?;
 | 
					    let lamports = required_lamports_from(matches, "amount", "unit")?;
 | 
				
			||||||
    let withdraw_authority = if matches.is_present(WITHDRAW_AUTHORITY_ARG.name) {
 | 
					    let withdraw_authority =
 | 
				
			||||||
        Some(SigningAuthority::new_from_matches(
 | 
					        SigningAuthority::new_from_matches(&matches, WITHDRAW_AUTHORITY_ARG.name, None)?;
 | 
				
			||||||
            &matches,
 | 
					 | 
				
			||||||
            WITHDRAW_AUTHORITY_ARG.name,
 | 
					 | 
				
			||||||
            None,
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        None
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(CliCommandInfo {
 | 
					    Ok(CliCommandInfo {
 | 
				
			||||||
        command: CliCommand::WithdrawStake {
 | 
					        command: CliCommand::WithdrawStake {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user