Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Get assets by stake address.
use std::sync::Arc;

use cardano_blockchain_types::{Slot, StakeAddress};
use scylla::{
prepared_statement::PreparedStatement, transport::iterator::TypedRowStream, DeserializeRow,
SerializeRow, Session,
Expand Down Expand Up @@ -31,7 +30,9 @@ pub(crate) struct GetAssetsByStakeAddressParams {

impl GetAssetsByStakeAddressParams {
/// Creates a new [`GetAssetsByStakeAddressParams`].
pub(crate) fn new(stake_address: StakeAddress, slot_no: Slot) -> Self {
pub(crate) fn new<StakeAddressT: Into<DbStakeAddress>, SlotNoT: Into<DbSlot>>(
stake_address: StakeAddressT, slot_no: SlotNoT,
) -> Self {
Self {
stake_address: stake_address.into(),
slot_no: slot_no.into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Get the TXO by Stake Address
use std::sync::Arc;

use cardano_blockchain_types::{Slot, StakeAddress};
use scylla::{
prepared_statement::PreparedStatement, transport::iterator::TypedRowStream, DeserializeRow,
SerializeRow, Session,
Expand Down Expand Up @@ -30,7 +29,9 @@ pub(crate) struct GetTxoByStakeAddressQueryParams {

impl GetTxoByStakeAddressQueryParams {
/// Creates a new [`GetTxoByStakeAddressQueryParams`].
pub(crate) fn new(stake_address: StakeAddress, slot_no: Slot) -> Self {
pub(crate) fn new<StakeAddressT: Into<DbStakeAddress>, SlotNoT: Into<DbSlot>>(
stake_address: StakeAddressT, slot_no: SlotNoT,
) -> Self {
Self {
stake_address: stake_address.into(),
slot_no: slot_no.into(),
Expand Down
7 changes: 2 additions & 5 deletions catalyst-gateway/bin/src/db/index/tests/scylla_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn test_get_assets_by_stake_addr() {

let mut row_stream = GetAssetsByStakeAddressQuery::execute(
&session,
GetAssetsByStakeAddressParams::new(stake_address_1(), u64::MAX.into()),
GetAssetsByStakeAddressParams::new(stake_address_1(), u64::MAX),
)
.await
.unwrap();
Expand Down Expand Up @@ -241,10 +241,7 @@ async fn test_get_txo_by_stake_address() {

let mut row_stream = GetTxoByStakeAddressQuery::execute(
&session,
GetTxoByStakeAddressQueryParams::new(
stake_address_1(),
u64::try_from(i64::MAX).unwrap().into(),
),
GetTxoByStakeAddressQueryParams::new(stake_address_1(), u64::try_from(i64::MAX).unwrap()),
)
.await
.unwrap();
Expand Down
8 changes: 8 additions & 0 deletions catalyst-gateway/bin/src/db/types/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use scylla::_macro_internal::{
SerializeValue, TypeCheckError, WrittenCellProof,
};

use crate::service::common::types::cardano::slot_no::SlotNo;

/// A `Slot` wrapper that can be stored to and load from a database.\
#[allow(clippy::module_name_repetitions)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down Expand Up @@ -42,6 +44,12 @@ impl From<DbSlot> for BigInt {
}
}

impl From<SlotNo> for DbSlot {
fn from(value: SlotNo) -> Self {
Self(value.into())
}
}

impl SerializeValue for DbSlot {
fn serialize<'b>(
&self, typ: &ColumnType, writer: CellWriter<'b>,
Expand Down
Loading
Loading