Skip to content

Commit

Permalink
cleanup args and help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
HardhatChad committed Aug 9, 2024
1 parent 89f59e7 commit dda287c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
30 changes: 8 additions & 22 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use clap::{arg, Parser};
#[derive(Parser, Debug)]
pub struct BalanceArgs {
#[arg(
long,
value_name = "ADDRESS",
help = "The address of the account to fetch the balance of"
help = "The account address to fetch the balance of"
)]
pub address: Option<String>,
}
Expand All @@ -28,7 +27,6 @@ pub struct BussesArgs {}
#[derive(Parser, Debug)]
pub struct ClaimArgs {
#[arg(
long,
value_name = "AMOUNT",
help = "The amount of rewards to claim. Defaults to max."
)]
Expand All @@ -37,7 +35,7 @@ pub struct ClaimArgs {
#[arg(
long,
value_name = "WALLET_ADDRESS",
help = "Wallet to receive claimed tokens."
help = "Wallet address to receive claimed tokens."
)]
pub to: Option<String>,
}
Expand Down Expand Up @@ -75,11 +73,7 @@ pub struct MineArgs {

#[derive(Parser, Debug)]
pub struct ProofArgs {
#[arg(
index = 0,
value_name = "ADDRESS",
help = "The address of the proof to fetch"
)]
#[arg(value_name = "ADDRESS", help = "The address of the proof to fetch")]
pub address: Option<String>,
}

Expand All @@ -89,32 +83,25 @@ pub struct RewardsArgs {}
#[derive(Parser, Debug)]
pub struct StakeArgs {
#[arg(
long,
value_name = "AMOUNT",
help = "The amount of Ore to stake. Defaults to max."
help = "The amount of ORE to stake. Defaults to max."
)]
pub amount: Option<f64>,

#[arg(
long,
value_name = "TOKEN_ACCOUNT_ADDRESS",
help = "Token account to send Ore from."
help = "Token account to send ORE from. Defaults to the associated token account."
)]
pub sender: Option<String>,
pub token_account: Option<String>,
}

#[derive(Parser, Debug)]
pub struct TransferArgs {
#[arg(
index = 0,
value_name = "AMOUNT",
help = "The amount of ORE to transfer.",
required = true
)]
#[arg(value_name = "AMOUNT", help = "The amount of ORE to transfer.")]
pub amount: f64,

#[arg(
index = 1,
value_name = "WALLET_ADDRESS",
help = "The wallet address of the receipient."
)]
Expand All @@ -124,9 +111,8 @@ pub struct TransferArgs {
#[derive(Parser, Debug)]
pub struct UpgradeArgs {
#[arg(
long,
value_name = "AMOUNT",
help = "The amount of Ore to upgrade from v1 to v2. Defaults to max."
help = "The amount of ORE to upgrade from v1 to v2. Defaults to max."
)]
pub amount: Option<f64>,
}
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ struct Args {
#[arg(
long,
value_name = "KEYPAIR_FILEPATH",
help = "Filepath to keypair to use.",
help = "Filepath to signer keypair.",
global = true
)]
keypair: Option<String>,

#[arg(
long,
value_name = "FEE_PAYER_FILEPATH",
help = "Filepath to keypair to use as transaction fee payer.",
help = "Filepath to transaction fee payer keypair.",
global = true
)]
fee_payer: Option<String>,

#[arg(
long,
value_name = "MICROLAMPORTS",
help = "Price to pay for compute units. If dynamic fees are being used, this value will be the max.",
help = "Price to pay for compute units. If dynamic fees are enabled, this value will be used as the cap.",
default_value = "500000",
global = true
)]
Expand All @@ -134,7 +134,7 @@ struct Args {
)]
dynamic_fee_url: Option<String>,

#[arg(long, help = "Use dynamic priority fees", global = true)]
#[arg(long, help = "Enable dynamic priority fees", global = true)]
dynamic_fee: bool,

#[command(subcommand)]
Expand Down
6 changes: 4 additions & 2 deletions src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ impl Miner {
pub async fn stake(&self, args: StakeArgs) {
// Get signer
let signer = self.signer();
let sender = match args.sender {
Some(sender) => Pubkey::from_str(&sender).expect("Failed to parse sender address"),
let sender = match args.token_account {
Some(address) => {
Pubkey::from_str(&address).expect("Failed to parse token account address")
}
None => spl_associated_token_account::get_associated_token_address(
&signer.pubkey(),
&ore_api::consts::MINT_ADDRESS,
Expand Down

0 comments on commit dda287c

Please sign in to comment.