Skip to content

Commit

Permalink
cli: Add subcommands for address lookup tables (solana-labs#27123)
Browse files Browse the repository at this point in the history
* cli: Add subcommand for creating address lookup tables

* cli: Add additional subcommands for address lookup tables

* short commands
  • Loading branch information
jstarry authored and haoran committed Aug 21, 2022
1 parent cfab5c5 commit 471ae90
Show file tree
Hide file tree
Showing 8 changed files with 1,135 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

69 changes: 69 additions & 0 deletions cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,75 @@ impl fmt::Display for CliUpgradeableBuffers {
}
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct CliAddressLookupTable {
pub lookup_table_address: String,
pub authority: Option<String>,
pub deactivation_slot: u64,
pub last_extended_slot: u64,
pub addresses: Vec<String>,
}
impl QuietDisplay for CliAddressLookupTable {}
impl VerboseDisplay for CliAddressLookupTable {}
impl fmt::Display for CliAddressLookupTable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f)?;
writeln_name_value(f, "Lookup Table Address:", &self.lookup_table_address)?;
if let Some(authority) = &self.authority {
writeln_name_value(f, "Authority:", authority)?;
} else {
writeln_name_value(f, "Authority:", "None (frozen)")?;
}
if self.deactivation_slot == u64::MAX {
writeln_name_value(f, "Deactivation Slot:", "None (still active)")?;
} else {
writeln_name_value(f, "Deactivation Slot:", &self.deactivation_slot.to_string())?;
}
if self.last_extended_slot == 0 {
writeln_name_value(f, "Last Extended Slot:", "None (empty)")?;
} else {
writeln_name_value(
f,
"Last Extended Slot:",
&self.last_extended_slot.to_string(),
)?;
}
if self.addresses.is_empty() {
writeln_name_value(f, "Address Table Entries:", "None (empty)")?;
} else {
writeln!(f, "{}", style("Address Table Entries:".to_string()).bold())?;
writeln!(f)?;
writeln!(
f,
"{}",
style(format!(" {:<5} {}", "Index", "Address")).bold()
)?;
for (index, address) in self.addresses.iter().enumerate() {
writeln!(f, " {:<5} {}", index, address)?;
}
}
Ok(())
}
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CliAddressLookupTableCreated {
pub lookup_table_address: String,
pub signature: String,
}
impl QuietDisplay for CliAddressLookupTableCreated {}
impl VerboseDisplay for CliAddressLookupTableCreated {}
impl fmt::Display for CliAddressLookupTableCreated {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f)?;
writeln_name_value(f, "Signature:", &self.signature)?;
writeln_name_value(f, "Lookup Table Address:", &self.lookup_table_address)?;
Ok(())
}
}

#[derive(Debug, Default)]
pub struct ReturnSignersConfig {
pub dump_transaction_message: bool,
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde = "1.0.143"
serde_derive = "1.0.103"
serde_json = "1.0.83"
solana-account-decoder = { path = "../account-decoder", version = "=1.12.0" }
solana-address-lookup-table-program = { path = "../programs/address-lookup-table", version = "=1.12.0" }
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.12.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.12.0" }
solana-cli-config = { path = "../cli-config", version = "=1.12.0" }
Expand Down
Loading

0 comments on commit 471ae90

Please sign in to comment.