Skip to content

Commit

Permalink
Add the max_uint subcommand to cast and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hammeiam committed Dec 13, 2021
1 parent e1b4408 commit 4882d8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,21 @@ impl SimpleCast {
Ok(U256::from_str(hex)?)
}

/// Returns maximum U256 value
///
/// ```
/// use cast::SimpleCast as Cast;
/// use ethers_core::types::U256;
///
/// fn main() -> eyre::Result<()> {
/// assert_eq!(U256::MAX, Cast::max_uint()?);
///
/// Ok(())
/// }
pub fn max_uint() -> Result<U256> {
Ok(U256::MAX)
}

/// Converts integers with specified decimals into fixed point numbers
///
/// ```
Expand Down
3 changes: 3 additions & 0 deletions cli/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ async fn main() -> eyre::Result<()> {

let opts = Opts::from_args();
match opts.sub {
Subcommands::MaxUint { } => {
println!("{}", SimpleCast::max_uint()?);
}
Subcommands::FromUtf8 { text } => {
let val = unwrap_or_stdin(text)?;
println!("{}", SimpleCast::from_utf8(&val));
Expand Down
3 changes: 3 additions & 0 deletions cli/src/cast_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(about = "Perform Ethereum RPC calls from the comfort of your command line.")]
pub enum Subcommands {
#[structopt(name = "--max-uint")]
#[structopt(about = "maximum u256 value")]
MaxUint { },
#[structopt(aliases = &["--from-ascii"])]
#[structopt(name = "--from-utf8")]
#[structopt(about = "convert text data into hexdata")]
Expand Down

0 comments on commit 4882d8d

Please sign in to comment.