From 1bbcccb28ff55f5aa14b3768c4d50918eb7065bc Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:22:30 +0000 Subject: [PATCH 1/8] specify use of thiserror::Error --- zingo-netutils/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zingo-netutils/src/lib.rs b/zingo-netutils/src/lib.rs index 557454213d..da616aeef5 100644 --- a/zingo-netutils/src/lib.rs +++ b/zingo-netutils/src/lib.rs @@ -10,7 +10,6 @@ use client::client_from_connector; use http::{uri::PathAndQuery, Uri}; use http_body_util::combinators::UnsyncBoxBody; use hyper_util::client::legacy::connect::HttpConnector; -use thiserror::Error; use tokio_rustls::rustls::pki_types::{Der, TrustAnchor}; use tokio_rustls::rustls::{ClientConfig, RootCertStore}; use tonic::Status; @@ -26,7 +25,7 @@ pub type UnderlyingService = BoxCloneService< >; #[allow(missing_docs)] // error types document themselves -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum GetClientError { #[error("bad uri: invalid scheme")] InvalidScheme, From 6a638aa1ab591b95f2d25ef190d6ce19ac663c87 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:27:47 +0000 Subject: [PATCH 2/8] specify use of thiserror::Error in wallet/send.rs --- zingolib/src/wallet/send.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zingolib/src/wallet/send.rs b/zingolib/src/wallet/send.rs index eb802fa30f..0428dcce15 100644 --- a/zingolib/src/wallet/send.rs +++ b/zingolib/src/wallet/send.rs @@ -89,9 +89,8 @@ impl LightWallet { } } -use thiserror::Error; #[allow(missing_docs)] // error types document themselves -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum BuildTransactionError { #[error("No witness trees. This is viewkey watch, not spendkey wallet.")] NoSpendCapability, From a4d9981d6cf4d04355c7fc7893c64797bbb4083a Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:29:28 +0000 Subject: [PATCH 3/8] specify use of thiserror::Error in lightclient/send.rs --- zingolib/src/lightclient/send.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index 366f1b2c79..22262497b5 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -36,7 +36,6 @@ pub mod send_with_proposal { use zcash_primitives::transaction::{Transaction, TxId}; - use thiserror::Error; use zingo_status::confirmation_status::ConfirmationStatus; use crate::lightclient::LightClient; @@ -44,7 +43,7 @@ pub mod send_with_proposal { use crate::wallet::propose::{ProposeSendError, ProposeShieldError}; #[allow(missing_docs)] // error types document themselves - #[derive(Clone, Debug, Error)] + #[derive(Clone, Debug, thiserror::Error)] pub enum TransactionCacheError { #[error("No witness trees. This is viewkey watch, not spendkey wallet.")] NoSpendCapability, @@ -55,7 +54,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Clone, Debug, Error)] + #[derive(Clone, Debug, thiserror::Error)] pub enum BroadcastCachedTransactionsError { #[error("Cant broadcast: {0:?}")] Cache(#[from] TransactionCacheError), @@ -66,7 +65,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Debug, Error)] + #[derive(Debug, thiserror::Error)] pub enum RecordCachedTransactionsError { #[error("Cant record: {0:?}")] Cache(#[from] TransactionCacheError), @@ -77,7 +76,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Debug, Error)] + #[derive(Debug, thiserror::Error)] pub enum CompleteAndBroadcastError { #[error("The transaction could not be calculated: {0:?}")] BuildTransaction(#[from] crate::wallet::send::BuildTransactionError), @@ -90,7 +89,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Debug, Error)] + #[derive(Debug, thiserror::Error)] pub enum CompleteAndBroadcastStoredProposalError { #[error("No proposal. Call do_propose first.")] NoStoredProposal, @@ -99,7 +98,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Debug, Error)] + #[derive(Debug, thiserror::Error)] pub enum QuickSendError { #[error("propose send {0:?}")] ProposeSend(#[from] ProposeSendError), @@ -108,7 +107,7 @@ pub mod send_with_proposal { } #[allow(missing_docs)] // error types document themselves - #[derive(Debug, Error)] + #[derive(Debug, thiserror::Error)] pub enum QuickShieldError { #[error("propose shield {0:?}")] Propose(#[from] ProposeShieldError), From eb24f947cfb9c60caaf07c91748d7c3eacca18ed Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:34:23 +0000 Subject: [PATCH 4/8] specify use of thiserror::Error in wallet/tx_map.rs --- zingolib/src/wallet/tx_map.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zingolib/src/wallet/tx_map.rs b/zingolib/src/wallet/tx_map.rs index 76fbee171e..a721c2c1d5 100644 --- a/zingolib/src/wallet/tx_map.rs +++ b/zingolib/src/wallet/tx_map.rs @@ -13,7 +13,6 @@ use crate::{ use getset::{Getters, MutGetters}; use spending_data::SpendingData; use std::{fmt::Debug, sync::Arc}; -use thiserror::Error; use zcash_client_backend::wallet::TransparentAddressMetadata; use zcash_primitives::legacy::{keys::EphemeralIvk, TransparentAddress}; @@ -87,7 +86,7 @@ impl TxMap { } } #[allow(missing_docs)] // error types document themselves -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum TxMapTraitError { #[error("No witness trees. This is viewkey watch, not a spendkey wallet.")] NoSpendCapability, From af7ad508e75a3e14d6d504faabbbca7f57a6a426 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:38:45 +0000 Subject: [PATCH 5/8] remove use::thiserror in this case, this change increases the file. however there are many arguments for - increases explicitness: Error is a crate, not to be confused with a standard derive trait, like Debug. - increased locality: rather than having a use statement in an arbitrary place, this groups error-related code together - standardization --- zingolib/src/wallet/error.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zingolib/src/wallet/error.rs b/zingolib/src/wallet/error.rs index 7e30a153f6..151d16017e 100644 --- a/zingolib/src/wallet/error.rs +++ b/zingolib/src/wallet/error.rs @@ -1,12 +1,11 @@ //! Errors for [`crate::wallet`] and sub-modules -use thiserror::Error; use zcash_keys::keys::DerivationError; use crate::wallet::data::OutgoingTxData; /// Errors associated with transaction fee calculation -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum FeeError { /// Sapling notes spent in a transaction not found in the wallet #[error("Sapling nullifier(s) {0:?} for this transaction not found in wallet. Is the wallet fully synced?")] @@ -33,7 +32,7 @@ pub enum FeeError { } /// Errors associated with balance calculation -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum BalanceError { /// failed to retrieve full viewing key #[error("failed to retrieve full viewing key.")] @@ -44,7 +43,7 @@ pub enum BalanceError { } /// Errors associated with balance key derivation -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum KeyError { /// Error asociated with standard IO #[error("{0}")] From cd4b8f36dd0393c4ae49687a492ba51b2ccc6159 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:42:36 +0000 Subject: [PATCH 6/8] another micro-commit, justified in previous commit message --- zingolib/src/wallet/propose.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zingolib/src/wallet/propose.rs b/zingolib/src/wallet/propose.rs index c03c5f4eb7..a45d2e9bb5 100644 --- a/zingolib/src/wallet/propose.rs +++ b/zingolib/src/wallet/propose.rs @@ -2,7 +2,6 @@ use std::{convert::Infallible, num::NonZeroU32, ops::DerefMut as _}; -use thiserror::Error; use zcash_client_backend::{ data_api::wallet::input_selection::GreedyInputSelector, zip321::{TransactionRequest, Zip321Error}, @@ -42,7 +41,7 @@ fn build_default_giskit(memo: Option) -> GISKit { } /// Errors that can result from do_propose -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum ProposeSendError { /// error in using trait to create spend proposal #[error("{0}")] @@ -69,7 +68,7 @@ pub enum ProposeSendError { } /// Errors that can result from do_propose -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum ProposeShieldError { /// error in parsed addresses #[error("{0}")] From b24c3b5462bde249cc1b47c51b7740b652b65634 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:43:48 +0000 Subject: [PATCH 7/8] same as above --- .../src/wallet/transaction_records_by_id/trait_inputsource.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs index 7bd99680c1..d611b887a3 100644 --- a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs +++ b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs @@ -19,13 +19,12 @@ use zcash_primitives::{ use crate::wallet::{notes::OutputInterface, transaction_records_by_id::TransactionRecordsById}; use std::fmt::Debug; -use thiserror::Error; use zcash_client_backend::wallet::NoteId; use zcash_primitives::transaction::components::amount::BalanceError; /// Error type used by InputSource trait -#[derive(Debug, PartialEq, Error)] +#[derive(Debug, PartialEq, thiserror::Error)] pub enum InputSourceError { /// No witness position found for note. Note cannot be spent. #[error("No witness position found for note. Note cannot be spent: {0:?}")] From d88207ef6e933d71c412d4aa7171ab12978382ab Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 28 Oct 2024 15:44:31 +0000 Subject: [PATCH 8/8] same as above --- zingolib/src/utils/conversion.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/zingolib/src/utils/conversion.rs b/zingolib/src/utils/conversion.rs index 42882f68d5..811e6cf0b0 100644 --- a/zingolib/src/utils/conversion.rs +++ b/zingolib/src/utils/conversion.rs @@ -1,14 +1,12 @@ //! Conversion specific utilities -use thiserror::Error; - use zcash_address::ZcashAddress; use zcash_primitives::transaction::{components::amount::NonNegativeAmount, TxId}; use super::error::ConversionError; #[allow(missing_docs)] // error types document themselves -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] pub enum TxIdFromHexEncodedStrError { #[error("{0}")] Decode(hex::FromHexError),