use core::fmt;
use primitives::{b256, hex, B256};
pub const EIP7702_MAGIC_HASH: B256 =
b256!("0xeadcdba66a79ab5dce91622d1d75c8cff5cff0b96944c3bf1072cd08ce018329");
pub const EIP7702_MAGIC: u16 = 0xEF01;
pub const EIP7702_MAGIC_BYTES: &[u8] = &hex!("ef01");
pub const EIP7702_VERSION: u8 = 0;
pub const EIP7702_BYTECODE_LEN: usize = 23;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Eip7702DecodeError {
InvalidLength,
InvalidMagic,
UnsupportedVersion,
}
impl fmt::Display for Eip7702DecodeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::InvalidLength => "Eip7702 is not 23 bytes long",
Self::InvalidMagic => "Bytecode is not starting with 0xEF01",
Self::UnsupportedVersion => "Unsupported Eip7702 version.",
};
f.write_str(s)
}
}
impl core::error::Error for Eip7702DecodeError {}