Skip to content

Commit

Permalink
chore: add optional unit to TokenV3
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Jan 9, 2024
1 parent 6e1d655 commit ccdd478
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion moksha-core/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_with::skip_serializing_none;
use url::Url;

use crate::{error::MokshaCoreError, proof::Proofs};
use crate::{error::MokshaCoreError, primitives::CurrencyUnit, proof::Proofs};

const TOKEN_PREFIX_V3: &str = "cashuA";

Expand Down Expand Up @@ -52,20 +52,23 @@ pub struct TokenV3 {
#[serde(rename = "token")]
pub tokens: Vec<Token>,
pub memo: Option<String>,
pub unit: Option<CurrencyUnit>,
}

impl TokenV3 {
pub fn new(token: Token) -> Self {
Self {
tokens: vec![token],
memo: None,
unit: None,
}
}

pub fn empty() -> Self {
Self {
tokens: vec![],
memo: None,
unit: None,
}
}

Expand Down Expand Up @@ -143,6 +146,7 @@ impl From<(Url, Proofs)> for TokenV3 {
proofs: from.1,
}],
memo: None,
unit: None,
}
}
}
Expand Down Expand Up @@ -204,6 +208,7 @@ mod tests {
let tokens = super::TokenV3 {
tokens: vec![token],
memo: Some("my memo".to_string()),
unit: None,
};

let serialized: String = tokens.try_into()?;
Expand Down

0 comments on commit ccdd478

Please sign in to comment.