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    ),
378    responses(
379        (status = 200, description = "Relayer status retrieved successfully", body = ApiResponse<RelayerStatus>),
380        (
381            status = 400,
382            description = "BadRequest",
383            body = ApiResponse<String>,
384            example = json!({
385                "success": false,
386                "message": "Bad Request",
387                "data": null
388            })
389        ),
390        (
391            status = 401,
392            description = "Unauthorized",
393            body = ApiResponse<String>,
394            example = json!({
395                "success": false,
396                "message": "Unauthorized",
397                "data": null
398            })
399        ),
400        (
401            status = 404,
402            description = "Not Found",
403            body = ApiResponse<String>,
404            example = json!({
405                "success": false,
406                "message": "Relayer with ID relayer_id not found",
407                "data": null
408            })
409        ),
410        (
411            status = 429,
412            description = "Too Many Requests",
413            body = ApiResponse<String>,
414            example = json!({
415                "success": false,
416                "message": "Too Many Requests",
417                "data": null
418            })
419        ),
420        (
421            status = 500,
422            description = "Internal server error",
423            body = ApiResponse<String>,
424            example = json!({
425                "success": false,
426                "message": "Internal Server Error",
427                "data": null
428            })
429        ),
430    )
431)]
432#[allow(dead_code)]
433fn doc_get_relayer_status() {}
434
435/// Retrieves the balance of a specific relayer.
436#[utoipa::path(
437    get,
438    path = "/api/v1/relayers/{relayer_id}/balance",
439    tag = "Relayers",
440    operation_id = "getRelayerBalance",
441    security(
442        ("bearer_auth" = [])
443    ),
444    params(
445        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
446    ),
447    responses(
448        (status = 200, description = "Relayer balance retrieved successfully", body = ApiResponse<BalanceResponse>),
449        (
450            status = 400,
451            description = "BadRequest",
452            body = ApiResponse<String>,
453            example = json!({
454                "success": false,
455                "message": "Bad Request",
456                "data": null
457            })
458        ),
459        (
460            status = 401,
461            description = "Unauthorized",
462            body = ApiResponse<String>,
463            example = json!({
464                "success": false,
465                "message": "Unauthorized",
466                "data": null
467            })
468        ),
469        (
470            status = 404,
471            description = "Not Found",
472            body = ApiResponse<String>,
473            example = json!({
474                "success": false,
475                "message": "Relayer with ID relayer_id not found",
476                "data": null
477            })
478        ),
479        (
480            status = 429,
481            description = "Too Many Requests",
482            body = ApiResponse<String>,
483            example = json!({
484                "success": false,
485                "message": "Too Many Requests",
486                "data": null
487            })
488        ),
489        (
490            status = 500,
491            description = "Internal server error",
492            body = ApiResponse<String>,
493            example = json!({
494                "success": false,
495                "message": "Internal Server Error",
496                "data": null
497            })
498        ),
499    )
500)]
501#[allow(dead_code)]
502fn doc_get_relayer_balance() {}
503
504/// Sends a transaction through the specified relayer.
505#[utoipa::path(
506    post,
507    path = "/api/v1/relayers/{relayer_id}/transactions",
508    tag = "Relayers",
509    operation_id = "sendTransaction",
510    security(
511        ("bearer_auth" = [])
512    ),
513    params(
514        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
515    ),
516    request_body = NetworkTransactionRequest,
517    responses(
518        (status = 200, description = "Relayer transactions sent successfully", body = ApiResponse<TransactionResponse>),
519        (
520            status = 400,
521            description = "BadRequest",
522            body = ApiResponse<String>,
523            example = json!({
524                "success": false,
525                "message": "Bad Request",
526                "data": null
527            })
528        ),
529        (
530            status = 401,
531            description = "Unauthorized",
532            body = ApiResponse<String>,
533            example = json!({
534                "success": false,
535                "message": "Unauthorized",
536                "data": null
537            })
538        ),
539        (
540            status = 404,
541            description = "Not Found",
542            body = ApiResponse<String>,
543            example = json!({
544                "success": false,
545                "message": "Relayer with ID relayer_id not found",
546                "data": null
547            })
548        ),
549        (
550            status = 429,
551            description = "Too Many Requests",
552            body = ApiResponse<String>,
553            example = json!({
554                "success": false,
555                "message": "Too Many Requests",
556                "data": null
557            })
558        ),
559        (
560            status = 500,
561            description = "Internal server error",
562            body = ApiResponse<String>,
563            example = json!({
564                "success": false,
565                "message": "Internal Server Error",
566                "data": null
567            })
568        ),
569    )
570)]
571#[allow(dead_code)]
572fn doc_send_transaction() {}
573
574/// Retrieves a specific transaction by its ID.
575#[utoipa::path(
576    get,
577    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
578    operation_id = "getTransactionById",
579    tag = "Relayers",
580    security(
581        ("bearer_auth" = [])
582    ),
583    params(
584        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
585        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
586    ),
587    responses(
588        (status = 200, description = "Relayer transaction retrieved successfully", body = ApiResponse<TransactionResponse>),
589        (
590            status = 400,
591            description = "BadRequest",
592            body = ApiResponse<String>,
593            example = json!({
594                "success": false,
595                "message": "Bad Request",
596                "data": null
597            })
598        ),
599        (
600            status = 401,
601            description = "Unauthorized",
602            body = ApiResponse<String>,
603            example = json!({
604                "success": false,
605                "message": "Unauthorized",
606                "data": null
607            })
608        ),
609        (
610            status = 429,
611            description = "Too Many Requests",
612            body = ApiResponse<String>,
613            example = json!({
614                "success": false,
615                "message": "Too Many Requests",
616                "data": null
617            })
618        ),
619        (
620            status = 404,
621            description = "Not Found",
622            body = ApiResponse<String>,
623            example = json!({
624                "success": false,
625                "message": "Not Found",
626                "data": null
627            })
628        ),
629        (
630            status = 500,
631            description = "Internal server error",
632            body = ApiResponse<String>,
633            example = json!({
634                "success": false,
635                "message": "Internal Server Error",
636                "data": null
637            })
638        ),
639    )
640)]
641#[allow(dead_code)]
642fn doc_get_transaction_by_id() {}
643
644/// Retrieves a transaction by its nonce value.
645#[utoipa::path(
646    get,
647    path = "/api/v1/relayers/{relayer_id}/transactions/by-nonce/{nonce}",
648    tag = "Relayers",
649    operation_id = "getTransactionByNonce",
650    security(
651        ("bearer_auth" = [])
652    ),
653    params(
654        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
655        ("nonce" = usize, Path, description = "The nonce of the transaction")
656    ),
657    responses(
658        (status = 200, description = "Relayer transaction retrieved successfully", body = ApiResponse<TransactionResponse>),
659        (
660            status = 400,
661            description = "BadRequest",
662            body = ApiResponse<String>,
663            example = json!({
664                "success": false,
665                "message": "Bad Request",
666                "data": null
667            })
668        ),
669        (
670            status = 401,
671            description = "Unauthorized",
672            body = ApiResponse<String>,
673            example = json!({
674                "success": false,
675                "message": "Unauthorized",
676                "data": null
677            })
678        ),
679        (
680            status = 404,
681            description = "Not Found",
682            body = ApiResponse<String>,
683            example = json!({
684                "success": false,
685                "message": "Not found",
686                "data": null
687            })
688        ),
689        (
690            status = 429,
691            description = "Too Many Requests",
692            body = ApiResponse<String>,
693            example = json!({
694                "success": false,
695                "message": "Too Many Requests",
696                "data": null
697            })
698        ),
699        (
700            status = 500,
701            description = "Internal server error",
702            body = ApiResponse<String>,
703            example = json!({
704                "success": false,
705                "message": "Internal Server Error",
706                "data": null
707            })
708        ),
709    )
710)]
711#[allow(dead_code)]
712fn doc_get_transaction_by_nonce() {}
713
714/// Lists all transactions for a specific relayer with pagination.
715#[utoipa::path(
716    get,
717    path = "/api/v1/relayers/{relayer_id}/transactions/",
718    tag = "Relayers",
719    operation_id = "listTransactions",
720    security(
721        ("bearer_auth" = [])
722    ),
723    params(
724        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
725        ("page" = Option<usize>, Query, description = "Page number for pagination (starts at 1)"),
726        ("per_page" = Option<usize>, Query, description = "Number of items per page (default: 10)")
727    ),
728    responses(
729        (status = 200, description = "Relayer transactions retrieved successfully", body = ApiResponse<Vec<TransactionResponse>>),
730        (
731            status = 400,
732            description = "BadRequest",
733            body = ApiResponse<String>,
734            example = json!({
735                "success": false,
736                "message": "Bad Request",
737                "data": null
738            })
739        ),
740        (
741            status = 401,
742            description = "Unauthorized",
743            body = ApiResponse<String>,
744            example = json!({
745                "success": false,
746                "message": "Unauthorized",
747                "data": null
748            })
749        ),
750        (
751            status = 404,
752            description = "Not Found",
753            body = ApiResponse<String>,
754            example = json!({
755                "success": false,
756                "message": "Relayer with ID relayer_id not found",
757                "data": null
758            })
759        ),
760        (
761            status = 429,
762            description = "Too Many Requests",
763            body = ApiResponse<String>,
764            example = json!({
765                "success": false,
766                "message": "Too Many Requests",
767                "data": null
768            })
769        ),
770        (
771            status = 500,
772            description = "Internal server error",
773            body = ApiResponse<String>,
774            example = json!({
775                "success": false,
776                "message": "Internal Server Error",
777                "data": null
778            })
779        ),
780    )
781)]
782#[allow(dead_code)]
783fn doc_list_transactions() {}
784
785/// Deletes all pending transactions for a specific relayer.
786#[utoipa::path(
787    delete,
788    path = "/api/v1/relayers/{relayer_id}/transactions/pending",
789    tag = "Relayers",
790    operation_id = "deletePendingTransactions",
791    security(
792        ("bearer_auth" = [])
793    ),
794    params(
795        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
796    ),
797    responses(
798        (status = 200, description = "Relayer pending transactions successfully", body = ApiResponse<DeletePendingTransactionsResponse>),
799        (
800            status = 400,
801            description = "BadRequest",
802            body = ApiResponse<String>,
803            example = json!({
804                "success": false,
805                "message": "Bad Request",
806                "data": null
807            })
808        ),
809        (
810            status = 401,
811            description = "Unauthorized",
812            body = ApiResponse<String>,
813            example = json!({
814                "success": false,
815                "message": "Unauthorized",
816                "data": null
817            })
818        ),
819        (
820            status = 404,
821            description = "Not Found",
822            body = ApiResponse<String>,
823            example = json!({
824                "success": false,
825                "message": "Relayer with ID relayer_id not found",
826                "data": null
827            })
828        ),
829        (
830            status = 429,
831            description = "Too Many Requests",
832            body = ApiResponse<String>,
833            example = json!({
834                "success": false,
835                "message": "Too Many Requests",
836                "data": null
837            })
838        ),
839        (
840            status = 500,
841            description = "Internal server error",
842            body = ApiResponse<String>,
843            example = json!({
844                "success": false,
845                "message": "Internal Server Error",
846                "data": null
847            })
848        ),
849    )
850)]
851#[allow(dead_code)]
852fn doc_delete_pending_transactions() {}
853
854/// Cancels a specific transaction by its ID.
855#[utoipa::path(
856    delete,
857    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
858    tag = "Relayers",
859    operation_id = "cancelTransaction",
860    security(
861        ("bearer_auth" = [])
862    ),
863    params(
864        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
865        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
866    ),
867    responses(
868        (status = 200, description = "Relayer transaction canceled successfully", body = ApiResponse<TransactionResponse>),
869        (
870            status = 400,
871            description = "BadRequest",
872            body = ApiResponse<String>,
873            example = json!({
874                "success": false,
875                "message": "Bad Request",
876                "data": null
877            })
878        ),
879        (
880            status = 401,
881            description = "Unauthorized",
882            body = ApiResponse<String>,
883            example = json!({
884                "success": false,
885                "message": "Unauthorized",
886                "data": null
887            })
888        ),
889        (
890            status = 404,
891            description = "Not Found",
892            body = ApiResponse<String>,
893            example = json!({
894                "success": false,
895                "message": "Not found",
896                "data": null
897            })
898        ),
899        (
900            status = 429,
901            description = "Too Many Requests",
902            body = ApiResponse<String>,
903            example = json!({
904                "success": false,
905                "message": "Too Many Requests",
906                "data": null
907            })
908        ),
909        (
910            status = 500,
911            description = "Internal server error",
912            body = ApiResponse<String>,
913            example = json!({
914                "success": false,
915                "message": "Internal Server Error",
916                "data": null
917            })
918        ),
919    )
920)]
921#[allow(dead_code)]
922fn doc_cancel_transaction() {}
923
924/// Replaces a specific transaction with a new one.
925#[utoipa::path(
926    put,
927    path = "/api/v1/relayers/{relayer_id}/transactions/{transaction_id}",
928    tag = "Relayers",
929    operation_id = "replaceTransaction",
930    security(
931        ("bearer_auth" = [])
932    ),
933    params(
934        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
935        ("transaction_id" = String, Path, description = "The unique identifier of the transaction")
936    ),
937    request_body = NetworkTransactionRequest,
938    responses(
939        (status = 200, description = "Relayer transaction replaced successfully", body = ApiResponse<TransactionResponse>),
940        (
941            status = 400,
942            description = "BadRequest",
943            body = ApiResponse<String>,
944            example = json!({
945                "success": false,
946                "message": "Bad Request",
947                "data": null
948            })
949        ),
950        (
951            status = 401,
952            description = "Unauthorized",
953            body = ApiResponse<String>,
954            example = json!({
955                "success": false,
956                "message": "Unauthorized",
957                "data": null
958            })
959        ),
960        (
961            status = 404,
962            description = "Not Found",
963            body = ApiResponse<String>,
964            example = json!({
965                "success": false,
966                "message": "Not found",
967                "data": null
968            })
969        ),
970        (
971            status = 429,
972            description = "Too Many Requests",
973            body = ApiResponse<String>,
974            example = json!({
975                "success": false,
976                "message": "Too Many Requests",
977                "data": null
978            })
979        ),
980        (
981            status = 500,
982            description = "Internal server error",
983            body = ApiResponse<String>,
984            example = json!({
985                "success": false,
986                "message": "Internal Server Error",
987                "data": null
988            })
989        ),
990    )
991)]
992#[allow(dead_code)]
993fn doc_replace_transaction() {}
994
995/// Signs data using the specified relayer.
996#[utoipa::path(
997    post,
998    path = "/api/v1/relayers/{relayer_id}/sign",
999    operation_id = "sign",
1000    tag = "Relayers",
1001    security(
1002        ("bearer_auth" = [])
1003    ),
1004    params(
1005        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1006    ),
1007    request_body = SignDataRequest,
1008    responses(
1009        (status = 200, description = "Relayer signed data successfully", body = ApiResponse<SignDataResponse>),
1010        (
1011            status = 400,
1012            description = "BadRequest",
1013            body = ApiResponse<String>,
1014            example = json!({
1015                "success": false,
1016                "message": "Bad Request",
1017                "data": null
1018            })
1019        ),
1020        (
1021            status = 401,
1022            description = "Unauthorized",
1023            body = ApiResponse<String>,
1024            example = json!({
1025                "success": false,
1026                "message": "Unauthorized",
1027                "data": null
1028            })
1029        ),
1030        (
1031            status = 404,
1032            description = "Not Found",
1033            body = ApiResponse<String>,
1034            example = json!({
1035                "success": false,
1036                "message": "Not found",
1037                "data": null
1038            })
1039        ),
1040        (
1041            status = 429,
1042            description = "Too Many Requests",
1043            body = ApiResponse<String>,
1044            example = json!({
1045                "success": false,
1046                "message": "Too Many Requests",
1047                "data": null
1048            })
1049        ),
1050        (
1051            status = 500,
1052            description = "Internal server error",
1053            body = ApiResponse<String>,
1054            example = json!({
1055                "success": false,
1056                "message": "Internal Server Error",
1057                "data": null
1058            })
1059        ),
1060    )
1061)]
1062#[allow(dead_code)]
1063fn doc_sign() {}
1064
1065/// Signs typed data using the specified relayer.
1066#[utoipa::path(
1067    post,
1068    path = "/api/v1/relayers/{relayer_id}/sign-typed-data",
1069    tag = "Relayers",
1070    operation_id = "signTypedData",
1071    security(
1072        ("bearer_auth" = [])
1073    ),
1074    params(
1075        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1076    ),
1077    request_body = SignTypedDataRequest,
1078    responses(
1079        (status = 200, description = "Relayer signed typed data successfully", body = ApiResponse<SignDataResponse>),
1080        (
1081            status = 400,
1082            description = "BadRequest",
1083            body = ApiResponse<String>,
1084            example = json!({
1085                "success": false,
1086                "message": "Bad Request",
1087                "data": null
1088            })
1089        ),
1090        (
1091            status = 401,
1092            description = "Unauthorized",
1093            body = ApiResponse<String>,
1094            example = json!({
1095                "success": false,
1096                "message": "Unauthorized",
1097                "data": null
1098            })
1099        ),
1100        (
1101            status = 404,
1102            description = "Not Found",
1103            body = ApiResponse<String>,
1104            example = json!({
1105                "success": false,
1106                "message": "Relayer with ID relayer_id not found",
1107                "data": null
1108            })
1109        ),
1110        (
1111            status = 429,
1112            description = "Too Many Requests",
1113            body = ApiResponse<String>,
1114            example = json!({
1115                "success": false,
1116                "message": "Too Many Requests",
1117                "data": null
1118            })
1119        ),
1120        (
1121            status = 500,
1122            description = "Internal server error",
1123            body = ApiResponse<String>,
1124            example = json!({
1125                "success": false,
1126                "message": "Internal Server Error",
1127                "data": null
1128            })
1129        ),
1130    )
1131)]
1132#[allow(dead_code)]
1133fn doc_sign_typed_data() {}
1134
1135/// Signs a transaction using the specified relayer (Stellar only).
1136#[utoipa::path(
1137    post,
1138    path = "/api/v1/relayers/{relayer_id}/sign-transaction",
1139    tag = "Relayers",
1140    operation_id = "signTransaction",
1141    security(
1142        ("bearer_auth" = [])
1143    ),
1144    params(
1145        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1146    ),
1147    request_body = SignTransactionRequest,
1148    responses(
1149        (status = 200, description = "Transaction signed successfully", body = ApiResponse<SignTransactionExternalResponse>),
1150        (
1151            status = 400,
1152            description = "BadRequest",
1153            body = ApiResponse<String>,
1154            example = json!({
1155                "success": false,
1156                "message": "Bad Request",
1157                "data": null
1158            })
1159        ),
1160        (
1161            status = 401,
1162            description = "Unauthorized",
1163            body = ApiResponse<String>,
1164            example = json!({
1165                "success": false,
1166                "message": "Unauthorized",
1167                "data": null
1168            })
1169        ),
1170        (
1171            status = 404,
1172            description = "Not Found",
1173            body = ApiResponse<String>,
1174            example = json!({
1175                "success": false,
1176                "message": "Relayer with ID relayer_id not found",
1177                "data": null
1178            })
1179        ),
1180        (
1181            status = 429,
1182            description = "Too Many Requests",
1183            body = ApiResponse<String>,
1184            example = json!({
1185                "success": false,
1186                "message": "Too Many Requests",
1187                "data": null
1188            })
1189        ),
1190        (
1191            status = 500,
1192            description = "Internal server error",
1193            body = ApiResponse<String>,
1194            example = json!({
1195                "success": false,
1196                "message": "Internal Server Error",
1197                "data": null
1198            })
1199        ),
1200    )
1201)]
1202#[allow(dead_code)]
1203fn doc_sign_transaction() {}
1204
1205/// Performs a JSON-RPC call using the specified relayer.
1206#[utoipa::path(
1207    post,
1208    path = "/api/v1/relayers/{relayer_id}/rpc",
1209    tag = "Relayers",
1210    operation_id = "rpc",
1211    security(
1212        ("bearer_auth" = [])
1213    ),
1214    params(
1215        ("relayer_id" = String, Path, description = "The unique identifier of the relayer"),
1216    ),
1217    request_body(content = JsonRpcRequest<NetworkRpcRequest>,
1218        description = "JSON-RPC request with method and parameters", content_type = "application/json", example = json!({
1219        "jsonrpc": "2.0",
1220        "method": "feeEstimate",
1221        "params": {
1222            "network": "solana",
1223            "transaction": "base64_encoded_transaction",
1224            "fee_token": "SOL"
1225        },
1226        "id": 1
1227    })),
1228    responses(
1229        (status = 200, description = "RPC method executed successfully", body = JsonRpcResponse<NetworkRpcResult>),
1230        (
1231            status = 400,
1232            description = "BadRequest",
1233            body = ApiResponse<String>,
1234            example = json!({
1235                "success": false,
1236                "message": "Bad Request",
1237                "data": null
1238            })
1239        ),
1240        (
1241            status = 401,
1242            description = "Unauthorized",
1243            body = ApiResponse<String>,
1244            example = json!({
1245                "success": false,
1246                "message": "Unauthorized",
1247                "data": null
1248            })
1249        ),
1250        (
1251            status = 404,
1252            description = "Not Found",
1253            body = ApiResponse<String>,
1254            example = json!({
1255                "success": false,
1256                "message": "Relayer with ID relayer_id not found",
1257                "data": null
1258            })
1259        ),
1260        (
1261            status = 429,
1262            description = "Too Many Requests",
1263            body = ApiResponse<String>,
1264            example = json!({
1265                "success": false,
1266                "message": "Too Many Requests",
1267                "data": null
1268            })
1269        ),
1270        (
1271            status = 500,
1272            description = "Internal server error",
1273            body = ApiResponse<String>,
1274            example = json!({
1275                "success": false,
1276                "message": "Internal Server Error",
1277                "data": null
1278            })
1279        ),
1280    )
1281)]
1282#[allow(dead_code)]
1283fn doc_rpc() {}
1284
1285/// Estimates fees for a sponsored (gasless) transaction.
1286///
1287/// This endpoint provides fee estimation for transactions where the relayer will pay the network fees
1288/// on behalf of the user. The user pays fees in a token of their choice (e.g., USDC) instead of the
1289/// native network currency (e.g., XLM for Stellar).
1290///
1291/// The endpoint accepts either a pre-built transaction XDR or a set of operations to build a transaction from.
1292/// It returns the estimated fee amount in the specified fee token and the conversion rate from the native currency.
1293#[utoipa::path(
1294    post,
1295    path = "/api/v1/relayers/{relayer_id}/transactions/sponsored/quote",
1296    tag = "Relayers",
1297    operation_id = "quoteSponsoredTransaction",
1298    security(
1299        ("bearer_auth" = [])
1300    ),
1301    params(
1302        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
1303    ),
1304    request_body = SponsoredTransactionQuoteRequest,
1305    responses(
1306        (
1307            status = 200,
1308            description = "Fee estimate retrieved successfully",
1309            body = ApiResponse<SponsoredTransactionQuoteResponse>,
1310            example = json!({
1311                "success": true,
1312                "message": "Fee estimate retrieved successfully",
1313                "data": {
1314                    "estimated_fee": "1.5",
1315                    "conversion_rate": "0.15"
1316                }
1317            })
1318        ),
1319        (
1320            status = 400,
1321            description = "Bad Request - Invalid request parameters",
1322            body = ApiResponse<String>,
1323            example = json!({
1324                "success": false,
1325                "message": "Bad Request",
1326                "data": null
1327            })
1328        ),
1329        (
1330            status = 401,
1331            description = "Unauthorized",
1332            body = ApiResponse<String>,
1333            example = json!({
1334                "success": false,
1335                "message": "Unauthorized",
1336                "data": null
1337            })
1338        ),
1339        (
1340            status = 404,
1341            description = "Not Found",
1342            body = ApiResponse<String>,
1343            example = json!({
1344                "success": false,
1345                "message": "Relayer with ID relayer_id not found",
1346                "data": null
1347            })
1348        ),
1349        (
1350            status = 429,
1351            description = "Too Many Requests",
1352            body = ApiResponse<String>,
1353            example = json!({
1354                "success": false,
1355                "message": "Too Many Requests",
1356                "data": null
1357            })
1358        ),
1359        (
1360            status = 500,
1361            description = "Internal server error",
1362            body = ApiResponse<String>,
1363            example = json!({
1364                "success": false,
1365                "message": "Internal Server Error",
1366                "data": null
1367            })
1368        ),
1369    )
1370)]
1371#[allow(dead_code)]
1372fn doc_quote_sponsored_transaction() {}
1373
1374/// Prepares a sponsored (gasless) transaction with fee payments.
1375///
1376/// This endpoint builds a transaction where the relayer will pay the network fees on behalf of the user.
1377/// The user pays fees in a token of their choice (e.g., USDC) instead of the native network currency.
1378///
1379/// The endpoint accepts either a pre-built transaction XDR or a set of operations to build a transaction from.
1380/// It returns a prepared transaction that includes:
1381/// - The transaction XDR (base64 encoded) ready for signing
1382/// - The fee amount in both the fee token and native currency (stroops for Stellar)
1383/// - The fee token identifier
1384/// - The transaction validity timestamp
1385///
1386/// After receiving the prepared transaction, the user must sign it and submit it through the standard
1387/// transaction submission endpoint. For Stellar, the transaction will be wrapped in a fee-bump transaction
1388/// where the relayer pays the network fees.
1389#[utoipa::path(
1390    post,
1391    path = "/api/v1/relayers/{relayer_id}/transactions/sponsored/build",
1392    tag = "Relayers",
1393    operation_id = "buildSponsoredTransaction",
1394    security(
1395        ("bearer_auth" = [])
1396    ),
1397    params(
1398        ("relayer_id" = String, Path, description = "The unique identifier of the relayer")
1399    ),
1400    request_body = SponsoredTransactionBuildRequest,
1401    responses(
1402        (
1403            status = 200,
1404            description = "Sponsored transaction built successfully",
1405            body = ApiResponse<SponsoredTransactionBuildResponse>,
1406            example = json!({
1407                "success": true,
1408                "message": "Sponsored transaction built successfully",
1409                "data": {
1410                    "transaction": "AAAAAgAAAAD...",
1411                    "fee_in_token": "1.5",
1412                    "fee_in_stroops": "100000",
1413                    "fee_token": "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
1414                    "valid_until": "2024-01-01T00:00:00Z"
1415                }
1416            })
1417        ),
1418        (
1419            status = 400,
1420            description = "Bad Request - Invalid request parameters",
1421            body = ApiResponse<String>,
1422            example = json!({
1423                "success": false,
1424                "message": "Bad Request",
1425                "data": null
1426            })
1427        ),
1428        (
1429            status = 401,
1430            description = "Unauthorized",
1431            body = ApiResponse<String>,
1432            example = json!({
1433                "success": false,
1434                "message": "Unauthorized",
1435                "data": null
1436            })
1437        ),
1438        (
1439            status = 404,
1440            description = "Not Found",
1441            body = ApiResponse<String>,
1442            example = json!({
1443                "success": false,
1444                "message": "Relayer with ID relayer_id not found",
1445                "data": null
1446            })
1447        ),
1448        (
1449            status = 429,
1450            description = "Too Many Requests",
1451            body = ApiResponse<String>,
1452            example = json!({
1453                "success": false,
1454                "message": "Too Many Requests",
1455                "data": null
1456            })
1457        ),
1458        (
1459            status = 500,
1460            description = "Internal server error",
1461            body = ApiResponse<String>,
1462            example = json!({
1463                "success": false,
1464                "message": "Internal Server Error",
1465                "data": null
1466            })
1467        ),
1468    )
1469)]
1470#[allow(dead_code)]
1471fn doc_build_sponsored_transaction() {}