-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: melt quote and melt to v1 in wallet sdk
- Loading branch information
1 parent
dcc3509
commit 754936d
Showing
17 changed files
with
308 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::ops::Deref; | ||
use std::str::FromStr; | ||
use std::sync::Arc; | ||
|
||
use cashu::nuts::CurrencyUnit; | ||
use cashu::types::MeltQuote as MeltQuoteSdk; | ||
|
||
use crate::{Amount, Bolt11Invoice}; | ||
|
||
pub struct MeltQuote { | ||
inner: MeltQuoteSdk, | ||
} | ||
|
||
impl Deref for MeltQuote { | ||
type Target = MeltQuoteSdk; | ||
fn deref(&self) -> &Self::Target { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl From<MeltQuoteSdk> for MeltQuote { | ||
fn from(inner: MeltQuoteSdk) -> MeltQuote { | ||
MeltQuote { inner } | ||
} | ||
} | ||
|
||
impl MeltQuote { | ||
pub fn new( | ||
id: String, | ||
amount: Arc<Amount>, | ||
unit: String, | ||
request: Arc<Bolt11Invoice>, | ||
fee_reserve: Arc<Amount>, | ||
paid: bool, | ||
expiry: u64, | ||
) -> Self { | ||
Self { | ||
inner: MeltQuoteSdk { | ||
id, | ||
amount: amount.as_ref().deref().clone(), | ||
unit: CurrencyUnit::from_str(&unit).unwrap(), | ||
request: request.as_ref().deref().clone(), | ||
fee_reserve: fee_reserve.as_ref().deref().clone(), | ||
paid, | ||
expiry, | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::ops::Deref; | ||
use std::str::FromStr; | ||
use std::sync::Arc; | ||
|
||
use cashu::nuts::CurrencyUnit; | ||
use cashu::types::MintQuote as MintQuoteSdk; | ||
|
||
use crate::{Amount, Bolt11Invoice}; | ||
|
||
pub struct MintQuote { | ||
inner: MintQuoteSdk, | ||
} | ||
|
||
impl Deref for MintQuote { | ||
type Target = MintQuoteSdk; | ||
fn deref(&self) -> &Self::Target { | ||
&self.inner | ||
} | ||
} | ||
|
||
impl From<MintQuoteSdk> for MintQuote { | ||
fn from(inner: MintQuoteSdk) -> MintQuote { | ||
MintQuote { inner } | ||
} | ||
} | ||
|
||
impl MintQuote { | ||
pub fn new( | ||
id: String, | ||
amount: Arc<Amount>, | ||
unit: String, | ||
request: Arc<Bolt11Invoice>, | ||
paid: bool, | ||
expiry: u64, | ||
) -> Self { | ||
Self { | ||
inner: MintQuoteSdk { | ||
id, | ||
amount: amount.as_ref().deref().clone(), | ||
unit: CurrencyUnit::from_str(&unit).unwrap(), | ||
request: request.as_ref().deref().clone(), | ||
paid, | ||
expiry, | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
pub mod amount; | ||
pub mod bolt11_invoice; | ||
pub mod keyset_info; | ||
pub mod mint_quote_info; | ||
pub mod melt_quote; | ||
pub mod mint_quote; | ||
pub mod secret; | ||
|
||
pub use amount::Amount; | ||
pub use bolt11_invoice::Bolt11Invoice; | ||
pub use keyset_info::KeySetInfo; | ||
pub use mint_quote_info::MintQuoteInfo; | ||
pub use melt_quote::MeltQuote; | ||
pub use mint_quote::MintQuote; | ||
pub use secret::Secret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.