use crate::deploy::error::BadDeploy;
use crate::utils::Dec;
use crate::utils::sign::{L1Action, Map};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ValidatorL1Stream {
risk_free_rate: Dec,
}
impl ValidatorL1Stream {
pub fn new(risk_free_rate: Dec) -> Result<Self, BadDeploy> {
if risk_free_rate.is_negative() {
return Err(BadDeploy::OutOfRange {
what: "a risk-free rate",
least: "0",
most: "any",
value: risk_free_rate.to_wire(),
});
}
Ok(ValidatorL1Stream { risk_free_rate })
}
#[must_use]
pub const fn risk_free_rate(self) -> Dec {
self.risk_free_rate
}
}
impl L1Action for ValidatorL1Stream {
fn action(&self) -> Map {
Map::new().put("type", "validatorL1Stream").put("riskFreeRate", self.risk_free_rate.to_wire())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AqaRole {
Technical,
Treasury,
}
impl AqaRole {
#[must_use]
pub const fn wire(self) -> &'static str {
match self {
AqaRole::Technical => "technical",
AqaRole::Treasury => "treasury",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AuthorizeAqav2Role {
pub token: u32,
pub role: AqaRole,
}
impl L1Action for AuthorizeAqav2Role {
fn action(&self) -> Map {
Map::new().put("type", "authorizeAqav2Role").put("token", self.token).put("role", self.role.wire())
}
}
#[cfg(test)]
#[path = "tests/aligned.rs"]
mod tests;