Skip to content

Commit

Permalink
fix(beacon_api): parse block_number from string
Browse files Browse the repository at this point in the history
  • Loading branch information
blombern committed May 10, 2024
1 parent 99a2599 commit a01e5ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/beacon_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct SyncStatus {
#[derive(Deserialize)]
pub struct ExecutionPayload {
pub block_hash: String,
#[serde(deserialize_with = "parse_i64_from_string")]
pub block_number: i64,
}

Expand All @@ -46,6 +47,14 @@ pub struct BeaconApi {
client: reqwest::Client,
}

fn parse_i64_from_string<'de, D>(deserializer: D) -> Result<i64, D::Error>
where
D: serde::de::Deserializer<'de>,
{
let s: String = serde::Deserialize::deserialize(deserializer)?;
s.parse::<i64>().map_err(serde::de::Error::custom)
}

impl BeaconApi {
pub fn new(nodes: &[Url]) -> Self {
if !nodes.is_empty() {
Expand Down

0 comments on commit a01e5ae

Please sign in to comment.