Skip to main content

AnyNetwork

Struct AnyNetwork 

Source
pub struct AnyNetwork { /* private fields */ }
Expand description

Types for a catch-all network.

AnyNetwork’s associated types allow for many different types of transactions, using catch-all fields. This Network should be used only when the application needs to support multiple networks via the same codepaths without knowing the networks at compile time.

§Rough Edges

Supporting arbitrary unknown types is hard, and users of this network should be aware of the following:

  • The implementation of Decodable2718 for AnyTxEnvelope will not work for non-Ethereum transaction types. It will successfully decode an Ethereum TxEnvelope, but will decode only the type for any unknown transaction type. It will also leave the buffer unconsumed, which will cause further deserialization to produce erroneous results.
  • The implementation of Encodable2718 for AnyTxEnvelope will panic for non-Ethereum transaction types. Unknown transaction types cannot be re-encoded through AnyNetwork; use a custom transaction type and network implementation instead.
  • The TransactionRequest will build ONLY Ethereum types. It will error when attempting to build any unknown type.
  • The Network::TransactionResponse may deserialize unknown metadata fields into the inner AnyTxEnvelope, rather than into the outer WithOtherFields.

Trait Implementations§

Source§

impl Clone for AnyNetwork

Source§

fn clone(&self) -> AnyNetwork

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnyNetwork

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Network for AnyNetwork

Source§

type TxType = AnyTxType

The network transaction type enum. Read more
Source§

type TxEnvelope = AnyTxEnvelope

The network transaction envelope type.
Source§

type UnsignedTx = AnyTypedTransaction

An enum over the various transaction types.
Source§

type ReceiptEnvelope = AnyReceiptEnvelope

The network receipt envelope type.
Source§

type Header = AnyHeader

The network header type.
Source§

type TransactionRequest = WithOtherFields<TransactionRequest>

The JSON body of a transaction request.
Source§

type TransactionResponse = AnyRpcTransaction

The JSON body of a transaction response.
Source§

type ReceiptResponse = AnyTransactionReceipt

The JSON body of a transaction receipt.
Source§

type HeaderResponse = Header<AnyHeader>

The JSON body of a header response.
Source§

type BlockResponse = AnyRpcBlock

The JSON body of a block response.
Source§

impl NetworkTransactionBuilder<AnyNetwork> for WithOtherFields<TransactionRequest>

Source§

fn build_unsigned( self, ) -> BuildResult<<AnyNetwork as Network>::UnsignedTx, AnyNetwork>

Build an unsigned typed transaction.

This method validates that all required fields are present and builds an unsigned transaction. Returns an error if any required fields are missing.

§Limitations

The TransactionRequest can only build Ethereum transaction types (Legacy, EIP-2930, EIP-1559, EIP-4844, EIP-7702). Attempting to build unknown transaction types will result in an error.

§Errors

Returns TransactionBuilderError::InvalidTransactionRequest if required fields are missing for the transaction type.

Source§

async fn build<W: NetworkWallet<AnyNetwork>>( self, wallet: &W, ) -> Result<<AnyNetwork as Network>::TxEnvelope, TransactionBuilderError<AnyNetwork>>

Build and sign a transaction using the provided wallet.

This method signs the transaction request with the given wallet and returns a signed transaction envelope ready for submission to the network.

§Limitations

The TransactionRequest can only build Ethereum transaction types. Unknown transaction types cannot be signed through this builder.

§Errors

Returns an error if signing fails or if the wallet cannot produce the required signature type for the transaction.

Source§

fn can_submit(&self) -> bool

True if the builder contains all necessary information to be submitted to the eth_sendTransaction endpoint.
Source§

fn can_build(&self) -> bool

True if the builder contains all necessary information to be built into a valid transaction.
Source§

fn complete_type( &self, ty: <AnyNetwork as Network>::TxType, ) -> Result<(), Vec<&'static str>>

Check if all necessary keys are present to build the specified type, returning a list of missing keys.
Source§

fn output_tx_type(&self) -> <AnyNetwork as Network>::TxType

Returns the transaction type that this builder will attempt to build. This does not imply that the builder is ready to build.
Source§

fn output_tx_type_checked(&self) -> Option<<AnyNetwork as Network>::TxType>

Returns the transaction type that this builder will build. None if the builder is not ready to build.
Source§

fn prep_for_submission(&mut self)

Trim any conflicting keys and populate any computed fields (like blob hashes). Read more
Source§

fn complete_preferred(&self) -> Result<(), Vec<&'static str>>

Check if all necessary keys are present to build the currently-preferred transaction type, returning a list of missing keys.
Source§

fn assert_preferred(&self, ty: N::TxType)

Assert that the builder prefers a certain transaction type. This does not indicate that the builder is ready to build. This function uses a dbg_assert_eq! to check the builder status, and will have no affect in release builds.
Source§

fn assert_preferred_chained(self, ty: N::TxType) -> Self

Assert that the builder prefers a certain transaction type. This does not indicate that the builder is ready to build. This function uses a dbg_assert_eq! to check the builder status, and will have no affect in release builds.
Source§

impl Copy for AnyNetwork

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 0 bytes