Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nits: improve doc clarity around build functions #1782

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,18 +659,16 @@ impl TransactionRequest {
Some(pref)
}

/// Build an [`TypedTransaction`]
/// Build a [`TypedTransaction`]
///
/// In case `Ok(...)` is returned, the `TypedTransaction` is guaranteed to be _complete_, e.g.
/// sendable to the network.
/// When `Ok(...)` is returned, the `TypedTransaction` is guaranteed to be _complete_. Which
/// is to say, that it is signable, and the signed versino can be sent to the network.
pub fn build_typed_tx(self) -> Result<TypedTransaction, Self> {
let tx_type = self.buildable_type();

if tx_type.is_none() {
let Some(tx_type) = self.buildable_type() else {
return Err(self);
}
};

Ok(match tx_type.expect("checked") {
Ok(match tx_type {
TxType::Legacy => self.build_legacy().expect("checked)").into(),
TxType::Eip2930 => self.build_2930().expect("checked)").into(),
TxType::Eip1559 => self.build_1559().expect("checked)").into(),
Expand All @@ -680,14 +678,15 @@ impl TransactionRequest {
})
}

/// Build an [`TypedTransaction`].
/// Build a [`TypedTransaction`].
///
/// In case `Ok(...)` is returned, the `TypedTransaction` does not guarantee to be _complete_,
/// e.g. sendable to the network.
/// When `Ok(...)` is returned, the `TypedTransaction` is not guaranteed to be _complete_,
/// only signable.
///
/// E.g. a particular case is when the transaction is of type `Eip4844` and the `sidecar` is not
/// set, in this case the transaction is not _complete_. It can still be used to calculate the
/// signature of the transaction though.
/// set, in this case the transaction is not _complete_, i.e. it cannot be sent to the network
/// once signed. However, it can still be used to calculate the signing hash, signature of
/// the transaction, and transaction trie hash.
///
/// In case the requirement is to build a _complete_ transaction, use `build_typed_tx` instead.
pub fn build_consensus_tx(self) -> Result<TypedTransaction, BuildTransactionErr> {
Expand Down
Loading