Skip to content

Commit

Permalink
fix: added PartialEq and Eq derives to AccountDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
polydez authored and hackaugusto committed Mar 11, 2024
1 parent e3545f5 commit fa535cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 3 additions & 7 deletions objects/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{
utils::string::*,
Digest, Word,
};
use crate::{notes::Note, utils::collections::*};
use crate::utils::collections::*;

// ACCOUNT ERROR
// ================================================================================================
Expand Down Expand Up @@ -349,15 +349,14 @@ impl fmt::Display for TransactionOutputError {
#[cfg(feature = "std")]
impl std::error::Error for TransactionOutputError {}

// PROVEN TRANSACTIOM ERROR
// PROVEN TRANSACTION ERROR
// ================================================================================================

#[derive(Debug)]
pub enum ProvenTransactionError {
AccountFinalHashMismatch(Digest, Digest),
AccountIdMismatch(AccountId, AccountId),
InputNotesError(TransactionInputError),
InvalidNoteDetail(NoteId, Note),
NoteDetailsForUnknownNotes(Vec<NoteId>),
OffChainAccountWithDetails(AccountId),
OnChainAccountMissingDetails(AccountId),
Expand All @@ -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!(
Expand All @@ -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)
},
Expand Down
7 changes: 4 additions & 3 deletions objects/src/transaction/proven_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -215,7 +215,7 @@ impl ProvenTransactionBuilder {
self
}

/// Add produce notes details.
/// Add produced notes details.
pub fn add_output_note_details<T>(mut self, notes: T) -> Self
where
T: IntoIterator<Item = (NoteId, Note)>,
Expand All @@ -230,6 +230,7 @@ impl ProvenTransactionBuilder {
self
}

/// Builds the [ProvenTransaction].
pub fn build(mut self) -> Result<ProvenTransaction, ProvenTransactionError> {
let output_note_details = self.output_note_details;
let known_output_ids = BTreeSet::from_iter(self.output_notes.iter().map(|n| n.note_id()));
Expand Down Expand Up @@ -292,7 +293,7 @@ impl ProvenTransactionBuilder {
),
)
},
(false, AccountDetails::Delta(_)) => todo!(),
(false, AccountDetails::Delta(_)) => (),
}
},
}
Expand Down

0 comments on commit fa535cb

Please sign in to comment.