Skip to content

Commit 3f8b513

Browse files
committed
Squash
1 parent 0f16fd2 commit 3f8b513

File tree

8 files changed

+641
-24
lines changed

8 files changed

+641
-24
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
.DS_Store
1818
*/**/.DS_Store
1919

20-
.vscode
20+
.vscode
21+
22+
*/tape.*.toml
23+
tape.*.toml

Cargo.lock

Lines changed: 86 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ mime = "0.3"
6969
mime_guess = "2.0"
7070
log = "0.4"
7171
env_logger = "0.11"
72+
shellexpand = "2.1.0"
7273

7374
# network-specific
7475
futures = "0.3"
@@ -82,6 +83,7 @@ hyper = { version = "1.6.0", features = ["http1", "server"] }
8283
hyper-util = { version = "0.1", features = ["tokio"] }
8384
lazy_static = "1.5.0"
8485
http-body-util = "0.1.3"
86+
toml = "0.9.5"
8587

8688
[patch.crates-io]
8789

cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tape-network.workspace = true
2222

2323
anyhow.workspace = true
2424
chrono.workspace = true
25+
serde.workspace = true
2526
serde_json.workspace = true
2627
clap.workspace = true
2728
colored.workspace = true
@@ -35,6 +36,8 @@ num_enum.workspace = true
3536
log.workspace = true
3637
env_logger.workspace = true
3738
num_cpus.workspace = true
39+
toml.workspace = true
40+
shellexpand.workspace = true
3841

3942
mime.workspace = true
4043
mime_guess.workspace = true

cli/src/cli.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use anyhow::Result;
22
use clap::{Parser, Subcommand};
33
use solana_client::nonblocking::rpc_client::RpcClient;
4-
use solana_sdk::commitment_config::CommitmentConfig;
54
use solana_sdk::signature::Keypair;
65
use tape_network::store::TapeStore;
76
use std::env;
@@ -10,6 +9,7 @@ use std::path::PathBuf;
109
use std::sync::Arc;
1110

1211
use crate::keypair::{get_keypair_path, get_payer};
12+
use crate::config::TapeConfig;
1313

1414
#[derive(Parser)]
1515
#[command(
@@ -22,18 +22,12 @@ pub struct Cli {
2222
#[command(subcommand)]
2323
pub command: Commands,
2424

25+
#[arg(short = 'c', long = "config", help = "Path to config file (overrides default)", global = true)]
26+
pub config_path: Option<PathBuf>,
27+
2528
#[arg(short = 'k', long = "keypair", global = true)]
2629
pub keypair_path: Option<PathBuf>,
2730

28-
#[arg(
29-
short = 'u',
30-
long = "cluster",
31-
default_value = "l",
32-
global = true,
33-
help = "Cluster to use: l (localnet), m (mainnet), d (devnet), t (testnet),\n or a custom RPC URL"
34-
)]
35-
pub cluster: Cluster,
36-
3731
#[arg(short = 'v', long = "verbose", help = "Print verbose output", global = true)]
3832
pub verbose: bool,
3933
}
@@ -236,13 +230,14 @@ pub struct Context {
236230
}
237231

238232
impl Context{
239-
pub fn try_build(cli:&Cli) -> Result<Self> {
240-
let rpc_url = cli.cluster.rpc_url();
233+
pub fn try_build(_cli:&Cli, config: &TapeConfig) -> Result<Self> {
234+
let rpc_url = config.solana.rpc_url.to_string();
235+
let commitment_level = config.solana.commitment.to_commitment_config();
241236
let rpc = Arc::new(
242237
RpcClient::new_with_commitment(rpc_url.clone(),
243-
CommitmentConfig::finalized())
238+
commitment_level)
244239
);
245-
let keypair_path = get_keypair_path(cli.keypair_path.clone());
240+
let keypair_path = get_keypair_path(Some(PathBuf::from(&*shellexpand::tilde(&config.identity.keypair_path))));
246241
let payer = get_payer(keypair_path.clone())?;
247242

248243
Ok(Self {

0 commit comments

Comments
 (0)