diff --git a/cast/src/lib.rs b/cast/src/lib.rs index 07b86be3f6777..f937f8a834252 100644 --- a/cast/src/lib.rs +++ b/cast/src/lib.rs @@ -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 { + Ok(U256::MAX) + } + /// Converts integers with specified decimals into fixed point numbers /// /// ``` diff --git a/cli/src/cast.rs b/cli/src/cast.rs index 1fc224267bab5..f0a5dfc3b474a 100644 --- a/cli/src/cast.rs +++ b/cli/src/cast.rs @@ -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)); diff --git a/cli/src/cast_opts.rs b/cli/src/cast_opts.rs index 6bacea86feedb..a41f013d1fdf5 100644 --- a/cli/src/cast_opts.rs +++ b/cli/src/cast_opts.rs @@ -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")]