DemesneGH commented on code in PR #192: URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/192#discussion_r2104005881
########## projects/web3/eth_wallet/ta/src/main.rs: ########## @@ -83,21 +101,27 @@ fn create_wallet(_input: &proto::CreateWalletInput) -> Result<proto::CreateWalle }) } -fn remove_wallet(input: &proto::RemoveWalletInput) -> Result<proto::RemoveWalletOutput> { +fn remove_wallet( + db_client: &SecureStorageClient, + input: &proto::RemoveWalletInput, +) -> Result<proto::RemoveWalletOutput> { dbg_println!("[+] Removing wallet: {:?}", input.wallet_id); - delete_from_secure_storage(input.wallet_id.as_bytes())?; + db_client.delete_entry::<Wallet>(&input.wallet_id.to_string())?; dbg_println!("[+] Wallet removed"); Ok(proto::RemoveWalletOutput {}) } -fn derive_address(input: &proto::DeriveAddressInput) -> Result<proto::DeriveAddressOutput> { - let secure_object = load_from_secure_storage(input.wallet_id.as_bytes()) +fn derive_address( + db_client: &SecureStorageClient, + input: &proto::DeriveAddressInput, +) -> Result<proto::DeriveAddressOutput> { + let wallet = db_client + .get::<Wallet>(&input.wallet_id.to_string()) Review Comment: ``` pub fn get<V>(&self, key: &V::Key) -> Result<V> where V: Storable + serde::de::DeserializeOwned, V::Key: Into<String> + Clone, ``` The StorageKey type (`V::Key`) should impl `Into<String>`, since the Uuid is from the third-party crate `uuid`, we cannot impl trait for it. ``` pub struct Wallet { id: Uuid, entropy: Vec<u8>, } impl Storable for Wallet { type Key = String; fn unique_id(&self) -> Self::Key { self.id.to_string() } } ``` Here I convert the Uuid into String and use the String as StorageKey type. But we need to `&input.wallet_id.to_string()`. To eliminate this maybe we can define a wrapper struct `UuidKey(Uuid)` which is also not elegant, or our abstraction needs to be improved for this case. -- 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