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