feat: Add function to retrieve the current keyspace name in WebAssembly bindings
This commit is contained in:
		| @@ -270,6 +270,22 @@ pub async fn sign(message: &[u8]) -> Result<JsValue, JsValue> { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /// Get the current keyspace name | ||||||
|  | #[wasm_bindgen] | ||||||
|  | pub fn get_current_keyspace_name() -> Result<String, JsValue> { | ||||||
|  |     SESSION_MANAGER.with(|cell| { | ||||||
|  |         if let Some(session) = cell.borrow().as_ref() { | ||||||
|  |             if let Some(keyspace_name) = session.current_keyspace_name() { | ||||||
|  |                 Ok(keyspace_name.to_string()) | ||||||
|  |             } else { | ||||||
|  |                 Err(JsValue::from_str("No keyspace unlocked")) | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             Err(JsValue::from_str("Session not initialized")) | ||||||
|  |         } | ||||||
|  |     }) | ||||||
|  | } | ||||||
|  |  | ||||||
| /// Sign message with default keypair (first keypair in keyspace) without changing session state | /// Sign message with default keypair (first keypair in keyspace) without changing session state | ||||||
| #[wasm_bindgen] | #[wasm_bindgen] | ||||||
| pub async fn sign_with_default_keypair(message: &[u8]) -> Result<JsValue, JsValue> { | pub async fn sign_with_default_keypair(message: &[u8]) -> Result<JsValue, JsValue> { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user