Skip to main content

dfns_sdk_rust/wallets/
mod.rs

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