Skip to content

Commit

Permalink
move the provider
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Jan 15, 2025
1 parent 4a27b51 commit 5d1c587
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion xmtp_mls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ use crate::{
group_message::StoredGroupMessage,
refresh_state::EntityKind,
wallet_addresses::WalletEntry,
xmtp_openmls_provider::XmtpOpenMlsProvider,
EncryptedMessageStore, NotFound, StorageError,
},
subscriptions::{LocalEventError, LocalEvents},
types::InstallationId,
verified_key_package_v2::{KeyPackageVerificationError, VerifiedKeyPackageV2},
xmtp_openmls_provider::XmtpOpenMlsProvider,
Fetch, Store, XmtpApi,
};
use crate::{groups::ConversationListItem, storage::ProviderTransactions};
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/device_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::{
consent_record::StoredConsentRecord,
group::{ConversationType, GroupQueryArgs, StoredGroup},
group_message::{GroupMessageKind, MsgQueryArgs, StoredGroupMessage},
xmtp_openmls_provider::XmtpOpenMlsProvider,
DbConnection, NotFound, StorageError,
},
subscriptions::{LocalEvents, StreamMessages, SubscribeError, SyncMessage},
xmtp_openmls_provider::XmtpOpenMlsProvider,
Client, Store,
};
use aes_gcm::aead::generic_array::GenericArray;
Expand Down
8 changes: 3 additions & 5 deletions xmtp_mls/src/groups/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use xmtp_id::InboxId;

use super::{validated_commit::extract_group_membership, GroupError, MlsGroup, ScopedGroupClient};

use crate::{
storage::{
association_state::StoredAssociationState,
consent_record::{ConsentState, ConsentType},
},
use crate::storage::{
association_state::StoredAssociationState,
consent_record::{ConsentState, ConsentType},
xmtp_openmls_provider::XmtpOpenMlsProvider,
};

Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/mls_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
identity::{parse_credential, IdentityError},
identity_updates::load_identity_updates,
intents::ProcessIntentError,
storage::xmtp_openmls_provider::XmtpOpenMlsProvider,
storage::{
db_connection::DbConnection,
group_intent::{IntentKind, IntentState, StoredGroupIntent, ID},
Expand All @@ -34,7 +35,6 @@ use crate::{
},
subscriptions::{LocalEvents, SyncMessage},
utils::{hash::sha256, id::calculate_message_id, time::hmac_epoch},
xmtp_openmls_provider::XmtpOpenMlsProvider,
Delete, Fetch, StoreOrIgnore,
};
use futures::future::try_join_all;
Expand Down
4 changes: 2 additions & 2 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ use crate::{
identity::{parse_credential, IdentityError},
identity_updates::{load_identity_updates, InstallationDiffError},
intents::ProcessIntentError,
storage::xmtp_openmls_provider::XmtpOpenMlsProvider,
storage::{
consent_record::{ConsentState, ConsentType, StoredConsentRecord},
db_connection::DbConnection,
Expand All @@ -99,7 +100,6 @@ use crate::{
},
subscriptions::{LocalEventError, LocalEvents},
utils::id::calculate_message_id,
xmtp_openmls_provider::XmtpOpenMlsProvider,
Store, MLS_COMMIT_LOCK,
};
use std::future::Future;
Expand Down Expand Up @@ -1791,9 +1791,9 @@ pub(crate) mod tests {
group::{ConversationType, GroupQueryArgs},
group_intent::{IntentKind, IntentState},
group_message::{GroupMessageKind, MsgQueryArgs, StoredGroupMessage},
xmtp_openmls_provider::XmtpOpenMlsProvider,
},
utils::test::FullXmtpClient,
xmtp_openmls_provider::XmtpOpenMlsProvider,
InboxOwner, StreamHandle as _,
};

Expand Down
6 changes: 4 additions & 2 deletions xmtp_mls/src/groups/scoped_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use crate::{
api::ApiClientWrapper,
client::{ClientError, XmtpMlsLocalContext},
identity_updates::{InstallationDiff, InstallationDiffError},
storage::{DbConnection, EncryptedMessageStore, StorageError},
storage::{
xmtp_openmls_provider::XmtpOpenMlsProvider, DbConnection, EncryptedMessageStore,
StorageError,
},
subscriptions::LocalEvents,
types::InstallationId,
verified_key_package_v2::VerifiedKeyPackageV2,
xmtp_openmls_provider::XmtpOpenMlsProvider,
Client,
};
use std::sync::Arc;
Expand Down
6 changes: 4 additions & 2 deletions xmtp_mls/src/hpke.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{
configuration::{CIPHERSUITE, WELCOME_HPKE_LABEL},
storage::sql_key_store::{SqlKeyStoreError, KEY_PACKAGE_REFERENCES},
xmtp_openmls_provider::XmtpOpenMlsProvider,
storage::{
sql_key_store::{SqlKeyStoreError, KEY_PACKAGE_REFERENCES},
xmtp_openmls_provider::XmtpOpenMlsProvider,
},
};
use openmls::{
ciphersuite::hash_ref::KeyPackageRef,
Expand Down
3 changes: 1 addition & 2 deletions xmtp_mls/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::storage::sql_key_store::{SqlKeyStore, SqlKeyStoreError, KEY_PACKAGE_R
use crate::{
api::{ApiClientWrapper, WrappedApiError},
configuration::{CIPHERSUITE, GROUP_MEMBERSHIP_EXTENSION_ID, MUTABLE_METADATA_EXTENSION_ID},
storage::StorageError,
xmtp_openmls_provider::XmtpOpenMlsProvider,
storage::{xmtp_openmls_provider::XmtpOpenMlsProvider, StorageError},
Fetch, Store, XmtpApi,
};
use openmls::prelude::hash_ref::HashReference;
Expand Down
4 changes: 1 addition & 3 deletions xmtp_mls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ pub mod subscriptions;
pub mod types;
pub mod utils;
pub mod verified_key_package_v2;
mod xmtp_openmls_provider;

pub use client::{Client, Network};
use std::collections::HashMap;
use std::sync::{Arc, LazyLock, Mutex};
use storage::{DuplicateItem, StorageError};
use storage::{xmtp_openmls_provider::XmtpOpenMlsProvider, DuplicateItem, StorageError};
use tokio::sync::{OwnedSemaphorePermit, Semaphore};
pub use xmtp_openmls_provider::XmtpOpenMlsProvider;

pub use xmtp_id::InboxOwner;
pub use xmtp_proto::api_client::trait_impls::*;
Expand Down
3 changes: 2 additions & 1 deletion xmtp_mls/src/storage/encrypted_store/db_connection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::xmtp_openmls_provider::XmtpOpenMlsProvider;
use parking_lot::Mutex;
use std::fmt;
use std::sync::Arc;

use crate::storage::xmtp_openmls_provider::XmtpOpenMlsProvider;

#[cfg(not(target_arch = "wasm32"))]
pub type DbConnection = DbConnectionPrivate<super::RawDbConnection>;

Expand Down
12 changes: 7 additions & 5 deletions xmtp_mls/src/storage/encrypted_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod identity_update;
pub mod key_package_history;
pub mod key_store_entry;
#[cfg(not(target_arch = "wasm32"))]
pub mod native;
pub(super) mod native;
pub mod refresh_state;
pub mod schema;
mod schema_gen;
Expand All @@ -31,7 +31,7 @@ mod sqlcipher_connection;
pub mod user_preferences;
pub mod wallet_addresses;
#[cfg(target_arch = "wasm32")]
pub mod wasm;
pub(super) mod wasm;

pub use self::db_connection::DbConnection;
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -46,8 +46,8 @@ pub use self::wasm::SqliteConnection;
#[cfg(target_arch = "wasm32")]
pub use sqlite_web::{connection::WasmSqliteConnection as RawDbConnection, WasmSqlite as Sqlite};

use super::StorageError;
use crate::{xmtp_openmls_provider::XmtpOpenMlsProviderPrivate, Store};
use super::{xmtp_openmls_provider::XmtpOpenMlsProviderPrivate, StorageError};
use crate::Store;
use db_connection::DbConnectionPrivate;
use diesel::{
connection::{LoadConnection, TransactionManager},
Expand Down Expand Up @@ -159,6 +159,8 @@ impl EncryptedMessageStore {

/// Shared Code between WebAssembly and Native using the `XmtpDb` trait
pub mod private {
use crate::storage::xmtp_openmls_provider::XmtpOpenMlsProviderPrivate;

use super::*;
use diesel::connection::SimpleConnection;
use diesel_migrations::MigrationHarness;
Expand Down Expand Up @@ -197,7 +199,7 @@ pub mod private {
&self,
) -> Result<XmtpOpenMlsProviderPrivate<Db, Db::Connection>, StorageError> {
let conn = self.conn()?;
Ok(crate::xmtp_openmls_provider::XmtpOpenMlsProviderPrivate::new(conn))
Ok(XmtpOpenMlsProviderPrivate::new(conn))
}

/// Pulls a new connection from the store
Expand Down
1 change: 1 addition & 0 deletions xmtp_mls/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub(super) mod encrypted_store;
mod errors;
pub mod serialization;
pub mod sql_key_store;
pub mod xmtp_openmls_provider;

pub use encrypted_store::*;
pub use errors::*;
Expand Down
6 changes: 4 additions & 2 deletions xmtp_mls/src/storage/sql_key_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,10 @@ pub(crate) mod tests {
use super::SqlKeyStore;
use crate::{
configuration::CIPHERSUITE,
storage::{sql_key_store::SqlKeyStoreError, EncryptedMessageStore, StorageOption},
xmtp_openmls_provider::XmtpOpenMlsProvider,
storage::{
sql_key_store::SqlKeyStoreError, xmtp_openmls_provider::XmtpOpenMlsProvider,
EncryptedMessageStore, StorageOption,
},
};
use xmtp_common::tmp_path;

Expand Down
File renamed without changes.

0 comments on commit 5d1c587

Please sign in to comment.