From e9cf1f3af81c75ba48ff058e9aa9a8268e3477b3 Mon Sep 17 00:00:00 2001 From: Alexander Tesfamichael Date: Tue, 3 Dec 2024 15:35:46 +0100 Subject: [PATCH] fix(mev_blocks): serialize from string --- src/mev_blocks/relay_api.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mev_blocks/relay_api.rs b/src/mev_blocks/relay_api.rs index 0becee3..10564b3 100644 --- a/src/mev_blocks/relay_api.rs +++ b/src/mev_blocks/relay_api.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use mockall::{automock, predicate::*}; use serde::Deserialize; +use crate::json_codecs::i32_from_string; use crate::units::WeiNewtype; use super::MevBlock; @@ -14,7 +15,9 @@ pub const EARLIEST_AVAILABLE_SLOT: i32 = 5616303; // These are accepted blocks only. #[derive(Deserialize)] pub struct MaybeMevBlock { + #[serde(deserialize_with = "i32_from_string")] slot: i32, + #[serde(deserialize_with = "i32_from_string")] block_number: i32, block_hash: String, #[serde(rename = "value")] @@ -123,8 +126,8 @@ mod tests { .with_status(200) .with_body( json!([{ - "slot": 0, - "block_number": 9191911, + "slot": "0", + "block_number": "9191911", "block_hash": "abc", "value": "100" }])