-
Notifications
You must be signed in to change notification settings - Fork 41
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
chore(rpc-types): Preferred Type #375
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,12 @@ | ||||||||||||||
use alloc::vec::Vec; | ||||||||||||||
use alloy_consensus::{ | ||||||||||||||
Sealed, SignableTransaction, Signed, TxEip1559, TxEip4844, TypedTransaction, | ||||||||||||||
Sealed, SignableTransaction, Signed, TxEip1559, TxEip4844, TxType, TypedTransaction, | ||||||||||||||
}; | ||||||||||||||
use alloy_eips::eip7702::SignedAuthorization; | ||||||||||||||
use alloy_network_primitives::TransactionBuilder7702; | ||||||||||||||
use alloy_primitives::{Address, PrimitiveSignature as Signature, TxKind, U256}; | ||||||||||||||
use alloy_rpc_types_eth::{AccessList, TransactionInput, TransactionRequest}; | ||||||||||||||
use op_alloy_consensus::{OpTxEnvelope, OpTypedTransaction, TxDeposit}; | ||||||||||||||
use op_alloy_consensus::{OpTxEnvelope, OpTxType, OpTypedTransaction, TxDeposit}; | ||||||||||||||
use serde::{Deserialize, Serialize}; | ||||||||||||||
|
||||||||||||||
/// Builder for [`OpTypedTransaction`]. | ||||||||||||||
|
@@ -90,6 +90,29 @@ impl OpTransactionRequest { | |||||||||||||
self | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// Check this builder's preferred type, based on the fields that are set. | ||||||||||||||
/// | ||||||||||||||
/// Types are preferred as follows: | ||||||||||||||
/// - Deposit Transactions if `chain_id` is not set | ||||||||||||||
/// - EIP-7702 if authorization_list is set | ||||||||||||||
/// - EIP-4844 if sidecar or max_blob_fee_per_gas is set | ||||||||||||||
/// - EIP-2930 if access_list is set | ||||||||||||||
/// - Legacy if gas_price is set and access_list is unset | ||||||||||||||
/// - EIP-1559 in all other cases | ||||||||||||||
Comment on lines
+97
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I just delegate docs when I delegate a call, that way I know I don't create doc bugs in future |
||||||||||||||
pub const fn preferred_type(&self) -> OpTxType { | ||||||||||||||
if self.0.chain_id.is_none() { | ||||||||||||||
return OpTxType::Deposit; | ||||||||||||||
} | ||||||||||||||
Comment on lines
+103
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is intended for clients sending txs, should we return deposit here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively we remove this and just fall-through to the |
||||||||||||||
match self.0.preferred_type() { | ||||||||||||||
TxType::Legacy => OpTxType::Legacy, | ||||||||||||||
TxType::Eip1559 => OpTxType::Eip1559, | ||||||||||||||
TxType::Eip2930 => OpTxType::Eip2930, | ||||||||||||||
// EIP-4844 transactions are not supported by Optimism. | ||||||||||||||
TxType::Eip4844 => OpTxType::Eip1559, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe add a debug log here as well |
||||||||||||||
TxType::Eip7702 => OpTxType::Eip7702, | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// Builds [`OpTypedTransaction`] from this builder. See [`TransactionRequest::build_typed_tx`] | ||||||||||||||
/// for more info. | ||||||||||||||
/// | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.