Skip to content

Commit e052c51

Browse files
Fix suggestions suggested by coderabbit review (#321)
1 parent 2077144 commit e052c51

File tree

7 files changed

+11
-13
lines changed

7 files changed

+11
-13
lines changed

rust/crates/cove-util/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ pub mod encryption;
22
pub mod format;
33
pub mod result_ext;
44

5+
pub use result_ext::ResultExt;
6+
57
use bitcoin::secp256k1::hashes::sha256::Hash as Sha256Hash;
68
use std::hash::{DefaultHasher, Hasher as _};
79

rust/crates/cove-util/src/result_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub trait ResultExt<T, InitialError> {
77
/// that takes a String, using the Display implementation of InitialError.
88
///
99
/// # Example
10-
/// ```
10+
/// ```rust
1111
/// use cove_util::result_ext::ResultExt;
1212
///
1313
/// #[derive(Debug, thiserror::Error)]

rust/src/database/unsigned_transactions.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ impl UnsignedTransactionsTable {
131131
fn get(&self, key: &TxId) -> Result<Option<UnsignedTransactionRecord>, Error> {
132132
let read_txn = self.db.begin_read().map_err_str(Error::DatabaseAccess)?;
133133

134-
let table = read_txn
135-
.open_table(MAIN_TABLE)
136-
.map_err(|error| Error::TableAccess(error.to_string()))?;
134+
let table = read_txn.open_table(MAIN_TABLE).map_err_str(Error::TableAccess)?;
137135

138136
let value = table
139137
.get(key)
@@ -146,9 +144,7 @@ impl UnsignedTransactionsTable {
146144
fn get_tx_ids_for_wallet_id(&self, key: &WalletId) -> Result<Vec<TxId>, Error> {
147145
let read_txn = self.db.begin_read().map_err_str(Error::DatabaseAccess)?;
148146

149-
let table = read_txn
150-
.open_table(BY_WALLET_TABLE)
151-
.map_err(|error| Error::TableAccess(error.to_string()))?;
147+
let table = read_txn.open_table(BY_WALLET_TABLE).map_err_str(Error::TableAccess)?;
152148

153149
let ids = table
154150
.get(key)

rust/src/file_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum FileHandlerError {
1717
#[error("Unable to open file {0}")]
1818
OpenFile(String),
1919

20-
#[error("Unable to to read file {0}")]
20+
#[error("Unable to read file {0}")]
2121
ReadFile(String),
2222

2323
#[error("File is not a recognized format: {0:?}")]

rust/src/manager/wallet_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ impl RustWalletManager {
634634
#[uniffi::method]
635635
pub async fn number_of_confirmations(&self, block_height: u32) -> Result<u32, Error> {
636636
let current_height = self.current_block_height().await?;
637-
Ok(current_height - block_height + 1)
637+
if block_height > current_height { Ok(0) } else { Ok(current_height - block_height + 1) }
638638
}
639639

640640
#[uniffi::method]
@@ -850,7 +850,7 @@ impl RustWalletManager {
850850
WalletAddressType::WrappedSegwit => json.bip49.clone(),
851851
WalletAddressType::Legacy => json.bip44.clone(),
852852
_ => {
853-
error!("trying to swtich to native segwit, but already segwit");
853+
error!("trying to switch to native segwit, but already segwit");
854854
return Ok(());
855855
}
856856
};

rust/src/multi_qr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum MultiQrError {
5252
#[error("Cannot add binary data to BBQR")]
5353
CannotAddBinaryDataToBbqr,
5454

55-
#[error("BBQr did not container seed words, found: {0}")]
55+
#[error("BBQR did not contain seed words, found: {0}")]
5656
BbqrDidNotContainSeedWords(String),
5757

5858
#[error(transparent)]

rust/src/reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Csv(Vec<u8>);
1919

2020
#[derive(Debug, thiserror::Error)]
2121
pub enum CsvCreationError {
22-
#[error("failed to fianlize csv: {0}")]
22+
#[error("failed to finalize csv: {0}")]
2323
FinalizeCsv(String),
2424

2525
#[error("failed to write csv row: {0}")]
@@ -32,7 +32,7 @@ impl Csv {
3232
}
3333

3434
pub fn into_string(self) -> String {
35-
String::from_utf8(self.into_bytes()).expect("we only create rows with valid uft8 strings")
35+
String::from_utf8(self.into_bytes()).expect("we only create rows with valid utf8 strings")
3636
}
3737
}
3838
type Row = TxnWithHistoricalPrice;

0 commit comments

Comments
 (0)