cat_gateway/service/common/objects/cardano/
cip36.rsuse poem_openapi::{types::Example, Object};
use crate::service::common::types::generic::ed25519_public_key::Ed25519HexEncodedPublicKey;
#[derive(Object, Default)]
#[oai(example = true)]
pub(crate) struct Cip36ReportingList {
#[oai(validator(max_items = "100000"))]
cip36: Vec<Cip36Reporting>,
}
impl Cip36ReportingList {
pub(crate) fn new() -> Self {
Self { cip36: vec![] }
}
pub(crate) fn add(&mut self, cip36: Cip36Reporting) {
self.cip36.push(cip36);
}
}
impl Example for Cip36ReportingList {
fn example() -> Self {
Self {
cip36: vec![Cip36Reporting::example()],
}
}
}
#[derive(Object, Default)]
#[oai(example = true)]
pub(crate) struct Cip36Reporting {
#[oai(validator(max_items = "100000"))]
cip36: Vec<Cip36Info>,
#[oai(validator(max_items = "100000"))]
invalids: Vec<InvalidRegistrationsReport>,
}
impl Cip36Reporting {
pub(crate) fn new(cip36: Vec<Cip36Info>, invalids: Vec<InvalidRegistrationsReport>) -> Self {
Self { cip36, invalids }
}
}
impl Example for Cip36Reporting {
fn example() -> Self {
Self {
cip36: vec![Cip36Info::example()],
invalids: vec![InvalidRegistrationsReport::example()],
}
}
}
#[derive(Object)]
#[oai(example = true)]
pub(crate) struct Cip36Info {
pub stake_pub_key: Ed25519HexEncodedPublicKey, #[oai(validator(minimum(value = "0"), maximum(value = "9223372036854775807")))]
pub nonce: u64,
#[oai(validator(minimum(value = "0"), maximum(value = "9223372036854775807")))]
pub slot_no: u64,
#[oai(validator(minimum(value = "0"), maximum(value = "9223372036854775807")))]
pub txn: i16,
#[oai(validator(max_length = 66, min_length = 66, pattern = "0x[0-9a-f]{64}"))]
pub vote_key: String,
#[oai(validator(max_length = 116, min_length = 66, pattern = "0x[0-9a-f]{64}"))]
pub payment_address: String,
pub is_payable: bool,
pub cip36: bool,
}
impl Example for Cip36Info {
fn example() -> Self {
Self {
stake_pub_key: Ed25519HexEncodedPublicKey::example(),
nonce: 0,
slot_no: 12345,
txn: 0,
vote_key: "0xa6a3c0447aeb9cc54cf6422ba32b294e5e1c3ef6d782f2acff4a70694c4d1663"
.to_string(),
payment_address: "0x00588e8e1d18cba576a4d35758069fe94e53f638b6faf7c07b8abd2bc5c5cdee47b60edc7772855324c85033c638364214cbfc6627889f81c4".to_string(),
is_payable: false,
cip36: true,
}
}
}
#[derive(Object)]
#[oai(example = true)]
pub(crate) struct InvalidRegistrationsReport {
#[oai(validator(max_items = "100000", max_length = "100", pattern = ".*"))]
pub error_report: Vec<String>,
pub stake_address: Ed25519HexEncodedPublicKey, #[oai(validator(max_length = 66, min_length = 0, pattern = "[0-9a-f]"))]
pub vote_key: String,
#[oai(validator(max_length = 116, min_length = 0, pattern = "[0-9a-f]"))]
pub payment_address: String,
pub is_payable: bool,
pub cip36: bool,
}
impl Example for InvalidRegistrationsReport {
fn example() -> Self {
Self {
error_report: vec!["Invalid registration".to_string()],
stake_address: Ed25519HexEncodedPublicKey::example(),
vote_key: "0xa6a3c0447aeb9cc54cf6422ba32b294e5e1c3ef6d782f2acff4a70694c4d1663".to_string(),
payment_address: "0x00588e8e1d18cba576a4d35758069fe94e53f638b6faf7c07b8abd2bc5c5cdee47b60edc7772855324c85033c638364214cbfc6627889f81c4".to_string(),
is_payable: false,
cip36: true,
}
}
}