From fdcaabf76195f21200c6f25afe4d5a0d875c8ed6 Mon Sep 17 00:00:00 2001 From: Daniil Polyakov Date: Tue, 10 Feb 2026 00:20:01 +0300 Subject: [PATCH] chore: remove useless optional account in explorer --- explorer_service/src/api.rs | 12 +--- .../src/components/account_preview.rs | 63 ++++++++----------- 2 files changed, 29 insertions(+), 46 deletions(-) diff --git a/explorer_service/src/api.rs b/explorer_service/src/api.rs index cc117ad7..c3360c01 100644 --- a/explorer_service/src/api.rs +++ b/explorer_service/src/api.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; pub struct SearchResults { pub blocks: Vec, pub transactions: Vec, - pub accounts: Vec<(AccountId, Option)>, + pub accounts: Vec<(AccountId, Account)>, } /// RPC client type @@ -60,14 +60,8 @@ pub async fn search(query: String) -> Result { // Try as account ID let account_id = AccountId { value: hash_array }; - match client.get_account(account_id).await { - Ok(account) => { - accounts.push((account_id, Some(account))); - } - Err(_) => { - // Account might not exist yet, still add it to results - accounts.push((account_id, None)); - } + if let Ok(account) = client.get_account(account_id).await { + accounts.push((account_id, account)); } } diff --git a/explorer_service/src/components/account_preview.rs b/explorer_service/src/components/account_preview.rs index 30bbae5b..3a99eeb8 100644 --- a/explorer_service/src/components/account_preview.rs +++ b/explorer_service/src/components/account_preview.rs @@ -6,7 +6,7 @@ use crate::format_utils; /// Account preview component #[component] -pub fn AccountPreview(account_id: AccountId, account: Option) -> impl IntoView { +pub fn AccountPreview(account_id: AccountId, account: Account) -> impl IntoView { let account_id_str = format_utils::format_account_id(&account_id); view! { @@ -19,42 +19,31 @@ pub fn AccountPreview(account_id: AccountId, account: Option) -> impl I {move || { - account - .as_ref() - .map(|Account { program_owner, balance, data, nonce }| { - let program_id = format_utils::format_program_id(program_owner); - view! { - - } - .into_any() - }) - .unwrap_or_else(|| { - view! { - - } - .into_any() - }) + let Account { program_owner, balance, data, nonce } = &account; + let program_id = format_utils::format_program_id(program_owner); + view! { + + } + .into_any() }}