Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ orchard_new = "0.10.1"
orchard_old = "=0.3.0"
sapling = { version = "0.3", default-features = false }
zewif = { version = "0.0.2", package = "zingolabs-zewif" }
zingolib = { version = "0.0.1" }
pepper-sync = { version = "0.0.1" }
zingolib = { git = "https://github.com/zingolabs/zingolib.git", rev = "a9b66315b853c9084008d51e149d2572954aba8e" }
pepper-sync = { git = "https://github.com/zingolabs/zingolib.git", rev = "a9b66315b853c9084008d51e149d2572954aba8e", package = "pepper-sync" }
1 change: 1 addition & 0 deletions zexcavator-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ prost = { workspace = true }
incrementalmerkletree = { workspace = true }
orchard_old = { package = "orchard", version = "=0.3.0" }
orchard_new = { package = "orchard", version = "0.10.1" }
zip32 = "0.2.0"
4 changes: 2 additions & 2 deletions zexcavator-tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod components;
mod views;
mod walletparsers;
use app::model::Model;
use zingolib::lightclient::PoolBalances;
use zingolib::wallet::balance::AccountBalance;
mod constants;

#[derive(Debug, PartialEq)]
Expand All @@ -39,7 +39,7 @@ pub enum Msg {
FromPathSubmit,
GoToResult,
InitializeLightClient,
BalanceReady(PoolBalances),
BalanceReady(AccountBalance),
FetchBalance,
None,
}
Expand Down
26 changes: 18 additions & 8 deletions zexcavator-tui/src/views/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ pub mod send;
pub mod zewif;
pub mod zingolib;

use std::num::NonZero;
use std::sync::Arc;

use ::zingolib::lightclient::{LightClient, PoolBalances};
use ::zingolib::lightclient::LightClient;
use ::zingolib::wallet::balance::AccountBalance;
use tokio::sync::RwLock;
use tuirealm::command::CmdResult;
use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
Expand Down Expand Up @@ -46,7 +48,7 @@ impl MenuOptions for ExportOptions {
#[derive(Debug, Clone)]
pub struct ExportView {
pub light_client: Arc<RwLock<Option<LightClient>>>,
pub balance: Arc<RwLock<Option<PoolBalances>>>,
pub balance: Arc<RwLock<Option<AccountBalance>>>,
pub menu: Menu<ExportOptions>,
}

Expand All @@ -59,10 +61,16 @@ impl ExportView {
}
}

pub async fn load_balance(&self) -> Option<PoolBalances> {
pub async fn load_balance(&self) -> Option<AccountBalance> {
let mut client_guard = self.light_client.write().await;
let client = client_guard.as_mut()?;
let b = client.do_balance().await;
let b = client
.wallet
.lock()
.await
.account_balance(zip32::AccountId::try_from(0).unwrap())
.await
.unwrap();
self.balance.try_write().unwrap().replace(b.clone());
drop(client_guard);
Some(b)
Expand All @@ -84,10 +92,12 @@ impl MockComponent for ExportView {
balance = balance_guard.clone().unwrap();
}

let total_balance = balance.confirmed_transparent_balance.unwrap_or(0)
+ balance.verified_sapling_balance.unwrap_or(0)
+ balance.verified_orchard_balance.unwrap_or(0);
let text = format!("Total ZEC found: {:}", total_balance);
let final_balance = balance.total_transparent_balance.unwrap()
+ balance.total_sapling_balance.unwrap()
+ balance.total_orchard_balance.unwrap();
let balance_in_zec = final_balance.unwrap() / NonZero::new(10u64.pow(8)).unwrap();

let text = format!("Total ZEC found: {:}", balance_in_zec.into_u64());
let para =
Paragraph::new(text).block(Block::default().borders(Borders::ALL).title("Balance"));
frame.render_widget(para, chunks[0]);
Expand Down
32 changes: 3 additions & 29 deletions zexcavator-tui/src/views/export/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,23 @@ use tuirealm::event::{Key, KeyEvent};
use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
use tuirealm::ratatui::widgets::{Block, Borders, Paragraph};
use tuirealm::{Component, Frame, MockComponent, NoUserEvent, State};
use zingolib::lightclient::{LightClient, PoolBalances};
use zingolib::lightclient::LightClient;
use zingolib::wallet::balance::AccountBalance;

use crate::Msg;
use crate::app::model::HasScreenAndQuit;
use crate::components::HandleMessage;

// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
// pub enum ExportOptions {
// ZeWIF,
// Send,
// }

// impl MenuOptions for ExportOptions {
// fn all() -> Vec<Self>
// where
// Self: Sized,
// {
// vec![Self::ZeWIF, Self::Send]
// }

// fn label(&self) -> &'static str {
// match self {
// Self::ZeWIF => "ZeWIF",
// Self::Send => "Send",
// }
// }
// }

#[derive(Debug, Clone)]
pub struct ExportSendView {
// pub light_client: Arc<RwLock<Option<LightClient>>>,
pub balance: Arc<RwLock<Option<PoolBalances>>>,
// pub menu: Menu<ExportOptions>,
pub balance: Arc<RwLock<Option<AccountBalance>>>,
}

impl ExportSendView {
pub fn new(_light_client: Arc<RwLock<Option<LightClient>>>) -> Self {
Self {
// light_client,
balance: Arc::new(RwLock::new(None)),
// menu: Menu::new("Choose an export option"),
}
}
}
Expand All @@ -64,8 +40,6 @@ impl MockComponent for ExportSendView {
Paragraph::new(text).block(Block::default().borders(Borders::ALL).title("Balance"));
frame.render_widget(para, chunks[0]);
}

// self.menu.view(frame, chunks[1]);
}

fn query(&self, _attr: tuirealm::Attribute) -> Option<tuirealm::AttrValue> {
Expand Down
2 changes: 1 addition & 1 deletion zexcavator-tui/src/views/export/zewif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl ExportZewifView {
let export_height = get_latest_block(lc.get_server_uri()).await.unwrap().height as u32;
drop(guard);

let (m, _) = mnemonic.unwrap();
let m = mnemonic.unwrap();

let path = ExportZewifView::export_to_zewif(Some(m), export_height);

Expand Down
1 change: 0 additions & 1 deletion zexcavator-tui/src/views/export/zingolib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl ExportZingolibView {
let network = lw_guard.network;
lw_guard
.write(&mut buf, &network)
.await
.context("failed to serialize LightWallet")?;
}

Expand Down
Loading