openzeppelin_relayer/api/routes/docs/
relayer_docs.rs

1//! # Relayer Documentation
2//!
3//! This module contains the OpenAPI documentation for the relayer API endpoints.
4//!
5//! ## Endpoints
6//!
7//! - `GET /api/v1/relayers`: List all relayers
8//! - `GET /api/v1/relayers/{id}`: Get a relayer by ID
9//! - `POST /api/v1/relayers`: Create a new relayer
10//! - `PATCH /api/v1/relayers/{id}`: Update a relayer
11//! - `DELETE /api/v1/relayers/{id}`: Delete a relayer
12//! - `POST /api/v1/relayers/{id}/transactions/sponsored/quote`: Get fee estimate for sponsored transaction
13//! - `POST /api/v1/relayers/{id}/transactions/sponsored/build`: Build a sponsored transaction
14
15use crate::{
16    domain::{
17        BalanceResponse, SignDataRequest, SignDataResponse, SignTransactionExternalResponse,
18        SignTransactionRequest, SignTypedDataRequest,
19    },
20    models::{
21        transaction::{
22            SponsoredTransactionBuildRequest, SponsoredTransactionBuildResponse,
23            SponsoredTransactionQuoteRequest, SponsoredTransactionQuoteResponse,
24        },
25        ApiResponse, CreateRelayerRequest, DeletePendingTransactionsResponse, JsonRpcRequest,
26        JsonRpcResponse, NetworkRpcRequest, NetworkRpcResult, NetworkTransactionRequest,
27        RelayerResponse, RelayerStatus, TransactionResponse, UpdateRelayerRequest,
28    },
29};
30
31/// Relayer routes implementation
32///
33/// Note: OpenAPI documentation for these endpoints can be found in the `openapi.rs` file
34///
35/// Lists all relayers with pagination support.
36#[utoipa::path(
37    get,
38    path = "/api/v1/relayers",
39    tag = "Relayers",
40    operation_id = "listRelayers",
41    security(
42        ("bearer_auth" = [])
43    ),
44    params(
45        ("page" = Option<usize>, Query, description = "Page number for pagination (starts at 1)"),
46        ("per_page" = Option<usize>, Query, description = "Number of items per page (default: 10)")
47    ),
48    responses(
49        (
50            status = 200,
51            description = "Relayer list retrieved successfully",
52            body = ApiResponse<Vec<RelayerResponse>>
53        ),
54        (
55            status = 400,
56            description = "BadRequest",
57            body = ApiResponse<String>,
58            example = json!({
59                "success": false,
60                "message": "Bad Request",
61                "data": null
62            })
63        ),
64        (
65            status = 401,
66            description = "Unauthorized",
67            body = ApiResponse<String>,
68            example = json!({
69                "success": false,
70                "message": "Unauthorized",
71                "data": null
72            })
73        ),
74        (
75            status = 429,
76            description = "Too Many Requests",
77            body = ApiResponse<String>,
78            example = json!({
79                "success": false,
80                "message": "Too Many Requests",
81                "data": null
82            })
83        ),
84        (
85            status = 500,
86            description = "Internal server error",
87            body = ApiResponse<String>,
88            example = json!({
89                "success": false,
90                "message": "Internal Server Error",
91                "data": null
92            })
93        ),
94    )
95)]
96#[allow(dead_code)]
97fn doc_list_relayers() {}
98
99/// Retrieves details of a specific relayer by ID.
100#[utoipa::path(
101    get,
102    path = "/api/v1/relayers/{relayer_id}",
103    tag = "Relayers",
104    operation_id = "getRelayer",
105    security(
106        ("bearer_auth" = [])
107    ),
108    params(
109        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
110    ),
111    responses(
112        (
113            status = 200,
114            description = "Relayer details retrieved successfully",
115            body = ApiResponse<RelayerResponse>
116        ),
117        (
118            status = 400,
119            description = "BadRequest",
120            body = ApiResponse<String>,
121            example = json!({
122                "success": false,
123                "message": "Bad Request",
124                "data": null
125            })
126        ),
127        (
128            status = 401,
129            description = "Unauthorized",
130            body = ApiResponse<String>,
131            example = json!({
132                "success": false,
133                "message": "Unauthorized",
134                "data": null
135            })
136        ),
137        (
138            status = 404,
139            description = "Not Found",
140            body = ApiResponse<String>,
141            example = json!({
142                "success": false,
143                "message": "Relayer with ID relayer_id not found",
144                "data": null
145            })
146        ),
147        (
148            status = 429,
149            description = "Too Many Requests",
150            body = ApiResponse<String>,
151            example = json!({
152                "success": false,
153                "message": "Too Many Requests",
154                "data": null
155            })
156        ),
157        (
158            status = 500,
159            description = "Internal server error",
160            body = ApiResponse<String>,
161            example = json!({
162                "success": false,
163                "message": "Internal Server Error",
164                "data": null
165            })
166        ),
167    )
168)]
169#[allow(dead_code)]
170fn doc_get_relayer() {}
171
172/// Creates a new relayer.
173#[utoipa::path(
174    post,
175    path = "/api/v1/relayers",
176    tag = "Relayers",
177    operation_id = "createRelayer",
178    security(
179        ("bearer_auth" = [])
180    ),
181    request_body = CreateRelayerRequest,
182    responses(
183        (
184            status = 201,
185            description = "Relayer created successfully",
186            body = ApiResponse<RelayerResponse>
187        ),
188        (
189            status = 400,
190            description = "Bad Request",
191            body = ApiResponse<String>,
192            example = json!({
193                "success": false,
194                "message": "Bad Request",
195                "data": null
196            })
197        ),
198        (
199            status = 401,
200            description = "Unauthorized",
201            body = ApiResponse<String>,
202            example = json!({
203                "success": false,
204                "message": "Unauthorized",
205                "data": null
206            })
207        ),
208        (
209            status = 409,
210            description = "Relayer with this ID already exists",
211            body = ApiResponse<String>,
212            example = json!({
213                "success": false,
214                "message": "Relayer with this ID already exists",
215                "data": null
216            })
217        ),
218        (
219            status = 500,
220            description = "Internal Server Error",
221            body = ApiResponse<String>,
222            example = json!({
223                "success": false,
224                "message": "Internal Server Error",
225                "data": null
226            })
227        )
228    )
229)]
230#[allow(dead_code)]
231fn doc_create_relayer() {}
232
233/// Updates a relayer's information based on the provided update request.
234#[utoipa::path(
235    patch,
236    path = "/api/v1/relayers/{relayer_id}",
237    tag = "Relayers",
238    operation_id = "updateRelayer",
239    security(
240        ("bearer_auth" = [])
241    ),
242    params(
243        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
244    ),
245    request_body = UpdateRelayerRequest,
246    responses(
247        (status = 200, description = "Relayer updated successfully", body = ApiResponse<RelayerResponse>),
248        (
249            status = 400,
250            description = "BadRequest",
251            body = ApiResponse<String>,
252            example = json!({
253                "success": false,
254                "message": "Bad Request",
255                "data": null
256            })
257        ),
258        (
259            status = 401,
260            description = "Unauthorized",
261            body = ApiResponse<String>,
262            example = json!({
263                "success": false,
264                "message": "Unauthorized",
265                "data": null
266            })
267        ),
268        (
269            status = 404,
270            description = "Not Found",
271            body = ApiResponse<String>,
272            example = json!({
273                "success": false,
274                "message": "Relayer with ID relayer_id not found",
275                "data": null
276            })
277        ),
278        (
279            status = 429,
280            description = "Too Many Requests",
281            body = ApiResponse<String>,
282            example = json!({
283                "success": false,
284                "message": "Too Many Requests",
285                "data": null
286            })
287        ),
288        (
289            status = 500,
290            description = "Internal server error",
291            body = ApiResponse<String>,
292            example = json!({
293                "success": false,
294                "message": "Internal Server Error",
295                "data": null
296            })
297        ),
298    )
299)]
300#[allow(dead_code)]
301fn doc_update_relayer() {}
302
303/// Deletes a relayer by ID.
304#[utoipa::path(
305    delete,
306    path = "/api/v1/relayers/{relayer_id}",
307    tag = "Relayers",
308    operation_id = "deleteRelayer",
309    security(
310        ("bearer_auth" = [])
311    ),
312    params(
313        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
314    ),
315    responses(
316        (
317            status = 200,
318            description = "Relayer deleted successfully",
319            body = ApiResponse<String>
320        ),
321        (
322            status = 400,
323            description = "Bad Request - Cannot delete relayer with active transactions",
324            body = ApiResponse<String>,
325            example = json!({
326                "success": false,
327                "message": "Cannot delete relayer 'relayer_id' because it has N transaction(s). Please wait for all transactions to complete or cancel them before deleting the relayer.",
328                "data": null
329            })
330        ),
331        (
332            status = 401,
333            description = "Unauthorized",
334            body = ApiResponse<String>,
335            example = json!({
336                "success": false,
337                "message": "Unauthorized",
338                "data": null
339            })
340        ),
341        (
342            status = 404,
343            description = "Not Found",
344            body = ApiResponse<String>,
345            example = json!({
346                "success": false,
347                "message": "Relayer with ID relayer_id not found",
348                "data": null
349            })
350        ),
351        (
352            status = 500,
353            description = "Internal Server Error",
354            body = ApiResponse<String>,
355            example = json!({
356                "success": false,
357                "message": "Internal Server Error",
358                "data": null
359            })
360        )
361    )
362)]
363#[allow(dead_code)]
364fn doc_delete_relayer() {}
365
366/// Fetches the current status of a specific relayer.
367#[utoipa::path(
368    get,
369    path = "/api/v1/relayers/{relayer_id}/status",
370    tag = "Relayers",
371    operation_id = "getRelayerStatus",
372    security(
373        ("bearer_auth" = [])
374    ),
375    params(
376        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
377        ("include_balance" = Option<bool>, Query, description = "Whether to include balance (default: true)"),
378        ("include_pending_count" = Option<bool>, Query, description = "Whether to include pending transaction count (default: true)"),
379        ("include_last_confirmed_tx" = Option<bool>, Query, description = "Whether to include last confirmed transaction timestamp (default: true)")
380    ),
381    responses(
382        (status = 200, description = "Relayer status retrieved successfully", body = ApiResponse<RelayerStatus>),
383        (
384            status = 400,
385            description = "BadRequest",
386            body = ApiResponse<String>,
387            example = json!({
388                "success": false,
389                "message": "Bad Request",
390                "data": null
391            })
392        ),
393        (
394            status = 401,
395            description = "Unauthorized",
396            body = ApiResponse<String>,
397            example = json!({
398                "success": false,
399                "message": "Unauthorized",
400                "data": null
401            })
402        ),
403        (
404            status = 404,
405            description = "Not Found",
406            body = ApiResponse<String>,
407            example = json!({
408                "success": false,
409                "message": "Relayer with ID relayer_id not found",
410                "data": null
411            })
412        ),
413        (
414            status = 429,
415            description = "Too Many Requests",
416            body = ApiResponse<String>,
417            example = json!({
418                "success": false,
419                "message": "Too Many Requests",
420                "data": null
421            })
422        ),
423        (
424            status = 500,
425            description = "Internal server error",
426            body = ApiResponse<String>,
427            example = json!({
428                "success": false,
429                "message": "Internal Server Error",
430                "data": null
431            })
432        ),
433    )
434)]
435#[allow(dead_code)]
436fn doc_get_relayer_status() {}
437
438/// Retrieves the balance of a specific relayer.
439#[utoipa::path(
440    get,
441    path = "/api/v1/relayers/{relayer_id}/balance",
442    tag = "Relayers",
443    operation_id = "getRelayerBalance",
444    security(
445        ("bearer_auth" = [])
446    ),
447    params(
448        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
449    ),
450    responses(
451        (status = 200, description = "Relayer balance retrieved successfully", body = ApiResponse<BalanceResponse>),
452        (
453            status = 400,
454            description = "BadRequest",
455            body = ApiResponse<String>,
456            example = json!({
457                "success": false,
458                "message": "Bad Request",
459                "data": null
460            })
461        ),
462        (
463            status = 401,
464            description = "Unauthorized",
465            body = ApiResponse<String>,
466            example = json!({
467                "success": false,
468                "message": "Unauthorized",
469                "data": null
470            })
471        ),
472        (
473            status = 404,
474            description = "Not Found",
475            body = ApiResponse<String>,
476            example = json!({
477                "success": false,
478                "message": "Relayer with ID relayer_id not found",
479                "data": null
480            })
481        ),
482        (
483            status = 429,
484            description = "Too Many Requests",
485            body = ApiResponse<String>,
486            example = json!({
487                "success": false,
488                "message": "Too Many Requests",
489                "data": null
490            })
491        ),
492        (
493            status = 500,
494            description = "Internal server error",
495            body = ApiResponse<String>,
496            example = json!({
497                "success": false,
498                "message": "Internal Server Error",
499                "data": null
500            })
501        ),
502    )
503)]
504#[allow(dead_code)]
505fn doc_get_relayer_balance() {}
506
507/// Sends a transaction through the specified relayer.
508#[utoipa::path(
509    post,
510    path = "/api/v1/relayers/{relayer_id}/transactions",
511    tag = "Relayers",
512    operation_id = "sendTransaction",
513    security(
514        ("bearer_auth" = [])
515    ),
516    params(
517        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
518    ),
519    request_body = NetworkTransactionRequest,
520    responses(
521        (status = 200, description = "Relayer transactions sent successfully", body = ApiResponse<TransactionResponse>),
522        (
523            status = 400,
524            description = "BadRequest",
525            body = ApiResponse<String>,
526            example = json!({
527                "success": false,
528                "message": "Bad Request",
529                "data": null
530            })
531        ),
532        (
533            status = 401,
534            description = "Unauthorized",
535            body = ApiResponse<String>,
536            example = json!({
537                "success": false,
538                "message": "Unauthorized",
539                "data": null
540            })
541        ),
542        (
543            status = 404,
544            description = "Not Found",
545            body = ApiResponse<String>,
546            example = json!({
547                "success": false,
548                "message": "Relayer with ID relayer_id not found",
549                "data": null
550            })
551        ),
552        (
553            status = 429,
554            description = "Too Many Requests",
555            body = ApiResponse<String>,
556            example = json!({
557                "success": false,
558                "message": "Too Many Requests",
559                "data": null
560            })
561        ),
562        (
563            status = 500,
564            description = "Internal server error",
565            body = ApiResponse<String>,
566            example = json!({
567                "success": false,
568                "message": "Internal Server Error",
569                "data": null
570            })
571        ),
572    )
573)]
574#[allow(dead_code)]
575fn doc_send_transaction() {}
576
577/// Retrieves a specific transaction by its ID.
578#[utoipa::path(
579    get,
580    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
581    operation_id = "getTransactionById",
582    tag = "Relayers",
583    security(
584        ("bearer_auth" = [])
585    ),
586    params(
587        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
588        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
589    ),
590    responses(
591        (status = 200, description = "Relayer transaction retrieved successfully", body = ApiResponse<TransactionResponse>),
592        (
593            status = 400,
594            description = "BadRequest",
595            body = ApiResponse<String>,
596            example = json!({
597                "success": false,
598                "message": "Bad Request",
599                "data": null
600            })
601        ),
602        (
603            status = 401,
604            description = "Unauthorized",
605            body = ApiResponse<String>,
606            example = json!({
607                "success": false,
608                "message": "Unauthorized",
609                "data": null
610            })
611        ),
612        (
613            status = 429,
614            description = "Too Many Requests",
615            body = ApiResponse<String>,
616            example = json!({
617                "success": false,
618                "message": "Too Many Requests",
619                "data": null
620            })
621        ),
622        (
623            status = 404,
624            description = "Not Found",
625            body = ApiResponse<String>,
626            example = json!({
627                "success": false,
628                "message": "Not Found",
629                "data": null
630            })
631        ),
632        (
633            status = 500,
634            description = "Internal server error",
635            body = ApiResponse<String>,
636            example = json!({
637                "success": false,
638                "message": "Internal Server Error",
639                "data": null
640            })
641        ),
642    )
643)]
644#[allow(dead_code)]
645fn doc_get_transaction_by_id() {}
646
647/// Retrieves a transaction by its nonce value.
648#[utoipa::path(
649    get,
650    path = "/api/v1/relayers/{relayer_id}/transactions/by-nonce/{nonce}",
651    tag = "Relayers",
652    operation_id = "getTransactionByNonce",
653    security(
654        ("bearer_auth" = [])
655    ),
656    params(
657        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
658        ("nonce" = usize, Path, description = "The nonce of the transaction")
659    ),
660    responses(
661        (status = 200, description = "Relayer transaction retrieved successfully", body = ApiResponse<TransactionResponse>),
662        (
663            status = 400,
664            description = "BadRequest",
665            body = ApiResponse<String>,
666            example = json!({
667                "success": false,
668                "message": "Bad Request",
669                "data": null
670            })
671        ),
672        (
673            status = 401,
674            description = "Unauthorized",
675            body = ApiResponse<String>,
676            example = json!({
677                "success": false,
678                "message": "Unauthorized",
679                "data": null
680            })
681        ),
682        (
683            status = 404,
684            description = "Not Found",
685            body = ApiResponse<String>,
686            example = json!({
687                "success": false,
688                "message": "Not found",
689                "data": null
690            })
691        ),
692        (
693            status = 429,
694            description = "Too Many Requests",
695            body = ApiResponse<String>,
696            example = json!({
697                "success": false,
698                "message": "Too Many Requests",
699                "data": null
700            })
701        ),
702        (
703            status = 500,
704            description = "Internal server error",
705            body = ApiResponse<String>,
706            example = json!({
707                "success": false,
708                "message": "Internal Server Error",
709                "data": null
710            })
711        ),
712    )
713)]
714#[allow(dead_code)]
715fn doc_get_transaction_by_nonce() {}
716
717/// Lists all transactions for a specific relayer with pagination.
718#[utoipa::path(
719    get,
720    path = "/api/v1/relayers/{relayer_id}/transactions/",
721    tag = "Relayers",
722    operation_id = "listTransactions",
723    security(
724        ("bearer_auth" = [])
725    ),
726    params(
727        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
728        ("page" = Option<usize>, Query, description = "Page number for pagination (starts at 1)"),
729        ("per_page" = Option<usize>, Query, description = "Number of items per page (default: 10)")
730    ),
731    responses(
732        (status = 200, description = "Relayer transactions retrieved successfully", body = ApiResponse<Vec<TransactionResponse>>),
733        (
734            status = 400,
735            description = "BadRequest",
736            body = ApiResponse<String>,
737            example = json!({
738                "success": false,
739                "message": "Bad Request",
740                "data": null
741            })
742        ),
743        (
744            status = 401,
745            description = "Unauthorized",
746            body = ApiResponse<String>,
747            example = json!({
748                "success": false,
749                "message": "Unauthorized",
750                "data": null
751            })
752        ),
753        (
754            status = 404,
755            description = "Not Found",
756            body = ApiResponse<String>,
757            example = json!({
758                "success": false,
759                "message": "Relayer with ID relayer_id not found",
760                "data": null
761            })
762        ),
763        (
764            status = 429,
765            description = "Too Many Requests",
766            body = ApiResponse<String>,
767            example = json!({
768                "success": false,
769                "message": "Too Many Requests",
770                "data": null
771            })
772        ),
773        (
774            status = 500,
775            description = "Internal server error",
776            body = ApiResponse<String>,
777            example = json!({
778                "success": false,
779                "message": "Internal Server Error",
780                "data": null
781            })
782        ),
783    )
784)]
785#[allow(dead_code)]
786fn doc_list_transactions() {}
787
788/// Deletes all pending transactions for a specific relayer.
789#[utoipa::path(
790    delete,
791    path = "/api/v1/relayers/{relayer_id}/transactions/pending",
792    tag = "Relayers",
793    operation_id = "deletePendingTransactions",
794    security(
795        ("bearer_auth" = [])
796    ),
797    params(
798        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
799    ),
800    responses(
801        (status = 200, description = "Relayer pending transactions successfully", body = ApiResponse<DeletePendingTransactionsResponse>),
802        (
803            status = 400,
804            description = "BadRequest",
805            body = ApiResponse<String>,
806            example = json!({
807                "success": false,
808                "message": "Bad Request",
809                "data": null
810            })
811        ),
812        (
813            status = 401,
814            description = "Unauthorized",
815            body = ApiResponse<String>,
816            example = json!({
817                "success": false,
818                "message": "Unauthorized",
819                "data": null
820            })
821        ),
822        (
823            status = 404,
824            description = "Not Found",
825            body = ApiResponse<String>,
826            example = json!({
827                "success": false,
828                "message": "Relayer with ID relayer_id not found",
829                "data": null
830            })
831        ),
832        (
833            status = 429,
834            description = "Too Many Requests",
835            body = ApiResponse<String>,
836            example = json!({
837                "success": false,
838                "message": "Too Many Requests",
839                "data": null
840            })
841        ),
842        (
843            status = 500,
844            description = "Internal server error",
845            body = ApiResponse<String>,
846            example = json!({
847                "success": false,
848                "message": "Internal Server Error",
849                "data": null
850            })
851        ),
852    )
853)]
854#[allow(dead_code)]
855fn doc_delete_pending_transactions() {}
856
857/// Cancels a specific transaction by its ID.
858#[utoipa::path(
859    delete,
860    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
861    tag = "Relayers",
862    operation_id = "cancelTransaction",
863    security(
864        ("bearer_auth" = [])
865    ),
866    params(
867        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
868        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
869    ),
870    responses(
871        (status = 200, description = "Relayer transaction canceled successfully", body = ApiResponse<TransactionResponse>),
872        (
873            status = 400,
874            description = "BadRequest",
875            body = ApiResponse<String>,
876            example = json!({
877                "success": false,
878                "message": "Bad Request",
879                "data": null
880            })
881        ),
882        (
883            status = 401,
884            description = "Unauthorized",
885            body = ApiResponse<String>,
886            example = json!({
887                "success": false,
888                "message": "Unauthorized",
889                "data": null
890            })
891        ),
892        (
893            status = 404,
894            description = "Not Found",
895            body = ApiResponse<String>,
896            example = json!({
897                "success": false,
898                "message": "Not found",
899                "data": null
900            })
901        ),
902        (
903            status = 429,
904            description = "Too Many Requests",
905            body = ApiResponse<String>,
906            example = json!({
907                "success": false,
908                "message": "Too Many Requests",
909                "data": null
910            })
911        ),
912        (
913            status = 500,
914            description = "Internal server error",
915            body = ApiResponse<String>,
916            example = json!({
917                "success": false,
918                "message": "Internal Server Error",
919                "data": null
920            })
921        ),
922    )
923)]
924#[allow(dead_code)]
925fn doc_cancel_transaction() {}
926
927/// Replaces a specific transaction with a new one.
928#[utoipa::path(
929    put,
930    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
931    tag = "Relayers",
932    operation_id = "replaceTransaction",
933    security(
934        ("bearer_auth" = [])
935    ),
936    params(
937        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
938        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
939    ),
940    request_body = NetworkTransactionRequest,
941    responses(
942        (status = 200, description = "Relayer transaction replaced successfully", body = ApiResponse<TransactionResponse>),
943        (
944            status = 400,
945            description = "BadRequest",
946            body = ApiResponse<String>,
947            example = json!({
948                "success": false,
949                "message": "Bad Request",
950                "data": null
951            })
952        ),
953        (
954            status = 401,
955            description = "Unauthorized",
956            body = ApiResponse<String>,
957            example = json!({
958                "success": false,
959                "message": "Unauthorized",
960                "data": null
961            })
962        ),
963        (
964            status = 404,
965            description = "Not Found",
966            body = ApiResponse<String>,
967            example = json!({
968                "success": false,
969                "message": "Not found",
970                "data": null
971            })
972        ),
973        (
974            status = 429,
975            description = "Too Many Requests",
976            body = ApiResponse<String>,
977            example = json!({
978                "success": false,
979                "message": "Too Many Requests",
980                "data": null
981            })
982        ),
983        (
984            status = 500,
985            description = "Internal server error",
986            body = ApiResponse<String>,
987            example = json!({
988                "success": false,
989                "message": "Internal Server Error",
990                "data": null
991            })
992        ),
993    )
994)]
995#[allow(dead_code)]
996fn doc_replace_transaction() {}
997
998/// Signs data using the specified relayer.
999#[utoipa::path(
1000    post,
1001    path = "/api/v1/relayers/{relayer_id}/sign",
1002    operation_id = "sign",
1003    tag = "Relayers",
1004    security(
1005        ("bearer_auth" = [])
1006    ),
1007    params(
1008        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1009    ),
1010    request_body = SignDataRequest,
1011    responses(
1012        (status = 200, description = "Relayer signed data successfully", body = ApiResponse<SignDataResponse>),
1013        (
1014            status = 400,
1015            description = "BadRequest",
1016            body = ApiResponse<String>,
1017            example = json!({
1018                "success": false,
1019                "message": "Bad Request",
1020                "data": null
1021            })
1022        ),
1023        (
1024            status = 401,
1025            description = "Unauthorized",
1026            body = ApiResponse<String>,
1027            example = json!({
1028                "success": false,
1029                "message": "Unauthorized",
1030                "data": null
1031            })
1032        ),
1033        (
1034            status = 404,
1035            description = "Not Found",
1036            body = ApiResponse<String>,
1037            example = json!({
1038                "success": false,
1039                "message": "Not found",
1040                "data": null
1041            })
1042        ),
1043        (
1044            status = 429,
1045            description = "Too Many Requests",
1046            body = ApiResponse<String>,
1047            example = json!({
1048                "success": false,
1049                "message": "Too Many Requests",
1050                "data": null
1051            })
1052        ),
1053        (
1054            status = 500,
1055            description = "Internal server error",
1056            body = ApiResponse<String>,
1057            example = json!({
1058                "success": false,
1059                "message": "Internal Server Error",
1060                "data": null
1061            })
1062        ),
1063    )
1064)]
1065#[allow(dead_code)]
1066fn doc_sign() {}
1067
1068/// Signs typed data using the specified relayer.
1069#[utoipa::path(
1070    post,
1071    path = "/api/v1/relayers/{relayer_id}/sign-typed-data",
1072    tag = "Relayers",
1073    operation_id = "signTypedData",
1074    security(
1075        ("bearer_auth" = [])
1076    ),
1077    params(
1078        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1079    ),
1080    request_body = SignTypedDataRequest,
1081    responses(
1082        (status = 200, description = "Relayer signed typed data successfully", body = ApiResponse<SignDataResponse>),
1083        (
1084            status = 400,
1085            description = "BadRequest",
1086            body = ApiResponse<String>,
1087            example = json!({
1088                "success": false,
1089                "message": "Bad Request",
1090                "data": null
1091            })
1092        ),
1093        (
1094            status = 401,
1095            description = "Unauthorized",
1096            body = ApiResponse<String>,
1097            example = json!({
1098                "success": false,
1099                "message": "Unauthorized",
1100                "data": null
1101            })
1102        ),
1103        (
1104            status = 404,
1105            description = "Not Found",
1106            body = ApiResponse<String>,
1107            example = json!({
1108                "success": false,
1109                "message": "Relayer with ID relayer_id not found",
1110                "data": null
1111            })
1112        ),
1113        (
1114            status = 429,
1115            description = "Too Many Requests",
1116            body = ApiResponse<String>,
1117            example = json!({
1118                "success": false,
1119                "message": "Too Many Requests",
1120                "data": null
1121            })
1122        ),
1123        (
1124            status = 500,
1125            description = "Internal server error",
1126            body = ApiResponse<String>,
1127            example = json!({
1128                "success": false,
1129                "message": "Internal Server Error",
1130                "data": null
1131            })
1132        ),
1133    )
1134)]
1135#[allow(dead_code)]
1136fn doc_sign_typed_data() {}
1137
1138/// Signs a transaction using the specified relayer (Stellar only).
1139#[utoipa::path(
1140    post,
1141    path = "/api/v1/relayers/{relayer_id}/sign-transaction",
1142    tag = "Relayers",
1143    operation_id = "signTransaction",
1144    security(
1145        ("bearer_auth" = [])
1146    ),
1147    params(
1148        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1149    ),
1150    request_body = SignTransactionRequest,
1151    responses(
1152        (status = 200, description = "Transaction signed successfully", body = ApiResponse<SignTransactionExternalResponse>),
1153        (
1154            status = 400,
1155            description = "BadRequest",
1156            body = ApiResponse<String>,
1157            example = json!({
1158                "success": false,
1159                "message": "Bad Request",
1160                "data": null
1161            })
1162        ),
1163        (
1164            status = 401,
1165            description = "Unauthorized",
1166            body = ApiResponse<String>,
1167            example = json!({
1168                "success": false,
1169                "message": "Unauthorized",
1170                "data": null
1171            })
1172        ),
1173        (
1174            status = 404,
1175            description = "Not Found",
1176            body = ApiResponse<String>,
1177            example = json!({
1178                "success": false,
1179                "message": "Relayer with ID relayer_id not found",
1180                "data": null
1181            })
1182        ),
1183        (
1184            status = 429,
1185            description = "Too Many Requests",
1186            body = ApiResponse<String>,
1187            example = json!({
1188                "success": false,
1189                "message": "Too Many Requests",
1190                "data": null
1191            })
1192        ),
1193        (
1194            status = 500,
1195            description = "Internal server error",
1196            body = ApiResponse<String>,
1197            example = json!({
1198                "success": false,
1199                "message": "Internal Server Error",
1200                "data": null
1201            })
1202        ),
1203    )
1204)]
1205#[allow(dead_code)]
1206fn doc_sign_transaction() {}
1207
1208/// Performs a JSON-RPC call using the specified relayer.
1209#[utoipa::path(
1210    post,
1211    path = "/api/v1/relayers/{relayer_id}/rpc",
1212    tag = "Relayers",
1213    operation_id = "rpc",
1214    security(
1215        ("bearer_auth" = [])
1216    ),
1217    params(
1218        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1219    ),
1220    request_body(content = JsonRpcRequest<NetworkRpcRequest>,
1221        description = "JSON-RPC request with method and parameters", content_type = "application/json", example = json!({
1222        "jsonrpc": "2.0",
1223        "method": "feeEstimate",
1224        "params": {
1225            "network": "solana",
1226            "transaction": "base64_encoded_transaction",
1227            "fee_token": "SOL"
1228        },
1229        "id": 1
1230    })),
1231    responses(
1232        (status = 200, description = "RPC method executed successfully", body = JsonRpcResponse<NetworkRpcResult>),
1233        (
1234            status = 400,
1235            description = "BadRequest",
1236            body = ApiResponse<String>,
1237            example = json!({
1238                "success": false,
1239                "message": "Bad Request",
1240                "data": null
1241            })
1242        ),
1243        (
1244            status = 401,
1245            description = "Unauthorized",
1246            body = ApiResponse<String>,
1247            example = json!({
1248                "success": false,
1249                "message": "Unauthorized",
1250                "data": null
1251            })
1252        ),
1253        (
1254            status = 404,
1255            description = "Not Found",
1256            body = ApiResponse<String>,
1257            example = json!({
1258                "success": false,
1259                "message": "Relayer with ID relayer_id not found",
1260                "data": null
1261            })
1262        ),
1263        (
1264            status = 429,
1265            description = "Too Many Requests",
1266            body = ApiResponse<String>,
1267            example = json!({
1268                "success": false,
1269                "message": "Too Many Requests",
1270                "data": null
1271            })
1272        ),
1273        (
1274            status = 500,
1275            description = "Internal server error",
1276            body = ApiResponse<String>,
1277            example = json!({
1278                "success": false,
1279                "message": "Internal Server Error",
1280                "data": null
1281            })
1282        ),
1283    )
1284)]
1285#[allow(dead_code)]
1286fn doc_rpc() {}
1287
1288/// Estimates fees for a sponsored (gasless) transaction.
1289///
1290/// This endpoint provides fee estimation for transactions where the relayer will pay the network fees
1291/// on behalf of the user. The user pays fees in a token of their choice (e.g., USDC) instead of the
1292/// native network currency (e.g., XLM for Stellar).
1293///
1294/// The endpoint accepts either a pre-built transaction XDR or a set of operations to build a transaction from.
1295/// It returns the estimated fee amount in the specified fee token and the conversion rate from the native currency.
1296#[utoipa::path(
1297    post,
1298    path = "/api/v1/relayers/{relayer_id}/transactions/sponsored/quote",
1299    tag = "Relayers",
1300    operation_id = "quoteSponsoredTransaction",
1301    security(
1302        ("bearer_auth" = [])
1303    ),
1304    params(
1305        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
1306    ),
1307    request_body = SponsoredTransactionQuoteRequest,
1308    responses(
1309        (
1310            status = 200,
1311            description = "Fee estimate retrieved successfully",
1312            body = ApiResponse<SponsoredTransactionQuoteResponse>,
1313            example = json!({
1314                "success": true,
1315                "message": "Fee estimate retrieved successfully",
1316                "data": {
1317                    "estimated_fee": "1.5",
1318                    "conversion_rate": "0.15"
1319                }
1320            })
1321        ),
1322        (
1323            status = 400,
1324            description = "Bad Request - Invalid request parameters",
1325            body = ApiResponse<String>,
1326            example = json!({
1327                "success": false,
1328                "message": "Bad Request",
1329                "data": null
1330            })
1331        ),
1332        (
1333            status = 401,
1334            description = "Unauthorized",
1335            body = ApiResponse<String>,
1336            example = json!({
1337                "success": false,
1338                "message": "Unauthorized",
1339                "data": null
1340            })
1341        ),
1342        (
1343            status = 404,
1344            description = "Not Found",
1345            body = ApiResponse<String>,
1346            example = json!({
1347                "success": false,
1348                "message": "Relayer with ID relayer_id not found",
1349                "data": null
1350            })
1351        ),
1352        (
1353            status = 429,
1354            description = "Too Many Requests",
1355            body = ApiResponse<String>,
1356            example = json!({
1357                "success": false,
1358                "message": "Too Many Requests",
1359                "data": null
1360            })
1361        ),
1362        (
1363            status = 500,
1364            description = "Internal server error",
1365            body = ApiResponse<String>,
1366            example = json!({
1367                "success": false,
1368                "message": "Internal Server Error",
1369                "data": null
1370            })
1371        ),
1372    )
1373)]
1374#[allow(dead_code)]
1375fn doc_quote_sponsored_transaction() {}
1376
1377/// Prepares a sponsored (gasless) transaction with fee payments.
1378///
1379/// This endpoint builds a transaction where the relayer will pay the network fees on behalf of the user.
1380/// The user pays fees in a token of their choice (e.g., USDC) instead of the native network currency.
1381///
1382/// The endpoint accepts either a pre-built transaction XDR or a set of operations to build a transaction from.
1383/// It returns a prepared transaction that includes:
1384/// - The transaction XDR (base64 encoded) ready for signing
1385/// - The fee amount in both the fee token and native currency (stroops for Stellar)
1386/// - The fee token identifier
1387/// - The transaction validity timestamp
1388///
1389/// After receiving the prepared transaction, the user must sign it and submit it through the standard
1390/// transaction submission endpoint. For Stellar, the transaction will be wrapped in a fee-bump transaction
1391/// where the relayer pays the network fees.
1392#[utoipa::path(
1393    post,
1394    path = "/api/v1/relayers/{relayer_id}/transactions/sponsored/build",
1395    tag = "Relayers",
1396    operation_id = "buildSponsoredTransaction",
1397    security(
1398        ("bearer_auth" = [])
1399    ),
1400    params(
1401        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
1402    ),
1403    request_body = SponsoredTransactionBuildRequest,
1404    responses(
1405        (
1406            status = 200,
1407            description = "Sponsored transaction built successfully",
1408            body = ApiResponse<SponsoredTransactionBuildResponse>,
1409            example = json!({
1410                "success": true,
1411                "message": "Sponsored transaction built successfully",
1412                "data": {
1413                    "transaction": "AAAAAgAAAAD...",
1414                    "fee_in_token": "1.5",
1415                    "fee_in_stroops": "100000",
1416                    "fee_token": "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
1417                    "valid_until": "2024-01-01T00:00:00Z"
1418                }
1419            })
1420        ),
1421        (
1422            status = 400,
1423            description = "Bad Request - Invalid request parameters",
1424            body = ApiResponse<String>,
1425            example = json!({
1426                "success": false,
1427                "message": "Bad Request",
1428                "data": null
1429            })
1430        ),
1431        (
1432            status = 401,
1433            description = "Unauthorized",
1434            body = ApiResponse<String>,
1435            example = json!({
1436                "success": false,
1437                "message": "Unauthorized",
1438                "data": null
1439            })
1440        ),
1441        (
1442            status = 404,
1443            description = "Not Found",
1444            body = ApiResponse<String>,
1445            example = json!({
1446                "success": false,
1447                "message": "Relayer with ID relayer_id not found",
1448                "data": null
1449            })
1450        ),
1451        (
1452            status = 429,
1453            description = "Too Many Requests",
1454            body = ApiResponse<String>,
1455            example = json!({
1456                "success": false,
1457                "message": "Too Many Requests",
1458                "data": null
1459            })
1460        ),
1461        (
1462            status = 500,
1463            description = "Internal server error",
1464            body = ApiResponse<String>,
1465            example = json!({
1466                "success": false,
1467                "message": "Internal Server Error",
1468                "data": null
1469            })
1470        ),
1471    )
1472)]
1473#[allow(dead_code)]
1474fn doc_build_sponsored_transaction() {}