Skip to content

Commit 2d85ed0

Browse files
authored
Merge pull request #134 from WalletConnect/develop
Beta 100 Release
2 parents 03f135b + c0acde3 commit 2d85ed0

File tree

261 files changed

+7933
-5057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+7933
-5057
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ lint/tmp/
8888

8989
# Android Profiling
9090
*.hprof
91+
92+
# Project ID
93+
/samples_common/src/main/res/values/project_id.xml

README.md

Lines changed: 141 additions & 142 deletions
Large diffs are not rendered by default.

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath("com.android.tools.build:gradle:7.1.0")
8+
classpath("com.android.tools.build:gradle:7.1.2")
99
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
1010
classpath("com.squareup.sqldelight:gradle-plugin:$sqlDelightVersion")
1111
}

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.gradle.api.JavaVersion
22
import org.gradle.kotlin.dsl.DependencyHandlerScope
33

4-
const val kotlinVersion = "1.5.31"
4+
const val kotlinVersion = "1.6.10"
55
val jvmVersion = JavaVersion.VERSION_11
66
const val sqlDelightVersion = "1.5.2"
77

@@ -22,13 +22,13 @@ fun DependencyHandlerScope.lifecycle() {
2222
val lifecycleVersion = "2.3.1"
2323
"implementation"("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
2424
"implementation"("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
25-
"implementation"("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01")
25+
"implementation"("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
2626
}
2727

2828
fun DependencyHandlerScope.navigationComponent() {
29-
val navVersion = "2.3.5"
30-
"implementation"("androidx.navigation:navigation-fragment-ktx:$navVersion")
31-
"implementation"("androidx.navigation:navigation-ui-ktx:$navVersion")
29+
val navVersion = "2.4.1"
30+
"api"("androidx.navigation:navigation-fragment-ktx:$navVersion")
31+
"api"("androidx.navigation:navigation-ui-ktx:$navVersion")
3232
}
3333

3434
fun DependencyHandlerScope.coroutines() {
@@ -50,7 +50,7 @@ fun DependencyHandlerScope.scarlet() {
5050
}
5151

5252
fun DependencyHandlerScope.moshi() {
53-
val moshiVersion = "1.12.0"
53+
val moshiVersion = "1.13.0"
5454
"implementation"("com.squareup.moshi:moshi-adapters:$moshiVersion")
5555
"implementation"("com.squareup.moshi:moshi-kotlin:$moshiVersion")
5656
"kapt"("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion")
@@ -88,6 +88,11 @@ fun DependencyHandlerScope.koin() {
8888
"api"("io.insert-koin:koin-android:$koinVersion")
8989
}
9090

91+
fun DependencyHandlerScope.glide_N_kapt() {
92+
"implementation"("com.github.bumptech.glide:glide:4.12.0")
93+
"kapt"("com.github.bumptech.glide:compiler:4.12.0")
94+
}
95+
9196
fun DependencyHandlerScope.jUnit5() {
9297
val jUnit5Version = "5.7.2"
9398

sample/build.gradle.kts renamed to dapp/build.gradle.kts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@ plugins {
55
}
66

77
android {
8-
compileSdk = 30
8+
compileSdk = 32
99

1010
defaultConfig {
11-
applicationId = "com.walletconnect.sample"
11+
applicationId = "com.walletconnect.dapp"
1212
minSdk = 24
13-
targetSdk = 30
13+
targetSdk = 32
1414
versionCode = 1
1515
versionName = "1.0"
1616

1717
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1818
}
1919

20-
buildFeatures {
21-
viewBinding = true
22-
}
23-
2420
buildTypes {
25-
getByName("release") {
21+
release {
2622
isMinifyEnabled = false
2723
signingConfig = signingConfigs.getByName("debug")
2824
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
@@ -37,24 +33,20 @@ android {
3733
kotlinOptions {
3834
jvmTarget = jvmVersion.toString()
3935
}
36+
37+
buildFeatures {
38+
viewBinding = true
39+
}
4040
}
4141

4242
dependencies {
4343
implementation(project(":walletconnectv2"))
44-
// implementation("com.github.walletconnect-labs.walletconnectkotlinv2:walletconnectkotlinv2:1.0.0-alpha01")
44+
implementation(project(":samples_common"))
4545

46+
glide_N_kapt()
4647
implementation("com.github.kenglxn.QRGen:android:2.6.0")
4748

48-
coroutines()
49-
navigationComponent()
50-
ktxCore()
51-
lifecycle()
52-
scanner()
53-
54-
implementation("com.github.bumptech.glide:glide:4.12.0")
55-
kapt("com.github.bumptech.glide:compiler:4.12.0")
56-
implementation("androidx.appcompat:appcompat:1.3.1")
57-
implementation("com.google.android.material:material:1.4.0")
58-
implementation("androidx.constraintlayout:constraintlayout:2.1.1")
59-
implementation("androidx.legacy:legacy-support-v4:1.0.0")
49+
testImplementation("junit:junit:4.13.2")
50+
androidTestImplementation("androidx.test.ext:junit:1.1.3")
51+
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
6052
}

sample/proguard-rules.pro renamed to dapp/proguard-rules.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add project specific ProGuard rules here.
22
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.kts.
3+
# proguardFiles setting in build.gradle.
44
#
55
# For more details, see
66
# http://developer.android.com/guide/developing/tools/proguard.html

dapp/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.walletconnect.dapp">
4+
5+
<application
6+
android:name=".DappSampleApplication"
7+
android:allowBackup="true"
8+
android:icon="@drawable/ic_walletconnect_circle_blue"
9+
android:label="@string/app_name"
10+
android:roundIcon="@drawable/ic_walletconnect_circle_blue"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.WalletConnect">
13+
14+
<activity
15+
android:name="com.walletconnect.dapp.ui.host.DappSampleActivity"
16+
android:exported="true"
17+
android:screenOrientation="portrait">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
</manifest>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.walletconnect.dapp
2+
3+
import android.app.Application
4+
import com.walletconnect.sample_common.R
5+
import com.walletconnect.sample_common.WALLET_CONNECT_PROD_RELAY_URL
6+
import com.walletconnect.walletconnectv2.client.WalletConnect
7+
import com.walletconnect.walletconnectv2.client.WalletConnectClient
8+
9+
class DappSampleApplication: Application() {
10+
11+
override fun onCreate() {
12+
super.onCreate()
13+
14+
// This is strictly for sample purposes
15+
val projectId = resources.getString(R.string.project_id)
16+
17+
// Sample of how to use parts of a URI to initialize the WalletConnect SDK
18+
// val initParts = WalletConnect.Params.Init(
19+
// application = this,
20+
// useTls = true,
21+
// hostName = WALLET_CONNECT_PROD_RELAY_URL,
22+
// projectId = projectId, //TODO: register at https://walletconnect.com/register to get a project ID
23+
// metadata = WalletConnect.Model.AppMetaData(
24+
// name = "Kotlin Dapp",
25+
// description = "Dapp description",
26+
// url = "example.dapp",
27+
// icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media")
28+
// )
29+
// )
30+
31+
// Sample of how to use a URI to initialize the WalletConnect SDK
32+
val initString = WalletConnect.Params.Init(
33+
application = this,
34+
relayServerUrl = "wss://$WALLET_CONNECT_PROD_RELAY_URL?projectId=$projectId", //TODO: register at https://walletconnect.com/register to get a project ID
35+
metadata = WalletConnect.Model.AppMetaData(
36+
name = "Kotlin Dapp",
37+
description = "Dapp description",
38+
url = "example.dapp",
39+
icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media")
40+
)
41+
)
42+
43+
WalletConnectClient.initialize(initString)
44+
}
45+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.walletconnect.dapp.domain
2+
3+
import com.walletconnect.walletconnectv2.client.WalletConnect
4+
import com.walletconnect.walletconnectv2.client.WalletConnectClient
5+
import kotlinx.coroutines.CoroutineScope
6+
import kotlinx.coroutines.Dispatchers
7+
import kotlinx.coroutines.SupervisorJob
8+
import kotlinx.coroutines.flow.MutableSharedFlow
9+
import kotlinx.coroutines.flow.SharedFlow
10+
import kotlinx.coroutines.flow.asSharedFlow
11+
import kotlinx.coroutines.launch
12+
13+
object DappDelegate : WalletConnectClient.DappDelegate {
14+
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
15+
private val _wcEventModels: MutableSharedFlow<WalletConnect.Model?> = MutableSharedFlow()
16+
val wcEventModels: SharedFlow<WalletConnect.Model?> = _wcEventModels.asSharedFlow()
17+
18+
var selectedSessionTopic: String? = null
19+
private set
20+
21+
init {
22+
WalletConnectClient.setDappDelegate(this)
23+
}
24+
25+
override fun onSessionApproved(approvedSession: WalletConnect.Model.ApprovedSession) {
26+
selectedSessionTopic = approvedSession.topic
27+
28+
scope.launch {
29+
_wcEventModels.emit(approvedSession)
30+
}
31+
}
32+
33+
override fun onSessionRejected(rejectedSession: WalletConnect.Model.RejectedSession) {
34+
scope.launch {
35+
_wcEventModels.emit(rejectedSession)
36+
}
37+
}
38+
39+
override fun onSessionUpdateAccounts(updatedSessionAccounts: WalletConnect.Model.UpdatedSessionAccounts) {
40+
scope.launch {
41+
_wcEventModels.emit(updatedSessionAccounts)
42+
}
43+
}
44+
45+
override fun onSessionUpdateMethods(updatedSessionMethods: WalletConnect.Model.UpdatedSessionMethods) {
46+
scope.launch {
47+
_wcEventModels.emit(updatedSessionMethods)
48+
}
49+
}
50+
51+
override fun onSessionUpdateEvents(updatedSessionEvents: WalletConnect.Model.UpdatedSessionEvents) {
52+
scope.launch {
53+
_wcEventModels.emit(updatedSessionEvents)
54+
}
55+
}
56+
57+
override fun onSessionDelete(deletedSession: WalletConnect.Model.DeletedSession) {
58+
deselectAccountDetails()
59+
60+
scope.launch {
61+
_wcEventModels.emit(deletedSession)
62+
}
63+
}
64+
65+
override fun onUpdateSessionExpiry(session: WalletConnect.Model.Session) {
66+
scope.launch {
67+
_wcEventModels.emit(session)
68+
}
69+
}
70+
71+
override fun onSessionRequestResponse(response: WalletConnect.Model.SessionRequestResponse) {
72+
scope.launch {
73+
_wcEventModels.emit(response)
74+
}
75+
}
76+
77+
fun deselectAccountDetails() {
78+
selectedSessionTopic = null
79+
}
80+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.walletconnect.dapp.ui
2+
3+
sealed class SampleDappEvents {
4+
5+
object SessionApproved : SampleDappEvents()
6+
7+
object SessionRejected : SampleDappEvents()
8+
9+
data class PingSuccess(val topic: String) : SampleDappEvents()
10+
11+
object PingError : SampleDappEvents()
12+
13+
object Disconnect : SampleDappEvents()
14+
15+
data class RequestSuccess(val result: String) : SampleDappEvents()
16+
17+
data class RequestPeerError(val errorMsg: String) : SampleDappEvents()
18+
19+
data class RequestError(val exceptionMsg: String) : SampleDappEvents()
20+
21+
object NoAction : SampleDappEvents()
22+
}

0 commit comments

Comments
 (0)