diff --git a/native/native_rust_library/src/identity_client.rs b/native/native_rust_library/src/identity_client.rs --- a/native/native_rust_library/src/identity_client.rs +++ b/native/native_rust_library/src/identity_client.rs @@ -35,10 +35,10 @@ WalletLoginResponse as WalletLoginResponseStruct, }; use crate::opaque::Cipher; -use crate::Client; +use crate::IdentityClient; pub async fn get_user_id( - mut client: Box, + mut client: Box, auth_type: i32, user_info: String, ) -> Result { @@ -56,7 +56,7 @@ } pub async fn verify_user_token( - mut client: Box, + mut client: Box, user_id: String, device_id: String, access_token: String, @@ -76,7 +76,7 @@ } pub async fn register_user( - mut client: Box, + mut client: Box, user_id: String, device_id: String, username: String, @@ -138,7 +138,7 @@ } pub async fn login_user_pake( - mut client: Box, + mut client: Box, user_id: String, device_id: String, password: String, @@ -202,7 +202,7 @@ } pub async fn login_user_wallet( - mut client: Box, + mut client: Box, user_id: String, device_id: String, siwe_message: String, diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -18,8 +18,6 @@ verify_user_token, }; -const IDENTITY_SERVICE_SOCKET_ADDR: &str = "https://[::1]:50051"; - lazy_static! { pub static ref RUNTIME: Arc = Arc::new( Builder::new_multi_thread() @@ -42,21 +40,21 @@ extern "Rust" { // Identity Service Client - type Client; - fn initialize_client() -> Box; + type IdentityClient; + fn initialize_identity_client(addr: String) -> Box; fn get_user_id_blocking( - client: Box, + client: Box, auth_type: i32, user_info: String, ) -> Result; fn verify_user_token_blocking( - client: Box, + client: Box, user_id: String, device_id: String, access_token: String, ) -> Result; fn register_user_blocking( - client: Box, + client: Box, user_id: String, device_id: String, username: String, @@ -64,14 +62,14 @@ user_public_key: String, ) -> Result; fn login_user_pake_blocking( - client: Box, + client: Box, user_id: String, device_id: String, password: String, user_public_key: String, ) -> Result; fn login_user_wallet_blocking( - client: Box, + client: Box, user_id: String, device_id: String, siwe_message: String, @@ -84,21 +82,21 @@ } #[derive(Debug)] -pub struct Client { +pub struct IdentityClient { identity_client: IdentityServiceClient, } -fn initialize_client() -> Box { - Box::new(Client { +fn initialize_identity_client(addr: String) -> Box { + Box::new(IdentityClient { identity_client: RUNTIME - .block_on(IdentityServiceClient::connect(IDENTITY_SERVICE_SOCKET_ADDR)) + .block_on(IdentityServiceClient::connect(addr)) .unwrap(), }) } #[instrument] fn get_user_id_blocking( - client: Box, + client: Box, auth_type: i32, user_info: String, ) -> Result { @@ -107,7 +105,7 @@ #[instrument] fn verify_user_token_blocking( - client: Box, + client: Box, user_id: String, device_id: String, access_token: String, @@ -117,7 +115,7 @@ #[instrument] fn register_user_blocking( - client: Box, + client: Box, user_id: String, device_id: String, username: String, @@ -136,7 +134,7 @@ #[instrument] fn login_user_pake_blocking( - client: Box, + client: Box, user_id: String, device_id: String, password: String, @@ -153,7 +151,7 @@ #[instrument] fn login_user_wallet_blocking( - client: Box, + client: Box, user_id: String, device_id: String, siwe_message: String,