moksha_wallet/client/
mod.rs

1use async_trait::async_trait;
2use moksha_core::{
3    blind::BlindedMessage,
4    keyset::V1Keysets,
5    primitives::{
6        CurrencyUnit, GetMeltOnchainResponse, KeysResponse, MintInfoResponse,
7        PostMeltBolt11Response, PostMeltOnchainResponse, PostMeltQuoteBolt11Response,
8        PostMeltQuoteOnchainResponse, PostMintBolt11Response, PostMintOnchainResponse,
9        PostMintQuoteBolt11Response, PostMintQuoteOnchainResponse, PostSwapResponse,
10    },
11    proof::Proofs,
12};
13
14use url::Url;
15
16use crate::error::MokshaWalletError;
17
18pub mod crossplatform;
19
20#[cfg(test)]
21use mockall::automock;
22
23#[cfg_attr(test, automock)]
24#[async_trait(?Send)]
25pub trait CashuClient {
26    async fn get_keys(&self, mint_url: &Url) -> Result<KeysResponse, MokshaWalletError>;
27
28    async fn get_keys_by_id(
29        &self,
30        mint_url: &Url,
31        keyset_id: String,
32    ) -> Result<KeysResponse, MokshaWalletError>;
33
34    async fn get_keysets(&self, mint_url: &Url) -> Result<V1Keysets, MokshaWalletError>;
35
36    async fn post_swap(
37        &self,
38        mint_url: &Url,
39        proofs: Proofs,
40        output: Vec<BlindedMessage>,
41    ) -> Result<PostSwapResponse, MokshaWalletError>;
42
43    async fn post_melt_bolt11(
44        &self,
45        mint_url: &Url,
46        proofs: Proofs,
47        quote: String,
48        outputs: Vec<BlindedMessage>,
49    ) -> Result<PostMeltBolt11Response, MokshaWalletError>;
50
51    async fn post_melt_quote_bolt11(
52        &self,
53        mint_url: &Url,
54        payment_request: String,
55        unit: CurrencyUnit,
56    ) -> Result<PostMeltQuoteBolt11Response, MokshaWalletError>;
57
58    async fn get_melt_quote_bolt11(
59        &self,
60        mint_url: &Url,
61        quote: String,
62    ) -> Result<PostMeltQuoteBolt11Response, MokshaWalletError>;
63
64    async fn post_mint_bolt11(
65        &self,
66        mint_url: &Url,
67        quote: String,
68        blinded_messages: Vec<BlindedMessage>,
69    ) -> Result<PostMintBolt11Response, MokshaWalletError>;
70
71    async fn post_mint_quote_bolt11(
72        &self,
73        mint_url: &Url,
74        amount: u64,
75        unit: CurrencyUnit,
76    ) -> Result<PostMintQuoteBolt11Response, MokshaWalletError>;
77
78    async fn get_mint_quote_bolt11(
79        &self,
80        mint_url: &Url,
81        quote: String,
82    ) -> Result<PostMintQuoteBolt11Response, MokshaWalletError>;
83
84    async fn get_info(&self, mint_url: &Url) -> Result<MintInfoResponse, MokshaWalletError>;
85
86    async fn is_v1_supported(&self, mint_url: &Url) -> Result<bool, MokshaWalletError>;
87
88    async fn post_mint_onchain(
89        &self,
90        mint_url: &Url,
91        quote: String,
92        blinded_messages: Vec<BlindedMessage>,
93    ) -> Result<PostMintOnchainResponse, MokshaWalletError>;
94
95    async fn post_mint_quote_onchain(
96        &self,
97        mint_url: &Url,
98        amount: u64,
99        unit: CurrencyUnit,
100    ) -> Result<PostMintQuoteOnchainResponse, MokshaWalletError>;
101
102    async fn get_mint_quote_onchain(
103        &self,
104        mint_url: &Url,
105        quote: String,
106    ) -> Result<PostMintQuoteOnchainResponse, MokshaWalletError>;
107
108    async fn post_melt_onchain(
109        &self,
110        mint_url: &Url,
111        proofs: Proofs,
112        quote: String,
113    ) -> Result<PostMeltOnchainResponse, MokshaWalletError>;
114
115    async fn post_melt_quote_onchain(
116        &self,
117        mint_url: &Url,
118        address: String,
119        amount: u64,
120        unit: CurrencyUnit,
121    ) -> Result<Vec<PostMeltQuoteOnchainResponse>, MokshaWalletError>;
122
123    async fn get_melt_quote_onchain(
124        &self,
125        mint_url: &Url,
126        quote: String,
127    ) -> Result<PostMeltQuoteOnchainResponse, MokshaWalletError>;
128
129    async fn get_melt_onchain(
130        &self,
131        mint_url: &Url,
132        txid: String,
133    ) -> Result<GetMeltOnchainResponse, MokshaWalletError>;
134}