alloy-eip7928 0.3.4

Implementation of EIP-7928 type definitions
Documentation
//! Contains the [`CodeChange`] struct, which represents a new code for an account.
//! Single code change: `tx_index` -> `new_code`
use crate::BlockAccessIndex;
use alloy_primitives::Bytes;

/// This struct is used to track the new codes of accounts in a block.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "rlp", derive(alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "borsh", derive(borsh::BorshSerialize, borsh::BorshDeserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CodeChange {
    /// The index of bal that stores this code change.
    #[cfg_attr(feature = "serde", serde(alias = "txIndex", with = "crate::quantity"))]
    pub block_access_index: BlockAccessIndex,
    /// The new code of the account.
    pub new_code: Bytes,
}
impl CodeChange {
    /// Creates a new [`CodeChange`].
    pub const fn new(block_access_index: BlockAccessIndex, new_code: Bytes) -> Self {
        Self { block_access_index, new_code }
    }

    /// Returns the bal index.
    #[inline]
    pub const fn block_access_index(&self) -> BlockAccessIndex {
        self.block_access_index
    }

    /// Returns the new code.
    #[inline]
    pub const fn new_code(&self) -> &Bytes {
        &self.new_code
    }
}