@@ -47,12 +47,9 @@ use mutiny_core::{
4747use mutiny_core:: { logging:: MutinyLogger , nostr:: ProfileType } ;
4848use nostr:: key:: { FromSkStr , Secp256k1 , SecretKey } ;
4949use nostr:: { FromBech32 , Keys , ToBech32 } ;
50+ use std:: collections:: HashMap ;
5051use std:: str:: FromStr ;
5152use std:: sync:: Arc ;
52- use std:: {
53- collections:: HashMap ,
54- sync:: atomic:: { AtomicBool , Ordering } ,
55- } ;
5653use wasm_bindgen:: prelude:: * ;
5754
5855static INITIALIZED : once_cell:: sync:: Lazy < Mutex < bool > > =
@@ -1356,26 +1353,9 @@ impl MutinyWallet {
13561353
13571354 /// Exports the current state of the node manager to a json object.
13581355 #[ wasm_bindgen]
1359- pub async fn get_logs (
1360- password : Option < String > ,
1361- ) -> Result < JsValue /* Option<Vec<String>> */ , MutinyJsError > {
1362- let logger = Arc :: new ( MutinyLogger :: default ( ) ) ;
1363- // TODO Password should not be required for logs
1364- let cipher = password
1365- . as_ref ( )
1366- . filter ( |p| !p. is_empty ( ) )
1367- . map ( |p| encryption_key_from_pass ( p) )
1368- . transpose ( ) ?;
1369- let storage = IndexedDbStorage :: new ( password, cipher, None , logger. clone ( ) ) . await ?;
1370- let stop = Arc :: new ( AtomicBool :: new ( false ) ) ;
1371- let logger = Arc :: new ( MutinyLogger :: with_writer (
1372- stop. clone ( ) ,
1373- storage. clone ( ) ,
1374- None ,
1375- ) ) ;
1376- let res = JsValue :: from_serde ( & NodeManager :: get_logs ( storage, logger) ?) ?;
1377- stop. swap ( true , Ordering :: Relaxed ) ;
1378- Ok ( res)
1356+ pub async fn get_logs ( ) -> Result < JsValue /* Option<Vec<String>> */ , MutinyJsError > {
1357+ let logs = IndexedDbStorage :: get_logs ( ) . await ?;
1358+ Ok ( JsValue :: from_serde ( & logs) ?)
13791359 }
13801360
13811361 /// Get nostr wallet connect profiles
@@ -2269,7 +2249,7 @@ mod tests {
22692249
22702250 // sleep to make sure logs save
22712251 sleep ( 6_000 ) . await ;
2272- let logs = MutinyWallet :: get_logs ( None ) . await . expect ( "should get logs" ) ;
2252+ let logs = MutinyWallet :: get_logs ( ) . await . expect ( "should get logs" ) ;
22732253 let parsed_logs = js_to_option_vec_string ( logs) . expect ( "should parse logs" ) ;
22742254 assert ! ( parsed_logs. is_some( ) ) ;
22752255 assert ! ( !parsed_logs. clone( ) . unwrap( ) . is_empty( ) ) ;
@@ -2326,9 +2306,7 @@ mod tests {
23262306
23272307 // sleep to make sure logs save
23282308 sleep ( 6_000 ) . await ;
2329- let logs = MutinyWallet :: get_logs ( password)
2330- . await
2331- . expect ( "should get logs" ) ;
2309+ let logs = MutinyWallet :: get_logs ( ) . await . expect ( "should get logs" ) ;
23322310 let parsed_logs = js_to_option_vec_string ( logs) . expect ( "should parse logs" ) ;
23332311 assert ! ( parsed_logs. is_some( ) ) ;
23342312 assert ! ( !parsed_logs. clone( ) . unwrap( ) . is_empty( ) ) ;
0 commit comments