-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add callex cmd with user-friendly params (#16)
- Function parameters must be defined in the form: --name value. Without quotes. - Integer parameter can be suffixed with `T`. Such parameter is automatically converted to nanovalue. - Array of integers can be defined without brackets `[]`. - [ADDRESS] [ABI] and [SIGN] positional parameters of `callex` commands can be omitted and in that case default values will be used from config file.
- Loading branch information
Showing
6 changed files
with
233 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
pub fn convert_token(amount: &str) -> Result<String, String> { | ||
let parts: Vec<&str> = amount.split(".").collect(); | ||
if parts.len() >= 1 && parts.len() <= 2 { | ||
let mut result = String::new(); | ||
result += parts[0]; | ||
if parts.len() == 2 { | ||
let fraction = format!("{:0<9}", parts[1]); | ||
if fraction.len() != 9 { | ||
return Err("invalid fractional part".to_string()); | ||
} | ||
result += &fraction; | ||
} else { | ||
result += "000000000"; | ||
} | ||
u64::from_str_radix(&result, 10) | ||
.map_err(|e| format!("failed to parse amount: {}", e))?; | ||
|
||
return Ok(result); | ||
} | ||
Err("Invalid amout value".to_string()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters