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(rpc-types): FeeHistory deser #1629

Merged
merged 2 commits into from
Nov 6, 2024
Merged

fix(rpc-types): FeeHistory deser #1629

merged 2 commits into from
Nov 6, 2024

Conversation

yash-atreya
Copy link
Member

Motivation

Currently we don't correctly handle a eth_feeHistory response in which gasUsedRatio is null.

Solution

Handle this case by deserializing to an empty vec.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

makes sense,

since this is just an rpc response type we can do this, but we have this helper already

@@ -45,6 +45,7 @@ pub struct FeeHistory {
pub base_fee_per_gas: Vec<u128>,
/// An array of block gas used ratios. These are calculated as the ratio
/// of `gasUsed` and `gasLimit`.
#[cfg_attr(feature = "serde", serde(deserialize_with = "gas_used_ratio_deser::deserialize"))]
Copy link
Member

Choose a reason for hiding this comment

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

I believe we have this in alloy-serde:

pub fn null_as_default<'de, T, D>(deserializer: D) -> Result<T, D::Error>

@yash-atreya yash-atreya enabled auto-merge (squash) November 6, 2024 17:39
@yash-atreya yash-atreya merged commit f919b37 into main Nov 6, 2024
26 checks passed
@yash-atreya yash-atreya deleted the yash/fee-hist-deser branch November 6, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants