xmtp-flutter icon indicating copy to clipboard operation
xmtp-flutter copied to clipboard

Bug: Starting a new conversation fails with some wallet addresses

Open bselwe opened this issue 2 years ago • 0 comments

Describe the bug

Starting a new conversation might throw an exception when the peer's contact is cached.

The method that throws when starting a conversation: https://github.com/xmtp/xmtp-flutter/blob/9075969f50fb005dd5b0ccf1d3858645beb36353/lib/src/conversation/conversation_v2.dart#L52

Thrown error
StateError (Bad state: No element)
#0      ListBase.firstWhere (dart:collection/list.dart:132:5)
#1      ContactManager.getUserContactV2 (package:xmtp/src/contact.dart:59:25)
<asynchronous suspension>
#2      ConversationManagerV2.newConversation (package:xmtp/src/conversation/conversation_v2.dart:52:23)
<asynchronous suspension>
#3      _conversationsIsolateEntry.<anonymous closure> (package:orb/component/xmtp/conversations_client.dart:290:17)

It seems that getUserContactV2 looks for v2 user contacts. However, getUserContacts might return a cached list of user contacts that only contains v1 contacts with the given wallet address. At this point, the method breaks as it expects at least one contact to be v2.

Expected behavior

The user can start a conversation with any wallet address.

Steps to reproduce the bug

No response

bselwe avatar Oct 17 '23 09:10 bselwe