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

fix: receipt status serde #1608

Merged
merged 3 commits into from
Nov 2, 2024
Merged

fix: receipt status serde #1608

merged 3 commits into from
Nov 2, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Nov 2, 2024

Motivation

ref foundry-rs/foundry#9239 (comment)

Right now we will fail to deserialize receipt if both status and root are present.

Solution

Update serde impl to deserialize Eip658Value as untagged enum with status and root. We prefer status as it is more common and adds useful context.

This also allowed to just use serde(flatten) for status field and remove manual serde for receipt.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[doc(alias = "TransactionReceipt", alias = "TxReceipt")]
pub struct Receipt<T = Log> {
/// If transaction is executed successfully.
///
/// This is the `statusCode`
#[cfg_attr(feature = "serde", serde(alias = "root"))]
#[cfg_attr(feature = "serde", serde(flatten))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right alias doesn't quite work here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants