Skip to content

Commit

Permalink
Merge pull request #692 from WalletConnect/develop
Browse files Browse the repository at this point in the history
BOM 1.6.1
  • Loading branch information
Talhaali00 authored Mar 1, 2023
2 parents 05cfc64 + 09e8e91 commit dde6fd4
Show file tree
Hide file tree
Showing 89 changed files with 1,884 additions and 326 deletions.
29 changes: 15 additions & 14 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ WalletConnect v2 protocols for Android applications.
####
## SDK Chart

| BOM | [Core SDK](androidCore) | [web3wallet](web3/wallet) | [Sign SDK](sign) | [Auth SDK](auth) | [Chat SDK](chat) |
|-------|-------------------------|---------------------------|------------------|------------------|------------------|
| 1.6.0 | 1.11.0 | 1.4.0 | 2.9.0 | 1.9.0 | 1.0.0-beta02 |
| 1.5.0 | 1.10.0 | 1.3.0 | 2.8.0 | 1.8.0 | 1.0.0-beta01 |
| 1.4.1 | 1.9.1 | 1.2.1 | 2.7.1 | 1.7.1 | 1.0.0-alpha09 |
| 1.3.0 | 1.8.0 | 1.1.0 | 2.6.0 | 1.6.0 | 1.0.0-alpha07 |
| 1.2.0 | 1.7.0 | 1.0.0 | 2.5.0 | 1.5.0 | 1.0.0-alpha06 |
| 1.1.1 | 1.6.0 | | 2.4.0 | 1.4.0 | 1.0.0-alpha05 |
| 1.0.1 | 1.5.0 | | 2.3.1 | 1.3.0 | 1.0.0-alpha04 |
| | 1.4.0 | | 2.2.0 | 1.2.0 | 1.0.0-alpha03 |
| | 1.3.0 | | 2.1.0 | 1.1.0 | 1.0.0-alpha02 |
| | 1.2.0 | | | | 1.0.0-alpha01 |
| | 1.1.0 | | 2.0.0 | 1.0.0 | |
| | 1.0.0 | | 2.0.0-rc.5 | 1.0.0-alpha01 | |
| BOM | [Core SDK](androidCore) | [web3wallet](web3/wallet) | [Sign SDK](sign) | [Auth SDK](auth) | [Chat SDK](chat) | [web3inbox](web3/inbox) |
|-------|-------------------------|---------------------------|------------------|------------------|------------------|-------------------------|
| 1.6.1 | 1.11.1 | 1.4.1 | 2.9.1 | 1.9.1 | 1.0.0-beta03 | 1.0.0-alpha03 |
| 1.6.0 | 1.11.0 | 1.4.0 | 2.9.0 | 1.9.0 | 1.0.0-beta02 | |
| 1.5.0 | 1.10.0 | 1.3.0 | 2.8.0 | 1.8.0 | 1.0.0-beta01 | |
| 1.4.1 | 1.9.1 | 1.2.1 | 2.7.1 | 1.7.1 | 1.0.0-alpha09 | |
| 1.3.0 | 1.8.0 | 1.1.0 | 2.6.0 | 1.6.0 | 1.0.0-alpha07 | |
| 1.2.0 | 1.7.0 | 1.0.0 | 2.5.0 | 1.5.0 | 1.0.0-alpha06 | |
| 1.1.1 | 1.6.0 | | 2.4.0 | 1.4.0 | 1.0.0-alpha05 | |
| 1.0.1 | 1.5.0 | | 2.3.1 | 1.3.0 | 1.0.0-alpha04 | |
| | 1.4.0 | | 2.2.0 | 1.2.0 | 1.0.0-alpha03 | |
| | 1.3.0 | | 2.1.0 | 1.1.0 | 1.0.0-alpha02 | |
| | 1.2.0 | | | | 1.0.0-alpha01 | |
| | 1.1.0 | | 2.0.0 | 1.0.0 | | |
| | 1.0.0 | | 2.0.0-rc.5 | 1.0.0-alpha01 | | |


## BOM Instructions:
Expand Down
1 change: 1 addition & 0 deletions androidCore/bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ dependencies {
api(project(":auth:sdk"))
api(project(":chat:sdk"))
api(project(":web3:wallet"))
api(project(":web3:inbox"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal object EchoClient : EchoInterface {
scope.launch(Dispatchers.IO) {
supervisorScope {
try {
val response = echoService.register(projectId.value, body)
val response = echoService.register(projectId.value, clientId, body)

if (response.isSuccessful && response.body() != null) {
if (response.body()!!.status == SUCCESS_STATUS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ package com.walletconnect.android.echo.network
import com.walletconnect.android.echo.network.model.EchoBody
import com.walletconnect.android.echo.network.model.EchoResponse
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.*

interface EchoService {

@POST("{projectId}/clients")
suspend fun register(@Path("projectId") projectId: String, @Body echoClientsBody: EchoBody): Response<EchoResponse>
suspend fun register(@Path("projectId") projectId: String, @Query("auth") clientID: String, @Body echoClientsBody: EchoBody): Response<EchoResponse>

@DELETE("{projectId}/clients/{clientId}")
suspend fun unregister(@Path("projectId") projectId: String, @Path("clientId") clientID: String): Response<EchoResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.walletconnect.android.internal.common.di

import android.net.Uri
import android.os.Build
import android.util.Log
import com.squareup.moshi.Moshi
import com.tinder.scarlet.Scarlet
import com.tinder.scarlet.lifecycle.LifecycleRegistry
Expand All @@ -12,6 +13,7 @@ import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory
import com.walletconnect.android.internal.common.connection.ConnectivityState
import com.walletconnect.android.internal.common.connection.ManualConnectionLifecycle
import com.walletconnect.android.internal.common.jwt.GenerateJwtStoreClientIdUseCase
import com.walletconnect.android.internal.common.wcKoinApp
import com.walletconnect.android.relay.ConnectionType
import com.walletconnect.foundation.network.data.ConnectionController
import com.walletconnect.foundation.network.data.adapter.FlowStreamAdapter
Expand All @@ -20,6 +22,7 @@ import okhttp3.Interceptor
import okhttp3.OkHttpClient
import org.koin.android.ext.koin.androidApplication
import org.koin.core.qualifier.named
import org.koin.core.scope.Scope
import org.koin.dsl.module
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -31,9 +34,9 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
val DEFAULT_BACKOFF_SECONDS = 5L
val TIMEOUT_TIME = 5000L

factory(named(AndroidCommonDITags.RELAY_URL)) {
factory<Uri>(named(AndroidCommonDITags.RELAY_URL)) {
val jwt = get<GenerateJwtStoreClientIdUseCase>().invoke(serverUrl)
Uri.parse("$serverUrl&auth=$jwt")!!.toString()
Uri.parse("$serverUrl&auth=$jwt")!!
}

single {
Expand All @@ -56,7 +59,7 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
.authenticator(authenticator = { _, response ->
response.request.run {
if (Uri.parse(serverUrl).host == this.url.host) {
val relayUrl = get<String>(named(AndroidCommonDITags.RELAY_URL))
val relayUrl = get<Uri>(named(AndroidCommonDITags.RELAY_URL)).toString()
this.newBuilder().url(relayUrl).build()
} else {
null
Expand All @@ -72,7 +75,6 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,

single(named(AndroidCommonDITags.MSG_ADAPTER)) { MoshiMessageAdapter.Factory(get<Moshi.Builder>(named(AndroidCommonDITags.MOSHI)).build()) }


single(named(AndroidCommonDITags.CONNECTION_CONTROLLER)) {
if (connectionType == ConnectionType.MANUAL) {
ConnectionController.Manual()
Expand All @@ -96,7 +98,7 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
single(named(AndroidCommonDITags.SCARLET)) {
Scarlet.Builder()
.backoffStrategy(get<LinearBackoffStrategy>())
.webSocketFactory(get<OkHttpClient>(named(AndroidCommonDITags.OK_HTTP)).newWebSocketFactory(get<String>(named(AndroidCommonDITags.RELAY_URL))))
.webSocketFactory(get<OkHttpClient>(named(AndroidCommonDITags.OK_HTTP)).newWebSocketFactory(get<Uri>(named(AndroidCommonDITags.RELAY_URL)).toString()))
.lifecycle(get(named(AndroidCommonDITags.LIFECYCLE)))
.addMessageAdapterFactory(get<MoshiMessageAdapter.Factory>(named(AndroidCommonDITags.MSG_ADAPTER)))
.addStreamAdapterFactory(get<FlowStreamAdapter.Factory>())
Expand All @@ -110,12 +112,4 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
single(named(AndroidCommonDITags.CONNECTIVITY_STATE)) {
ConnectivityState(androidApplication())
}

single(named(AndroidCommonDITags.ECHO_RETROFIT)) {
Retrofit.Builder()
.baseUrl("https://echo.walletconnect.com/")
.addConverterFactory(MoshiConverterFactory.create())
.client(get(named(AndroidCommonDITags.OK_HTTP)))
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ import com.walletconnect.android.echo.network.EchoService
import org.koin.core.qualifier.named
import org.koin.dsl.module
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory

@JvmSynthetic
internal fun echoModule() = module {

single(named(AndroidCommonDITags.ECHO_RETROFIT)) {
Retrofit.Builder()
.baseUrl("https://echo.walletconnect.com/")
.addConverterFactory(MoshiConverterFactory.create())
.client(get(named(AndroidCommonDITags.OK_HTTP)))
.build()
}

single {
get<Retrofit>(named(AndroidCommonDITags.ECHO_RETROFIT))
.create(EchoService::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class JsonRpcSerializer(
}

inline fun <reified T> tryDeserialize(json: String): T? = runCatching { moshi.adapter(T::class.java).fromJson(json) }.getOrNull()
private fun tryDeserialize(json: String, type: KClass<*>): Any? = runCatching { moshi.adapter(type.java).fromJson(json) }.getOrNull()
fun tryDeserialize(json: String, type: KClass<*>): Any? = runCatching { moshi.adapter(type.java).fromJson(json) }.getOrNull()
private inline fun <reified T> trySerialize(type: T): String = moshi.adapter(T::class.java).toJson(type)
private fun trySerialize(payload: Any, type: KClass<*>): String = moshi.adapter<Any>(type.java).toJson(payload)
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ internal class JsonRpcInteractor(
result.fold(
onSuccess = { acknowledgement ->
subscriptions.plus(topics.zip(acknowledgement.result).toMap())
logger.error("Batch subscribe to topics: $topics")
onSuccess(topics)
},
onFailure = { error ->
Expand Down
16 changes: 8 additions & 8 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID"
const val KEY_SDK_NAME = "SDK_NAME"

//Latest versions
const val BOM_VERSION = "1.6.0"
const val FOUNDATION_VERSION = "1.6.0"
const val CORE_VERSION = "1.11.0"
const val SIGN_VERSION = "2.9.0"
const val AUTH_VERSION = "1.9.0"
const val CHAT_VERSION = "1.0.0-beta02"
const val WEB_3_WALLET = "1.4.0"
const val WEB_3_INBOX = "1.0.0-alpha02"
const val BOM_VERSION = "1.6.1"
const val FOUNDATION_VERSION = "1.6.1"
const val CORE_VERSION = "1.11.1"
const val SIGN_VERSION = "2.9.1"
const val AUTH_VERSION = "1.9.1"
const val CHAT_VERSION = "1.0.0-beta03"
const val WEB_3_WALLET = "1.4.1"
const val WEB_3_INBOX = "1.0.0-alpha03"

val jvmVersion = JavaVersion.VERSION_11
const val MIN_SDK: Int = 23
Expand Down
3 changes: 3 additions & 0 deletions chat/sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ android {
buildFeatures {
viewBinding = true
}
packagingOptions {
exclude("META-INF/LICENSE-notice.md")
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ sealed class ChatSharedEvents {
object NoAction : ChatSharedEvents()

data class OnInvite(val invite: Chat.Model.Invite.Received) : ChatSharedEvents()
data class OnInviteAccepted(val topic: String) : ChatSharedEvents()
data class OnInviteRejected(val topic: String) : ChatSharedEvents()
data class OnInviteAccepted(val topic: String, val invite: Chat.Model.Invite.Sent) : ChatSharedEvents()
data class OnInviteRejected(val invite: Chat.Model.Invite.Sent) : ChatSharedEvents()
data class OnMessage(val message: Chat.Model.Message) : ChatSharedEvents()
data class OnLeft(val topic: String) : ChatSharedEvents()
}

fun Chat.Model.Events.OnInvite.toChatSharedEvents() = ChatSharedEvents.OnInvite(invite)
fun Chat.Model.Events.OnInviteAccepted.toChatSharedEvents() = ChatSharedEvents.OnInviteAccepted(topic)
fun Chat.Model.Events.OnInviteAccepted.toChatSharedEvents() = ChatSharedEvents.OnInviteAccepted(topic, invite)
fun Chat.Model.Events.OnMessage.toChatSharedEvents() = ChatSharedEvents.OnMessage(message)
fun Chat.Model.Events.OnLeft.toChatSharedEvents() = ChatSharedEvents.OnLeft(topic)
fun Chat.Model.Events.OnInviteRejected.toChatSharedEvents() = ChatSharedEvents.OnInviteRejected(topic)
fun Chat.Model.Events.OnInviteRejected.toChatSharedEvents() = ChatSharedEvents.OnInviteRejected(invite)
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ class ChatSharedViewModel(application: Application) : AndroidViewModel(applicati
_publicKey = publicKey
_privateKey = privateKey
// Note: This is only demo. Normally you want more security with private key
Log.d(TAG, "Registered identity successfully, account: $account, identityKey: $publicKey")
} else {
registerIdentity()
}
registerIdentity()
}

private fun goPublic() {
Expand All @@ -97,7 +95,7 @@ class ChatSharedViewModel(application: Application) : AndroidViewModel(applicati

val register = Chat.Params.Register(Chat.Type.AccountId(_account))
ChatClient.register(register, object : Chat.Listeners.Register {
override fun onSign(message: String): Chat.Model.Cacao.Signature {
override fun onSign(message: String): Chat.Model.Cacao.Signature? {
return CacaoSigner.sign(message, _privateKey.hexToBytes(), SignatureType.EIP191)
}

Expand All @@ -122,7 +120,7 @@ class ChatSharedViewModel(application: Application) : AndroidViewModel(applicati
ChatClient.invite(
invite,
{ Log.d(TAG, "Invited, inviter: $_account, invitee: $contact") },
{ error -> Log.e(tag(this), error.throwable.stackTraceToString()) }
{ error -> Log.e(tag(this@ChatSharedViewModel), error.throwable.stackTraceToString()) }
)

runBlocking(Dispatchers.Main) {
Expand All @@ -149,8 +147,7 @@ class ChatSharedViewModel(application: Application) : AndroidViewModel(applicati
fun rejectInvitation(id: Long?) {
id?.let {
val reject = Chat.Params.Reject(it)
ChatClient.reject(reject) { error -> Log.e(TAG, "Unable to find reject invitation: $error") }
updateInvites(id)
ChatClient.reject(reject, onSuccess = { updateInvites(id) }, onError = { error -> Log.e(TAG, "Unable to find reject invitation: $error") })
} ?: Log.e(TAG, "Unable to find id on reject invitation: $id")
}

Expand All @@ -161,7 +158,7 @@ class ChatSharedViewModel(application: Application) : AndroidViewModel(applicati
listOfMessages.add(MessageUI(userName, message, System.currentTimeMillis(), _account))
_listOfMessagesStateFlow.value = listOfMessages.toList()

ChatClient.message(Chat.Params.Message(topic, Chat.Type.ChatMessage(message))) { error ->
ChatClient.message(Chat.Params.Message(topic, Chat.Type.ChatMessage(message)), onSuccess = {}) { error ->
Log.e(TAG, error.throwable.stackTraceToString())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object Chat {
}

interface SignMessage : Listeners {
fun onSign(message: String): Model.Cacao.Signature
fun onSign(message: String): Model.Cacao.Signature?
}

interface Resolve : PublicKeyOnSuccess
Expand Down Expand Up @@ -93,8 +93,8 @@ object Chat {

sealed class Events : Model() {
data class OnInvite(val invite: Invite.Received) : Events()
data class OnInviteAccepted(val topic: String) : Events()
data class OnInviteRejected(val topic: String) : Events()
data class OnInviteAccepted(val topic: String, val invite: Invite.Sent) : Events()
data class OnInviteRejected(val invite: Invite.Sent) : Events()
data class OnMessage(val message: Message) : Events()
data class OnLeft(val topic: String) : Events()
}
Expand Down Expand Up @@ -143,5 +143,5 @@ object Chat {
data class GoPublic(val account: Type.AccountId) : Params()
}

const val DEFUALT_KEYSERVER_URL = "https://staging.keys.walletconnect.com"
const val DEFUALT_KEYSERVER_URL = "https://keys.walletconnect.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface ChatInterface {
fun goPublic(goPublic: Chat.Params.GoPublic, onSuccess: (String) -> Unit, onError: (Chat.Model.Error) -> Unit)
fun invite(invite: Chat.Params.Invite, onSuccess: (Long) -> Unit, onError: (Chat.Model.Error) -> Unit)
fun accept(accept: Chat.Params.Accept, onSuccess: (String) -> Unit, onError: (Chat.Model.Error) -> Unit)
fun reject(reject: Chat.Params.Reject, onError: (Chat.Model.Error) -> Unit)
fun message(message: Chat.Params.Message, onError: (Chat.Model.Error) -> Unit)
fun reject(reject: Chat.Params.Reject, onSuccess: () -> Unit, onError: (Chat.Model.Error) -> Unit)
fun message(message: Chat.Params.Message, onSuccess: () -> Unit, onError: (Chat.Model.Error) -> Unit)
fun ping(ping: Chat.Params.Ping, onSuccess: (String) -> Unit, onError: (Chat.Model.Error) -> Unit)
fun leave(leave: Chat.Params.Leave, onError: (Chat.Model.Error) -> Unit)
fun setContact(setContact: Chat.Params.SetContact, onError: (Chat.Model.Error) -> Unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ internal class ChatProtocol : ChatInterface {
}

@Throws(IllegalStateException::class)
override fun reject(reject: Chat.Params.Reject, onError: (Chat.Model.Error) -> Unit) = protocolFunction(onError) {
chatEngine.reject(reject.inviteId) { error -> onError(Chat.Model.Error(error)) }
override fun reject(reject: Chat.Params.Reject, onSuccess: () -> Unit, onError: (Chat.Model.Error) -> Unit) = protocolFunction(onError) {
chatEngine.reject(reject.inviteId, onSuccess) { error -> onError(Chat.Model.Error(error)) }
}

@Throws(IllegalStateException::class)
override fun message(message: Chat.Params.Message, onError: (Chat.Model.Error) -> Unit) = protocolFunction(onError) {
chatEngine.message(message.topic, message.toCommon()) { error -> onError(Chat.Model.Error(error)) }
override fun message(message: Chat.Params.Message, onSuccess: () -> Unit, onError: (Chat.Model.Error) -> Unit) = protocolFunction(onError) {
chatEngine.message(message.topic, message.toCommon(), onSuccess) { error -> onError(Chat.Model.Error(error)) }
}

@Throws(IllegalStateException::class)
Expand Down
Loading

0 comments on commit dde6fd4

Please sign in to comment.