Merge pull request #3 from zcash-hackworks/ux-improvements

UX improvements
This commit is contained in:
str4d 2023-07-07 00:07:42 +01:00 committed by GitHub
commit 1c9b81a0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 4 deletions

99
Cargo.lock generated
View File

@ -1065,6 +1065,15 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "matchit"
version = "0.7.0"
@ -1159,6 +1168,16 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7"
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-bigint"
version = "0.4.3"
@ -1254,6 +1273,12 @@ dependencies = [
"zcash_note_encryption",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "pairing"
version = "0.23.0"
@ -1582,9 +1607,24 @@ version = "1.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
dependencies = [
"regex-syntax",
"regex-syntax 0.7.2",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.7.2"
@ -1828,6 +1868,15 @@ dependencies = [
"digest 0.10.7",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "slab"
version = "0.4.8"
@ -1997,6 +2046,16 @@ dependencies = [
"syn 2.0.23",
]
[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if",
"once_cell",
]
[[package]]
name = "time"
version = "0.2.27"
@ -2232,6 +2291,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
@ -2295,6 +2384,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
@ -2655,6 +2750,8 @@ dependencies = [
"secrecy",
"tokio",
"tonic",
"tracing",
"tracing-subscriber",
"zcash_client_backend",
"zcash_client_sqlite",
"zcash_primitives",

View File

@ -15,6 +15,8 @@ schemer = "0.2"
secrecy = "0.8"
tokio = { version = "1.21.0", features = ["fs", "macros", "rt-multi-thread"] }
tonic = { version = "0.9", features = ["gzip", "tls-webpki-roots"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
zcash_client_backend = { version = "0.9", features = ["lightwalletd-tonic"] }
zcash_client_sqlite = { version = "0.7", features = ["unstable"] }
zcash_primitives = "0.11"

View File

@ -24,18 +24,20 @@ impl Command {
let address = db_data
.get_current_address(account)?
.ok_or(error::Error::InvalidRecipient)?;
let (balance, verified_balance) = {
let (height, balance, verified_balance) = {
let (target_height, anchor_height) = db_data
.get_target_and_anchor_heights(MIN_CONFIRMATIONS)?
.ok_or(error::WalletErrorT::ScanRequired)
.map_err(|e| anyhow!("{:?}", e))?;
(
target_height,
db_data.get_balance_at(account, target_height)?,
db_data.get_balance_at(account, anchor_height)?,
)
};
println!("{}", address.encode(&params));
println!(" Height: {}", height);
println!(" Balance: {} zatoshis", u64::from(balance));
println!(" Verified: {} zatoshis", u64::from(verified_balance));

View File

@ -31,10 +31,10 @@ use crate::{
// Options accepted for the `send` command
#[derive(Debug, Options)]
pub(crate) struct Command {
#[options(help = "the recipient's Sapling or transparent address")]
#[options(required, help = "the recipient's Sapling or transparent address")]
address: String,
#[options(help = "the amount in zatoshis")]
#[options(required, help = "the amount in zatoshis")]
value: u64,
}

View File

@ -3,6 +3,8 @@
//! This is **NOT IMPLEMENTED SECURELY**, and it is not written to be efficient or usable!
//! It is only intended to show the overall light client workflow using this crate.
use std::env;
use gumdrop::Options;
use zcash_primitives::consensus::TEST_NETWORK;
@ -47,6 +49,10 @@ enum Command {
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let opts = MyOptions::parse_args_default_or_exit();
let filter = env::var("RUST_LOG").unwrap_or_else(|_| "info".to_owned());
tracing_subscriber::fmt().with_env_filter(filter).init();
let params = TEST_NETWORK;
match opts.command {