Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli-vault): command show to vaults by index #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cli/src/command/display_vault.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use squads_multisig::pda::get_vault_pda;
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;

use clap::Args;

#[derive(Args)]
pub struct DisplayVault {
/// Multisig Program ID
#[arg(long)]
program_id: Option<String>,

/// Path to the Program Config Initializer Keypair
#[arg(long)]
multisig_address: String,

// index to derive the vault, default 0
#[arg(long)]
vault_index: Option<u8>,
}

impl DisplayVault {
pub async fn execute(self) -> eyre::Result<()> {
let Self {
program_id,
multisig_address,
vault_index,
} = self;

let program_id = program_id.unwrap_or_else(|| {
"SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf".to_string()
});

let program_id = Pubkey::from_str(&program_id).expect("Invalid program ID");

let multisig_address = Pubkey::from_str(&multisig_address).expect("Invalid multisig address");

let vault_index = vault_index.unwrap_or(0);

let vault_address = get_vault_pda(&multisig_address, vault_index, Some(&program_id));

println!("Vault: {:?}", vault_address);

Ok(())
}
}
3 changes: 3 additions & 0 deletions cli/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::command::proposal_vote::ProposalVote;
use crate::command::vault_transaction_accounts_close::VaultTransactionAccountsClose;
use crate::command::vault_transaction_create::VaultTransactionCreate;
use crate::command::vault_transaction_execute::VaultTransactionExecute;
use crate::command::display_vault::DisplayVault;

use clap::Subcommand;

Expand All @@ -21,6 +22,7 @@ pub mod proposal_vote;
pub mod vault_transaction_accounts_close;
pub mod vault_transaction_create;
pub mod vault_transaction_execute;
pub mod display_vault;

#[derive(Subcommand)]
pub enum Command {
Expand All @@ -34,4 +36,5 @@ pub enum Command {
VaultTransactionAccountsClose(VaultTransactionAccountsClose),
InitiateTransfer(InitiateTransfer),
InitiateProgramUpgrade(InitiateProgramUpgrade),
DisplayVault(DisplayVault),
}
1 change: 1 addition & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ async fn main() -> eyre::Result<()> {
Command::VaultTransactionAccountsClose(command) => command.execute().await,
Command::InitiateTransfer(command) => command.execute().await,
Command::InitiateProgramUpgrade(command) => command.execute().await,
Command::DisplayVault(command) => command.execute().await,
}
}
Loading