Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::types::Withdrawal;
use crate::types::{AccessList, AuthorizationList, Hash};
use crate::types::{Authorization, Withdrawal};
use crate::types::{HelloMessage, Transaction};
use crate::utils;
use num::BigUint;
Expand Down Expand Up @@ -435,17 +435,16 @@ pub fn parse_transaction(payload: Vec<u8>) -> Option<Transaction> {
let authorization = tmp.at(n).unwrap();
assert!(authorization.is_list());

// Some asshole create a transaction with 1407996450619573357857283148491789578994728514355 as a chain ID. WHY ?
let chain_id: Vec<u8> = authorization.at(0).unwrap().as_val().unwrap();
let address: Vec<u8> = authorization.at(1).unwrap().as_val().unwrap();
let nonce: u32 = authorization.at(2).unwrap().as_val().unwrap();
let y_parity: u64 = authorization.at(3).unwrap().as_val().unwrap();
let r: Vec<u8> = authorization.at(4).unwrap().as_val().unwrap();
let s: Vec<u8> = authorization.at(5).unwrap().as_val().unwrap();

authorization_list
.0
.push((chain_id, address, nonce, y_parity, r, s));
let authorization = Authorization {
chain_id: authorization.at(0).unwrap().as_val().unwrap(),
address: authorization.at(1).unwrap().as_val().unwrap(),
nonce: authorization.at(2).unwrap().as_val().unwrap(),
y_parity: authorization.at(3).unwrap().as_val().unwrap(),
r: authorization.at(4).unwrap().as_val().unwrap(),
s: authorization.at(5).unwrap().as_val().unwrap(),
};

authorization_list.0.push(authorization);
}

let v: u64 = t.at(10).unwrap().as_val().unwrap();
Expand Down
19 changes: 17 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ pub struct Hash(#[serde(with = "hex::serde")] pub Vec<u8>);
pub struct AccessList(pub Vec<(Hash, Vec<Hash>)>);

#[derive(Serialize, Clone, Debug)]
pub struct AuthorizationList(pub Vec<(Vec<u8>, Vec<u8>, u32, u64, Vec<u8>, Vec<u8>)>);
pub struct AuthorizationList(pub Vec<Authorization>);

// See https://eips.ethereum.org/EIPS/eip-7702
#[derive(Serialize, Clone, Debug)]
pub struct Authorization {
#[serde(with = "hex::serde")]
pub chain_id: Vec<u8>, // Some asshole created a transaction with 1407996450619573357857283148491789578994728514355 as a chain ID. WHY ?
#[serde(with = "hex::serde")]
pub address: Vec<u8>,
pub nonce: u32,
pub y_parity: u64,
#[serde(with = "hex::serde")]
pub r: Vec<u8>,
#[serde(with = "hex::serde")]
pub s: Vec<u8>,
}

#[derive(Clone, Debug)]
pub struct Transaction {
Expand All @@ -34,7 +49,7 @@ pub struct Transaction {
pub access_list: Option<AccessList>, // Introduce in type 2 transactions
pub max_fee_per_blob_gas: Option<u64>, // Introduce in type 3 transactions
pub blob_versioned_hashes: Option<Vec<Hash>>, // Introduce in type 3 transactions
pub authorization_list: Option<AuthorizationList>,
pub authorization_list: Option<AuthorizationList>, // Introduce in type 4 transactions
pub v: u64,
pub r: Vec<u8>,
pub s: Vec<u8>,
Expand Down