Skip to main content

dfns_sdk_rust/wallets/
mod.rs

1// Code generated by rust-sdk-generator. DO NOT EDIT.
2
3pub mod delegated;
4pub mod types;
5
6#[allow(unused_imports)]
7use types::*;
8
9/// Client for wallets operations.
10#[derive(Clone)]
11pub struct WalletsClient {
12    client: crate::client::Client,
13}
14
15impl WalletsClient {
16    pub fn new(client: crate::client::Client) -> Self {
17        WalletsClient { client }
18    }
19
20    /// Aborts a transaction that is currently in 'Executing' status and has not yet been signed. Sets the transaction status to 'Failed' and removes it from the retry queue.
21    ///
22    ///   This is useful when a transaction is stuck in the execution pipeline (e.g., during construct or sign phase) and you want to abort it without waiting for it to fail on its own.
23    ///
24    pub async fn abort_transaction(
25        &self,
26        wallet_id: String,
27        transaction_id: String,
28    ) -> Result<AbortTransactionResponse, crate::error::Error> {
29        let path = format!(
30            "/wallets/{}/transactions/{}/abort",
31            urlencoding::encode(&wallet_id),
32            urlencoding::encode(&transaction_id)
33        );
34        self.client
35            .request::<AbortTransactionResponse>(reqwest::Method::PUT, &path, None, true)
36            .await
37    }
38
39    /// Aborts a transfer that is currently in 'Executing' status and has not yet been signed. Sets the transfer status to 'Failed' and removes it from the retry queue.
40    ///
41    ///   This is useful when a transfer is stuck in the execution pipeline (e.g., during construct or sign phase) and you want to abort it without waiting for it to fail on its own.
42    ///
43    pub async fn abort_transfer(
44        &self,
45        wallet_id: String,
46        transfer_id: String,
47    ) -> Result<AbortTransferResponse, crate::error::Error> {
48        let path = format!(
49            "/wallets/{}/transfers/{}/abort",
50            urlencoding::encode(&wallet_id),
51            urlencoding::encode(&transfer_id)
52        );
53        self.client
54            .request::<AbortTransferResponse>(reqwest::Method::PUT, &path, None, true)
55            .await
56    }
57
58    /// Activates a wallet by deploying the account contract on-chain, making it ready for transactions.
59    ///
60    ///     This operation is required for wallets on networks where you need to explicitly activate your account on-chain
61    ///     before it can be used for transactions.
62    pub async fn activate_wallet(
63        &self,
64        wallet_id: String,
65        body: ActivateWalletRequest,
66    ) -> Result<ActivateWalletResponse, crate::error::Error> {
67        let path = format!("/wallets/{}/activate", urlencoding::encode(&wallet_id));
68        let body = serde_json::to_value(&body)?;
69        self.client
70            .request::<ActivateWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
71            .await
72    }
73
74    /// Retrieves a list of transactions requests for the specified wallet.
75    pub async fn list_transactions(
76        &self,
77        wallet_id: String,
78        query: Option<ListTransactionsQuery>,
79    ) -> Result<ListTransactionsResponse, crate::error::Error> {
80        let mut path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
81        if let Some(query) = &query {
82            let mut q: Vec<String> = Vec::new();
83            if let Some(v) = &query.limit {
84                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
85            }
86            if let Some(v) = &query.pagination_token {
87                q.push(format!(
88                    "paginationToken={}",
89                    urlencoding::encode(&v.to_string())
90                ));
91            }
92            if !q.is_empty() {
93                path.push('?');
94                path.push_str(&q.join("&"));
95            }
96        }
97        self.client
98            .request::<ListTransactionsResponse>(reqwest::Method::GET, &path, None, false)
99            .await
100    }
101
102    /// Sign & Broadcast transaction enables communication with any arbitrary smart contract of the target blockchain. You can construct a transaction that performs a complex task and this endpoint will sign the transaction, add the signature and broadcast it to chain. It can be used to call smart contract functions like mint tokens and even deploy new smart contracts.
103    ///
104    /// | Status      | Definition                                                                                                                                      |
105    /// |-------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
106    pub async fn sign_and_broadcast_transaction(
107        &self,
108        wallet_id: String,
109        body: SignAndBroadcastTransactionRequest,
110    ) -> Result<SignAndBroadcastTransactionResponse, crate::error::Error> {
111        let path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
112        let body = serde_json::to_value(&body)?;
113        self.client
114            .request::<SignAndBroadcastTransactionResponse>(
115                reqwest::Method::POST,
116                &path,
117                Some(&body),
118                true,
119            )
120            .await
121    }
122
123    /// Cancels an EVM transaction by creating a replacement transaction with the same nonce. The new transaction sends 0 value to the same address, effectively nullifying the original transaction.
124    ///   
125    ///   This endpoint works for:
126    ///   - EVM-compatible networks (Ethereum, Polygon, BSC, etc.)
127    pub async fn cancel_transaction(
128        &self,
129        wallet_id: String,
130        transaction_id: String,
131    ) -> Result<CancelTransactionResponse, crate::error::Error> {
132        let path = format!(
133            "/wallets/{}/transactions/{}/cancel",
134            urlencoding::encode(&wallet_id),
135            urlencoding::encode(&transaction_id)
136        );
137        self.client
138            .request::<CancelTransactionResponse>(reqwest::Method::POST, &path, None, true)
139            .await
140    }
141
142    /// Cancels an EVM transfer by creating a replacement transaction with the same nonce. The new transaction sends 0 value to the same address, effectively nullifying the original transfer.
143    ///   
144    ///   This endpoint works for:
145    ///   - EVM-compatible networks (Ethereum, Polygon, BSC, etc.)
146    pub async fn cancel_transfer(
147        &self,
148        wallet_id: String,
149        transfer_id: String,
150    ) -> Result<CancelTransferResponse, crate::error::Error> {
151        let path = format!(
152            "/wallets/{}/transfers/{}/cancel",
153            urlencoding::encode(&wallet_id),
154            urlencoding::encode(&transfer_id)
155        );
156        self.client
157            .request::<CancelTransferResponse>(reqwest::Method::POST, &path, None, true)
158            .await
159    }
160
161    /// Proxies a request to the Canton Ledger API associated with this wallet, using the validator's OAuth2 credentials. Restricted to a curated allow-list of read-style resources. Used to satisfy the Canton WalletConnect `canton_ledgerApi` method.
162    pub async fn proxy_arequest_to_the_canton_ledger_api(
163        &self,
164        wallet_id: String,
165        body: ProxyARequestToTheCantonLedgerApiRequest,
166    ) -> Result<serde_json::Value, crate::error::Error> {
167        let path = format!(
168            "/wallets/{}/canton/ledger-api",
169            urlencoding::encode(&wallet_id)
170        );
171        let body = serde_json::to_value(&body)?;
172        self.client
173            .request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
174            .await
175    }
176
177    /// Speeds up a transaction by creating a replacement transaction with the same parameters but higher gas fees.
178    ///   
179    ///   This endpoint only works for:
180    ///   - EVM-compatible networks (Ethereum, Polygon, BSC, etc.)
181    pub async fn speed_up_transaction(
182        &self,
183        wallet_id: String,
184        transaction_id: String,
185    ) -> Result<SpeedUpTransactionResponse, crate::error::Error> {
186        let path = format!(
187            "/wallets/{}/transactions/{}/speed-up",
188            urlencoding::encode(&wallet_id),
189            urlencoding::encode(&transaction_id)
190        );
191        self.client
192            .request::<SpeedUpTransactionResponse>(reqwest::Method::POST, &path, None, true)
193            .await
194    }
195
196    /// Speeds up a transfer by creating a replacement transaction with the same parameters but higher gas fees.
197    ///   
198    ///   This endpoint only works for:
199    ///   - EVM-compatible networks (Ethereum, Polygon, BSC, etc.)
200    pub async fn speed_up_transfer(
201        &self,
202        wallet_id: String,
203        transfer_id: String,
204    ) -> Result<SpeedUpTransferResponse, crate::error::Error> {
205        let path = format!(
206            "/wallets/{}/transfers/{}/speed-up",
207            urlencoding::encode(&wallet_id),
208            urlencoding::encode(&transfer_id)
209        );
210        self.client
211            .request::<SpeedUpTransferResponse>(reqwest::Method::POST, &path, None, true)
212            .await
213    }
214
215    /// Retrieves the list of Wallets in your organization. You can filter the results by owner (either by owner id or owner username). Pagination is supported via limit and paginationToken parameters.
216    pub async fn list_wallets(
217        &self,
218        query: Option<ListWalletsQuery>,
219    ) -> Result<ListWalletsResponse, crate::error::Error> {
220        let mut path = String::from("/wallets");
221        if let Some(query) = &query {
222            let mut q: Vec<String> = Vec::new();
223            if let Some(v) = &query.limit {
224                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
225            }
226            if let Some(v) = &query.pagination_token {
227                q.push(format!(
228                    "paginationToken={}",
229                    urlencoding::encode(&v.to_string())
230                ));
231            }
232            if let Some(v) = &query.owner {
233                q.push(format!("owner={}", urlencoding::encode(&v.to_string())));
234            }
235            if let Some(v) = &query.owner_id {
236                q.push(format!("ownerId={}", urlencoding::encode(&v.to_string())));
237            }
238            if let Some(v) = &query.owner_username {
239                q.push(format!(
240                    "ownerUsername={}",
241                    urlencoding::encode(&v.to_string())
242                ));
243            }
244            if !q.is_empty() {
245                path.push('?');
246                path.push_str(&q.join("&"));
247            }
248        }
249        self.client
250            .request::<ListWalletsResponse>(reqwest::Method::GET, &path, None, false)
251            .await
252    }
253
254    /// Creates a new Wallet associated with the given chain (such as Bitcoin or Ethereum ). Returns a new wallet entity.
255    pub async fn create_wallet(
256        &self,
257        body: CreateWalletRequest,
258    ) -> Result<CreateWalletResponse, crate::error::Error> {
259        let path = String::from("/wallets");
260        let body = serde_json::to_value(&body)?;
261        self.client
262            .request::<CreateWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
263            .await
264    }
265
266    /// Retrieve information about a specific transaction.
267    pub async fn get_transaction(
268        &self,
269        wallet_id: String,
270        transaction_id: String,
271    ) -> Result<GetTransactionResponse, crate::error::Error> {
272        let path = format!(
273            "/wallets/{}/transactions/{}",
274            urlencoding::encode(&wallet_id),
275            urlencoding::encode(&transaction_id)
276        );
277        self.client
278            .request::<GetTransactionResponse>(reqwest::Method::GET, &path, None, false)
279            .await
280    }
281
282    /// Retrieves a Wallet Transfer Request by its ID.
283    pub async fn get_transfer(
284        &self,
285        wallet_id: String,
286        transfer_id: String,
287    ) -> Result<GetTransferResponse, crate::error::Error> {
288        let path = format!(
289            "/wallets/{}/transfers/{}",
290            urlencoding::encode(&wallet_id),
291            urlencoding::encode(&transfer_id)
292        );
293        self.client
294            .request::<GetTransferResponse>(reqwest::Method::GET, &path, None, false)
295            .await
296    }
297
298    /// Retrieves a Wallet information by its ID.
299    pub async fn get_wallet(
300        &self,
301        wallet_id: String,
302    ) -> Result<GetWalletResponse, crate::error::Error> {
303        let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
304        self.client
305            .request::<GetWalletResponse>(reqwest::Method::GET, &path, None, false)
306            .await
307    }
308
309    /// Updates the name of an existing wallet.
310    pub async fn update_wallet(
311        &self,
312        wallet_id: String,
313        body: UpdateWalletRequest,
314    ) -> Result<UpdateWalletResponse, crate::error::Error> {
315        let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
316        let body = serde_json::to_value(&body)?;
317        self.client
318            .request::<UpdateWalletResponse>(reqwest::Method::PUT, &path, Some(&body), true)
319            .await
320    }
321
322    /// Retrieves a list of assets owned by the specified wallet.  Return values vary by chain as shown below.
323    pub async fn get_wallet_assets(
324        &self,
325        wallet_id: String,
326        query: Option<GetWalletAssetsQuery>,
327    ) -> Result<GetWalletAssetsResponse, crate::error::Error> {
328        let mut path = format!("/wallets/{}/assets", urlencoding::encode(&wallet_id));
329        if let Some(query) = &query {
330            let mut q: Vec<String> = Vec::new();
331            if let Some(v) = &query.net_worth {
332                q.push(format!("netWorth={}", urlencoding::encode(&v.to_string())));
333            }
334            if !q.is_empty() {
335                path.push('?');
336                path.push_str(&q.join("&"));
337            }
338        }
339        self.client
340            .request::<GetWalletAssetsResponse>(reqwest::Method::GET, &path, None, false)
341            .await
342    }
343
344    /// Retrieves a list of historical on chain activities for the specified wallet.
345    ///
346    /// The list reflects the indexed on-chain activity: it includes confirmed transactions only.
347    ///
348    pub async fn get_wallet_history(
349        &self,
350        wallet_id: String,
351        query: Option<GetWalletHistoryQuery>,
352    ) -> Result<GetWalletHistoryResponse, crate::error::Error> {
353        let mut path = format!("/wallets/{}/history", urlencoding::encode(&wallet_id));
354        if let Some(query) = &query {
355            let mut q: Vec<String> = Vec::new();
356            if let Some(v) = &query.limit {
357                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
358            }
359            if let Some(v) = &query.pagination_token {
360                q.push(format!(
361                    "paginationToken={}",
362                    urlencoding::encode(&v.to_string())
363                ));
364            }
365            if let Some(v) = &query.direction {
366                q.push(format!("direction={}", urlencoding::encode(&v.to_string())));
367            }
368            if let Some(v) = &query.kind {
369                q.push(format!("kind={}", urlencoding::encode(&v.to_string())));
370            }
371            if let Some(v) = &query.contract {
372                q.push(format!("contract={}", urlencoding::encode(&v.to_string())));
373            }
374            if !q.is_empty() {
375                path.push('?');
376                path.push_str(&q.join("&"));
377            }
378        }
379        self.client
380            .request::<GetWalletHistoryResponse>(reqwest::Method::GET, &path, None, false)
381            .await
382    }
383
384    /// Retrieves a list of NFTs owned by the specified Wallet.
385    pub async fn get_wallet_nfts(
386        &self,
387        wallet_id: String,
388    ) -> Result<GetWalletNftsResponse, crate::error::Error> {
389        let path = format!("/wallets/{}/nfts", urlencoding::encode(&wallet_id));
390        self.client
391            .request::<GetWalletNftsResponse>(reqwest::Method::GET, &path, None, false)
392            .await
393    }
394
395    /// <Warning>
396    /// This endpoint is not enabled by default. [Contact Dfns](https://support.dfns.co) to have it activated.
397    /// </Warning>
398    ///
399    pub async fn import_wallet(
400        &self,
401        body: ImportWalletRequest,
402    ) -> Result<ImportWalletResponse, crate::error::Error> {
403        let path = String::from("/wallets/import");
404        let body = serde_json::to_value(&body)?;
405        self.client
406            .request::<ImportWalletResponse>(reqwest::Method::POST, &path, Some(&body), true)
407            .await
408    }
409
410    /// Retrieves a list of transfer requests for the specified wallet.
411    pub async fn list_transfers(
412        &self,
413        wallet_id: String,
414        query: Option<ListTransfersQuery>,
415    ) -> Result<ListTransfersResponse, crate::error::Error> {
416        let mut path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
417        if let Some(query) = &query {
418            let mut q: Vec<String> = Vec::new();
419            if let Some(v) = &query.limit {
420                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
421            }
422            if let Some(v) = &query.pagination_token {
423                q.push(format!(
424                    "paginationToken={}",
425                    urlencoding::encode(&v.to_string())
426                ));
427            }
428            if !q.is_empty() {
429                path.push('?');
430                path.push_str(&q.join("&"));
431            }
432        }
433        self.client
434            .request::<ListTransfersResponse>(reqwest::Method::GET, &path, None, false)
435            .await
436    }
437
438    /// Transfer an asset out of the specified wallet to a destination address.
439    /// For all fungible token transfers, the transfer amount must be specified in the minimum denomination of that token.
440    /// For example, use the amount in Satoshi for a Bitcoin transfer, or the amount in Wei for an Ethereum transfer etc.
441    ///
442    pub async fn transfer_asset(
443        &self,
444        wallet_id: String,
445        body: TransferAssetRequest,
446    ) -> Result<TransferAssetResponse, crate::error::Error> {
447        let path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
448        let body = serde_json::to_value(&body)?;
449        self.client
450            .request::<TransferAssetResponse>(reqwest::Method::POST, &path, Some(&body), true)
451            .await
452    }
453
454    /// Add a [Tag](https://docs.dfns.co/api-reference/wallets/tags) to a wallet.
455    pub async fn tag_wallet(
456        &self,
457        wallet_id: String,
458        body: TagWalletRequest,
459    ) -> Result<TagWalletResponse, crate::error::Error> {
460        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
461        let body = serde_json::to_value(&body)?;
462        self.client
463            .request::<TagWalletResponse>(reqwest::Method::PUT, &path, Some(&body), true)
464            .await
465    }
466
467    /// Removes the specified tags from a wallet.
468    pub async fn untag_wallet(
469        &self,
470        wallet_id: String,
471        body: UntagWalletRequest,
472    ) -> Result<UntagWalletResponse, crate::error::Error> {
473        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
474        let body = serde_json::to_value(&body)?;
475        self.client
476            .request::<UntagWalletResponse>(reqwest::Method::DELETE, &path, Some(&body), true)
477            .await
478    }
479
480    /// Retrieve information about a specific offer received on your wallet.
481    pub async fn get_offer(
482        &self,
483        wallet_id: String,
484        offer_id: String,
485    ) -> Result<GetOfferResponse, crate::error::Error> {
486        let path = format!(
487            "/wallets/{}/offers/{}",
488            urlencoding::encode(&wallet_id),
489            urlencoding::encode(&offer_id)
490        );
491        self.client
492            .request::<GetOfferResponse>(reqwest::Method::GET, &path, None, false)
493            .await
494    }
495
496    /// List all offers received on a specific wallet.
497    pub async fn list_offers(
498        &self,
499        wallet_id: String,
500        query: Option<ListOffersQuery>,
501    ) -> Result<ListOffersResponse, crate::error::Error> {
502        let mut path = format!("/wallets/{}/offers", urlencoding::encode(&wallet_id));
503        if let Some(query) = &query {
504            let mut q: Vec<String> = Vec::new();
505            if let Some(v) = &query.limit {
506                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
507            }
508            if let Some(v) = &query.pagination_token {
509                q.push(format!(
510                    "paginationToken={}",
511                    urlencoding::encode(&v.to_string())
512                ));
513            }
514            if !q.is_empty() {
515                path.push('?');
516                path.push_str(&q.join("&"));
517            }
518        }
519        self.client
520            .request::<ListOffersResponse>(reqwest::Method::GET, &path, None, false)
521            .await
522    }
523
524    /// Accept an offer received on your wallet.
525    pub async fn accept_offer(
526        &self,
527        wallet_id: String,
528        offer_id: String,
529    ) -> Result<AcceptOfferResponse, crate::error::Error> {
530        let path = format!(
531            "/wallets/{}/offers/{}/accept",
532            urlencoding::encode(&wallet_id),
533            urlencoding::encode(&offer_id)
534        );
535        self.client
536            .request::<AcceptOfferResponse>(reqwest::Method::PUT, &path, None, true)
537            .await
538    }
539
540    /// Reject an offer received on your wallet.
541    pub async fn reject_offer(
542        &self,
543        wallet_id: String,
544        offer_id: String,
545    ) -> Result<RejectOfferResponse, crate::error::Error> {
546        let path = format!(
547            "/wallets/{}/offers/{}/reject",
548            urlencoding::encode(&wallet_id),
549            urlencoding::encode(&offer_id)
550        );
551        self.client
552            .request::<RejectOfferResponse>(reqwest::Method::PUT, &path, None, true)
553            .await
554    }
555
556    /// Retrieve the transaction history across all wallets within a specified timeframe. The time range is unbounded, but the CSV export is capped at 100,000 rows.
557    pub async fn list_org_wallet_history(
558        &self,
559        query: Option<ListOrgWalletHistoryQuery>,
560    ) -> Result<serde_json::Value, crate::error::Error> {
561        let mut path = String::from("/wallets/all/history");
562        if let Some(query) = &query {
563            let mut q: Vec<String> = Vec::new();
564            if let Some(v) = &query.limit {
565                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
566            }
567            if let Some(v) = &query.pagination_token {
568                q.push(format!(
569                    "paginationToken={}",
570                    urlencoding::encode(&v.to_string())
571                ));
572            }
573            q.push(format!(
574                "startTime={}",
575                urlencoding::encode(&query.start_time.to_string())
576            ));
577            q.push(format!(
578                "endTime={}",
579                urlencoding::encode(&query.end_time.to_string())
580            ));
581            if !q.is_empty() {
582                path.push('?');
583                path.push_str(&q.join("&"));
584            }
585        }
586        self.client
587            .request::<serde_json::Value>(reqwest::Method::GET, &path, None, false)
588            .await
589    }
590}