cat_gateway/service/common/objects/legacy/fragment_status.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
//! Defines API schemas of fragment status types.
use poem_openapi::{types::Example, Object, Union};
use crate::service::common::objects::legacy::{block::BlockDate, hash::Hash};
#[derive(Object)]
#[oai(example = false)]
/// DEPRECATED: Fragment is pending.
pub(crate) struct StatusPending;
#[derive(Object)]
#[oai(example = true)]
/// DEPRECATED: Fragment was rejected.
pub(crate) struct StatusRejected {
/// Reason the fragment was rejected.
// Should start with capital letter.
// TODO(bkioshn): https://github.com/input-output-hk/catalyst-voices/issues/239
#[oai(validator(max_length = "250", pattern = r"^[A-Z].*$"))]
pub reason: String,
}
impl Example for StatusRejected {
fn example() -> Self {
Self {
reason: "Transaction malformed".to_string(),
}
}
}
#[derive(Object)]
#[oai(example = true)]
/// DEPRECATED: Fragment is included in a block.
pub(crate) struct StatusInABlock {
/// Block date at which the fragment was included in a block.
pub date: BlockDate,
/// Hash of the block the fragment was included in.
pub block: Hash,
}
impl Example for StatusInABlock {
fn example() -> Self {
Self {
date: BlockDate::example(),
block: Hash::example(),
}
}
}
#[derive(Union)]
#[oai(one_of = true)]
/// DEPRECATED: Possible fragment statuses.
pub(crate) enum FragmentStatus {
/// Fragment is pending inclusion in a block.
Pending(StatusPending),
/// Fragment was rejected.
Rejected(StatusRejected),
/// Fragment was included in a block.
InABlock(StatusInABlock),
}