mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-23 05:56:02 +01:00
chore: clippy
This commit is contained in:
@@ -29,4 +29,5 @@ url = "2.3.1"
|
||||
tokio = { version = "1", default-features = false }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
uniffi = "0.24"
|
||||
uniffi = "0.24"
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ impl From<ParseOrSemanticError> for CashuError {
|
||||
impl From<cashu::nuts::nut02::Error> for CashuError {
|
||||
fn from(err: cashu::nuts::nut02::Error) -> Self {
|
||||
Self::Generic {
|
||||
err: "Nut 2 error".to_string(),
|
||||
err: err.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ impl BlindedSignature {
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Arc<Id> {
|
||||
Arc::new(self.inner.id.clone().into())
|
||||
Arc::new(self.inner.id.into())
|
||||
}
|
||||
|
||||
pub fn amount(&self) -> Arc<Amount> {
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Proof {
|
||||
amount: *amount.as_ref().deref(),
|
||||
secret: secret.as_ref().deref().clone(),
|
||||
c: c.as_ref().deref().clone(),
|
||||
id: id.map(|id| id.as_ref().deref().clone()),
|
||||
id: id.map(|id| *id.as_ref().deref()),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ impl Proof {
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<Arc<Id>> {
|
||||
self.inner.id.clone().map(|id| Arc::new(id.into()))
|
||||
self.inner.id.map(|id| Arc::new(id.into()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl From<&Proof> for ProofSdk {
|
||||
amount: *proof.amount().as_ref().deref(),
|
||||
secret: proof.secret().as_ref().deref().clone(),
|
||||
c: proof.c().deref().into(),
|
||||
id: proof.id().map(|id| id.as_ref().deref().clone()),
|
||||
id: proof.id().map(|id| *id.as_ref().deref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ pub mod mint {
|
||||
amount: amount.map(|a| *a.as_ref().deref()),
|
||||
secret: secret.as_ref().deref().clone(),
|
||||
c: c.map(|c| c.as_ref().into()),
|
||||
id: id.map(|id| id.as_ref().deref().clone()),
|
||||
id: id.map(|id| *id.as_ref().deref()),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ pub mod mint {
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<Arc<Id>> {
|
||||
self.inner.id.clone().map(|id| Arc::new(id.into()))
|
||||
self.inner.id.map(|id| Arc::new(id.into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ impl KeySet {
|
||||
pub fn new(id: Arc<Id>, keys: Arc<Keys>) -> Self {
|
||||
Self {
|
||||
inner: KeySetSdk {
|
||||
id: id.as_ref().deref().clone(),
|
||||
id: *id.as_ref().deref(),
|
||||
keys: keys.as_ref().deref().clone(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Arc<Id> {
|
||||
Arc::new(self.inner.id.clone().into())
|
||||
Arc::new(self.inner.id.into())
|
||||
}
|
||||
|
||||
pub fn keys(&self) -> Arc<Keys> {
|
||||
|
||||
@@ -13,6 +13,12 @@ impl Deref for Secret {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Secret {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Secret {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -17,7 +17,7 @@ mod ffi {
|
||||
pub use crate::client::Client;
|
||||
pub use crate::error::CashuSdkError;
|
||||
pub use crate::mint::Mint;
|
||||
pub use crate::types::{FeeReserve, Melted, ProofsStatus, SendProofs};
|
||||
pub use crate::types::{Melted, ProofsStatus, SendProofs};
|
||||
pub use crate::wallet::Wallet;
|
||||
|
||||
// UDL
|
||||
|
||||
@@ -4,17 +4,14 @@ use std::{
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
use cashu_sdk::mint::Mint as MintSdk;
|
||||
|
||||
use cashu_sdk::nuts::nut02::Id as IdSdk;
|
||||
use fee_reserve::FeeReserve;
|
||||
|
||||
use crate::{error::Result, types::fee_reserve};
|
||||
use cashu_ffi::{
|
||||
Amount, CheckSpendableRequest, CheckSpendableResponse, Id, KeySet, KeySetResponse, MeltRequest,
|
||||
MeltResponse, MintKeySet, MintRequest, PostMintResponse, Proof, Secret, SplitRequest,
|
||||
SplitResponse,
|
||||
MeltResponse, MintKeySet, MintRequest, PostMintResponse, Secret, SplitRequest, SplitResponse,
|
||||
};
|
||||
use cashu_sdk::mint::Mint as MintSdk;
|
||||
use cashu_sdk::nuts::nut02::Id as IdSdk;
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
pub struct Mint {
|
||||
inner: RwLock<MintSdk>,
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use cashu_ffi::Amount;
|
||||
use cashu_sdk::mint::FeeReserve as FeeReserveSdk;
|
||||
|
||||
pub struct FeeReserve {
|
||||
inner: FeeReserveSdk,
|
||||
}
|
||||
|
||||
impl FeeReserve {
|
||||
pub fn new(min_fee_reserve: Arc<Amount>, percent_fee_reserve: f32) -> Self {
|
||||
Self {
|
||||
inner: FeeReserveSdk {
|
||||
min_fee_reserve: *min_fee_reserve.as_ref().deref(),
|
||||
percent_fee_reserve,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
pub mod fee_reserve;
|
||||
pub mod melted;
|
||||
pub mod proofs_status;
|
||||
pub mod send_proofs;
|
||||
|
||||
pub use fee_reserve::FeeReserve;
|
||||
pub use melted::Melted;
|
||||
pub use proofs_status::ProofsStatus;
|
||||
pub use send_proofs::SendProofs;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// https://github.com/cashubtc/nuts/blob/main/02.md
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use bitcoin::hashes::sha256;
|
||||
@@ -17,6 +18,15 @@ pub enum Error {
|
||||
Length,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Length => write!(f, "NUT02: Id invalid length"),
|
||||
Self::Base64(err) => write!(f, "NUT02: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A keyset ID is an identifier for a specific keyset. It can be derived by
|
||||
/// anyone who knows the set of public keys of a mint. The keyset ID **CAN**
|
||||
/// be stored in a Cashu token such that the token can be used to identify
|
||||
|
||||
Reference in New Issue
Block a user