pub trait NetworkTransactionBuilder<N: Network>: TransactionBuilder {
// Required methods
fn can_submit(&self) -> bool;
fn can_build(&self) -> bool;
fn complete_type(&self, ty: N::TxType) -> Result<(), Vec<&'static str>>;
fn output_tx_type(&self) -> N::TxType;
fn output_tx_type_checked(&self) -> Option<N::TxType>;
fn prep_for_submission(&mut self);
fn build_unsigned(self) -> BuildResult<N::UnsignedTx, N>;
fn build<W: NetworkWallet<N>>(
self,
wallet: &W,
) -> impl Send + Future<Output = Result<N::TxEnvelope, TransactionBuilderError<N>>>;
// Provided methods
fn complete_preferred(&self) -> Result<(), Vec<&'static str>> { ... }
fn assert_preferred(&self, ty: N::TxType) { ... }
fn assert_preferred_chained(self, ty: N::TxType) -> Self { ... }
}Expand description
Network-specific transaction builder.
Extends TransactionBuilder with build_unsigned
and build methods.
Required Methods§
Sourcefn can_submit(&self) -> bool
fn can_submit(&self) -> bool
True if the builder contains all necessary information to be submitted
to the eth_sendTransaction endpoint.
Sourcefn can_build(&self) -> bool
fn can_build(&self) -> bool
True if the builder contains all necessary information to be built into a valid transaction.
Sourcefn complete_type(&self, ty: N::TxType) -> Result<(), Vec<&'static str>>
fn complete_type(&self, ty: N::TxType) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build the specified type, returning a list of missing keys.
Sourcefn output_tx_type(&self) -> N::TxType
fn output_tx_type(&self) -> N::TxType
Returns the transaction type that this builder will attempt to build. This does not imply that the builder is ready to build.
Sourcefn output_tx_type_checked(&self) -> Option<N::TxType>
fn output_tx_type_checked(&self) -> Option<N::TxType>
Returns the transaction type that this builder will build. None if
the builder is not ready to build.
Sourcefn prep_for_submission(&mut self)
fn prep_for_submission(&mut self)
Trim any conflicting keys and populate any computed fields (like blob hashes).
This is useful for transaction requests that have multiple conflicting fields. While these may be buildable, they may not be submitted to the RPC. This method should be called before RPC submission, but is not necessary before building.
Sourcefn build_unsigned(self) -> BuildResult<N::UnsignedTx, N>
fn build_unsigned(self) -> BuildResult<N::UnsignedTx, N>
Build an unsigned, but typed, transaction.
Sourcefn build<W: NetworkWallet<N>>(
self,
wallet: &W,
) -> impl Send + Future<Output = Result<N::TxEnvelope, TransactionBuilderError<N>>>
fn build<W: NetworkWallet<N>>( self, wallet: &W, ) -> impl Send + Future<Output = Result<N::TxEnvelope, TransactionBuilderError<N>>>
Build a signed transaction.
Provided Methods§
Sourcefn complete_preferred(&self) -> Result<(), Vec<&'static str>>
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.
Sourcefn assert_preferred(&self, ty: N::TxType)
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.
Sourcefn assert_preferred_chained(self, ty: N::TxType) -> Self
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl NetworkTransactionBuilder<AnyNetwork> for WithOtherFields<TransactionRequest>
impl NetworkTransactionBuilder<AnyNetwork> for WithOtherFields<TransactionRequest>
Source§fn build_unsigned(
self,
) -> BuildResult<<AnyNetwork as Network>::UnsignedTx, AnyNetwork>
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>>
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.