cat_gateway/service/api/cardano/cip36/
mod.rs

1//! CIP36 Registration Endpoints
2
3use poem_openapi::{param::Query, OpenApi};
4
5use self::cardano::slot_no::SlotNo;
6use crate::service::common::{
7    self,
8    auth::api_key::InternalApiKeyAuthorization,
9    tags::ApiTags,
10    types::cardano::{self},
11};
12
13pub(crate) mod endpoint;
14
15pub(crate) mod filter;
16
17pub(crate) mod response;
18
19/// Cardano Staking API Endpoints
20pub(crate) struct Api;
21
22#[OpenApi(tag = "ApiTags::Cardano")]
23impl Api {
24    /// CIP36 registrations.
25    ///
26    /// This endpoint gets the latest registration given either the voting key, stake
27    /// address, stake public key or the auth token.
28    ///
29    /// Registration can be the latest to date, or at a particular date-time or slot
30    /// number.
31    // Required To be able to look up for:
32    // 1. Voting Public Key
33    // 2. Cip-19 stake address
34    // 3. All - Hidden option and would need a hidden api key header (used to create a snapshot
35    //    replacement.)
36    // 4. Stake addresses associated with current Role0 registration (if none of the above
37    //    provided).
38    // If none of the above provided, return not found.
39    #[oai(
40        path = "/v1/cardano/registration/cip36",
41        method = "get",
42        operation_id = "cardanoRegistrationCip36",
43        hidden = true
44    )]
45    async fn get_registration(
46        &self, lookup: Query<Option<cardano::query::stake_or_voter::StakeOrVoter>>,
47        asat: Query<Option<cardano::query::AsAt>>,
48        page: Query<Option<common::types::generic::query::pagination::Page>>,
49        limit: Query<Option<common::types::generic::query::pagination::Limit>>,
50        _auth: InternalApiKeyAuthorization,
51    ) -> response::AllRegistration {
52        endpoint::cip36_registrations(
53            lookup.0,
54            SlotNo::into_option(asat.0),
55            page.0.unwrap_or_default(),
56            limit.0.unwrap_or_default(),
57        )
58        .await
59    }
60}