chore(sdk): define helper trait FullNodePrimitives (#12331)

This commit is contained in:
Emilia Hane
2024-11-11 12:58:34 +01:00
committed by GitHub
parent 56b5937691
commit 5d5f442024
10 changed files with 82 additions and 37 deletions

View File

@ -10,11 +10,14 @@ use crate::Block;
/// Abstraction for block's body.
pub trait BlockBody:
Clone
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ Default
+ serde::Serialize
+ for<'de> serde::Deserialize<'de>
+ alloy_rlp::Encodable

View File

@ -20,11 +20,14 @@ impl<T> FullBlock for T where T: Block<Header: Compact> + Compact {}
// todo: make with senders extension trait, so block can be impl by block type already containing
// senders
pub trait Block:
fmt::Debug
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ Default
+ serde::Serialize
+ for<'a> serde::Deserialize<'a>
+ From<(Self::Header, Self::Body)>

View File

@ -22,7 +22,7 @@ pub mod account;
pub use account::{Account, Bytecode};
pub mod receipt;
pub use receipt::Receipt;
pub use receipt::{FullReceipt, Receipt};
pub mod transaction;
pub use transaction::{

View File

@ -1,5 +1,7 @@
//! Receipt abstraction
use core::fmt;
use alloy_consensus::TxReceipt;
use reth_codecs::Compact;
use serde::{Deserialize, Serialize};
@ -11,8 +13,13 @@ impl<T> FullReceipt for T where T: Receipt + Compact {}
/// Abstraction of a receipt.
pub trait Receipt:
TxReceipt
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ TxReceipt
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
+ Serialize

View File

@ -1,6 +1,6 @@
//! Transaction abstraction
use core::{fmt::Debug, hash::Hash};
use core::{fmt, hash::Hash};
use alloy_primitives::{TxKind, B256};
@ -12,9 +12,12 @@ pub mod signed;
#[allow(dead_code)]
/// Abstraction of a transaction.
pub trait Transaction:
Debug
+ Default
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ Eq
+ PartialEq
+ Hash

View File

@ -16,13 +16,15 @@ impl<T> FullSignedTx for T where T: SignedTransaction<Transaction: Compact> + Co
/// A signed transaction.
pub trait SignedTransaction:
fmt::Debug
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ PartialEq
+ Eq
+ Hash
+ Send
+ Sync
+ serde::Serialize
+ for<'a> serde::Deserialize<'a>
+ alloy_rlp::Encodable

View File

@ -1,27 +1,28 @@
use core::fmt;
use alloy_eips::eip2718::Eip2718Error;
use alloy_primitives::{U64, U8};
use alloy_rlp::{Decodable, Encodable};
use core::fmt::{Debug, Display};
/// Trait representing the behavior of a transaction type.
pub trait TxType:
Into<u8>
+ Into<U8>
+ PartialEq
+ Eq
+ PartialEq<u8>
+ TryFrom<u8, Error = Eip2718Error>
+ TryFrom<u64>
+ TryFrom<U64>
+ Debug
+ Display
Send
+ Sync
+ Unpin
+ Clone
+ Copy
+ Default
+ fmt::Debug
+ fmt::Display
+ PartialEq
+ Eq
+ PartialEq<u8>
+ Into<u8>
+ Into<U8>
+ TryFrom<u8, Error = Eip2718Error>
+ TryFrom<u64>
+ TryFrom<U64>
+ Encodable
+ Decodable
+ Send
+ Sync
+ 'static
{
}