1use kona_protocol::L2BlockInfo;
4use op_alloy_rpc_types_engine::OpPayloadAttributes;
5
6#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct OpAttributesWithParent {
10 pub attributes: OpPayloadAttributes,
12 pub parent: L2BlockInfo,
14 pub is_last_in_span: bool,
16}
17
18impl OpAttributesWithParent {
19 pub const fn new(
21 attributes: OpPayloadAttributes,
22 parent: L2BlockInfo,
23 is_last_in_span: bool,
24 ) -> Self {
25 Self { attributes, parent, is_last_in_span }
26 }
27
28 pub const fn attributes(&self) -> &OpPayloadAttributes {
30 &self.attributes
31 }
32
33 pub const fn parent(&self) -> &L2BlockInfo {
35 &self.parent
36 }
37
38 pub const fn is_last_in_span(&self) -> bool {
40 self.is_last_in_span
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_op_attributes_with_parent() {
50 let attributes = OpPayloadAttributes::default();
51 let parent = L2BlockInfo::default();
52 let is_last_in_span = true;
53 let op_attributes_with_parent =
54 OpAttributesWithParent::new(attributes.clone(), parent, is_last_in_span);
55
56 assert_eq!(op_attributes_with_parent.attributes(), &attributes);
57 assert_eq!(op_attributes_with_parent.parent(), &parent);
58 assert_eq!(op_attributes_with_parent.is_last_in_span(), is_last_in_span);
59 }
60}