Skip to content

Commit 17ce0c7

Browse files
authored
Merge branch 'main' into fix/cip36-assets-indexing
2 parents f0a6e83 + 33f7e2e commit 17ce0c7

File tree

135 files changed

+2490
-981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+2490
-981
lines changed

catalyst-gateway/bin/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-
2020
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
2121
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
2222
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
23+
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250406-00" }
2324

2425
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
2526
pallas-traverse = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
@@ -97,6 +98,8 @@ stats_alloc = "0.1.10"
9798
memory-stats = "1.0.0"
9899
derive_more = { version = "2.0.1", default-features = false, features = ["from", "into"] }
99100
rayon = "1.10"
101+
x509-cert = "0.2.5"
102+
minicbor = { version = "0.25.1", features = ["alloc"] }
100103

101104
# Its a transitive dependency of the "poem-openapi" crate,
102105
# but its breaks API after version "5.1.8".

catalyst-gateway/bin/src/db/index/queries/cql/get_catalyst_id_for_stake_address.cql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SELECT
2-
catalyst_id
2+
catalyst_id,
3+
slot_no
34
FROM
45
catalyst_id_for_stake_address
56
WHERE

catalyst-gateway/bin/src/db/index/queries/rbac/get_catalyst_id_from_stake_address.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::db::{
1313
queries::{PreparedQueries, PreparedSelectQuery},
1414
session::CassandraSession,
1515
},
16-
types::{DbCatalystId, DbStakeAddress},
16+
types::{DbCatalystId, DbSlot, DbStakeAddress},
1717
};
1818

1919
/// Get Catalyst ID by stake address query string.
@@ -27,12 +27,12 @@ pub(crate) struct QueryParams {
2727
}
2828

2929
/// Get Catalyst ID by stake address query.
30-
// TODO: Remove the `dead_code` annotation when the query is used.
31-
#[allow(dead_code)]
3230
#[derive(Debug, Clone, DeserializeRow)]
3331
pub(crate) struct Query {
3432
/// Catalyst ID for the queries stake address.
3533
pub catalyst_id: DbCatalystId,
34+
/// A slot number.
35+
pub slot_no: DbSlot,
3636
}
3737

3838
impl Query {
@@ -46,8 +46,6 @@ impl Query {
4646
}
4747

4848
/// Executes a get Catalyst ID by stake address query.
49-
// TODO: Remove the `dead_code` annotation when the query is used.
50-
#[allow(dead_code)]
5149
pub(crate) async fn execute(
5250
session: &CassandraSession, params: QueryParams,
5351
) -> anyhow::Result<TypedRowStream<Query>> {

catalyst-gateway/bin/src/db/index/queries/rbac/get_rbac_registrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) struct QueryParams {
2828

2929
/// Get registrations by Catalyst ID query.
3030
#[allow(dead_code)]
31-
#[derive(DeserializeRow)]
31+
#[derive(DeserializeRow, Clone)]
3232
pub(crate) struct Query {
3333
/// Registration transaction id.
3434
pub txn_id: DbTransactionId,

catalyst-gateway/bin/src/service/api/cardano/cip36/endpoint.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
//! Implementation of the GET `/cardano/cip36` endpoint
22
3-
use poem::http::HeaderMap;
43
use tracing::error;
54

6-
use self::cardano::query::stake_or_voter::StakeAddressOrPublicKey;
75
use super::{
8-
cardano::{self},
96
filter::{get_registration_given_stake_key_hash, get_registration_given_vote_key, snapshot},
107
response, SlotNo,
118
};
129
use crate::{
1310
db::index::session::CassandraSession,
1411
service::{
1512
api::cardano::cip36::response::AllRegistration,
16-
common::{self, types::headers::retry_after::RetryAfterOption},
13+
common::{
14+
self,
15+
types::{
16+
cardano::query::stake_or_voter::StakeOrVoter,
17+
headers::retry_after::RetryAfterOption,
18+
},
19+
},
1720
},
1821
};
1922

2023
/// Process the endpoint operation
2124
pub(crate) async fn cip36_registrations(
22-
lookup: Option<cardano::query::stake_or_voter::StakeOrVoter>, asat: Option<SlotNo>,
25+
lookup: Option<StakeOrVoter>, asat: Option<SlotNo>,
2326
_page: common::types::generic::query::pagination::Page,
24-
_limit: common::types::generic::query::pagination::Limit, _headers: &HeaderMap,
27+
_limit: common::types::generic::query::pagination::Limit,
2528
) -> AllRegistration {
2629
let Some(session) = CassandraSession::get(true) else {
2730
error!("Failed to acquire db session");
@@ -32,8 +35,8 @@ pub(crate) async fn cip36_registrations(
3235
};
3336

3437
if let Some(stake_or_voter) = lookup {
35-
match StakeAddressOrPublicKey::from(stake_or_voter) {
36-
StakeAddressOrPublicKey::Address(cip19_stake_address) => {
38+
match stake_or_voter {
39+
StakeOrVoter::Address(cip19_stake_address) => {
3740
// Typically, a stake address will start with 'stake1',
3841
// We need to convert this to a stake hash as per our data model to then find the,
3942
// Full Stake Public Key (32 byte Ed25519 Public key, not hashed).
@@ -52,7 +55,7 @@ pub(crate) async fn cip36_registrations(
5255

5356
return get_registration_given_stake_key_hash(address, session, asat).await;
5457
},
55-
StakeAddressOrPublicKey::PublicKey(ed25519_hex_encoded_public_key) => {
58+
StakeOrVoter::PublicKey(ed25519_hex_encoded_public_key) => {
5659
// As above...
5760
// Except using a voting key.
5861
return get_registration_given_vote_key(
@@ -62,7 +65,7 @@ pub(crate) async fn cip36_registrations(
6265
)
6366
.await;
6467
},
65-
StakeAddressOrPublicKey::All =>
68+
StakeOrVoter::All =>
6669
// As above...
6770
// Snapshot replacement, returns all registrations or returns a
6871
// subset of registrations if constrained by a given time.

catalyst-gateway/bin/src/service/api/cardano/cip36/filter.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ use super::{
1515
AllRegistration, Cip36Details, Cip36Registration, Cip36RegistrationList,
1616
Cip36RegistrationsForVotingPublicKey,
1717
},
18-
Ed25519HexEncodedPublicKey, SlotNo,
18+
SlotNo,
1919
};
20-
use crate::db::index::{
21-
queries::registrations::{
22-
get_all_invalids::{GetAllInvalidRegistrationsParams, GetAllInvalidRegistrationsQuery},
23-
get_all_registrations::{GetAllRegistrationsParams, GetAllRegistrationsQuery},
24-
get_from_stake_addr::{GetRegistrationParams, GetRegistrationQuery},
25-
get_from_stake_address::{GetStakeAddrParams, GetStakeAddrQuery},
26-
get_from_vote_key::{GetStakeAddrFromVoteKeyParams, GetStakeAddrFromVoteKeyQuery},
27-
get_invalid::{GetInvalidRegistrationParams, GetInvalidRegistrationQuery},
20+
use crate::{
21+
db::index::{
22+
queries::registrations::{
23+
get_all_invalids::{GetAllInvalidRegistrationsParams, GetAllInvalidRegistrationsQuery},
24+
get_all_registrations::{GetAllRegistrationsParams, GetAllRegistrationsQuery},
25+
get_from_stake_addr::{GetRegistrationParams, GetRegistrationQuery},
26+
get_from_stake_address::{GetStakeAddrParams, GetStakeAddrQuery},
27+
get_from_vote_key::{GetStakeAddrFromVoteKeyParams, GetStakeAddrFromVoteKeyQuery},
28+
get_invalid::{GetInvalidRegistrationParams, GetInvalidRegistrationQuery},
29+
},
30+
session::CassandraSession,
2831
},
29-
session::CassandraSession,
32+
service::common::types::generic::ed25519_public_key::Ed25519HexEncodedPublicKey,
3033
};
3134

3235
/// Get registration given a stake key hash, it can be time specific based on asat param,

catalyst-gateway/bin/src/service/api/cardano/cip36/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use poem_openapi::{param::Query, payload::Json, OpenApi};
55
use response::Cip36RegistrationUnprocessableContent;
66

77
use self::{cardano::slot_no::SlotNo, common::auth::none::NoAuthorization};
8-
use super::Ed25519HexEncodedPublicKey;
98
use crate::service::common::{
109
self,
1110
tags::ApiTags,
@@ -72,7 +71,6 @@ impl Api {
7271
SlotNo::into_option(asat.0),
7372
page.0.unwrap_or_default(),
7473
limit.0.unwrap_or_default(),
75-
headers,
7674
)
7775
.await
7876
}

catalyst-gateway/bin/src/service/api/cardano/cip36/response.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use poem_openapi::{
88
ApiResponse, NewType, Object,
99
};
1010

11-
use crate::service::{common, common::types::array_types::impl_array_types};
11+
use crate::service::common::{self, types::array_types::impl_array_types};
1212

1313
// ToDo: The examples of this response should be taken from representative data from a
1414
// response generated on pre-prod.
@@ -141,11 +141,9 @@ pub(crate) struct Cip36Details {
141141
#[oai(skip_serializing_if_is_none)]
142142
pub payment_address: Option<common::types::cardano::cip19_shelley_address::Cip19ShelleyAddress>,
143143
/// If the payment address is a script, then it can not be payed rewards.
144-
#[oai(default)]
145-
pub is_payable: common::types::cardano::boolean::IsPayable,
144+
pub is_payable: common::types::generic::boolean::BooleanFlag,
146145
/// If this field is set, then the registration was in CIP15 format.
147-
#[oai(default)]
148-
pub cip15: common::types::cardano::boolean::IsCip15,
146+
pub cip15: common::types::generic::boolean::BooleanFlag,
149147
/// If there are errors with this registration, they are listed here.
150148
/// This field is *NEVER* returned for a valid registration.
151149
#[oai(skip_serializing_if_is_none)]
Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,8 @@
11
//! Cardano API endpoints
2-
use poem_openapi::{param::Path, OpenApi};
3-
4-
use crate::service::common::{
5-
auth::none_or_rbac::NoneOrRBAC,
6-
objects::cardano::hash::Hash128,
7-
tags::ApiTags,
8-
types::{
9-
cardano::{catalyst_id::CatalystId, cip19_stake_address::Cip19StakeAddress},
10-
generic::ed25519_public_key::Ed25519HexEncodedPublicKey,
11-
},
12-
};
132
143
pub(crate) mod cip36;
15-
mod rbac;
16-
// mod registration_get;
4+
pub(crate) mod rbac;
175
pub(crate) mod staking;
186

19-
/// Cardano Follower API Endpoints
20-
pub(crate) struct Api;
21-
22-
#[OpenApi(tag = "ApiTags::Cardano")]
23-
impl Api {
24-
// TODO: "Chain root" was replaced by "Catalyst ID", so this endpoint needs to be updated
25-
// or removed.
26-
#[oai(
27-
path = "/draft/rbac/chain_root/:stake_address",
28-
method = "get",
29-
operation_id = "rbacChainRootGet"
30-
)]
31-
/// Get RBAC chain root
32-
///
33-
/// This endpoint returns the RBAC certificate chain root for a given stake address.
34-
async fn rbac_chain_root_get(
35-
&self,
36-
/// Stake address to get the chain root for.
37-
Path(stake_address): Path<Cip19StakeAddress>,
38-
/// No Authorization required, but Token permitted.
39-
_auth: NoneOrRBAC,
40-
) -> rbac::chain_root_get::AllResponses {
41-
rbac::chain_root_get::endpoint(stake_address).await
42-
}
43-
44-
#[oai(
45-
path = "/draft/rbac/registrations/:catalyst_id",
46-
method = "get",
47-
operation_id = "rbacRegistrations"
48-
)]
49-
/// Get registrations by Catalyst short ID.
50-
///
51-
/// This endpoint returns RBAC registrations for the given Catalyst short identifier.
52-
async fn rbac_registrations_get(
53-
&self,
54-
/// A Catalyst short ID to get the registrations for.
55-
Path(catalyst_id): Path<CatalystId>,
56-
/// No Authorization required, but Token permitted.
57-
_auth: NoneOrRBAC,
58-
) -> rbac::registrations_get::AllResponses {
59-
rbac::registrations_get::endpoint(catalyst_id.into()).await
60-
}
61-
62-
// TODO: "Chain root" was replaced by "Catalyst ID", so this endpoint needs to be updated
63-
// or removed.
64-
#[oai(
65-
path = "/draft/rbac/role0_chain_root/:role0_key",
66-
method = "get",
67-
operation_id = "rbacRole0KeyChainRoot"
68-
)]
69-
/// Get RBAC chain root for a given role0 key.
70-
///
71-
/// This endpoint returns the RBAC certificate chain root for a given role 0 key.
72-
async fn rbac_role0_key_chain_root(
73-
&self, /// Role0 key to get the chain root for.
74-
Path(role0_key): Path<Hash128>,
75-
/// No Authorization required, but Token permitted.
76-
_auth: NoneOrRBAC,
77-
) -> rbac::role0_chain_root_get::AllResponses {
78-
rbac::role0_chain_root_get::endpoint(role0_key.to_string()).await
79-
}
80-
}
81-
82-
/// Cardano API Endpoints
83-
pub(crate) type CardanoApi = (Api, staking::Api, cip36::Api);
7+
/// All Cardano API Endpoints
8+
pub(crate) type CardanoApi = (rbac::Api, staking::Api, cip36::Api);

catalyst-gateway/bin/src/service/api/cardano/rbac/chain_root_get.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)