1use core::fmt;
4use primitives::{b256, hex, B256};
5
6pub const EIP7702_MAGIC_HASH: B256 =
8 b256!("0xeadcdba66a79ab5dce91622d1d75c8cff5cff0b96944c3bf1072cd08ce018329");
9
10pub const EIP7702_MAGIC: u16 = 0xEF01;
12
13pub const EIP7702_MAGIC_BYTES: &[u8] = &hex!("ef01");
15
16pub const EIP7702_VERSION: u8 = 0;
18
19pub const EIP7702_BYTECODE_LEN: usize = 23;
21
22#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25pub enum Eip7702DecodeError {
26 InvalidLength,
30 InvalidMagic,
34 UnsupportedVersion,
38}
39
40impl fmt::Display for Eip7702DecodeError {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 let s = match self {
43 Self::InvalidLength => "Eip7702 is not 23 bytes long",
44 Self::InvalidMagic => "Bytecode is not starting with 0xEF01",
45 Self::UnsupportedVersion => "Unsupported Eip7702 version.",
46 };
47 f.write_str(s)
48 }
49}
50
51impl core::error::Error for Eip7702DecodeError {}