Skip to content

Commit e75f8e1

Browse files
committed
Change from_timestamp type from u32 to u64
Updated the from_timestamp parameter from Option<u32> to Option<u64> in asset, notification, and transaction APIs and client methods to support larger timestamp values and prevent potential overflows.
1 parent b0498e7 commit e75f8e1

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

apps/api/src/assets/cilent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl AssetsClient {
3535
Ok(self.database.assets()?.get_asset_full(asset_id)?)
3636
}
3737

38-
pub fn get_assets_by_device_id(&self, device_id: &str, wallet_index: i32, from_timestamp: Option<u32>) -> Result<Vec<AssetId>, Box<dyn Error + Send + Sync>> {
38+
pub fn get_assets_by_device_id(&self, device_id: &str, wallet_index: i32, from_timestamp: Option<u64>) -> Result<Vec<AssetId>, Box<dyn Error + Send + Sync>> {
3939
let subscriptions = self.database.subscriptions()?.get_subscriptions_by_device_id(device_id, Some(wallet_index))?;
4040
let chain_addresses = subscriptions.into_iter().map(|x| ChainAddress::new(x.chain, x.address)).collect();
4141
let from_datetime = from_timestamp.and_then(|ts| DateTime::<Utc>::from_timestamp(ts as i64, 0).map(|dt| dt.naive_utc()));

apps/api/src/assets/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub async fn get_assets_search(
5454
pub async fn get_assets_by_device_id(
5555
device_id: DeviceIdParam,
5656
wallet_index: i32,
57-
from_timestamp: Option<u32>,
57+
from_timestamp: Option<u64>,
5858
client: &State<Mutex<AssetsClient>>,
5959
) -> Result<ApiResponse<Vec<AssetId>>, ApiError> {
6060
Ok(client.lock().await.get_assets_by_device_id(&device_id.0, wallet_index, from_timestamp)?.into())

apps/api/src/notifications/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl NotificationsClient {
1515
Self { database }
1616
}
1717

18-
pub fn get_notifications(&self, device_id: &str, from_timestamp: Option<u32>) -> Result<Vec<InAppNotification>, Box<dyn Error + Send + Sync>> {
18+
pub fn get_notifications(&self, device_id: &str, from_timestamp: Option<u64>) -> Result<Vec<InAppNotification>, Box<dyn Error + Send + Sync>> {
1919
let localizer = LanguageLocalizer::new();
2020
let from_datetime = from_timestamp.and_then(|ts| DateTime::<Utc>::from_timestamp(ts as i64, 0).map(|dt| dt.naive_utc()));
2121
let notifications = self.database.notifications()?.get_notifications_by_device_id(device_id, from_datetime)?;

apps/api/src/notifications/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rocket::{State, get, post, tokio::sync::Mutex};
99
#[get("/notifications/<device_id>?<from_timestamp>")]
1010
pub async fn get_notifications(
1111
device_id: DeviceIdParam,
12-
from_timestamp: Option<u32>,
12+
from_timestamp: Option<u64>,
1313
client: &State<Mutex<NotificationsClient>>,
1414
) -> Result<ApiResponse<Vec<InAppNotification>>, ApiError> {
1515
Ok(client.lock().await.get_notifications(&device_id.0, from_timestamp)?.into())

0 commit comments

Comments
 (0)