Skip to content

Commit fac7233

Browse files
committed
feat: support 7702 txns when filling
1 parent 6be8a0a commit fac7233

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trevm"
3-
version = "0.23.5"
3+
version = "0.23.6"
44
rust-version = "1.83.0"
55
edition = "2021"
66
authors = ["init4"]

src/fill/alloy.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,55 @@ impl Tx for Signed<alloy::consensus::TxEip4844Variant> {
223223
}
224224
}
225225

226+
impl Tx for Signed<alloy::consensus::TxEip7702> {
227+
fn fill_tx_env(&self, tx_env: &mut TxEnv) {
228+
let TxEnv {
229+
tx_type,
230+
caller,
231+
gas_limit,
232+
gas_price,
233+
kind,
234+
value,
235+
data,
236+
nonce,
237+
chain_id,
238+
access_list,
239+
gas_priority_fee,
240+
blob_hashes,
241+
max_fee_per_blob_gas,
242+
authorization_list,
243+
} = tx_env;
244+
*tx_type = TxType::Eip7702 as u8;
245+
*caller = self.recover_signer().unwrap();
246+
*gas_limit = self.tx().gas_limit;
247+
*gas_price = self.tx().max_fee_per_gas;
248+
*kind = self.tx().to.into();
249+
*value = self.tx().value;
250+
*data = self.tx().input.clone();
251+
*nonce = self.tx().nonce;
252+
*chain_id = Some(self.tx().chain_id);
253+
access_list.clone_from(&self.tx().access_list);
254+
*gas_priority_fee = Some(self.tx().max_priority_fee_per_gas);
255+
blob_hashes.clear();
256+
*max_fee_per_blob_gas = 0;
257+
*authorization_list = self
258+
.tx()
259+
.authorization_list
260+
.iter()
261+
.cloned()
262+
.map(revm::context::either::Either::Left)
263+
.collect();
264+
}
265+
}
266+
226267
impl Tx for alloy::consensus::TxEnvelope {
227268
fn fill_tx_env(&self, tx_env: &mut TxEnv) {
228269
match self {
229270
Self::Legacy(t) => t.fill_tx_env(tx_env),
230271
Self::Eip2930(t) => t.fill_tx_env(tx_env),
231272
Self::Eip1559(t) => t.fill_tx_env(tx_env),
232273
Self::Eip4844(t) => t.fill_tx_env(tx_env),
233-
_ => panic!("Unsupported transaction type"),
274+
Self::Eip7702(t) => t.fill_tx_env(tx_env),
234275
}
235276
}
236277
}

0 commit comments

Comments
 (0)