DemesneGH commented on code in PR #192: URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/192#discussion_r2106432914
########## projects/web3/eth_wallet/ta/src/main.rs: ########## @@ -18,37 +18,66 @@ #![no_main] mod hash; -mod secure_storage; mod wallet; -use crate::secure_storage::{ - delete_from_secure_storage, load_from_secure_storage, save_in_secure_storage, -}; use optee_utee::{ ta_close_session, ta_create, ta_destroy, ta_invoke_command, ta_open_session, trace_println, }; use optee_utee::{Error, ErrorKind, Parameters}; use proto::Command; +use secure_db::SecureStorageClient; use anyhow::{anyhow, bail, Result}; -use std::convert::TryInto; use std::io::Write; use wallet::Wallet; +const DB_NAME: &str = "eth_wallet_db"; + +/// Represents the session context for the Ethereum wallet Trusted Application (TA). +/// +/// The `WalletSession` struct manages session-specific data and provides access +/// to the secure storage client (`SecureStorageClient`) for database operations. +pub struct WalletSession { + db_client: SecureStorageClient, +} + +impl WalletSession { + pub fn new() -> Result<Self> { + let db_client = SecureStorageClient::open(DB_NAME) + .map_err(|e| anyhow!("Failed to create SecureStorageClient: {:?}", e))?; + Ok(Self { db_client }) + } +} + +impl Default for WalletSession { + fn default() -> Self { + Self::new().unwrap_or_else(|e| { + trace_println!("Error initializing WalletSession: {:?}", e); + panic!("Failed to initialize WalletSession"); Review Comment: This copilot comment: We cannot change the return type of Default trait, when we define a new trait we can achieve then. Nothing changed for this comment. Comments suppressed due to low confidence (3): 1. Fixed. 2. We have a secure_db_abtraction example acting as a unit test. Nothing changed for this comment. 3. Fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For additional commands, e-mail: dev-h...@teaclave.apache.org