Skip to content

Commit

Permalink
Merge pull request #7 from wakumo/feature/upgrade-latest-sdk
Browse files Browse the repository at this point in the history
Upgrade the latest SDK for Android
  • Loading branch information
ludowkm authored Apr 11, 2023
2 parents 8bc4e38 + 71ded45 commit 71ef639
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 45 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
## 1.0.0

* Official support for DApps by creating Pairing, connect with Wallet, send Request and receive Response

## 1.0.1

* Upgrade to the latest SDKs Android Bom 1.8.0
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'com.avacus.wallet_connect_v2'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
Expand Down Expand Up @@ -47,7 +47,7 @@ android {

dependencies {
implementation 'com.google.code.gson:gson:2.10'
implementation(platform("com.walletconnect:android-bom:1.4.1"))
implementation(platform("com.walletconnect:android-bom:1.8.0"))
implementation("com.walletconnect:android-core")
implementation("com.walletconnect:sign")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,17 @@ class WalletConnectV2Plugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result.success(null)
}
"connect" -> {
CoreClient.Relay.connect {
onError("connect_error", errorMessage = it)
val handleError: (Core.Model.Error) -> Unit = {
onError("connect_error", errorMessage = it.throwable.message ?: "")
}
CoreClient.Relay.connect(onError = handleError)
result.success(null)
}
"disconnect" -> {
CoreClient.Relay.disconnect {
onError("disconnect_error", errorMessage = it)
val handleError: (Core.Model.Error) -> Unit = {
onError("disconnect_error", errorMessage = it.throwable.message ?: "")
}
CoreClient.Relay.disconnect(onError = handleError)
result.success(null)
}
"pair" -> {
Expand Down Expand Up @@ -333,12 +335,13 @@ class WalletConnectV2Plugin : FlutterPlugin, MethodCallHandler, ActivityAware,
chainId = arguments["chainId"] as String,
params = gson.toJson(arguments["params"])
)
SignClient.request(requestParams, onError = {
val handleSuccess: (Sign.Model.SentRequest) -> Unit = {
result.success(null)
}
val handleError: (Sign.Model.Error) -> Unit = {
onError("send_request_error", errorMessage = it.throwable.message ?: "")
}, onSuccess = {
result.success(null)
})
}
SignClient.request(requestParams, onError = handleError, onSuccess = handleSuccess)
}
else -> {
result.notImplemented()
Expand Down Expand Up @@ -403,14 +406,7 @@ fun Sign.Model.SessionProposal.toFlutterValue(): Map<String, Any> {
key to mapOf(
"chains" to value.chains,
"methods" to value.methods,
"events" to value.events,
"extensions" to value.extensions?.map {
mapOf(
"chains" to it.chains,
"methods" to it.methods,
"events" to it.events,
)
},
"events" to value.events
)
}.toMap()
)
Expand All @@ -430,14 +426,7 @@ fun Sign.Model.Session.toFlutterValue(): Map<String, Any> {
key to mapOf(
"accounts" to value.accounts,
"methods" to value.methods,
"events" to value.events,
"extensions" to value.extensions?.map {
mapOf(
"accounts" to it.accounts,
"methods" to it.methods,
"events" to it.events,
)
},
"events" to value.events
)
}.toMap()
)
Expand Down
1 change: 1 addition & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ android {
exclude "META-INF/DEPENDENCIES"
exclude "META-INF/LICENSE.md"
exclude "META-INF/NOTICE.md"
exclude "META-INF/versions/9/previous-compilation-data.bin"
}
}

Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:7.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
19 changes: 5 additions & 14 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
bool _isLoading = false;
bool _isInitiated = false;
bool _isForeground = true;
bool _isBackground = false;

@override
void initState() {
Expand Down Expand Up @@ -181,7 +180,7 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
};

_walletConnectV2Plugin.onEventError = (code, message) {
_showDialog(child: Text(message));
_showDialog(child: Text('code: $code | message: $message'));
};

_walletConnectV2Plugin.onSessionRequest = (request) async {
Expand Down Expand Up @@ -639,27 +638,19 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
super.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.resumed:
_isBackground = false;
_isForeground = true;
debugPrint('---: DO CONNECT');
if (_isInitiated) {
_walletConnectV2Plugin.connect();
}
break;
case AppLifecycleState.inactive:
_isForeground = false;
if (!_isBackground) {
debugPrint('---: DO DISCONNECT');
if (_isInitiated) {
_walletConnectV2Plugin.disconnect();
}
}
break;
case AppLifecycleState.paused:
_isForeground = false;
_isBackground = true;
debugPrint('---: DO DISCONNECT');
if (_isInitiated) {
_walletConnectV2Plugin.disconnect();
}
break;
case AppLifecycleState.detached:
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "1.0.0"
watcher:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wallet_connect_v2
description: Wallet Connect V2 for Flutter
version: 1.0.0
version: 1.0.1
homepage: https://avacus.cc
repository: https://github.com/wakumo/flutter-wallet-connect-v2

Expand Down

0 comments on commit 71ef639

Please sign in to comment.