From 75b2590a7002a0c7ef1c0ee9633aac58eed0c643 Mon Sep 17 00:00:00 2001 From: Jemshit Iskenderov Date: Sat, 13 Aug 2022 10:02:07 +0300 Subject: [PATCH] Upgrade dependencies, Remove outdated (#47) * * Upgrade Kotlin 1.5.31 -> 1.6.21 * Upgrade Grade Build Tool 4.0.0 -> 7.2.1 * Upgrade Gradle 6.1.1 -> 7.4.2 * sourceCompatibility/targetCompatibility Java 8 -> Java 11 * (sample) app module depends on library module directly instead of using Jitpack * Upgrade all dependencies - Remove jcenter() * + CHANGELOG.md * + ViewBinding - Kotlin Android Extensions * * Fix trustwallet-core dep. version * * Update CHANGELOG.md Co-authored-by: Viacheslav Kulish <32914239+vcoolish@users.noreply.github.com> --- CHANGELOG.md | 86 +++++++++++++++++++ app/build.gradle | 25 +++--- .../walletconnect/sample/MainActivity.kt | 39 +++++---- build.gradle | 8 +- gradle/wrapper/gradle-wrapper.properties | 2 +- walletconnect/build.gradle | 19 ++-- .../com/trustwallet/walletconnect/WCClient.kt | 1 + 7 files changed, 134 insertions(+), 46 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..308d585 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,86 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- [Sample app](app) +- [CHANGELOG.md](CHANGELOG.md) +- `ViewBinding` + +### Changed + +- [README.md](README.md) +- Upgrade Kotlin, Gradle, all dependencies +- sourceCompatibility/targetCompatibility Java 8 -> Java 11 +- (sample) app module depends on library module directly instead of using Jitpack + +### Removed + +- jcenter() +- `appcompat-v7` dependency from library +- `kotlin android extensions` + +### Fixed + +- `trustwallet:wallet-core` dep. version in sample app + +## [1.5.4] - 2021-11-11 + +### Changed + +- Allow chain changes on session approve + +## [1.5.3] - 2021-10-06 + +### Added + +- EIP-1559 fields to ETH transaction model + +## [1.5.2] - 2021-05-15 + +### Fixed + +- Parse ETH transaction payload params ([#26](https://github.com/trustwallet/wallet-connect-kotlin/issues/26)) + +## [1.5.1] - 2021-05-14 + +### Fixed + +- Parse ETH transaction payload params ([#26](https://github.com/trustwallet/wallet-connect-kotlin/issues/26)) + +## [1.5.0] - 2020-09-30 + +### Added + +- Persist chainId + +## [1.4.9] - 2020-06-16 + +### Added + +- Decode gas and gasLimit in WCEthereumTransaction + +### Changed + +- Upgrade Gradle dependencies + + +[Unreleased]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.0.0...HEAD + +[1.5.4]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.5.3...1.5.4 + +[1.5.3]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.5.2...1.5.3 + +[1.5.2]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.5.1...1.5.2 + +[1.5.1]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.5.0...1.5.1 + +[1.5.0]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.4.9...1.5.0 + +[1.4.9]: https://github.com/trustwallet/wallet-connect-kotlin/compare/1.4.8...1.4.9 \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d3963b6..21f9231 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,8 +2,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - android { compileSdkVersion 31 defaultConfig { @@ -14,6 +12,9 @@ android { versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + buildFeatures { + viewBinding = true + } buildTypes { release { minifyEnabled false @@ -21,23 +22,23 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(":walletconnect") - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31" - implementation 'androidx.appcompat:appcompat:1.4.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.2' - implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.google.android.material:material:1.6.1' - implementation "com.squareup.okhttp3:okhttp:4.9.1" - implementation "com.google.code.gson:gson:2.8.8" + implementation "com.squareup.okhttp3:okhttp:4.9.3" + implementation "com.google.code.gson:gson:2.9.0" - implementation "com.github.TrustWallet:wallet-connect-kotlin:1.5.4" - implementation "com.trustwallet:wallet-core:2.6.33" + implementation "com.trustwallet:wallet-core:2.9.5" } diff --git a/app/src/main/java/com/trustwallet/walletconnect/sample/MainActivity.kt b/app/src/main/java/com/trustwallet/walletconnect/sample/MainActivity.kt index 1e7b3f2..dbf7d08 100644 --- a/app/src/main/java/com/trustwallet/walletconnect/sample/MainActivity.kt +++ b/app/src/main/java/com/trustwallet/walletconnect/sample/MainActivity.kt @@ -16,14 +16,15 @@ import com.trustwallet.walletconnect.models.binance.WCBinanceTxConfirmParam import com.trustwallet.walletconnect.models.ethereum.WCEthereumSignMessage import com.trustwallet.walletconnect.models.ethereum.WCEthereumTransaction import com.trustwallet.walletconnect.models.session.WCSession -import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.activity_main.view.* +import com.trustwallet.walletconnect.sample.databinding.ActivityMainBinding import okhttp3.OkHttpClient import wallet.core.jni.CoinType import wallet.core.jni.PrivateKey class MainActivity : AppCompatActivity() { + private lateinit var binding: ActivityMainBinding + private val wcClient by lazy { WCClient(GsonBuilder(), OkHttpClient()) } @@ -37,11 +38,18 @@ class MainActivity : AppCompatActivity() { private var remotePeerMeta: WCPeerMeta? = null + companion object { + init { + System.loadLibrary("TrustWalletCore") + } + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) - addressInput.editText?.setText(address) + binding.addressInput.editText?.setText(address) wcClient.onDisconnect = { _, _ -> onDisconnect() } wcClient.onFailure = { t -> onFailure(t) } wcClient.onSessionRequest = { _, peer -> onSessionRequest(peer) } @@ -62,9 +70,9 @@ class MainActivity : AppCompatActivity() { private fun setupConnectButton() { runOnUiThread { - connectButton.text = "Connect" - connectButton.setOnClickListener { - connect(uriInput.editText?.text?.toString() ?: return@setOnClickListener) + binding.connectButton.text = "Connect" + binding.connectButton.setOnClickListener { + connect(binding.uriInput.editText?.text?.toString() ?: return@setOnClickListener) } } } @@ -84,11 +92,11 @@ class MainActivity : AppCompatActivity() { } fun approveSession() { - val address = addressInput.editText?.text?.toString() ?: address - val chainId = chainInput.editText?.text?.toString()?.toIntOrNull() ?: 1 + val address = binding.addressInput.editText?.text?.toString() ?: address + val chainId = binding.chainInput.editText?.text?.toString()?.toIntOrNull() ?: 1 wcClient.approveSession(listOf(address), chainId) - connectButton.text = "Kill Session" - connectButton.setOnClickListener { + binding.connectButton.text = "Kill Session" + binding.connectButton.setOnClickListener { disconnect() } } @@ -158,8 +166,8 @@ class MainActivity : AppCompatActivity() { private fun onGetAccounts(id: Long) { val account = WCAccount( - chainInput.editText?.text?.toString()?.toIntOrNull() ?: 1, - addressInput.editText?.text?.toString() ?: address, + binding.chainInput.editText?.text?.toString()?.toIntOrNull() ?: 1, + binding.addressInput.editText?.text?.toString() ?: address, ) wcClient.approveRequest(id, account) } @@ -175,9 +183,4 @@ class MainActivity : AppCompatActivity() { .toByteArray() } - companion object { - init { - System.loadLibrary("TrustWalletCore") - } - } } diff --git a/build.gradle b/build.gradle index f64eeeb..2116de2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.5.31' + ext.kotlin_version = '1.6.21' repositories { google() - jcenter() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.0' + classpath 'com.android.tools.build:gradle:7.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -19,7 +18,6 @@ buildscript { allprojects { repositories { google() - jcenter() mavenCentral() maven { url 'https://jitpack.io' } maven { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1ad6372..69d8b16 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip diff --git a/walletconnect/build.gradle b/walletconnect/build.gradle index 0f6ea75..190adfc 100644 --- a/walletconnect/build.gradle +++ b/walletconnect/build.gradle @@ -5,12 +5,12 @@ apply plugin: 'kotlin-android' group='com.github.TrustWallet' android { - compileSdkVersion 28 + compileSdkVersion 31 defaultConfig { minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -31,20 +31,19 @@ android { } } compileOptions { - sourceCompatibility = "1.8" - targetCompatibility = 1.8 + sourceCompatibility = "11" + targetCompatibility = 11 } - buildToolsVersion = '28.0.3' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.squareup.okhttp3:okhttp:4.7.2' - implementation 'com.google.code.gson:gson:2.8.6' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation 'com.squareup.okhttp3:okhttp:4.9.3' + implementation 'com.google.code.gson:gson:2.9.0' implementation 'com.github.salomonbrys.kotson:kotson:2.5.0' - implementation 'com.android.support:appcompat-v7:28.0.0' - testImplementation 'junit:junit:4.13' + + testImplementation 'junit:junit:4.13.2' testImplementation 'org.robolectric:robolectric:4.3' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/walletconnect/src/main/java/com/trustwallet/walletconnect/WCClient.kt b/walletconnect/src/main/java/com/trustwallet/walletconnect/WCClient.kt index 13041eb..b19a746 100644 --- a/walletconnect/src/main/java/com/trustwallet/walletconnect/WCClient.kt +++ b/walletconnect/src/main/java/com/trustwallet/walletconnect/WCClient.kt @@ -344,6 +344,7 @@ open class WCClient ( .firstOrNull() ?: throw InvalidJsonRpcParamsException(request.id) onWalletAddNetwork(request.id, param) } + null -> TODO() } }