use indexer_service_protocol::{ PrivacyPreservingMessage, PrivacyPreservingTransaction, ProgramDeploymentMessage, ProgramDeploymentTransaction, PublicMessage, PublicTransaction, WitnessSet, }; use leptos::prelude::*; use super::AccountNonceList; /// Public transaction details component #[component] pub fn PublicTxDetails(tx: PublicTransaction) -> impl IntoView { let PublicTransaction { hash: _, message, witness_set, } = tx; let PublicMessage { program_id, account_ids, nonces, instruction_data, } = message; let WitnessSet { signatures_and_public_keys, proof, } = witness_set; let program_id_str = program_id.to_string(); let proof_len = proof.map_or(0, |p| p.0.len()); let signatures_count = signatures_and_public_keys.len(); view! {

"Public Transaction Details"

"Program ID:" {program_id_str}
"Instruction Data:" {format!("{} u32 values", instruction_data.len())}
"Proof Size:" {format!("{proof_len} bytes")}
"Signatures:" {signatures_count.to_string()}

"Accounts"

} } /// Privacy-preserving transaction details component #[component] pub fn PrivacyPreservingTxDetails(tx: PrivacyPreservingTransaction) -> impl IntoView { let PrivacyPreservingTransaction { hash: _, message, witness_set, } = tx; let PrivacyPreservingMessage { public_account_ids, nonces, public_post_states: _, encrypted_private_post_states, new_commitments, new_nullifiers, block_validity_window, timestamp_validity_window, } = message; let WitnessSet { signatures_and_public_keys: _, proof, } = witness_set; let proof_len = proof.map_or(0, |p| p.0.len()); view! {

"Privacy-Preserving Transaction Details"

"Public Accounts:" {public_account_ids.len().to_string()}
"New Commitments:" {new_commitments.len().to_string()}
"Nullifiers:" {new_nullifiers.len().to_string()}
"Encrypted States:" {encrypted_private_post_states.len().to_string()}
"Proof Size:" {format!("{proof_len} bytes")}
"Block Validity Window:" {block_validity_window.to_string()}
"Timestamp Validity Window:" {timestamp_validity_window.to_string()}

"Public Accounts"

} } /// Program deployment transaction details component #[component] pub fn ProgramDeploymentTxDetails(tx: ProgramDeploymentTransaction) -> impl IntoView { let ProgramDeploymentTransaction { hash: _, message } = tx; let ProgramDeploymentMessage { bytecode } = message; let bytecode_len = bytecode.len(); view! {

"Program Deployment Transaction Details"

"Bytecode Size:" {format!("{bytecode_len} bytes")}
} }