Bump alloy to 0.8.0 (#13268)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
morito
2024-12-11 05:06:21 +09:00
committed by GitHub
parent 62e2cbfe86
commit 73f1583455
14 changed files with 192 additions and 216 deletions

View File

@ -127,7 +127,7 @@ impl TryFrom<AnyRpcTransaction> for TransactionSigned {
}
#[cfg(feature = "optimism")]
AnyTxEnvelope::Unknown(alloy_network::UnknownTxEnvelope { hash, inner }) => {
use alloy_consensus::Transaction as _;
use alloy_consensus::{Transaction as _, Typed2718};
if inner.ty() == crate::TxType::Deposit {
let fields: op_alloy_rpc_types::OpTransactionFields = inner

View File

@ -3,7 +3,7 @@ use crate::{
RecoveredTx, SealedHeader, TransactionSigned,
};
use alloc::vec::Vec;
use alloy_consensus::Header;
use alloy_consensus::{Header, Typed2718};
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
use alloy_primitives::{Address, Bytes, B256};
use alloy_rlp::{Decodable, Encodable, RlpDecodable, RlpEncodable};

View File

@ -3,7 +3,7 @@
use alloc::vec::Vec;
use alloy_consensus::{
transaction::RlpEcdsaTx, SignableTransaction, Signed, Transaction as _, TxEip1559, TxEip2930,
TxEip4844, TxEip4844Variant, TxEip7702, TxLegacy, TypedTransaction,
TxEip4844, TxEip4844Variant, TxEip7702, TxLegacy, Typed2718, TypedTransaction,
};
use alloy_eips::{
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
@ -192,6 +192,20 @@ impl<'a> arbitrary::Arbitrary<'a> for Transaction {
}
}
impl Typed2718 for Transaction {
fn ty(&self) -> u8 {
match self {
Self::Legacy(tx) => tx.ty(),
Self::Eip2930(tx) => tx.ty(),
Self::Eip1559(tx) => tx.ty(),
Self::Eip4844(tx) => tx.ty(),
Self::Eip7702(tx) => tx.ty(),
#[cfg(feature = "optimism")]
Self::Deposit(tx) => tx.ty(),
}
}
}
// === impl Transaction ===
impl Transaction {
@ -710,18 +724,6 @@ impl alloy_consensus::Transaction for Transaction {
}
}
fn ty(&self) -> u8 {
match self {
Self::Legacy(tx) => tx.ty(),
Self::Eip2930(tx) => tx.ty(),
Self::Eip1559(tx) => tx.ty(),
Self::Eip4844(tx) => tx.ty(),
Self::Eip7702(tx) => tx.ty(),
#[cfg(feature = "optimism")]
Self::Deposit(tx) => tx.ty(),
}
}
fn access_list(&self) -> Option<&AccessList> {
match self {
Self::Legacy(tx) => tx.access_list(),
@ -826,6 +828,12 @@ impl PartialEq for TransactionSigned {
}
}
impl Typed2718 for TransactionSigned {
fn ty(&self) -> u8 {
self.deref().ty()
}
}
// === impl TransactionSigned ===
impl TransactionSigned {
@ -1202,10 +1210,6 @@ impl alloy_consensus::Transaction for TransactionSigned {
self.deref().input()
}
fn ty(&self) -> u8 {
self.deref().ty()
}
fn access_list(&self) -> Option<&AccessList> {
self.deref().access_list()
}
@ -1240,7 +1244,7 @@ impl Encodable for TransactionSigned {
fn length(&self) -> usize {
let mut payload_length = self.encode_2718_len();
if !self.is_legacy() {
if !Encodable2718::is_legacy(self) {
payload_length += Header { list: false, payload_length }.length();
}

View File

@ -10,7 +10,7 @@ use alloc::vec::Vec;
use alloy_consensus::{
constants::EIP4844_TX_TYPE_ID,
transaction::{TxEip1559, TxEip2930, TxEip4844, TxLegacy},
SignableTransaction, Signed, TxEip4844WithSidecar,
SignableTransaction, Signed, TxEip4844WithSidecar, Typed2718,
};
use alloy_eips::{
eip2718::{Decodable2718, Eip2718Result, Encodable2718},
@ -230,7 +230,7 @@ impl Encodable for PooledTransactionsElement {
fn length(&self) -> usize {
let mut payload_length = self.encode_2718_len();
if !self.is_legacy() {
if !Encodable2718::is_legacy(self) {
payload_length += Header { list: false, payload_length }.length();
}
@ -383,6 +383,18 @@ impl Decodable2718 for PooledTransactionsElement {
}
}
impl Typed2718 for PooledTransactionsElement {
fn ty(&self) -> u8 {
match self {
Self::Legacy(tx) => tx.tx().ty(),
Self::Eip2930(tx) => tx.tx().ty(),
Self::Eip1559(tx) => tx.tx().ty(),
Self::BlobTransaction(tx) => tx.tx().ty(),
Self::Eip7702(tx) => tx.tx().ty(),
}
}
}
impl alloy_consensus::Transaction for PooledTransactionsElement {
fn chain_id(&self) -> Option<ChainId> {
match self {
@ -524,16 +536,6 @@ impl alloy_consensus::Transaction for PooledTransactionsElement {
}
}
fn ty(&self) -> u8 {
match self {
Self::Legacy(tx) => tx.tx().ty(),
Self::Eip2930(tx) => tx.tx().ty(),
Self::Eip1559(tx) => tx.tx().ty(),
Self::Eip7702(tx) => tx.tx().ty(),
Self::BlobTransaction(tx) => tx.tx().ty(),
}
}
fn access_list(&self) -> Option<&AccessList> {
match self {
Self::Legacy(tx) => tx.tx().access_list(),