Skip to content
Merged
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
7 changes: 6 additions & 1 deletion clients/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use {
create_mint::{command_create_mint, CreateMintArgs},
find_pdas::{command_get_pdas, FindPdasArgs},
output::parse_output_format,
unwrap::{command_unwrap, UnwrapArgs},
wrap::{command_wrap, WrapArgs},
CommandResult,
},
Expand Down Expand Up @@ -87,9 +88,12 @@ pub struct Cli {
pub enum Command {
/// Create a wrapped mint for a given SPL Token
CreateMint(CreateMintArgs),
/// Escrow SPL tokens and mint their wrapped version
Wrap(WrapArgs),
/// Find the PDA addresses associated with unwrapped mints
FindPdas(FindPdasArgs),
// TODO: Unwrap
/// Convert wrapped tokens back into their original unwrapped version
Unwrap(UnwrapArgs),
}

impl Command {
Expand All @@ -103,6 +107,7 @@ impl Command {
Command::CreateMint(args) => command_create_mint(config, args).await,
Command::Wrap(args) => command_wrap(config, args, matches, wallet_manager).await,
Command::FindPdas(args) => command_get_pdas(config, args).await,
Command::Unwrap(args) => command_unwrap(config, args, matches, wallet_manager).await,
}
}
}
16 changes: 16 additions & 0 deletions clients/cli/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ use {
crate::{config::Config, output::println_display, Error},
clap::ArgMatches,
solana_clap_v3_utils::keypair::pubkey_from_path,
solana_client::nonblocking::rpc_client::RpcClient,
solana_presigner::Presigner,
solana_pubkey::Pubkey,
solana_signature::Signature,
solana_transaction::Transaction,
spl_token_2022::{extension::PodStateWithExtensions, pod::PodAccount},
std::str::FromStr,
};

Expand Down Expand Up @@ -71,3 +73,17 @@ pub async fn process_transaction(
))
}
}

pub async fn get_mint_for_token_account(
rpc_client: &RpcClient,
token_account_address: &Pubkey,
) -> Result<Pubkey, Error> {
let token_account_info = rpc_client.get_account(token_account_address).await?;
let unpacked_account = PodStateWithExtensions::<PodAccount>::unpack(&token_account_info.data)?;
Ok(unpacked_account.base.mint)
}

pub async fn get_account_owner(rpc_client: &RpcClient, account: &Pubkey) -> Result<Pubkey, Error> {
let owner = rpc_client.get_account(account).await?.owner;
Ok(owner)
}
1 change: 1 addition & 0 deletions clients/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod config;
mod create_mint;
mod find_pdas;
mod output;
mod unwrap;
mod wrap;

use {
Expand Down
Loading