From fa535cb015548048b1e602464113c58c7edcbde2 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Sun, 10 Mar 2024 13:48:51 +0500 Subject: [PATCH] fix: added `PartialEq` and `Eq` derives to `AccountDetails` --- objects/src/errors.rs | 10 +++------- objects/src/transaction/proven_tx.rs | 7 ++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/objects/src/errors.rs b/objects/src/errors.rs index 83d19a03c..502e9bd38 100644 --- a/objects/src/errors.rs +++ b/objects/src/errors.rs @@ -11,7 +11,7 @@ use super::{ utils::string::*, Digest, Word, }; -use crate::{notes::Note, utils::collections::*}; +use crate::utils::collections::*; // ACCOUNT ERROR // ================================================================================================ @@ -349,7 +349,7 @@ impl fmt::Display for TransactionOutputError { #[cfg(feature = "std")] impl std::error::Error for TransactionOutputError {} -// PROVEN TRANSACTIOM ERROR +// PROVEN TRANSACTION ERROR // ================================================================================================ #[derive(Debug)] @@ -357,7 +357,6 @@ pub enum ProvenTransactionError { AccountFinalHashMismatch(Digest, Digest), AccountIdMismatch(AccountId, AccountId), InputNotesError(TransactionInputError), - InvalidNoteDetail(NoteId, Note), NoteDetailsForUnknownNotes(Vec), OffChainAccountWithDetails(AccountId), OnChainAccountMissingDetails(AccountId), @@ -370,7 +369,7 @@ impl fmt::Display for ProvenTransactionError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { ProvenTransactionError::AccountFinalHashMismatch(tx_digest, details_hash) => { - write!(f, "Provent transaction account_final_hash {} and account_details.hash must match {}.", tx_digest, details_hash) + write!(f, "Proven transaction account_final_hash {} and account_details.hash must match {}.", tx_digest, details_hash) }, ProvenTransactionError::AccountIdMismatch(tx_id, details_id) => { write!( @@ -382,9 +381,6 @@ impl fmt::Display for ProvenTransactionError { ProvenTransactionError::InputNotesError(inner) => { write!(f, "Invalid input notes: {}", inner) }, - ProvenTransactionError::InvalidNoteDetail(id, _note) => { - write!(f, "Note detail {} for an unknown output note.", id) - }, ProvenTransactionError::NoteDetailsForUnknownNotes(note_ids) => { write!(f, "Note details for unknown note ids: {:?}", note_ids) }, diff --git a/objects/src/transaction/proven_tx.rs b/objects/src/transaction/proven_tx.rs index 7ec089199..36e730f8a 100644 --- a/objects/src/transaction/proven_tx.rs +++ b/objects/src/transaction/proven_tx.rs @@ -15,7 +15,7 @@ use crate::{ // PROVEN TRANSACTION // ================================================================================================ -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum AccountDetails { /// The whole state is needed for new accounts Full(Account), @@ -215,7 +215,7 @@ impl ProvenTransactionBuilder { self } - /// Add produce notes details. + /// Add produced notes details. pub fn add_output_note_details(mut self, notes: T) -> Self where T: IntoIterator, @@ -230,6 +230,7 @@ impl ProvenTransactionBuilder { self } + /// Builds the [ProvenTransaction]. pub fn build(mut self) -> Result { let output_note_details = self.output_note_details; let known_output_ids = BTreeSet::from_iter(self.output_notes.iter().map(|n| n.note_id())); @@ -292,7 +293,7 @@ impl ProvenTransactionBuilder { ), ) }, - (false, AccountDetails::Delta(_)) => todo!(), + (false, AccountDetails::Delta(_)) => (), } }, }