|
2 | 2 | use alloy_consensus::{ |
3 | 3 | Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930, |
4 | 4 | TxEnvelope, TxLegacy, TxReceipt, Typed2718, |
5 | | - constants::{ |
6 | | - EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, |
7 | | - LEGACY_TX_TYPE_ID, |
8 | | - }, |
9 | 5 | transaction::{ |
10 | 6 | Recovered, TxEip7702, |
11 | 7 | eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar}, |
@@ -1360,147 +1356,13 @@ impl FromRecoveredTx<TypedTransaction> for TxEnv { |
1360 | 1356 | } |
1361 | 1357 |
|
1362 | 1358 | match tx { |
1363 | | - TypedTransaction::Legacy(signed_tx) => { |
1364 | | - let tx = signed_tx.tx(); |
1365 | | - let TxLegacy { nonce, gas_price, gas_limit, value, to, input, chain_id, .. } = tx; |
1366 | | - Self { |
1367 | | - caller, |
1368 | | - kind: transact_to(to), |
1369 | | - data: input.clone(), |
1370 | | - chain_id: *chain_id, |
1371 | | - nonce: *nonce, |
1372 | | - value: *value, |
1373 | | - gas_price: *gas_price, |
1374 | | - gas_priority_fee: None, |
1375 | | - gas_limit: *gas_limit, |
1376 | | - access_list: vec![].into(), |
1377 | | - tx_type: LEGACY_TX_TYPE_ID, |
1378 | | - ..Default::default() |
1379 | | - } |
1380 | | - } |
1381 | | - TypedTransaction::EIP2930(signed_tx) => { |
1382 | | - let tx = signed_tx.tx(); |
1383 | | - let TxEip2930 { |
1384 | | - chain_id, |
1385 | | - nonce, |
1386 | | - gas_price, |
1387 | | - gas_limit, |
1388 | | - to, |
1389 | | - value, |
1390 | | - input, |
1391 | | - access_list, |
1392 | | - .. |
1393 | | - } = tx; |
1394 | | - Self { |
1395 | | - caller, |
1396 | | - kind: transact_to(to), |
1397 | | - data: input.clone(), |
1398 | | - chain_id: Some(*chain_id), |
1399 | | - nonce: *nonce, |
1400 | | - value: *value, |
1401 | | - gas_price: *gas_price, |
1402 | | - gas_priority_fee: None, |
1403 | | - gas_limit: *gas_limit, |
1404 | | - access_list: access_list.clone(), |
1405 | | - tx_type: EIP2930_TX_TYPE_ID, |
1406 | | - ..Default::default() |
1407 | | - } |
1408 | | - } |
1409 | | - TypedTransaction::EIP1559(signed_tx) => { |
1410 | | - let tx = signed_tx.tx(); |
1411 | | - let TxEip1559 { |
1412 | | - chain_id, |
1413 | | - nonce, |
1414 | | - max_priority_fee_per_gas, |
1415 | | - max_fee_per_gas, |
1416 | | - gas_limit, |
1417 | | - to, |
1418 | | - value, |
1419 | | - input, |
1420 | | - access_list, |
1421 | | - .. |
1422 | | - } = tx; |
1423 | | - Self { |
1424 | | - caller, |
1425 | | - kind: transact_to(to), |
1426 | | - data: input.clone(), |
1427 | | - chain_id: Some(*chain_id), |
1428 | | - nonce: *nonce, |
1429 | | - value: *value, |
1430 | | - gas_price: *max_fee_per_gas, |
1431 | | - gas_priority_fee: Some(*max_priority_fee_per_gas), |
1432 | | - gas_limit: *gas_limit, |
1433 | | - access_list: access_list.clone(), |
1434 | | - tx_type: EIP1559_TX_TYPE_ID, |
1435 | | - ..Default::default() |
1436 | | - } |
1437 | | - } |
| 1359 | + TypedTransaction::Legacy(signed_tx) => Self::from_recovered_tx(signed_tx.tx(), caller), |
| 1360 | + TypedTransaction::EIP2930(signed_tx) => Self::from_recovered_tx(signed_tx.tx(), caller), |
| 1361 | + TypedTransaction::EIP1559(signed_tx) => Self::from_recovered_tx(signed_tx.tx(), caller), |
1438 | 1362 | TypedTransaction::EIP4844(signed_tx) => { |
1439 | | - let tx = signed_tx.tx().tx(); |
1440 | | - let TxEip4844 { |
1441 | | - chain_id, |
1442 | | - nonce, |
1443 | | - max_fee_per_blob_gas, |
1444 | | - max_fee_per_gas, |
1445 | | - max_priority_fee_per_gas, |
1446 | | - gas_limit, |
1447 | | - to, |
1448 | | - value, |
1449 | | - input, |
1450 | | - access_list, |
1451 | | - blob_versioned_hashes, |
1452 | | - .. |
1453 | | - } = tx; |
1454 | | - Self { |
1455 | | - caller, |
1456 | | - kind: TxKind::Call(*to), |
1457 | | - data: input.clone(), |
1458 | | - chain_id: Some(*chain_id), |
1459 | | - nonce: *nonce, |
1460 | | - value: *value, |
1461 | | - gas_price: *max_fee_per_gas, |
1462 | | - gas_priority_fee: Some(*max_priority_fee_per_gas), |
1463 | | - max_fee_per_blob_gas: *max_fee_per_blob_gas, |
1464 | | - blob_hashes: blob_versioned_hashes.clone(), |
1465 | | - gas_limit: *gas_limit, |
1466 | | - access_list: access_list.clone(), |
1467 | | - tx_type: EIP4844_TX_TYPE_ID, |
1468 | | - ..Default::default() |
1469 | | - } |
1470 | | - } |
1471 | | - TypedTransaction::EIP7702(signed_tx) => { |
1472 | | - let tx = signed_tx.tx(); |
1473 | | - let TxEip7702 { |
1474 | | - chain_id, |
1475 | | - nonce, |
1476 | | - gas_limit, |
1477 | | - max_fee_per_gas, |
1478 | | - max_priority_fee_per_gas, |
1479 | | - to, |
1480 | | - value, |
1481 | | - access_list, |
1482 | | - authorization_list, |
1483 | | - input, |
1484 | | - } = tx; |
1485 | | - |
1486 | | - let mut tx_env = Self { |
1487 | | - caller, |
1488 | | - kind: TxKind::Call(*to), |
1489 | | - data: input.clone(), |
1490 | | - chain_id: Some(*chain_id), |
1491 | | - nonce: *nonce, |
1492 | | - value: *value, |
1493 | | - gas_price: *max_fee_per_gas, |
1494 | | - gas_priority_fee: Some(*max_priority_fee_per_gas), |
1495 | | - gas_limit: *gas_limit, |
1496 | | - access_list: access_list.clone(), |
1497 | | - tx_type: EIP7702_TX_TYPE_ID, |
1498 | | - ..Default::default() |
1499 | | - }; |
1500 | | - tx_env.set_signed_authorization(authorization_list.clone()); |
1501 | | - |
1502 | | - tx_env |
| 1363 | + Self::from_recovered_tx(signed_tx.tx().tx(), caller) |
1503 | 1364 | } |
| 1365 | + TypedTransaction::EIP7702(signed_tx) => Self::from_recovered_tx(signed_tx.tx(), caller), |
1504 | 1366 | TypedTransaction::Deposit(tx) => { |
1505 | 1367 | let TxDeposit { to, value, gas_limit, input, .. } = tx; |
1506 | 1368 |
|
|
0 commit comments