Skip to content

Commit

Permalink
cli: create alt authority-signer alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored and buffalojoec committed Nov 19, 2024
1 parent cfacde1 commit dec4542
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 41 deletions.
46 changes: 7 additions & 39 deletions cli/src/address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use {
pub enum AddressLookupTableCliCommand {
CreateLookupTable {
authority_pubkey: Pubkey,
authority_signer_index: Option<SignerIndex>,
payer_signer_index: SignerIndex,
},
FreezeLookupTable {
Expand Down Expand Up @@ -76,26 +75,12 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.arg(
Arg::with_name("authority")
.long("authority")
.alias("authority-signer")
.value_name("AUTHORITY_PUBKEY")
.takes_value(true)
.validator(is_pubkey)
.validator(is_pubkey_or_keypair)
.help(
"Lookup table authority address \
[default: the default configured keypair]. \
WARNING: Cannot be used for creating a lookup table for \
a cluster running v1.11 or earlier which requires the \
authority to sign for lookup table creation.",
),
)
.arg(
Arg::with_name("authority_signer")
.long("authority-signer")
.value_name("AUTHORITY_SIGNER")
.takes_value(true)
.conflicts_with("authority")
.validator(is_valid_signer)
.help(
"Lookup table authority keypair \
[default: the default configured keypair].",
),
)
Expand Down Expand Up @@ -278,12 +263,7 @@ pub fn parse_address_lookup_table_subcommand(
default_signer.signer_from_path(matches, wallet_manager)?,
)];

let authority_pubkey = if let Ok((authority_signer, Some(authority_pubkey))) =
signer_of(matches, "authority_signer", wallet_manager)
{
bulk_signers.push(authority_signer);
authority_pubkey
} else if let Some(authority_pubkey) = pubkey_of(matches, "authority") {
let authority_pubkey = if let Some(authority_pubkey) = pubkey_of(matches, "authority") {
authority_pubkey
} else {
default_signer
Expand Down Expand Up @@ -311,7 +291,6 @@ pub fn parse_address_lookup_table_subcommand(
command: CliCommand::AddressLookupTable(
AddressLookupTableCliCommand::CreateLookupTable {
authority_pubkey,
authority_signer_index: signer_info.index_of(Some(authority_pubkey)),
payer_signer_index: signer_info.index_of(payer_pubkey).unwrap(),
},
),
Expand Down Expand Up @@ -500,15 +479,10 @@ pub fn process_address_lookup_table_subcommand(
match subcommand {
AddressLookupTableCliCommand::CreateLookupTable {
authority_pubkey,
authority_signer_index,
payer_signer_index,
} => process_create_lookup_table(
&rpc_client,
config,
*authority_pubkey,
*authority_signer_index,
*payer_signer_index,
),
} => {
process_create_lookup_table(&rpc_client, config, *authority_pubkey, *payer_signer_index)
}
AddressLookupTableCliCommand::FreezeLookupTable {
lookup_table_pubkey,
authority_signer_index,
Expand Down Expand Up @@ -565,10 +539,8 @@ fn process_create_lookup_table(
rpc_client: &RpcClient,
config: &CliConfig,
authority_address: Pubkey,
authority_signer_index: Option<usize>,
payer_signer_index: usize,
) -> ProcessResult {
let authority_signer = authority_signer_index.map(|index| config.signers[index]);
let payer_signer = config.signers[payer_signer_index];

let get_clock_result = rpc_client
Expand All @@ -588,11 +560,7 @@ fn process_create_lookup_table(
Some(&config.signers[0].pubkey()),
));

let mut keypairs: Vec<&dyn Signer> = vec![config.signers[0], payer_signer];
if let Some(authority_signer) = authority_signer {
keypairs.push(authority_signer);
}

let keypairs: Vec<&dyn Signer> = vec![config.signers[0], payer_signer];
tx.try_sign(&keypairs, blockhash)?;
let result = rpc_client.send_and_confirm_transaction_with_spinner_and_config(
&tx,
Expand Down
2 changes: 0 additions & 2 deletions cli/tests/address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ fn test_cli_create_extend_and_freeze_address_lookup_table() {
config.command =
CliCommand::AddressLookupTable(AddressLookupTableCliCommand::CreateLookupTable {
authority_pubkey: keypair.pubkey(),
authority_signer_index: None,
payer_signer_index: 0,
});
let response: CliAddressLookupTableCreated =
Expand Down Expand Up @@ -158,7 +157,6 @@ fn test_cli_create_and_deactivate_address_lookup_table() {
config.command =
CliCommand::AddressLookupTable(AddressLookupTableCliCommand::CreateLookupTable {
authority_pubkey: keypair.pubkey(),
authority_signer_index: Some(0),
payer_signer_index: 0,
});
let response: CliAddressLookupTableCreated =
Expand Down

0 comments on commit dec4542

Please sign in to comment.