Skip to content

Commit

Permalink
zcash_client_backend: non controversial serde derives
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2 committed Oct 10, 2024
1 parent e296133 commit 7eb8177
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions zcash_client_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ rand_core.workspace = true
base64.workspace = true
bech32.workspace = true
bs58.workspace = true
serde.workspace = true

# - Errors
bip32 = { workspace = true, optional = true }
Expand Down Expand Up @@ -123,7 +124,6 @@ tower = { workspace = true, optional = true }
http-body-util = { workspace = true, optional = true }
hyper-util = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
tokio-rustls = { workspace = true, optional = true }
webpki-roots = { workspace = true, optional = true }

Expand Down Expand Up @@ -186,7 +186,6 @@ tor = [
"dep:hyper-util",
"dep:rand",
"dep:rust_decimal",
"dep:serde",
"dep:serde_json",
"dep:tokio",
"dep:tokio-rustls",
Expand Down
7 changes: 4 additions & 3 deletions zcash_client_backend/src/fees.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt;

use serde::{Deserialize, Serialize};
use zcash_primitives::{
consensus::{self, BlockHeight},
memo::MemoBytes,
Expand All @@ -24,10 +25,10 @@ pub mod zip317;
/// `ChangeValue` represents either a proposed change output to a shielded pool
/// (with an optional change memo), or if the "transparent-inputs" feature is
/// enabled, an ephemeral output to the transparent pool.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ChangeValue(ChangeValueInner);

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
enum ChangeValueInner {
Shielded {
protocol: ShieldedProtocol,
Expand Down Expand Up @@ -114,7 +115,7 @@ impl ChangeValue {
/// The amount of change and fees required to make a transaction's inputs and
/// outputs balance under a specific fee rule, as computed by a particular
/// [`ChangeStrategy`] that is aware of that rule.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct TransactionBalance {
proposed_change: Vec<ChangeValue>,
fee_required: NonNegativeAmount,
Expand Down
5 changes: 3 additions & 2 deletions zcash_client_backend/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
};

use nonempty::NonEmpty;
use serde::{Deserialize, Serialize};
use zcash_primitives::{
consensus::BlockHeight,
transaction::{components::amount::NonNegativeAmount, TxId},
Expand Down Expand Up @@ -330,14 +331,14 @@ impl<FeeRuleT: Debug, NoteRef> Debug for Proposal<FeeRuleT, NoteRef> {
}

/// A reference to either a payment or change output within a step.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum StepOutputIndex {
Payment(usize),
Change(usize),
}

/// A reference to the output of a step in a proposal.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct StepOutput {
step_index: usize,
output_index: StepOutputIndex,
Expand Down
3 changes: 2 additions & 1 deletion zcash_client_backend/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! light client.
use incrementalmerkletree::Position;
use serde::{Deserialize, Serialize};
use zcash_address::ZcashAddress;
use zcash_note_encryption::EphemeralKeyBytes;
use zcash_primitives::{
Expand All @@ -28,7 +29,7 @@ use crate::fees::orchard as orchard_fees;
use zcash_primitives::legacy::keys::{NonHardenedChildIndex, TransparentKeyScope};

/// A unique identifier for a shielded transaction output
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct NoteId {
txid: TxId,
protocol: ShieldedProtocol,
Expand Down

0 comments on commit 7eb8177

Please sign in to comment.