use maili_protocol::L2BlockInfo;
use op_alloy_rpc_types_engine::OpPayloadAttributes;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OpAttributesWithParent {
pub attributes: OpPayloadAttributes,
pub parent: L2BlockInfo,
pub is_last_in_span: bool,
}
impl OpAttributesWithParent {
pub const fn new(
attributes: OpPayloadAttributes,
parent: L2BlockInfo,
is_last_in_span: bool,
) -> Self {
Self { attributes, parent, is_last_in_span }
}
pub const fn attributes(&self) -> &OpPayloadAttributes {
&self.attributes
}
pub const fn parent(&self) -> &L2BlockInfo {
&self.parent
}
pub const fn is_last_in_span(&self) -> bool {
self.is_last_in_span
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_op_attributes_with_parent() {
let attributes = OpPayloadAttributes::default();
let parent = L2BlockInfo::default();
let is_last_in_span = true;
let op_attributes_with_parent =
OpAttributesWithParent::new(attributes.clone(), parent, is_last_in_span);
assert_eq!(op_attributes_with_parent.attributes(), &attributes);
assert_eq!(op_attributes_with_parent.parent(), &parent);
assert_eq!(op_attributes_with_parent.is_last_in_span(), is_last_in_span);
}
}