diff --git a/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt b/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt index cbcc2933d..ecb56c21c 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/TestHelpers.kt @@ -67,8 +67,8 @@ class FakeSCWWallet : SigningKey { override val address: String get() = walletAddress - override val isSmartContractWallet: Boolean - get() = true + override val type: WalletType + get() = WalletType.SCW override var chainId: Long? = 31337L diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index e59ccfec1..37a610b4f 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -325,7 +325,7 @@ class Client() { this.hasV2Client = false val clientOptions = options ?: ClientOptions(enableV3 = true) val accountAddress = - if (account.isSmartContractWallet) "eip155:${account.chainId}:${account.address.lowercase()}" else account.address.lowercase() + if (account.chainId != null) "eip155:${account.chainId}:${account.address.lowercase()}" else account.address.lowercase() return try { initializeV3Client(accountAddress, clientOptions, account) } catch (e: Exception) { @@ -448,9 +448,8 @@ class Client() { } v3Client.signatureRequest()?.let { signatureRequest -> if (account != null) { - if (account.isSmartContractWallet) { - val chainId = account.chainId - ?: throw XMTPException("ChainId is required for smart contract wallets") + if (account.type == WalletType.SCW) { + val chainId = account.chainId ?: throw XMTPException("ChainId is required for smart contract wallets") signatureRequest.addScwSignature( account.signSCW(signatureRequest.signatureText()), account.address.lowercase(), diff --git a/library/src/main/java/org/xmtp/android/library/Conversations.kt b/library/src/main/java/org/xmtp/android/library/Conversations.kt index 039672e4b..76f7afe60 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversations.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversations.kt @@ -37,7 +37,6 @@ import org.xmtp.proto.keystore.api.v1.Keystore.GetConversationHmacKeysResponse.H import org.xmtp.proto.keystore.api.v1.Keystore.TopicMap.TopicData import org.xmtp.proto.message.contents.Contact import org.xmtp.proto.message.contents.Invitation -import uniffi.xmtpv3.FfiConsentState import uniffi.xmtpv3.FfiConversation import uniffi.xmtpv3.FfiConversationCallback import uniffi.xmtpv3.FfiConversations @@ -554,10 +553,20 @@ data class Conversations( } } } - val stream = libXMTPConversations?.stream(conversationCallback) - ?: throw XMTPException("Client does not support V3") + ?: throw XMTPException("Client does not support Groups") + awaitClose { stream.end() } + } + + private fun streamGroupConversations(): Flow = callbackFlow { + val groupCallback = object : FfiConversationCallback { + override fun onConversation(conversation: FfiConversation) { + trySend(Conversation.Group(Group(client, conversation))) + } + } + val stream = libXMTPConversations?.streamGroups(groupCallback) + ?: throw XMTPException("Client does not support Groups") awaitClose { stream.end() } } @@ -665,17 +674,6 @@ data class Conversations( awaitClose { stream.end() } } - private fun streamGroupConversations(): Flow = callbackFlow { - val groupCallback = object : FfiConversationCallback { - override fun onConversation(conversation: FfiConversation) { - trySend(Conversation.Group(Group(client, conversation))) - } - } - val stream = libXMTPConversations?.streamGroups(groupCallback) - ?: throw XMTPException("Client does not support Groups") - awaitClose { stream.end() } - } - // ------- V1 V2 to be deprecated ------ /** diff --git a/library/src/main/java/org/xmtp/android/library/SigningKey.kt b/library/src/main/java/org/xmtp/android/library/SigningKey.kt index 2febe0278..f1a10a395 100644 --- a/library/src/main/java/org/xmtp/android/library/SigningKey.kt +++ b/library/src/main/java/org/xmtp/android/library/SigningKey.kt @@ -19,9 +19,9 @@ import java.util.Date interface SigningKey { val address: String - // If this signing key is a smart contract wallet - val isSmartContractWallet: Boolean - get() = false + // The wallet type if Smart Contract Wallet this should be type SCW. + val type: WalletType + get() = WalletType.EOA // The chainId of the Smart Contract Wallet value should be null if not SCW var chainId: Long? @@ -46,6 +46,11 @@ interface SigningKey { } } +enum class WalletType { + SCW, // Smart Contract Wallet + EOA // Externally Owned Account *Default +} + /** * This prompts the wallet to sign a personal message. * It authorizes the `identity` key to act on behalf of this wallet.