-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat: impl TryFrom<Transaction> for TxEnvelope
#343
Conversation
crates/eips/src/eip2718.rs
Outdated
/// Missing `chainId` field for EIP-155 transaction. | ||
MissingChainId, | ||
/// Signature error from [`alloy_primitives`]. | ||
SignatureError(SignatureError), |
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.
none of these are 2718 errors. they should not be in this enum
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.
What'd be the best place for them?
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.
created separate ConversionError
for now
3643606
to
b1706e6
Compare
@mattsse the other way to approach this would be to enforce completeness requirements during serde deser. i.e. make it impossible to construct a |
this could be done by embedding a |
wouldn't such approach cause issues with deposit transaction? we have optional signature for this case I believe |
Optimism is on the hook for making their own rpc |
since all fields are public, I don't think we can guarantee this easily, it's also possible that impls are faulty/incomplete for this endpoint, like missing field, I've seen this on a few newer networks, but this should not affect the rpc response imo and only be a problem when converting to consensus tx |
we already have validity and correctness checks for the RPC response member data types, e.g. we reject an object in the |
this and I don't think we should do any additional checks on deserialization Also, in order to actually enforce we'd need to make the rpc response type's field private, which I think would be inconvenient |
well wed just need a _:() to prevent incorrect instantiation? |
this only solves instantiation, but not mut access, for example: let mut tx = p.tx_byhash(<>);
tx.max_fee_per_gas.take(); we could solve this by changing the rpc::Tx to an enum instead, but I'd really prefer a simple object here and keep conversion fallible |
ya, id like to revisit this in the future tho |
@@ -115,6 +120,123 @@ impl Transaction { | |||
} | |||
} | |||
|
|||
impl TryFrom<Transaction> for Signed<TxLegacy> { |
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.
much improved 👌
This reverts commit 5515915.
Motivation
alloy_rpc_types::Signature
toalloy_primitives::Signature
alloy_rpc_types::AccessList
toalloy_eips::AccessList
alloy_rpc_types::Transaction
toTxEnvelope
Blocked by #338
PR Checklist