Skip to content

Commit

Permalink
imporve: use types exported in nuts mod
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Nov 16, 2023
1 parent 3f6e7bf commit 4118ee0
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions crates/cashu/src/dhke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use k256::{Scalar, SecretKey};

use crate::error;
#[cfg(feature = "wallet")]
use crate::nuts::nut00::{BlindedSignature, Proof, Proofs};
#[cfg(feature = "wallet")]
use crate::nuts::nut01::{Keys, PublicKey};
#[cfg(feature = "wallet")]
use crate::nuts::*;
#[cfg(feature = "wallet")]
use crate::nuts::{BlindedSignature, Proof, Proofs};
use crate::secret::Secret;

fn hash_to_curve(message: &[u8]) -> k256::PublicKey {
Expand Down
6 changes: 3 additions & 3 deletions crates/cashu/src/nuts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ pub mod nut09;

#[cfg(feature = "wallet")]
pub use nut00::wallet::{BlindedMessages, Token};
#[cfg(feature = "mint")]
pub use nut00::BlindedMessage;
pub use nut00::{BlindedSignature, Proof, Proofs};
pub use nut00::{BlindedMessage, BlindedSignature, Proof};
pub use nut01::{Keys, KeysResponse, PublicKey, SecretKey};
pub use nut02::mint::KeySet as MintKeySet;
pub use nut02::{Id, KeySet, KeysetResponse};
Expand All @@ -34,3 +32,5 @@ pub use nut07::{CheckSpendableRequest, CheckSpendableResponse};
pub use nut08::{MeltRequest, MeltResponse};
#[cfg(feature = "nut09")]
pub use nut09::MintInfo;

pub type Proofs = Vec<Proof>;
13 changes: 4 additions & 9 deletions crates/cashu/src/nuts/nut00.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

use serde::{Deserialize, Serialize};

use super::nut01::PublicKey;
use super::nut02::Id;
use super::{Id, Proofs, PublicKey};
use crate::secret::Secret;
use crate::url::UncheckedUrl;
use crate::Amount;
Expand All @@ -31,8 +30,7 @@ pub mod wallet {
use super::MintProofs;
use crate::dhke::blind_message;
use crate::error::wallet;
use crate::nuts::nut00::{BlindedMessage, Proofs};
use crate::nuts::nut01;
use crate::nuts::{BlindedMessage, Proofs, SecretKey};
use crate::secret::Secret;
use crate::url::UncheckedUrl;
use crate::{error, Amount};
Expand All @@ -45,7 +43,7 @@ pub mod wallet {
/// Secrets
pub secrets: Vec<Secret>,
/// Rs
pub rs: Vec<nut01::SecretKey>,
pub rs: Vec<SecretKey>,
/// Amounts
pub amounts: Vec<Amount>,
}
Expand Down Expand Up @@ -206,9 +204,6 @@ pub struct Proof {
pub id: Option<Id>,
}

/// List of proofs
pub type Proofs = Vec<Proof>;

impl From<Proof> for mint::Proof {
fn from(proof: Proof) -> Self {
Self {
Expand Down Expand Up @@ -245,7 +240,7 @@ pub mod mint {
/// List of proofs
pub type Proofs = Vec<Proof>;

pub fn mint_proofs_from_proofs(proofs: super::Proofs) -> Proofs {
pub fn mint_proofs_from_proofs(proofs: crate::nuts::Proofs) -> Proofs {
proofs.iter().map(|p| p.to_owned().into()).collect()
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cashu/src/nuts/nut04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/cashubtc/nuts/blob/main/04.md
use serde::{Deserialize, Serialize};

use super::nut00::{BlindedMessage, BlindedSignature};
use super::{BlindedMessage, BlindedSignature};
use crate::Amount;

/// Post Mint Request [NUT-04]
Expand Down
2 changes: 1 addition & 1 deletion crates/cashu/src/nuts/nut05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use serde::{Deserialize, Serialize};

use super::nut00::Proofs;
use crate::error::Error;
use crate::nuts::Proofs;
use crate::{Amount, Bolt11Invoice};

/// Check Fees Response [NUT-05]
Expand Down
4 changes: 2 additions & 2 deletions crates/cashu/src/nuts/nut06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};

use super::nut00::BlindedSignature;
#[cfg(feature = "wallet")]
use crate::nuts::nut00::wallet::BlindedMessages;
use crate::nuts::nut00::{BlindedMessage, Proofs};
use crate::nuts::BlindedMessages;
use crate::nuts::{BlindedMessage, Proofs};
use crate::Amount;

#[cfg(feature = "wallet")]
Expand Down
2 changes: 1 addition & 1 deletion crates/cashu/src/nuts/nut08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use lightning_invoice::Bolt11Invoice;
use serde::{Deserialize, Serialize};

use super::nut00::{BlindedMessage, BlindedSignature, Proofs};
use super::{BlindedMessage, BlindedSignature, Proofs};
use crate::error::Error;
use crate::Amount;

Expand Down
4 changes: 2 additions & 2 deletions crates/cashu/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use serde::{Deserialize, Serialize};

use crate::nuts::nut00::{mint, Proofs};
use crate::nuts::nut02::Id;
use crate::nuts::nut00::mint;
use crate::nuts::{Id, Proofs};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProofsStatus {
Expand Down

0 comments on commit 4118ee0

Please sign in to comment.