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

Fix identifiers report function #1739

Merged
merged 6 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
4 changes: 2 additions & 2 deletions bindings_ffi/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use xmtp_id::associations::{ident, Identifier};

use crate::GenericError;

#[derive(uniffi::Record, Hash, PartialEq, Eq, Clone)]
#[derive(uniffi::Record, Hash, PartialEq, Eq, Clone, Debug)]
pub struct FfiIdentifier {
pub identifier: String,
pub identifier_kind: FfiIdentifierKind,
}

#[derive(uniffi::Enum, Hash, PartialEq, Eq, Clone)]
#[derive(uniffi::Enum, Hash, PartialEq, Eq, Clone, Debug)]
pub enum FfiIdentifierKind {
Ethereum,
Passkey,
Expand Down
30 changes: 26 additions & 4 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ impl FfiConversationListItem {
}
}

#[derive(uniffi::Record)]
#[derive(uniffi::Record, Debug)]
pub struct FfiUpdateGroupMembershipResult {
added_members: HashMap<String, u64>,
removed_members: Vec<String>,
Expand Down Expand Up @@ -3336,7 +3336,7 @@ mod tests {
identifier_kind: FfiIdentifierKind::Passkey,
};
let inbox_id = ident.inbox_id(nonce).unwrap();
let client = create_client(
let client2 = create_client(
connect_to_backend(xmtp_api_grpc::LOCALHOST_ADDRESS.to_string(), false)
.await
.unwrap(),
Expand All @@ -3351,7 +3351,7 @@ mod tests {
.await
.unwrap();

let sig_request = client.signature_request().unwrap().clone();
let sig_request = client2.signature_request().unwrap().clone();
let challenge = sig_request.signature_text().await.unwrap();
let challenge_bytes = challenge.as_bytes().to_vec();

Expand Down Expand Up @@ -3387,7 +3387,29 @@ mod tests {
// should be good
.unwrap();

client.register_identity(sig_request).await.unwrap();
client2.register_identity(sig_request).await.unwrap();

let bob = new_test_client().await;
let fernando = new_test_client().await;
let group = client2
.conversations()
.create_group_with_inbox_ids(vec![bob.inbox_id()], FfiCreateGroupOptions::default())
.await
.unwrap();

let result = group
.add_members_by_inbox_id(vec![fernando.inbox_id(), alex.inbox_id()])
.await
.unwrap();

assert_eq!(result.added_members.len(), 2);

let members = group.list_members().await.unwrap();
let passkey_ident = client2.account_identifier.identifier.clone();
assert!(members.into_iter().any(|m| m
.account_identifiers
.into_iter()
.any(|i| i.identifier == passkey_ident)));
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
Expand Down
4 changes: 3 additions & 1 deletion xmtp_id/src/associations/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ impl AssociationState {
}

pub fn identifiers(&self) -> Vec<Identifier> {
self.members_by_kind(MemberKind::Ethereum)
self.members
.values()
.cloned()
.into_iter()
.filter_map(|member| match member.identifier {
MemberIdentifier::Ethereum(eth) => Some(Identifier::Ethereum(eth)),
Expand Down
Loading