-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rs
59 lines (54 loc) · 1.63 KB
/
cli.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use clap::{Parser, Subcommand, ValueEnum};
use crate::constants::{DEFAULT_CHAIN, DEFAULT_TOKEN_ADDRESS}; // Import the constants
// Define the Chain enum
#[derive(ValueEnum, Clone, Debug)]
pub enum Chain {
Ethereum,
BinanceSmartChain,
Polygon,
Chiliz,
Arbitrum,
// More chains can be added here
}
// Implement the Chain enum
impl Chain {
pub fn rpc_env_var(&self) -> &'static str {
match self {
Chain::Ethereum => "ETH_RPC_URL",
Chain::BinanceSmartChain => "BSC_RPC_URL",
Chain::Polygon => "POLYGON_RPC_URL",
Chain::Chiliz => "CHILIZ_RPC_URL",
Chain::Arbitrum => "ARBITRUM_RPC_URL",
// Add more chains here
}
}
}
// Define the Cli struct
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[arg(short, long, value_enum, default_value_t = DEFAULT_CHAIN)] // Default chain is chiliz (lowercase)
pub chain: Chain,
#[arg(short, long, default_value_t = DEFAULT_TOKEN_ADDRESS.to_string())] // Provide a default token address
pub token_address: String, // Add token address as an argument
#[command(subcommand)]
pub command: Option<Commands>,
}
// Define the Commands enum
#[derive(Subcommand)]
pub enum Commands {
FetchTransfers {
#[arg(short, long)]
blocks_back: u64,
#[arg(short, long, num_args = 1.., value_delimiter = ',')]
addresses: Vec<String>,
},
FetchTransactionsBetween {
#[arg(short, long)]
from: String,
#[arg(short, long)]
to: String,
#[arg(short, long)]
blocks_back: u64,
},
}