This commit is contained in:
Matthew Watt 2023-10-09 06:46:12 -05:00
parent 9d7ac07b1a
commit c4175342ac
5 changed files with 15 additions and 25 deletions

View File

@ -15,6 +15,7 @@ use zcash_primitives::{
zip32::AccountId,
};
use crate::data_api::PoolType;
use crate::data_api::wallet::input_selection::InputSelectorError;
#[cfg(feature = "transparent-inputs")]
@ -22,7 +23,7 @@ use zcash_primitives::{legacy::TransparentAddress, zip32::DiversifierIndex};
/// Errors that can occur as a consequence of wallet operations.
#[derive(Debug)]
pub enum Error<DataSourceError, CommitmentTreeError, SelectionError, FeeError, NoteRef, PoolType> {
pub enum Error<DataSourceError, CommitmentTreeError, SelectionError, FeeError, NoteRef> {
/// An error occurred retrieving data from the underlying data source
DataSource(DataSourceError),
@ -68,14 +69,13 @@ pub enum Error<DataSourceError, CommitmentTreeError, SelectionError, FeeError, N
ChildIndexOutOfRange(DiversifierIndex),
}
impl<DE, CE, SE, FE, N, PT> fmt::Display for Error<DE, CE, SE, FE, N, PT>
impl<DE, CE, SE, FE, N> fmt::Display for Error<DE, CE, SE, FE, N>
where
DE: fmt::Display,
CE: fmt::Display,
SE: fmt::Display,
FE: fmt::Display,
N: fmt::Display,
PT: fmt::Display
N: fmt::Display
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self {
@ -134,14 +134,13 @@ where
}
}
impl<DE, CE, SE, FE, N, PT> error::Error for Error<DE, CE, SE, FE, N, PT>
impl<DE, CE, SE, FE, N> error::Error for Error<DE, CE, SE, FE, N>
where
DE: Debug + Display + error::Error + 'static,
CE: Debug + Display + error::Error + 'static,
SE: Debug + Display + error::Error + 'static,
FE: Debug + Display + 'static,
N: Debug + Display,
PT: Debug + Display
{
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match &self {
@ -154,19 +153,19 @@ where
}
}
impl<DE, CE, SE, FE, N, PT> From<builder::Error<FE>> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<builder::Error<FE>> for Error<DE, CE, SE, FE, N> {
fn from(e: builder::Error<FE>) -> Self {
Error::Builder(e)
}
}
impl<DE, CE, SE, FE, N, PT> From<BalanceError> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<BalanceError> for Error<DE, CE, SE, FE, N> {
fn from(e: BalanceError) -> Self {
Error::BalanceError(e)
}
}
impl<DE, CE, SE, FE, N, PT> From<InputSelectorError<DE, SE>> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<InputSelectorError<DE, SE>> for Error<DE, CE, SE, FE, N> {
fn from(e: InputSelectorError<DE, SE>) -> Self {
match e {
InputSelectorError::DataSource(e) => Error::DataSource(e),
@ -183,19 +182,19 @@ impl<DE, CE, SE, FE, N, PT> From<InputSelectorError<DE, SE>> for Error<DE, CE, S
}
}
impl<DE, CE, SE, FE, N, PT> From<sapling::builder::Error> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<sapling::builder::Error> for Error<DE, CE, SE, FE, N> {
fn from(e: sapling::builder::Error) -> Self {
Error::Builder(builder::Error::SaplingBuild(e))
}
}
impl<DE, CE, SE, FE, N, PT> From<transparent::builder::Error> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<transparent::builder::Error> for Error<DE, CE, SE, FE, N> {
fn from(e: transparent::builder::Error) -> Self {
Error::Builder(builder::Error::TransparentBuild(e))
}
}
impl<DE, CE, SE, FE, N, PT> From<ShardTreeError<CE>> for Error<DE, CE, SE, FE, N, PT> {
impl<DE, CE, SE, FE, N> From<ShardTreeError<CE>> for Error<DE, CE, SE, FE, N> {
fn from(e: ShardTreeError<CE>) -> Self {
Error::CommitmentTree(e)
}

View File

@ -207,7 +207,6 @@ pub fn create_spend_to_address<DbT, ParamsT>(
GreedyInputSelectorError<BalanceError, DbT::NoteRef>,
Infallible,
DbT::NoteRef,
PoolType,
>,
>
where
@ -311,7 +310,6 @@ pub fn spend<DbT, ParamsT, InputsT>(
InputsT::Error,
<InputsT::FeeRule as FeeRule>::Error,
DbT::NoteRef,
PoolType,
>,
>
where
@ -366,7 +364,6 @@ pub fn propose_transfer<DbT, ParamsT, InputsT, CommitmentTreeErrT>(
InputsT::Error,
<InputsT::FeeRule as FeeRule>::Error,
DbT::NoteRef,
PoolType,
>,
>
where
@ -450,7 +447,6 @@ pub fn create_proposed_transaction<DbT, ParamsT, InputsErrT, FeeRuleT>(
InputsErrT,
FeeRuleT::Error,
DbT::NoteRef,
PoolType,
>,
>
where
@ -496,7 +492,7 @@ where
let checkpoint_depth = wallet_db.get_checkpoint_depth(min_confirmations)?;
wallet_db.with_sapling_tree_mut::<_, _, Error<_, _, _, _, _, _>>(|sapling_tree| {
wallet_db.with_sapling_tree_mut::<_, _, Error<_, _, _, _, _>>(|sapling_tree| {
for selected in proposal.sapling_inputs() {
let (note, key, merkle_path) = select_key_for_note(
sapling_tree,

View File

@ -15,7 +15,7 @@ use tempfile::NamedTempFile;
use tempfile::TempDir;
use zcash_client_backend::data_api::chain::ScanSummary;
use zcash_client_backend::data_api::{AccountBalance, WalletRead, PoolType};
use zcash_client_backend::data_api::{AccountBalance, WalletRead};
#[allow(deprecated)]
use zcash_client_backend::{
address::RecipientAddress,
@ -446,7 +446,6 @@ impl<Cache> TestState<Cache> {
GreedyInputSelectorError<BalanceError, ReceivedNoteId>,
Infallible,
ReceivedNoteId,
PoolType,
>,
> {
let params = self.network();
@ -480,7 +479,6 @@ impl<Cache> TestState<Cache> {
InputsT::Error,
<InputsT::FeeRule as FeeRule>::Error,
ReceivedNoteId,
PoolType,
>,
>
where
@ -515,7 +513,6 @@ impl<Cache> TestState<Cache> {
InputsT::Error,
<InputsT::FeeRule as FeeRule>::Error,
ReceivedNoteId,
PoolType,
>,
>
where
@ -582,7 +579,6 @@ impl<Cache> TestState<Cache> {
Infallible,
FeeRuleT::Error,
ReceivedNoteId,
PoolType,
>,
>
where

View File

@ -136,7 +136,7 @@ pub(crate) fn pool_code(pool_type: PoolType) -> i64 {
match pool_type {
PoolType::Transparent => 0i64,
PoolType::Shielded(ShieldedProtocol::Sapling) => 2i64,
PoolType::Shielded(ShieldedProtocol::Orchard) => 4i64
PoolType::Shielded(ShieldedProtocol::Orchard) => 3i64
}
}

View File

@ -465,7 +465,7 @@ pub(crate) mod tests {
error::Error,
wallet::input_selection::{GreedyInputSelector, GreedyInputSelectorError},
AccountBirthday, Ratio, ShieldedProtocol, WalletCommitmentTrees, WalletRead,
WalletWrite, PoolType,
WalletWrite,
},
decrypt_transaction,
fees::{fixed, zip317, DustOutputPolicy},
@ -983,7 +983,6 @@ pub(crate) mod tests {
GreedyInputSelectorError<BalanceError, ReceivedNoteId>,
Infallible,
ReceivedNoteId,
PoolType,
>,
> {
let txid = st.create_spend_to_address(