Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Oct 30, 2024
1 parent 932e95c commit 68c1d4e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 7 additions & 1 deletion bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use xmtp_id::{
},
InboxId,
};
use xmtp_mls::groups::scoped_client::LocalScopedGroupClient;
use xmtp_mls::storage::group_message::MsgQueryArgs;
use xmtp_mls::storage::group_message::SortDirection;
use xmtp_mls::{
Expand Down Expand Up @@ -397,10 +398,15 @@ impl FfiXmtpClient {
}

pub async fn request_history_sync(&self) -> Result<(), GenericError> {
let provider = self
.inner_client
.mls_provider()
.map_err(GenericError::from_error)?;
self.inner_client
.send_history_sync_request()
.send_history_sync_request(&provider)
.await
.map_err(GenericError::from_error)?;

Ok(())
}

Expand Down
9 changes: 7 additions & 2 deletions bindings_node/src/mls_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub use xmtp_api_grpc::grpc_api_helper::Client as TonicApiClient;
use xmtp_cryptography::signature::ed25519_public_key_to_address;
use xmtp_id::associations::builder::SignatureRequest;
use xmtp_mls::builder::ClientBuilder;
use xmtp_mls::groups::scoped_client::LocalScopedGroupClient;
use xmtp_mls::identity::IdentityStrategy;
use xmtp_mls::storage::{EncryptedMessageStore, EncryptionKey, StorageOption};
use xmtp_mls::Client as MlsClient;
Expand Down Expand Up @@ -179,11 +180,15 @@ impl NapiClient {

#[napi]
pub async fn request_history_sync(&self) -> Result<()> {
let provider = self
.inner_client
.mls_provider()
.map_err(ErrorWrapper::from)?;
let _ = self
.inner_client
.send_history_sync_request()
.send_history_sync_request(&provider)
.await
.map_err(ErrorWrapper::from);
.map_err(ErrorWrapper::from)?;

Ok(())
}
Expand Down
7 changes: 6 additions & 1 deletion bindings_wasm/src/mls_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use xmtp_cryptography::signature::ed25519_public_key_to_address;
use xmtp_id::associations::builder::SignatureRequest;
use xmtp_id::associations::unverified::UnverifiedSignature;
use xmtp_mls::builder::ClientBuilder;
use xmtp_mls::groups::scoped_client::LocalScopedGroupClient;
use xmtp_mls::identity::IdentityStrategy;
use xmtp_mls::storage::consent_record::StoredConsentRecord;
use xmtp_mls::storage::{EncryptedMessageStore, EncryptionKey, StorageOption};
Expand Down Expand Up @@ -287,9 +288,13 @@ impl WasmClient {

#[wasm_bindgen(js_name = requestHistorySync)]
pub async fn request_history_sync(&self) -> Result<(), JsError> {
let provider = self
.inner_client
.mls_provider()
.map_err(|e| JsError::new(format!("{}", e).as_str()))?;
let _ = self
.inner_client
.send_history_sync_request()
.send_history_sync_request(&provider)
.await
.map_err(|e| JsError::new(format!("{}", e).as_str()))?;

Expand Down
10 changes: 5 additions & 5 deletions examples/cli/cli-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ async fn main() {
let conn = client.store().conn().unwrap();
let provider = client.mls_provider().unwrap();
client.sync_welcomes(&conn).await.unwrap();
client.create_sync_group(&provider).await.unwrap();
let (group_id, _) = client.send_history_sync_request().await.unwrap();
client.enable_sync(&provider).await.unwrap();
let (group_id, _) = client.send_history_sync_request(&provider).await.unwrap();
let group_id_str = hex::encode(group_id);
info!("Sent history sync request in sync group {group_id_str}", { group_id: group_id_str})
}
Expand All @@ -382,7 +382,7 @@ async fn main() {
let conn = client.store().conn().unwrap();
let provider = client.mls_provider().unwrap();
client.sync_welcomes(&conn).await.unwrap();
client.create_sync_group(&provider).await.unwrap();
client.enable_sync(&provider).await.unwrap();
client.process_history_sync_reply(&provider).await.unwrap();

info!("History bundle downloaded and inserted into user DB", {})
Expand All @@ -394,7 +394,7 @@ async fn main() {
let conn = client.store().conn().unwrap();
let provider = client.mls_provider().unwrap();
client.sync_welcomes(&conn).await.unwrap();
client.create_sync_group(&provider).await.unwrap();
client.enable_sync(&provider).await.unwrap();
client.process_consent_sync_reply(&provider).await.unwrap();

info!("Consent bundle downloaded and inserted into user DB", {})
Expand All @@ -406,7 +406,7 @@ async fn main() {
let conn = client.store().conn().unwrap();
let provider = client.mls_provider().unwrap();
client.sync_welcomes(&conn).await.unwrap();
client.create_sync_group(&provider).await.unwrap();
client.enable_sync(&provider).await.unwrap();
let group = client.get_sync_group().unwrap();
let group_id_str = hex::encode(group.group_id.clone());
group.sync().await.unwrap();
Expand Down

0 comments on commit 68c1d4e

Please sign in to comment.