1use serde::{Deserialize, Serialize};
2
3use crate::client::MpcClient;
4use crate::error::Error;
5
6#[derive(Debug, Serialize)]
8pub struct CreateWalletRequest {
9 pub wallet_name: String,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub description: Option<String>,
12}
13
14#[derive(Debug, Deserialize)]
16pub struct Wallet {
17 pub wallet_id: String,
18 pub client_id: String,
19 pub wallet_name: String,
20 pub description: String,
21 pub status: String,
22 pub key_status: String,
23 pub created_at: String,
24 pub updated_at: String,
25}
26
27#[derive(Debug, Default)]
29pub struct ListWalletsRequest {
30 pub page: Option<i32>,
31 pub page_size: Option<i32>,
32}
33
34#[derive(Debug, Deserialize)]
36pub struct ListWalletsResponse {
37 #[serde(rename = "data")]
38 pub items: Vec<Wallet>,
39 pub total: i64,
40 pub has_more: bool,
41}
42
43impl MpcClient {
44 pub async fn create_wallet(&self, req: &CreateWalletRequest) -> Result<Wallet, Error> {
46 self.post("/api/v1/wallets", req).await
47 }
48
49 pub async fn get_wallet(&self, wallet_id: &str) -> Result<Wallet, Error> {
51 self.get(&format!("/api/v1/wallets/{wallet_id}")).await
52 }
53
54 pub async fn list_wallets(
56 &self,
57 req: &ListWalletsRequest,
58 ) -> Result<ListWalletsResponse, Error> {
59 let mut params = Vec::new();
60 if let Some(page) = req.page {
61 params.push(("page".to_string(), page.to_string()));
62 }
63 if let Some(page_size) = req.page_size {
64 params.push(("page_size".to_string(), page_size.to_string()));
65 }
66 self.get_with_query("/api/v1/wallets", ¶ms).await
67 }
68}