Skip to content

Commit

Permalink
Add timestamp to get_token_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu-shankar-yral committed Feb 12, 2025
1 parent f38d70d commit c2b4b84
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ssr/src/utils/token/icpump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use futures::StreamExt;

use leptos::*;

use yral_grpc_traits::{TokenInfoProvider, TokenListItemFS};
use yral_grpc_traits::{TokenInfoProvider, TokenListItemFS, TokenListItemFSWithTimestamp};

#[cfg(feature = "ssr")]
#[derive(Debug, Clone)]
Expand All @@ -34,13 +34,15 @@ pub struct TokenListItem {
}

#[server]
pub async fn get_token_by_id(token_id: String) -> Result<TokenListItemFS, ServerFnError> {
pub async fn get_token_by_id(token_id: String) -> Result<TokenListItemFSWithTimestamp, ServerFnError> {
#[cfg(feature = "firestore")]
{
use speedate::DateTime;

let firestore_db: firestore::FirestoreDb = expect_context();
const TEST_COLLECTION_NAME: &str = "tokens-list";

let token = firestore_db
let token: TokenListItemFS = firestore_db
.fluent()
.select()
.by_id_in(TEST_COLLECTION_NAME)
Expand All @@ -54,7 +56,9 @@ pub async fn get_token_by_id(token_id: String) -> Result<TokenListItemFS, Server
)
})?;

Ok(token)
let timestamp = DateTime::parse_str(&token.created_at).unwrap().timestamp();

Ok(TokenListItemFSWithTimestamp::from_token_list_item_fs(token, timestamp))
}

#[cfg(not(feature = "firestore"))]
Expand Down Expand Up @@ -302,7 +306,7 @@ pub struct IcpumpTokenInfo;
impl TokenInfoProvider for IcpumpTokenInfo {
type Error = ServerFnError;

async fn get_token_by_id(&self, token_id: String) -> Result<TokenListItemFS, ServerFnError> {
async fn get_token_by_id(&self, token_id: String) -> Result<TokenListItemFSWithTimestamp, ServerFnError> {
get_token_by_id(token_id).await
}
}
Expand Down

0 comments on commit c2b4b84

Please sign in to comment.