Skip to content

Commit

Permalink
rusk-wallet: Remove requestty dependency and replace with Inquire
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksh14 committed Nov 13, 2024
1 parent a14109d commit ce86b10
Show file tree
Hide file tree
Showing 15 changed files with 470 additions and 563 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ humantime-serde = "=1.1.1"
hyper = "=1.4.1"
hyper-tungstenite = "=0.13.0"
hyper-util = "=0.1.9"
inquire = "=0.7.5"
konst = "=0.3.9"
lazy_static = "=1.5.0"
lru = "=0.12.4"
Expand All @@ -114,7 +115,6 @@ parking_lot = "=0.12.3"
pin-project = "=1.1.5"
rand = { version = "=0.8.5", default-features = false }
rand_chacha = { version = "=0.3.1", default-features = false }
requestty = "=0.5.0"
reqwest = "=0.12.7"
ringbuffer = "=0.15.0"
rkyv = { version = "=0.7.39", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions rusk-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ serde_json = { workspace = true }
hex = { workspace = true }
tiny-bip39 = { workspace = true }
crossterm = { workspace = true }
requestty = { workspace = true }
futures = { workspace = true }
base64 = { workspace = true }
blake3 = { workspace = true }
Expand Down Expand Up @@ -55,7 +54,7 @@ tracing-subscriber = { workspace = true, features = [
] }

rkyv = { workspace = true }

inquire = { workspace = true }
konst = { workspace = true }

[dev-dependencies]
Expand Down
33 changes: 18 additions & 15 deletions rusk-wallet/src/bin/command/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt::{self, Display};

use rusk_wallet::DecodedNote;
use rusk_wallet::{BlockTransaction, DecodedNote, GraphQL};

use execution_core::{dusk, from_dusk, transfer::Transaction};

use crate::io::{self, GraphQL};
use crate::io::{self};
use crate::settings::Settings;

pub struct TransactionHistory {
Expand Down Expand Up @@ -94,19 +94,22 @@ pub(crate) async fn transaction_from_notes(

let note_hash = decoded_note.note.hash();
// Looking for the transaction which created the note
let note_creator = txs.iter().find(|(t, _, _)| {
t.outputs().iter().any(|n| n.hash().eq(&note_hash))
|| t.nullifiers()
.iter()
.any(|tx_null| nullifiers.iter().any(|(n, _)| n == tx_null))
});
let note_creator = txs.iter_mut().find(|tx_block| {
let tx = &tx_block.tx;

if let Some((t, tx_id, gas_spent)) = note_creator {
let inputs_amount: f64 = t
tx.outputs().iter().any(|note| note.hash().eq(&note_hash))
|| tx.nullifiers().iter().any(|tx_null| {
nullifiers.iter().any(|(nullifier, _)| nullifier == tx_null)
})
});
if let Some(BlockTransaction { tx, id, gas_spent }) = note_creator {
let inputs_amount: f64 = tx
.nullifiers()
.iter()
.filter_map(|input| {
nullifiers.iter().find_map(|n| n.0.eq(input).then_some(n.1))
nullifiers.iter().find_map(|(nullifier, gas)| {
nullifier.eq(input).then_some(gas)
})
})
.sum::<u64>() as f64;

Expand All @@ -115,15 +118,15 @@ pub(crate) async fn transaction_from_notes(
false => TransactionDirection::In,
};

match ret.iter_mut().find(|th| &th.id == tx_id) {
match ret.iter_mut().find(|th| &th.id == id) {
Some(tx) => tx.amount += note_amount,
None => ret.push(TransactionHistory {
direction,
height: decoded_note.block_height,
amount: note_amount - inputs_amount,
fee: gas_spent * t.gas_price(),
tx: t.clone(),
id: tx_id.clone(),
fee: *gas_spent * tx.gas_price(),
tx: tx.clone(),
id: id.clone(),
}),
}
} else {
Expand Down
Loading

0 comments on commit ce86b10

Please sign in to comment.