alloy_eip7928/
code_change.rs1use crate::BlockAccessIndex;
4use alloy_primitives::Bytes;
5
6#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
8#[cfg_attr(feature = "rlp", derive(alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable))]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
11#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
12#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
13pub struct CodeChange {
14 #[cfg_attr(
16 feature = "serde",
17 serde(rename = "index", alias = "blockAccessIndex", alias = "txIndex")
18 )]
19 pub block_access_index: BlockAccessIndex,
20 #[cfg_attr(feature = "serde", serde(rename = "code", alias = "newCode"))]
22 pub new_code: Bytes,
23}
24impl CodeChange {
25 pub const fn new(block_access_index: BlockAccessIndex, new_code: Bytes) -> Self {
27 Self { block_access_index, new_code }
28 }
29
30 #[inline]
32 pub const fn block_access_index(&self) -> BlockAccessIndex {
33 self.block_access_index
34 }
35
36 #[inline]
38 pub const fn new_code(&self) -> &Bytes {
39 &self.new_code
40 }
41
42 #[inline]
44 pub fn into_code(self) -> Bytes {
45 self.new_code
46 }
47}