Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniffi simple message relay #970

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix service endpoint constant
Signed-off-by: Swapnil Tripathi <swapnil06.st@gmail.com>
swaptr committed Sep 24, 2023
commit a81eb8c0eea070945d637dd6b36584fa959c1b61
9 changes: 3 additions & 6 deletions uniffi_aries_vcx/README.md
Original file line number Diff line number Diff line change
@@ -58,13 +58,10 @@ Aries-VCX supports connection to [tools/simple_message_relay](/tools/simple_mess

The demo app needs this endpoint to establish communication with the peer.

Update [serviceEndpoint](./demo/app/src/main/res/values/strings.xml) to reflect the public IP.
Update [BASE_RELAY_ENDPOINT](./demo/app/src/main/java/org/hyperledger/ariesvcx/Constants.kt) to reflect the public IP.

```xml
<resources>
...
<string name="serviceEndpoint">{YOUR_PUBLIC_IP}</string>
</resources>
```kt
const val BASE_RELAY_ENDPOINT = <your-public-ip-endpoint>;
```

Now you are ready to start communicating. Use the QR scanner in the app to establish connection with the peer.
5 changes: 4 additions & 1 deletion uniffi_aries_vcx/core/src/core/unpack_message.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,10 @@ pub struct UnpackMessage {
pub sender_verkey: Option<String>,
}

pub fn unpack_message(profile_holder: Arc<ProfileHolder>, packed_msg: String) -> VcxUniFFIResult<UnpackMessage> {
pub fn unpack_message(
profile_holder: Arc<ProfileHolder>,
packed_msg: String,
) -> VcxUniFFIResult<UnpackMessage> {
block_on(async {
let packed_bytes = packed_msg.as_bytes();
let wallet = profile_holder.inner.inject_wallet();
6 changes: 0 additions & 6 deletions uniffi_aries_vcx/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -10,10 +10,4 @@ use crate::core::unpack_message::*;
use crate::errors::error::*;
use aries_vcx::aries_vcx_core::wallet::indy::WalletConfig;
use aries_vcx::protocols::connection::pairwise_info::PairwiseInfo;
use diddoc_legacy::{
aries::service::AriesService,
w3c::model::{Authentication, Ed25519PublicKey},
};
use handlers::connection::*;

use crate::{core::profile::*, errors::error::*};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.hyperledger.ariesvcx

// Set your public IP address here, this endpoint will be used while communicating with the peer(agent).
const val BASE_RELAY_ENDPOINT = "https://b199-27-57-116-96.ngrok-free.app";
const val RELAY_USER_ID = "demo-user-1";
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavHostController
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@@ -46,9 +45,8 @@ fun HomeScreen(
mutableStateOf(true)
}

val serviceEndpoint = stringResource(R.string.serviceEndpoint)
val request = Request.Builder()
.url("$serviceEndpoint/pop_user_message/${walletConfig.walletKey}")
.url("$BASE_RELAY_ENDPOINT/pop_user_message/$RELAY_USER_ID")
.build()


Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
import android.util.Base64
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavHostController
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -58,8 +57,6 @@ fun ScanScreen(
ProcessCameraProvider.getInstance(context)
}

val serviceEndpoint = stringResource(R.string.serviceEndpoint)

scannedQRCodeText?.let { text ->
val encoded = Uri.parse(text)?.getQueryParameter("c_i")
val decoded = String(Base64.decode(encoded, Base64.DEFAULT))
@@ -77,7 +74,7 @@ fun ScanScreen(
)
connection.sendRequest(
profileHolder,
"$serviceEndpoint/send_user_message/${walletConfig.walletKey}",
"$BASE_RELAY_ENDPOINT/send_user_message/$RELAY_USER_ID",
emptyList()
)
withContext(Dispatchers.Main) {
1 change: 0 additions & 1 deletion uniffi_aries_vcx/demo/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<resources>
<string name="app_name">demo</string>
<string name="serviceEndpoint">https://b199-27-57-116-96.ngrok-free.app</string>
</resources>