DemesneGH commented on code in PR #192:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/192#discussion_r2103997581


##########
projects/web3/eth_wallet/ta/src/main.rs:
##########
@@ -18,37 +18,53 @@
 #![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";
+
+// Define session context structure
+pub struct WalletSession {
+    db_client: SecureStorageClient,
+}
+
+impl Default for WalletSession {
+    fn default() -> Self {
+        Self {
+            db_client: SecureStorageClient::open(DB_NAME)
+                .expect("Failed to create SecureStorageClient"),
+        }
+    }
+}
+
 #[ta_create]
 fn create() -> optee_utee::Result<()> {
     trace_println!("[+] TA create");
     Ok(())
 }
 
 #[ta_open_session]
-fn open_session(_params: &mut Parameters) -> optee_utee::Result<()> {
+fn open_session(_params: &mut Parameters, _sess_ctx: &mut WalletSession) -> 
optee_utee::Result<()> {

Review Comment:
   Add explanation as code comment:
   // The _sess_ctx: &mut WalletSession is explicitly defined here to fit into 
the
   // macros definition (optee-utee/macros/src/lib.rs), meaning that we have a
   // context for the session which would be initialized in the open_session() 
method.
   // The context is initialized automatically by calling 
WalletSession::default()
   // in the macro.



-- 
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

Reply via email to