Skip to content

Commit

Permalink
Merge pull request #11 from wakumo/feature/android-redirect
Browse files Browse the repository at this point in the history
feat: upgrade android bom to 1.9.3, add missing redirect field in ses…
  • Loading branch information
ludowkm authored May 11, 2023
2 parents 826fbd2 + b6b7912 commit cee5fcd
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@
## 1.0.3

* Update session request params, add example for sending request

## 1.0.4

* Upgrade to the latest SDKs Android Bom 1.9.3
* Add missing redirect field from session proposal
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {

dependencies {
implementation 'com.google.code.gson:gson:2.10'
implementation(platform("com.walletconnect:android-bom:1.8.0"))
implementation(platform("com.walletconnect:android-bom:1.9.3"))
implementation("com.walletconnect:android-core")
implementation("com.walletconnect:sign")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class WalletConnectV2Plugin : FlutterPlugin, MethodCallHandler, ActivityAware,

val walletDelegate = object : SignClient.WalletDelegate {
override fun onSessionProposal(sessionProposal: Sign.Model.SessionProposal) {
// TODO: it should be have redirect here!
// https://github.com/WalletConnect/WalletConnectKotlinV2/issues/792
onEvent(
name = "proposal", data = sessionProposal.toFlutterValue()
)
Expand Down Expand Up @@ -341,6 +339,7 @@ class WalletConnectV2Plugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result.success(null)
}
val handleError: (Sign.Model.Error) -> Unit = {
result.success(null)
onError("send_request_error", errorMessage = it.throwable.message ?: "")
}
SignClient.request(requestParams, onError = handleError, onSuccess = handleSuccess)
Expand Down Expand Up @@ -403,7 +402,7 @@ fun Sign.Model.SessionProposal.toFlutterValue(): Map<String, Any> {
"description" to this.description,
"url" to this.url,
"icons" to this.icons.map { it.toString() },
// TODO: should have redirect field here
"redirect" to this.redirect.ifBlank { null }
),
"namespaces" to this.requiredNamespaces.map { (key, value) ->
key to mapOf(
Expand Down
10 changes: 9 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:launchMode="singleInstance"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand All @@ -24,6 +24,14 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
<data android:scheme="wcexample" />
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
31 changes: 18 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:convert';
import 'dart:io';

import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
Expand Down Expand Up @@ -691,20 +690,26 @@ extension StringExt on String {
Future launch({int delayInMillis = 500}) async {
try {
await Future.delayed(Duration(milliseconds: delayInMillis));
final uri = Uri.parse(this);
if (Platform.isAndroid) {
final isAbleToLaunch = await canLaunchUrl(uri);
if (!isAbleToLaunch) return;
}
final uri = Uri.parse(contains(':') ? this : '$this:');
if (startsWith('http')) {
await launchUrl(
uri,
mode: LaunchMode.externalApplication,
);
} else if (contains('://')) {
await launchUrl(uri);
await _launchUniversalLink(uri);
} else {
await launchUrl(Uri.parse('$this://'));
await launchUrl(uri);
}
} catch (_) {}
}

Future _launchUniversalLink(Uri url) async {
try {
final bool nativeAppLaunchSucceeded = await launchUrl(
url,
mode: LaunchMode.externalNonBrowserApplication,
);
if (!nativeAppLaunchSucceeded) {
return await launchUrl(
url,
mode: LaunchMode.inAppWebView,
);
}
} catch (_) {}
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.3"
version: "1.0.4"
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, available for both Wallet and DApp to interact easier
version: 1.0.3
version: 1.0.4
homepage: https://avacus.cc
repository: https://github.com/wakumo/flutter-wallet-connect-v2

Expand Down

0 comments on commit cee5fcd

Please sign in to comment.