Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.1.14 - Improvements and layout changes in sample wallet #251

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.14

- Minor improvements

## 2.1.13

- Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion example/dapp/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>myflutterwallet</string>
<string>wcflutterwallet</string>
</array>
</dict>
</plist>
21 changes: 11 additions & 10 deletions example/dapp/lib/pages/connect_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:fl_toast/fl_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:qr_flutter/qr_flutter.dart';
// ignore: unused_import
import 'package:url_launcher/url_launcher_string.dart';
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
import 'package:walletconnect_flutter_v2_dapp/models/chain_metadata.dart';
import 'package:walletconnect_flutter_v2_dapp/utils/constants.dart';
Expand Down Expand Up @@ -156,23 +158,22 @@ class ConnectPageState extends State<ConnectPage> {
// It is currently safer to send chains approvals on optionalNamespaces
// but depending on Wallet implementation you may need to send some (for innstance eip155:1) as required
final ConnectResponse res = await widget.web3App.connect(
requiredNamespaces: {
'eip155': const RequiredNamespace(
chains: [],
methods: MethodsConstants.requiredMethods,
events: EventsConstants.requiredEvents,
),
},
optionalNamespaces: {
'eip155': RequiredNamespace(
chains: _selectedChains.map((c) => c.chainId).toList(),
methods: MethodsConstants.optionalMethods,
events: EventsConstants.optionalEvents,
methods: MethodsConstants.allMethods,
events: EventsConstants.allEvents,
),
},
);

_showQrCode(res);
final encodedUri = Uri.encodeComponent(res.uri.toString());
final uri = 'wcflutterwallet://wc?uri=$encodedUri';
if (await canLaunchUrlString(uri)) {
launchUrlString(uri, mode: LaunchMode.externalApplication);
} else {
_showQrCode(res);
}

try {
debugPrint('Awaiting session proposal settlement');
Expand Down
19 changes: 9 additions & 10 deletions example/dapp/lib/widgets/session_widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
import 'package:walletconnect_flutter_v2_dapp/models/chain_metadata.dart';
import 'package:walletconnect_flutter_v2_dapp/utils/constants.dart';
Expand Down Expand Up @@ -183,22 +184,20 @@ class SessionWidgetState extends State<SessionWidget> {
),
child: ElevatedButton(
onPressed: () async {
final walletUrl = widget.session.peer.metadata.redirect?.native;
if ((walletUrl ?? '').isNotEmpty) {
launchUrlString(
walletUrl!,
mode: LaunchMode.externalApplication,
);
}
Future<dynamic> future = callChainMethod(
chainMetadata.type,
method,
chainMetadata,
address,
);
// print('got here');
// print(await future);
// if (chainMetadata.type == ChainType.eip155) {
// future =
// }
MethodDialog.show(
context,
method,
future,
);
MethodDialog.show(context, method, future);
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Expand Down
75 changes: 4 additions & 71 deletions example/dapp/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
name: walletconnect_flutter_v2_dapp
description: An example dApp for WalletConnect v2 built with Flutter.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none"

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
sdk: '>=2.18.6 <3.0.0'
sdk: ">=2.18.6 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
qr_flutter: ^4.0.0
json_annotation: ^4.8.1
walletconnect_flutter_v2:
path: ../..
fl_toast: ^3.1.0
# kadena_dart_sdk: ^2.0.0
url_launcher: ^6.2.2
walletconnect_flutter_v2:
path: ../..

dev_dependencies:
flutter_test:
Expand All @@ -50,51 +27,7 @@ dev_dependencies:
json_serializable: ^6.5.3
dependency_validator: ^3.2.2

# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
4 changes: 2 additions & 2 deletions example/wallet/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="wallet"
android:label="Web3Wallet Flutter"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -27,7 +27,7 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myflutterwallet" />
<data android:scheme="wcflutterwallet" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,65 @@
package com.walletconnect.flutterwallet

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.annotation.NonNull

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel

class MainActivity: FlutterActivity() {
private val eventsChannel = "com.walletconnect.flutterwallet/events"
private val methodsChannel = "com.walletconnect.flutterwallet/methods"

private var initialLink: String? = null
private var linksReceiver: BroadcastReceiver? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val intent: Intent? = intent
initialLink = intent?.data?.toString()

EventChannel(flutterEngine?.dartExecutor?.binaryMessenger, eventsChannel).setStreamHandler(
object : EventChannel.StreamHandler {
override fun onListen(args: Any?, events: EventChannel.EventSink) {
linksReceiver = createChangeReceiver(events)
}
override fun onCancel(args: Any?) {
linksReceiver = null
}
}
)

MethodChannel(flutterEngine!!.dartExecutor.binaryMessenger, methodsChannel).setMethodCallHandler { call, result ->
if (call.method == "initialLink") {
if (initialLink != null) {
result.success(initialLink)
}
}
}
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (intent.action === Intent.ACTION_VIEW) {
linksReceiver?.onReceive(this.applicationContext, intent)
}
}

fun createChangeReceiver(events: EventChannel.EventSink): BroadcastReceiver? {
return object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val dataString = intent.dataString ?:
events.error("UNAVAILABLE", "Link unavailable", null)
events.success(dataString)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#F5EDFF</color>
</resources>
6 changes: 6 additions & 0 deletions example/wallet/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
trunk:
Expand All @@ -93,6 +96,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Expand All @@ -111,6 +116,7 @@ SPEC CHECKSUMS:
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

Expand Down
Loading