-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP feat: Seth command parity pt. 1 #14
Conversation
Looks like there isn't a way to get localized timezone in Rust?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. Some nits.
dapptools/src/seth.rs
Outdated
unwrap_or_stdin(decimals)?, | ||
unwrap_or_stdin(value)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double stdin args don't work I believe, so best to make the first argument the stdin one, to be consistent with seth.
dapptools/src/seth_opts.rs
Outdated
ToDec { hexvalue: String }, | ||
#[structopt(name = "--to-fix")] | ||
#[structopt(about = "convert integers into fixed point with specified decimals")] | ||
ToFix { decimals: Option<u128>, value: Option<u128> }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I tested OG seth and you can only do echo 1 | seth --to-fix 3
(outputs 0.001
), double stdin doesn't work so only have value
being Option
and have decimals be mandatory
pub fn namehash(ens: &str) -> Result<String> { | ||
let mut node = vec![0u8; 32]; | ||
|
||
if !ens.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use this upstream function instead of re-implementing it.
/// Ok(()) | ||
/// } | ||
/// ``` | ||
pub fn to_wei(value: u128, unit: String) -> Result<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a command called format_units
and parse_units
which calls back to ethers::utils::{parse_units, format_units}
? Maybe for the next PR.
let mut ascii = String::new(); | ||
for letter in iter.collect::<Vec<_>>() { | ||
ascii.push(letter.unwrap() as char); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of something you'd do with fold
For gas-price, I think it would be useful to return both the value from the provider and the one from Bonus points for some coloring in the return values. I made a similar PR in daptools OG and would be happy to port it here. The end game is to use this command + |
Adds more Seth commands:
seth: --to-fix
seth block-number
seth basefee
seth chain-id
seth age
seth namehash
seth keccak
seth gas-price
seth chain
seth --to-wei
seth --to-uint256
seth --to-dec
seth --to-ascii