Skip to content

Commit

Permalink
Merge pull request #1467 from AloeareV/align_default_new
Browse files Browse the repository at this point in the history
align default and new in note builder
  • Loading branch information
zancas authored Oct 23, 2024
2 parents e5e3654 + 39b4aa9 commit c6d3c7d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
31 changes: 17 additions & 14 deletions zingolib/src/wallet/notes/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,14 @@ pub mod mocks {
have_spending_key: Option<bool>,
}

#[allow(dead_code)] //TODO: fix this gross hack that I tossed in to silence the language-analyzer false positive
impl OrchardNoteBuilder {
/// blank builder
#[allow(dead_code)] //TODO: fix this gross hack that I tossed in to silence the language-analyzer false positive
/// A builder, for a 'blank' note.
/// Be aware that two notes generated with
/// this function will be identical if built
/// with no changes.
pub fn new() -> Self {
OrchardNoteBuilder {
diversifier: None,
note: None,
witnessed_position: None,
output_index: None,
nullifier: None,
spending_tx_status: None,
memo: None,
is_change: None,
have_spending_key: None,
}
Self::default()
}

// Methods to set each field
Expand Down Expand Up @@ -281,7 +274,17 @@ pub mod mocks {

impl Default for OrchardNoteBuilder {
fn default() -> Self {
let mut builder = OrchardNoteBuilder::new();
let mut builder = OrchardNoteBuilder {
diversifier: None,
note: None,
witnessed_position: None,
output_index: None,
nullifier: None,
spending_tx_status: None,
memo: None,
is_change: None,
have_spending_key: None,
};
builder
.diversifier(Diversifier::from_bytes([0; 11]))
.note(OrchardCryptoNoteBuilder::default())
Expand Down
31 changes: 17 additions & 14 deletions zingolib/src/wallet/notes/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,14 @@ pub mod mocks {
have_spending_key: Option<bool>,
}

#[allow(dead_code)] //TODO: fix this gross hack that I tossed in to silence the language-analyzer false positive
impl SaplingNoteBuilder {
/// blank builder
/// A builder, for a 'blank' note.
/// Be aware that two notes generated with
/// this function will be identical if built
/// with no changes.
#[allow(dead_code)]
pub fn new() -> Self {
SaplingNoteBuilder {
diversifier: None,
note: None,
witnessed_position: None,
output_index: None,
nullifier: None,
spending_tx_status: None,
memo: None,
is_change: None,
have_spending_key: None,
}
Self::default()
}

// Methods to set each field
Expand Down Expand Up @@ -297,7 +290,17 @@ pub mod mocks {

impl Default for SaplingNoteBuilder {
fn default() -> Self {
let mut builder = SaplingNoteBuilder::new();
let mut builder = SaplingNoteBuilder {
diversifier: None,
note: None,
witnessed_position: None,
output_index: None,
nullifier: None,
spending_tx_status: None,
memo: None,
is_change: None,
have_spending_key: None,
};
builder
.diversifier(sapling_crypto::Diversifier([0; 11]))
.note(crate::mocks::SaplingCryptoNoteBuilder::default())
Expand Down

0 comments on commit c6d3c7d

Please sign in to comment.