Skip to main content

dfns_sdk_rust/wallets/
delegated.rs

1// Code generated by rust-sdk-generator. DO NOT EDIT.
2
3#[allow(unused_imports)]
4use super::types::*;
5
6/// Delegated client for wallets operations. Signed operations are split into
7/// init/complete pairs so the challenge can be signed on the user side.
8#[derive(Clone)]
9pub struct DelegatedWalletsClient {
10    client: crate::client::Client,
11}
12
13impl DelegatedWalletsClient {
14    pub fn new(client: crate::client::Client) -> Self {
15        DelegatedWalletsClient { client }
16    }
17
18    /// Starts delegated signing for abortTransaction: returns the challenge to sign.
19    /// Pass the signed assertion to abort_transaction_complete with the same arguments.
20    pub async fn abort_transaction_init(
21        &self,
22        wallet_id: String,
23        transaction_id: String,
24    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
25        let path = format!(
26            "/wallets/{}/transactions/{}/abort",
27            urlencoding::encode(&wallet_id),
28            urlencoding::encode(&transaction_id)
29        );
30        self.client
31            .create_user_action_challenge(reqwest::Method::PUT, &path, None)
32            .await
33    }
34
35    /// Finishes delegated signing for abortTransaction: submits the signed challenge
36    /// and issues the request.
37    pub async fn abort_transaction_complete(
38        &self,
39        wallet_id: String,
40        transaction_id: String,
41        challenge_identifier: String,
42        assertion: crate::signer::CredentialAssertion,
43    ) -> Result<AbortTransactionResponse, crate::error::Error> {
44        let path = format!(
45            "/wallets/{}/transactions/{}/abort",
46            urlencoding::encode(&wallet_id),
47            urlencoding::encode(&transaction_id)
48        );
49        let user_action = self
50            .client
51            .complete_user_action_signing(challenge_identifier, &assertion)
52            .await?;
53        self.client
54            .request_with_user_action::<AbortTransactionResponse>(
55                reqwest::Method::PUT,
56                &path,
57                None,
58                &user_action,
59            )
60            .await
61    }
62
63    /// Starts delegated signing for abortTransfer: returns the challenge to sign.
64    /// Pass the signed assertion to abort_transfer_complete with the same arguments.
65    pub async fn abort_transfer_init(
66        &self,
67        wallet_id: String,
68        transfer_id: String,
69    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
70        let path = format!(
71            "/wallets/{}/transfers/{}/abort",
72            urlencoding::encode(&wallet_id),
73            urlencoding::encode(&transfer_id)
74        );
75        self.client
76            .create_user_action_challenge(reqwest::Method::PUT, &path, None)
77            .await
78    }
79
80    /// Finishes delegated signing for abortTransfer: submits the signed challenge
81    /// and issues the request.
82    pub async fn abort_transfer_complete(
83        &self,
84        wallet_id: String,
85        transfer_id: String,
86        challenge_identifier: String,
87        assertion: crate::signer::CredentialAssertion,
88    ) -> Result<AbortTransferResponse, crate::error::Error> {
89        let path = format!(
90            "/wallets/{}/transfers/{}/abort",
91            urlencoding::encode(&wallet_id),
92            urlencoding::encode(&transfer_id)
93        );
94        let user_action = self
95            .client
96            .complete_user_action_signing(challenge_identifier, &assertion)
97            .await?;
98        self.client
99            .request_with_user_action::<AbortTransferResponse>(
100                reqwest::Method::PUT,
101                &path,
102                None,
103                &user_action,
104            )
105            .await
106    }
107
108    /// Starts delegated signing for activateWallet: returns the challenge to sign.
109    /// Pass the signed assertion to activate_wallet_complete with the same arguments.
110    pub async fn activate_wallet_init(
111        &self,
112        wallet_id: String,
113        body: ActivateWalletRequest,
114    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
115        let path = format!("/wallets/{}/activate", urlencoding::encode(&wallet_id));
116        let body = serde_json::to_value(&body)?;
117        self.client
118            .create_user_action_challenge(reqwest::Method::POST, &path, Some(&body))
119            .await
120    }
121
122    /// Finishes delegated signing for activateWallet: submits the signed challenge
123    /// and issues the request.
124    pub async fn activate_wallet_complete(
125        &self,
126        wallet_id: String,
127        body: ActivateWalletRequest,
128        challenge_identifier: String,
129        assertion: crate::signer::CredentialAssertion,
130    ) -> Result<ActivateWalletResponse, crate::error::Error> {
131        let path = format!("/wallets/{}/activate", urlencoding::encode(&wallet_id));
132        let body = serde_json::to_value(&body)?;
133        let user_action = self
134            .client
135            .complete_user_action_signing(challenge_identifier, &assertion)
136            .await?;
137        self.client
138            .request_with_user_action::<ActivateWalletResponse>(
139                reqwest::Method::POST,
140                &path,
141                Some(&body),
142                &user_action,
143            )
144            .await
145    }
146
147    /// Retrieves a list of transactions requests for the specified wallet.
148    pub async fn list_transactions(
149        &self,
150        wallet_id: String,
151        query: Option<ListTransactionsQuery>,
152    ) -> Result<ListTransactionsResponse, crate::error::Error> {
153        let mut path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
154        if let Some(query) = &query {
155            let mut q: Vec<String> = Vec::new();
156            if let Some(v) = &query.limit {
157                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
158            }
159            if let Some(v) = &query.pagination_token {
160                q.push(format!(
161                    "paginationToken={}",
162                    urlencoding::encode(&v.to_string())
163                ));
164            }
165            if !q.is_empty() {
166                path.push('?');
167                path.push_str(&q.join("&"));
168            }
169        }
170        self.client
171            .request::<ListTransactionsResponse>(reqwest::Method::GET, &path, None, false)
172            .await
173    }
174
175    /// Starts delegated signing for signAndBroadcastTransaction: returns the challenge to sign.
176    /// Pass the signed assertion to sign_and_broadcast_transaction_complete with the same arguments.
177    pub async fn sign_and_broadcast_transaction_init(
178        &self,
179        wallet_id: String,
180        body: SignAndBroadcastTransactionRequest,
181    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
182        let path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
183        let body = serde_json::to_value(&body)?;
184        self.client
185            .create_user_action_challenge(reqwest::Method::POST, &path, Some(&body))
186            .await
187    }
188
189    /// Finishes delegated signing for signAndBroadcastTransaction: submits the signed challenge
190    /// and issues the request.
191    pub async fn sign_and_broadcast_transaction_complete(
192        &self,
193        wallet_id: String,
194        body: SignAndBroadcastTransactionRequest,
195        challenge_identifier: String,
196        assertion: crate::signer::CredentialAssertion,
197    ) -> Result<SignAndBroadcastTransactionResponse, crate::error::Error> {
198        let path = format!("/wallets/{}/transactions", urlencoding::encode(&wallet_id));
199        let body = serde_json::to_value(&body)?;
200        let user_action = self
201            .client
202            .complete_user_action_signing(challenge_identifier, &assertion)
203            .await?;
204        self.client
205            .request_with_user_action::<SignAndBroadcastTransactionResponse>(
206                reqwest::Method::POST,
207                &path,
208                Some(&body),
209                &user_action,
210            )
211            .await
212    }
213
214    /// Starts delegated signing for cancelTransaction: returns the challenge to sign.
215    /// Pass the signed assertion to cancel_transaction_complete with the same arguments.
216    pub async fn cancel_transaction_init(
217        &self,
218        wallet_id: String,
219        transaction_id: String,
220    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
221        let path = format!(
222            "/wallets/{}/transactions/{}/cancel",
223            urlencoding::encode(&wallet_id),
224            urlencoding::encode(&transaction_id)
225        );
226        self.client
227            .create_user_action_challenge(reqwest::Method::POST, &path, None)
228            .await
229    }
230
231    /// Finishes delegated signing for cancelTransaction: submits the signed challenge
232    /// and issues the request.
233    pub async fn cancel_transaction_complete(
234        &self,
235        wallet_id: String,
236        transaction_id: String,
237        challenge_identifier: String,
238        assertion: crate::signer::CredentialAssertion,
239    ) -> Result<CancelTransactionResponse, crate::error::Error> {
240        let path = format!(
241            "/wallets/{}/transactions/{}/cancel",
242            urlencoding::encode(&wallet_id),
243            urlencoding::encode(&transaction_id)
244        );
245        let user_action = self
246            .client
247            .complete_user_action_signing(challenge_identifier, &assertion)
248            .await?;
249        self.client
250            .request_with_user_action::<CancelTransactionResponse>(
251                reqwest::Method::POST,
252                &path,
253                None,
254                &user_action,
255            )
256            .await
257    }
258
259    /// Starts delegated signing for cancelTransfer: returns the challenge to sign.
260    /// Pass the signed assertion to cancel_transfer_complete with the same arguments.
261    pub async fn cancel_transfer_init(
262        &self,
263        wallet_id: String,
264        transfer_id: String,
265    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
266        let path = format!(
267            "/wallets/{}/transfers/{}/cancel",
268            urlencoding::encode(&wallet_id),
269            urlencoding::encode(&transfer_id)
270        );
271        self.client
272            .create_user_action_challenge(reqwest::Method::POST, &path, None)
273            .await
274    }
275
276    /// Finishes delegated signing for cancelTransfer: submits the signed challenge
277    /// and issues the request.
278    pub async fn cancel_transfer_complete(
279        &self,
280        wallet_id: String,
281        transfer_id: String,
282        challenge_identifier: String,
283        assertion: crate::signer::CredentialAssertion,
284    ) -> Result<CancelTransferResponse, crate::error::Error> {
285        let path = format!(
286            "/wallets/{}/transfers/{}/cancel",
287            urlencoding::encode(&wallet_id),
288            urlencoding::encode(&transfer_id)
289        );
290        let user_action = self
291            .client
292            .complete_user_action_signing(challenge_identifier, &assertion)
293            .await?;
294        self.client
295            .request_with_user_action::<CancelTransferResponse>(
296                reqwest::Method::POST,
297                &path,
298                None,
299                &user_action,
300            )
301            .await
302    }
303
304    /// 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.
305    pub async fn proxy_arequest_to_the_canton_ledger_api(
306        &self,
307        wallet_id: String,
308        body: ProxyARequestToTheCantonLedgerApiRequest,
309    ) -> Result<serde_json::Value, crate::error::Error> {
310        let path = format!(
311            "/wallets/{}/canton/ledger-api",
312            urlencoding::encode(&wallet_id)
313        );
314        let body = serde_json::to_value(&body)?;
315        self.client
316            .request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
317            .await
318    }
319
320    /// Starts delegated signing for speedUpTransaction: returns the challenge to sign.
321    /// Pass the signed assertion to speed_up_transaction_complete with the same arguments.
322    pub async fn speed_up_transaction_init(
323        &self,
324        wallet_id: String,
325        transaction_id: String,
326    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
327        let path = format!(
328            "/wallets/{}/transactions/{}/speed-up",
329            urlencoding::encode(&wallet_id),
330            urlencoding::encode(&transaction_id)
331        );
332        self.client
333            .create_user_action_challenge(reqwest::Method::POST, &path, None)
334            .await
335    }
336
337    /// Finishes delegated signing for speedUpTransaction: submits the signed challenge
338    /// and issues the request.
339    pub async fn speed_up_transaction_complete(
340        &self,
341        wallet_id: String,
342        transaction_id: String,
343        challenge_identifier: String,
344        assertion: crate::signer::CredentialAssertion,
345    ) -> Result<SpeedUpTransactionResponse, crate::error::Error> {
346        let path = format!(
347            "/wallets/{}/transactions/{}/speed-up",
348            urlencoding::encode(&wallet_id),
349            urlencoding::encode(&transaction_id)
350        );
351        let user_action = self
352            .client
353            .complete_user_action_signing(challenge_identifier, &assertion)
354            .await?;
355        self.client
356            .request_with_user_action::<SpeedUpTransactionResponse>(
357                reqwest::Method::POST,
358                &path,
359                None,
360                &user_action,
361            )
362            .await
363    }
364
365    /// Starts delegated signing for speedUpTransfer: returns the challenge to sign.
366    /// Pass the signed assertion to speed_up_transfer_complete with the same arguments.
367    pub async fn speed_up_transfer_init(
368        &self,
369        wallet_id: String,
370        transfer_id: String,
371    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
372        let path = format!(
373            "/wallets/{}/transfers/{}/speed-up",
374            urlencoding::encode(&wallet_id),
375            urlencoding::encode(&transfer_id)
376        );
377        self.client
378            .create_user_action_challenge(reqwest::Method::POST, &path, None)
379            .await
380    }
381
382    /// Finishes delegated signing for speedUpTransfer: submits the signed challenge
383    /// and issues the request.
384    pub async fn speed_up_transfer_complete(
385        &self,
386        wallet_id: String,
387        transfer_id: String,
388        challenge_identifier: String,
389        assertion: crate::signer::CredentialAssertion,
390    ) -> Result<SpeedUpTransferResponse, crate::error::Error> {
391        let path = format!(
392            "/wallets/{}/transfers/{}/speed-up",
393            urlencoding::encode(&wallet_id),
394            urlencoding::encode(&transfer_id)
395        );
396        let user_action = self
397            .client
398            .complete_user_action_signing(challenge_identifier, &assertion)
399            .await?;
400        self.client
401            .request_with_user_action::<SpeedUpTransferResponse>(
402                reqwest::Method::POST,
403                &path,
404                None,
405                &user_action,
406            )
407            .await
408    }
409
410    /// 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.
411    pub async fn list_wallets(
412        &self,
413        query: Option<ListWalletsQuery>,
414    ) -> Result<ListWalletsResponse, crate::error::Error> {
415        let mut path = String::from("/wallets");
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 let Some(v) = &query.owner {
428                q.push(format!("owner={}", urlencoding::encode(&v.to_string())));
429            }
430            if let Some(v) = &query.owner_id {
431                q.push(format!("ownerId={}", urlencoding::encode(&v.to_string())));
432            }
433            if let Some(v) = &query.owner_username {
434                q.push(format!(
435                    "ownerUsername={}",
436                    urlencoding::encode(&v.to_string())
437                ));
438            }
439            if !q.is_empty() {
440                path.push('?');
441                path.push_str(&q.join("&"));
442            }
443        }
444        self.client
445            .request::<ListWalletsResponse>(reqwest::Method::GET, &path, None, false)
446            .await
447    }
448
449    /// Starts delegated signing for createWallet: returns the challenge to sign.
450    /// Pass the signed assertion to create_wallet_complete with the same arguments.
451    pub async fn create_wallet_init(
452        &self,
453        body: CreateWalletRequest,
454    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
455        let path = String::from("/wallets");
456        let body = serde_json::to_value(&body)?;
457        self.client
458            .create_user_action_challenge(reqwest::Method::POST, &path, Some(&body))
459            .await
460    }
461
462    /// Finishes delegated signing for createWallet: submits the signed challenge
463    /// and issues the request.
464    pub async fn create_wallet_complete(
465        &self,
466        body: CreateWalletRequest,
467        challenge_identifier: String,
468        assertion: crate::signer::CredentialAssertion,
469    ) -> Result<CreateWalletResponse, crate::error::Error> {
470        let path = String::from("/wallets");
471        let body = serde_json::to_value(&body)?;
472        let user_action = self
473            .client
474            .complete_user_action_signing(challenge_identifier, &assertion)
475            .await?;
476        self.client
477            .request_with_user_action::<CreateWalletResponse>(
478                reqwest::Method::POST,
479                &path,
480                Some(&body),
481                &user_action,
482            )
483            .await
484    }
485
486    /// Retrieve information about a specific transaction.
487    pub async fn get_transaction(
488        &self,
489        wallet_id: String,
490        transaction_id: String,
491    ) -> Result<GetTransactionResponse, crate::error::Error> {
492        let path = format!(
493            "/wallets/{}/transactions/{}",
494            urlencoding::encode(&wallet_id),
495            urlencoding::encode(&transaction_id)
496        );
497        self.client
498            .request::<GetTransactionResponse>(reqwest::Method::GET, &path, None, false)
499            .await
500    }
501
502    /// Retrieves a Wallet Transfer Request by its ID.
503    pub async fn get_transfer(
504        &self,
505        wallet_id: String,
506        transfer_id: String,
507    ) -> Result<GetTransferResponse, crate::error::Error> {
508        let path = format!(
509            "/wallets/{}/transfers/{}",
510            urlencoding::encode(&wallet_id),
511            urlencoding::encode(&transfer_id)
512        );
513        self.client
514            .request::<GetTransferResponse>(reqwest::Method::GET, &path, None, false)
515            .await
516    }
517
518    /// Retrieves a Wallet information by its ID.
519    pub async fn get_wallet(
520        &self,
521        wallet_id: String,
522    ) -> Result<GetWalletResponse, crate::error::Error> {
523        let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
524        self.client
525            .request::<GetWalletResponse>(reqwest::Method::GET, &path, None, false)
526            .await
527    }
528
529    /// Starts delegated signing for updateWallet: returns the challenge to sign.
530    /// Pass the signed assertion to update_wallet_complete with the same arguments.
531    pub async fn update_wallet_init(
532        &self,
533        wallet_id: String,
534        body: UpdateWalletRequest,
535    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
536        let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
537        let body = serde_json::to_value(&body)?;
538        self.client
539            .create_user_action_challenge(reqwest::Method::PUT, &path, Some(&body))
540            .await
541    }
542
543    /// Finishes delegated signing for updateWallet: submits the signed challenge
544    /// and issues the request.
545    pub async fn update_wallet_complete(
546        &self,
547        wallet_id: String,
548        body: UpdateWalletRequest,
549        challenge_identifier: String,
550        assertion: crate::signer::CredentialAssertion,
551    ) -> Result<UpdateWalletResponse, crate::error::Error> {
552        let path = format!("/wallets/{}", urlencoding::encode(&wallet_id));
553        let body = serde_json::to_value(&body)?;
554        let user_action = self
555            .client
556            .complete_user_action_signing(challenge_identifier, &assertion)
557            .await?;
558        self.client
559            .request_with_user_action::<UpdateWalletResponse>(
560                reqwest::Method::PUT,
561                &path,
562                Some(&body),
563                &user_action,
564            )
565            .await
566    }
567
568    /// Retrieves a list of assets owned by the specified wallet.  Return values vary by chain as shown below.
569    pub async fn get_wallet_assets(
570        &self,
571        wallet_id: String,
572        query: Option<GetWalletAssetsQuery>,
573    ) -> Result<GetWalletAssetsResponse, crate::error::Error> {
574        let mut path = format!("/wallets/{}/assets", urlencoding::encode(&wallet_id));
575        if let Some(query) = &query {
576            let mut q: Vec<String> = Vec::new();
577            if let Some(v) = &query.net_worth {
578                q.push(format!("netWorth={}", urlencoding::encode(&v.to_string())));
579            }
580            if !q.is_empty() {
581                path.push('?');
582                path.push_str(&q.join("&"));
583            }
584        }
585        self.client
586            .request::<GetWalletAssetsResponse>(reqwest::Method::GET, &path, None, false)
587            .await
588    }
589
590    /// Retrieves a list of historical on chain activities for the specified wallet.
591    ///
592    /// The list reflects the indexed on-chain activity: it includes confirmed transactions only.
593    ///
594    pub async fn get_wallet_history(
595        &self,
596        wallet_id: String,
597        query: Option<GetWalletHistoryQuery>,
598    ) -> Result<GetWalletHistoryResponse, crate::error::Error> {
599        let mut path = format!("/wallets/{}/history", urlencoding::encode(&wallet_id));
600        if let Some(query) = &query {
601            let mut q: Vec<String> = Vec::new();
602            if let Some(v) = &query.limit {
603                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
604            }
605            if let Some(v) = &query.pagination_token {
606                q.push(format!(
607                    "paginationToken={}",
608                    urlencoding::encode(&v.to_string())
609                ));
610            }
611            if let Some(v) = &query.direction {
612                q.push(format!("direction={}", urlencoding::encode(&v.to_string())));
613            }
614            if let Some(v) = &query.kind {
615                q.push(format!("kind={}", urlencoding::encode(&v.to_string())));
616            }
617            if let Some(v) = &query.contract {
618                q.push(format!("contract={}", urlencoding::encode(&v.to_string())));
619            }
620            if !q.is_empty() {
621                path.push('?');
622                path.push_str(&q.join("&"));
623            }
624        }
625        self.client
626            .request::<GetWalletHistoryResponse>(reqwest::Method::GET, &path, None, false)
627            .await
628    }
629
630    /// Retrieves a list of NFTs owned by the specified Wallet.
631    pub async fn get_wallet_nfts(
632        &self,
633        wallet_id: String,
634    ) -> Result<GetWalletNftsResponse, crate::error::Error> {
635        let path = format!("/wallets/{}/nfts", urlencoding::encode(&wallet_id));
636        self.client
637            .request::<GetWalletNftsResponse>(reqwest::Method::GET, &path, None, false)
638            .await
639    }
640
641    /// Starts delegated signing for importWallet: returns the challenge to sign.
642    /// Pass the signed assertion to import_wallet_complete with the same arguments.
643    pub async fn import_wallet_init(
644        &self,
645        body: ImportWalletRequest,
646    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
647        let path = String::from("/wallets/import");
648        let body = serde_json::to_value(&body)?;
649        self.client
650            .create_user_action_challenge(reqwest::Method::POST, &path, Some(&body))
651            .await
652    }
653
654    /// Finishes delegated signing for importWallet: submits the signed challenge
655    /// and issues the request.
656    pub async fn import_wallet_complete(
657        &self,
658        body: ImportWalletRequest,
659        challenge_identifier: String,
660        assertion: crate::signer::CredentialAssertion,
661    ) -> Result<ImportWalletResponse, crate::error::Error> {
662        let path = String::from("/wallets/import");
663        let body = serde_json::to_value(&body)?;
664        let user_action = self
665            .client
666            .complete_user_action_signing(challenge_identifier, &assertion)
667            .await?;
668        self.client
669            .request_with_user_action::<ImportWalletResponse>(
670                reqwest::Method::POST,
671                &path,
672                Some(&body),
673                &user_action,
674            )
675            .await
676    }
677
678    /// Retrieves a list of transfer requests for the specified wallet.
679    pub async fn list_transfers(
680        &self,
681        wallet_id: String,
682        query: Option<ListTransfersQuery>,
683    ) -> Result<ListTransfersResponse, crate::error::Error> {
684        let mut path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
685        if let Some(query) = &query {
686            let mut q: Vec<String> = Vec::new();
687            if let Some(v) = &query.limit {
688                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
689            }
690            if let Some(v) = &query.pagination_token {
691                q.push(format!(
692                    "paginationToken={}",
693                    urlencoding::encode(&v.to_string())
694                ));
695            }
696            if !q.is_empty() {
697                path.push('?');
698                path.push_str(&q.join("&"));
699            }
700        }
701        self.client
702            .request::<ListTransfersResponse>(reqwest::Method::GET, &path, None, false)
703            .await
704    }
705
706    /// Starts delegated signing for transferAsset: returns the challenge to sign.
707    /// Pass the signed assertion to transfer_asset_complete with the same arguments.
708    pub async fn transfer_asset_init(
709        &self,
710        wallet_id: String,
711        body: TransferAssetRequest,
712    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
713        let path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
714        let body = serde_json::to_value(&body)?;
715        self.client
716            .create_user_action_challenge(reqwest::Method::POST, &path, Some(&body))
717            .await
718    }
719
720    /// Finishes delegated signing for transferAsset: submits the signed challenge
721    /// and issues the request.
722    pub async fn transfer_asset_complete(
723        &self,
724        wallet_id: String,
725        body: TransferAssetRequest,
726        challenge_identifier: String,
727        assertion: crate::signer::CredentialAssertion,
728    ) -> Result<TransferAssetResponse, crate::error::Error> {
729        let path = format!("/wallets/{}/transfers", urlencoding::encode(&wallet_id));
730        let body = serde_json::to_value(&body)?;
731        let user_action = self
732            .client
733            .complete_user_action_signing(challenge_identifier, &assertion)
734            .await?;
735        self.client
736            .request_with_user_action::<TransferAssetResponse>(
737                reqwest::Method::POST,
738                &path,
739                Some(&body),
740                &user_action,
741            )
742            .await
743    }
744
745    /// Starts delegated signing for tagWallet: returns the challenge to sign.
746    /// Pass the signed assertion to tag_wallet_complete with the same arguments.
747    pub async fn tag_wallet_init(
748        &self,
749        wallet_id: String,
750        body: TagWalletRequest,
751    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
752        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
753        let body = serde_json::to_value(&body)?;
754        self.client
755            .create_user_action_challenge(reqwest::Method::PUT, &path, Some(&body))
756            .await
757    }
758
759    /// Finishes delegated signing for tagWallet: submits the signed challenge
760    /// and issues the request.
761    pub async fn tag_wallet_complete(
762        &self,
763        wallet_id: String,
764        body: TagWalletRequest,
765        challenge_identifier: String,
766        assertion: crate::signer::CredentialAssertion,
767    ) -> Result<TagWalletResponse, crate::error::Error> {
768        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
769        let body = serde_json::to_value(&body)?;
770        let user_action = self
771            .client
772            .complete_user_action_signing(challenge_identifier, &assertion)
773            .await?;
774        self.client
775            .request_with_user_action::<TagWalletResponse>(
776                reqwest::Method::PUT,
777                &path,
778                Some(&body),
779                &user_action,
780            )
781            .await
782    }
783
784    /// Starts delegated signing for untagWallet: returns the challenge to sign.
785    /// Pass the signed assertion to untag_wallet_complete with the same arguments.
786    pub async fn untag_wallet_init(
787        &self,
788        wallet_id: String,
789        body: UntagWalletRequest,
790    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
791        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
792        let body = serde_json::to_value(&body)?;
793        self.client
794            .create_user_action_challenge(reqwest::Method::DELETE, &path, Some(&body))
795            .await
796    }
797
798    /// Finishes delegated signing for untagWallet: submits the signed challenge
799    /// and issues the request.
800    pub async fn untag_wallet_complete(
801        &self,
802        wallet_id: String,
803        body: UntagWalletRequest,
804        challenge_identifier: String,
805        assertion: crate::signer::CredentialAssertion,
806    ) -> Result<UntagWalletResponse, crate::error::Error> {
807        let path = format!("/wallets/{}/tags", urlencoding::encode(&wallet_id));
808        let body = serde_json::to_value(&body)?;
809        let user_action = self
810            .client
811            .complete_user_action_signing(challenge_identifier, &assertion)
812            .await?;
813        self.client
814            .request_with_user_action::<UntagWalletResponse>(
815                reqwest::Method::DELETE,
816                &path,
817                Some(&body),
818                &user_action,
819            )
820            .await
821    }
822
823    /// Retrieve information about a specific offer received on your wallet.
824    pub async fn get_offer(
825        &self,
826        wallet_id: String,
827        offer_id: String,
828    ) -> Result<GetOfferResponse, crate::error::Error> {
829        let path = format!(
830            "/wallets/{}/offers/{}",
831            urlencoding::encode(&wallet_id),
832            urlencoding::encode(&offer_id)
833        );
834        self.client
835            .request::<GetOfferResponse>(reqwest::Method::GET, &path, None, false)
836            .await
837    }
838
839    /// List all offers received on a specific wallet.
840    pub async fn list_offers(
841        &self,
842        wallet_id: String,
843        query: Option<ListOffersQuery>,
844    ) -> Result<ListOffersResponse, crate::error::Error> {
845        let mut path = format!("/wallets/{}/offers", urlencoding::encode(&wallet_id));
846        if let Some(query) = &query {
847            let mut q: Vec<String> = Vec::new();
848            if let Some(v) = &query.limit {
849                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
850            }
851            if let Some(v) = &query.pagination_token {
852                q.push(format!(
853                    "paginationToken={}",
854                    urlencoding::encode(&v.to_string())
855                ));
856            }
857            if !q.is_empty() {
858                path.push('?');
859                path.push_str(&q.join("&"));
860            }
861        }
862        self.client
863            .request::<ListOffersResponse>(reqwest::Method::GET, &path, None, false)
864            .await
865    }
866
867    /// Starts delegated signing for acceptOffer: returns the challenge to sign.
868    /// Pass the signed assertion to accept_offer_complete with the same arguments.
869    pub async fn accept_offer_init(
870        &self,
871        wallet_id: String,
872        offer_id: String,
873    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
874        let path = format!(
875            "/wallets/{}/offers/{}/accept",
876            urlencoding::encode(&wallet_id),
877            urlencoding::encode(&offer_id)
878        );
879        self.client
880            .create_user_action_challenge(reqwest::Method::PUT, &path, None)
881            .await
882    }
883
884    /// Finishes delegated signing for acceptOffer: submits the signed challenge
885    /// and issues the request.
886    pub async fn accept_offer_complete(
887        &self,
888        wallet_id: String,
889        offer_id: String,
890        challenge_identifier: String,
891        assertion: crate::signer::CredentialAssertion,
892    ) -> Result<AcceptOfferResponse, crate::error::Error> {
893        let path = format!(
894            "/wallets/{}/offers/{}/accept",
895            urlencoding::encode(&wallet_id),
896            urlencoding::encode(&offer_id)
897        );
898        let user_action = self
899            .client
900            .complete_user_action_signing(challenge_identifier, &assertion)
901            .await?;
902        self.client
903            .request_with_user_action::<AcceptOfferResponse>(
904                reqwest::Method::PUT,
905                &path,
906                None,
907                &user_action,
908            )
909            .await
910    }
911
912    /// Starts delegated signing for rejectOffer: returns the challenge to sign.
913    /// Pass the signed assertion to reject_offer_complete with the same arguments.
914    pub async fn reject_offer_init(
915        &self,
916        wallet_id: String,
917        offer_id: String,
918    ) -> Result<crate::signer::UserActionChallenge, crate::error::Error> {
919        let path = format!(
920            "/wallets/{}/offers/{}/reject",
921            urlencoding::encode(&wallet_id),
922            urlencoding::encode(&offer_id)
923        );
924        self.client
925            .create_user_action_challenge(reqwest::Method::PUT, &path, None)
926            .await
927    }
928
929    /// Finishes delegated signing for rejectOffer: submits the signed challenge
930    /// and issues the request.
931    pub async fn reject_offer_complete(
932        &self,
933        wallet_id: String,
934        offer_id: String,
935        challenge_identifier: String,
936        assertion: crate::signer::CredentialAssertion,
937    ) -> Result<RejectOfferResponse, crate::error::Error> {
938        let path = format!(
939            "/wallets/{}/offers/{}/reject",
940            urlencoding::encode(&wallet_id),
941            urlencoding::encode(&offer_id)
942        );
943        let user_action = self
944            .client
945            .complete_user_action_signing(challenge_identifier, &assertion)
946            .await?;
947        self.client
948            .request_with_user_action::<RejectOfferResponse>(
949                reqwest::Method::PUT,
950                &path,
951                None,
952                &user_action,
953            )
954            .await
955    }
956
957    /// 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.
958    pub async fn list_org_wallet_history(
959        &self,
960        query: Option<ListOrgWalletHistoryQuery>,
961    ) -> Result<serde_json::Value, crate::error::Error> {
962        let mut path = String::from("/wallets/all/history");
963        if let Some(query) = &query {
964            let mut q: Vec<String> = Vec::new();
965            if let Some(v) = &query.limit {
966                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
967            }
968            if let Some(v) = &query.pagination_token {
969                q.push(format!(
970                    "paginationToken={}",
971                    urlencoding::encode(&v.to_string())
972                ));
973            }
974            q.push(format!(
975                "startTime={}",
976                urlencoding::encode(&query.start_time.to_string())
977            ));
978            q.push(format!(
979                "endTime={}",
980                urlencoding::encode(&query.end_time.to_string())
981            ));
982            if !q.is_empty() {
983                path.push('?');
984                path.push_str(&q.join("&"));
985            }
986        }
987        self.client
988            .request::<serde_json::Value>(reqwest::Method::GET, &path, None, false)
989            .await
990    }
991}