From 53bb7ab151226304fe74f5a1652c0d0f2fe795e7 Mon Sep 17 00:00:00 2001
From: Alfreedom <00tango.bromine@icloud.com>
Date: Fri, 5 Jan 2024 19:09:48 +0100
Subject: [PATCH 1/5] Fix an Android bug happening when sending a request from
a dApp in a different device than the paired wallet
---
CHANGELOG.md | 4 +
example/android/gradle.properties | 4 +-
example/ios/Runner.xcodeproj/project.pbxproj | 12 +-
example/ios/Runner/Info.plist | 4 +-
example/pubspec.lock | 2 +-
example/pubspec.yaml | 2 +-
lib/constants/string_constants.dart | 2 +-
lib/pages/connect_wallet_page.dart | 4 +-
.../explorer_service/explorer_service.dart | 57 +++---
.../explorer_service/i_explorer_service.dart | 18 +-
.../storage_service/i_storage_service.dart | 1 +
.../storage_service/storage_service.dart | 5 +
lib/services/w3m_service/i_w3m_service.dart | 21 +-
lib/services/w3m_service/w3m_service.dart | 65 ++----
lib/version.dart | 2 +-
pubspec.yaml | 2 +-
test/mock_classes.mocks.dart | 187 +++++++++---------
17 files changed, 188 insertions(+), 204 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d9f7b16..7b918152 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 3.0.21
+
+- Fix an Android bug happening when sending a request from a dApp in a different device than the paired wallet
+
## 3.0.20
- Minor improvements
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 8cd29c5f..68b9b0ae 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,5 +1,5 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
-versionName=3.0.20
-versionCode=20
+versionName=3.0.21
+versionCode=21
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 80624b43..9897cced 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -470,7 +470,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
@@ -496,7 +496,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -514,7 +514,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -530,7 +530,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample.RunnerTests;
@@ -655,7 +655,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
@@ -686,7 +686,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
- CURRENT_PROJECT_VERSION = 20;
+ CURRENT_PROJECT_VERSION = 21;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = W5R8AG9K22;
ENABLE_BITCODE = NO;
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index 78c62300..94206223 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -19,7 +19,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 3.0.20
+ 3.0.21
CFBundleSignature
????
CFBundleURLTypes
@@ -34,7 +34,7 @@
CFBundleVersion
- 20
+ 21
ITSAppUsesNonExemptEncryption
LSApplicationQueriesSchemes
diff --git a/example/pubspec.lock b/example/pubspec.lock
index b697a376..07b7d9cc 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1115,7 +1115,7 @@ packages:
path: ".."
relative: true
source: path
- version: "3.0.20"
+ version: "3.0.21"
web_socket_channel:
dependency: transitive
description:
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index d61ad5ab..6e82dcaa 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -3,7 +3,7 @@ description: A dApp showing how to use WalletConnect v2 with Flutter
publish_to: "none"
-version: 3.0.20
+version: 3.0.21
environment:
sdk: ">=3.0.1 <4.0.0"
diff --git a/lib/constants/string_constants.dart b/lib/constants/string_constants.dart
index 2b37326e..6fab07c6 100644
--- a/lib/constants/string_constants.dart
+++ b/lib/constants/string_constants.dart
@@ -29,7 +29,7 @@ class StringConstants {
// Storage
static const String recentWalletId = 'w3m_recentWallet';
- static const String walletData = 'w3m_walletData';
+ static const String connectedWalletData = 'w3m_walletData';
static const String selectedChainId = 'w3m_selectedChainId';
// Urls
diff --git a/lib/pages/connect_wallet_page.dart b/lib/pages/connect_wallet_page.dart
index 46a70f46..c15e68b9 100644
--- a/lib/pages/connect_wallet_page.dart
+++ b/lib/pages/connect_wallet_page.dart
@@ -82,7 +82,9 @@ class _ConnectWalletPageState extends State
kNavbarHeight -
(kPadding16 * 2);
//
- final walletRedirect = _service!.selectedWalletRedirect;
+ final walletRedirect = explorerService.instance?.getWalletRedirect(
+ _service!.selectedWallet,
+ );
final webOnlyWallet = walletRedirect?.webOnly == true;
final mobileOnlyWallet = walletRedirect?.mobileOnly == true;
//
diff --git a/lib/services/explorer_service/explorer_service.dart b/lib/services/explorer_service/explorer_service.dart
index 79af140b..a21955cd 100644
--- a/lib/services/explorer_service/explorer_service.dart
+++ b/lib/services/explorer_service/explorer_service.dart
@@ -125,7 +125,7 @@ class ExplorerService implements IExplorerService {
Future _getRecentWalletAndOrder() async {
W3MWalletInfo? walletInfo;
final walletString = storageService.instance.getString(
- StringConstants.walletData,
+ StringConstants.connectedWalletData,
);
final recentWalletId = storageService.instance.getString(
StringConstants.recentWalletId,
@@ -234,16 +234,41 @@ class ExplorerService implements IExplorerService {
}
@override
- Future storeConnectedWalletData(W3MWalletInfo? walletInfo) async {
+ Future storeConnectedWallet(W3MWalletInfo? walletInfo) async {
if (walletInfo == null) return;
final walletDataString = jsonEncode(walletInfo.toJson());
await storageService.instance.setString(
- StringConstants.walletData,
+ StringConstants.connectedWalletData,
walletDataString,
);
await _updateRecentWalletId(walletInfo);
}
+ @override
+ W3MWalletInfo? getConnectedWallet() {
+ try {
+ final walletString = storageService.instance.getString(
+ StringConstants.connectedWalletData,
+ defaultValue: '',
+ );
+ if (walletString!.isNotEmpty) {
+ return W3MWalletInfo.fromJson(jsonDecode(walletString));
+ }
+ } catch (e, s) {
+ W3MLoggerUtil.logger.e(
+ '[$runtimeType] error getConnectedWallet:',
+ error: e,
+ stackTrace: s,
+ );
+ }
+ return null;
+ }
+
+ @override
+ Future deleteConnectedWallet() async {
+ await storageService.instance.clearKey(StringConstants.connectedWalletData);
+ }
+
Future _updateRecentWalletId(
W3MWalletInfo? walletInfo, {
String? walletId,
@@ -322,29 +347,11 @@ class ExplorerService implements IExplorerService {
}
@override
- WalletRedirect? getWalletRedirect(Listing listing) {
- final wallet = listings.value.firstWhereOrNull(
- (item) => listing.id == item.listing.id,
- );
- if (wallet == null) {
- return null;
- }
- return WalletRedirect(
- mobile: wallet.listing.mobileLink,
- desktop: wallet.listing.desktopLink,
- web: wallet.listing.webappLink,
- );
- }
+ WalletRedirect? getWalletRedirect(W3MWalletInfo? walletInfo) {
+ if (walletInfo == null) return null;
- @override
- Future tryWalletRedirectByName(String? name) async {
- if (name == null) return null;
- final results = await _fetchListings(
- params: RequestParams(page: 1, entries: 100, search: name),
- updateCount: false,
- );
- final wallet = results.firstWhereOrNull(
- (item) => item.listing.name.toLowerCase() == name.toLowerCase(),
+ final wallet = listings.value.firstWhereOrNull(
+ (item) => walletInfo.listing.id == item.listing.id,
);
if (wallet == null) {
return null;
diff --git a/lib/services/explorer_service/i_explorer_service.dart b/lib/services/explorer_service/i_explorer_service.dart
index 06d53fb5..29ccd31e 100644
--- a/lib/services/explorer_service/i_explorer_service.dart
+++ b/lib/services/explorer_service/i_explorer_service.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
-import 'package:web3modal_flutter/services/explorer_service/models/api_response.dart';
import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart';
import 'package:web3modal_flutter/web3modal_flutter.dart';
@@ -38,13 +37,20 @@ abstract class IExplorerService {
String get searchValue;
/// update the recently used position to the top list
- Future storeConnectedWalletData(W3MWalletInfo? walletInfo);
+ Future storeConnectedWallet(W3MWalletInfo? walletInfo);
- String getWalletImageUrl(String imageId);
+ /// Get connected wallet data from local storage
+ W3MWalletInfo? getConnectedWallet();
- String getAssetImageUrl(String imageId);
+ /// Removes connected wallet data from local storage
+ Future deleteConnectedWallet();
- WalletRedirect? getWalletRedirect(Listing listing);
+ /// Gets the WalletRedirect object from a wallet info data
+ WalletRedirect? getWalletRedirect(W3MWalletInfo? walletInfo);
- Future tryWalletRedirectByName(String? name);
+ /// Given an imageId it return the wallet app icon from our services
+ String getWalletImageUrl(String imageId);
+
+ /// Given an imageId it return the chain icon from our services
+ String getAssetImageUrl(String imageId);
}
diff --git a/lib/services/storage_service/i_storage_service.dart b/lib/services/storage_service/i_storage_service.dart
index fc93ed7a..c724cae3 100644
--- a/lib/services/storage_service/i_storage_service.dart
+++ b/lib/services/storage_service/i_storage_service.dart
@@ -2,4 +2,5 @@ abstract class IStorageService {
Future init();
String? getString(String key, {String? defaultValue});
Future setString(String key, String value);
+ Future clearKey(String key);
}
diff --git a/lib/services/storage_service/storage_service.dart b/lib/services/storage_service/storage_service.dart
index 011b086f..7dc501ea 100644
--- a/lib/services/storage_service/storage_service.dart
+++ b/lib/services/storage_service/storage_service.dart
@@ -18,4 +18,9 @@ class StorageService implements IStorageService {
Future setString(String key, String value) async {
return _prefs!.setString(key, value);
}
+
+ @override
+ Future clearKey(String key) async {
+ return _prefs!.remove(key);
+ }
}
diff --git a/lib/services/w3m_service/i_w3m_service.dart b/lib/services/w3m_service/i_w3m_service.dart
index 5d38277c..6746babb 100644
--- a/lib/services/w3m_service/i_w3m_service.dart
+++ b/lib/services/w3m_service/i_w3m_service.dart
@@ -1,6 +1,5 @@
import 'package:event/event.dart';
import 'package:flutter/material.dart';
-import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart';
import 'package:web3modal_flutter/web3modal_flutter.dart';
enum W3MServiceStatus {
@@ -99,14 +98,6 @@ abstract class IW3MService with ChangeNotifier {
/// This will do nothing if [isConnected] is true.
Future buildConnectionUri();
- /// Subscribe to listen to pairing expirations
- final Event onPairingExpire = Event();
-
- WalletRedirect? get selectedWalletRedirect;
-
- /// When users rejects connection or an error occurs this will event
- final Event onWalletConnectionError = Event();
-
/// Connects the [selectedWallet] previously selected
Future connectSelectedWallet({bool inBrowser = false});
@@ -121,13 +112,19 @@ abstract class IW3MService with ChangeNotifier {
/// Gets the name of the currently connected wallet.
String getReferer();
- /// Closes the modal.
- void closeModal();
-
/// Disconnects the session and pairing, if any.
/// If there is no session, this does nothing.
Future disconnect({bool disconnectAllSessions = true});
+ /// Closes the modal.
+ void closeModal();
+
@override
void dispose();
+
+ /// Subscribe to listen to pairing expirations
+ final Event onPairingExpire = Event();
+
+ /// When users rejects connection or an error occurs this will event
+ final Event onWalletConnectionError = Event();
}
diff --git a/lib/services/w3m_service/w3m_service.dart b/lib/services/w3m_service/w3m_service.dart
index e774e7be..9fac562e 100644
--- a/lib/services/w3m_service/w3m_service.dart
+++ b/lib/services/w3m_service/w3m_service.dart
@@ -1,5 +1,4 @@
import 'dart:async';
-import 'dart:convert';
import 'package:event/event.dart';
import 'package:flutter/material.dart';
@@ -8,7 +7,6 @@ import 'package:url_launcher/url_launcher.dart';
import 'package:web3modal_flutter/constants/string_constants.dart';
import 'package:web3modal_flutter/services/explorer_service/explorer_service.dart';
import 'package:web3modal_flutter/services/explorer_service/explorer_service_singleton.dart';
-import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart';
import 'package:web3modal_flutter/services/ledger_service/ledger_service_singleton.dart';
import 'package:web3modal_flutter/utils/asset_util.dart';
import 'package:web3modal_flutter/utils/core/core_utils_singleton.dart';
@@ -429,15 +427,16 @@ class W3MService with ChangeNotifier implements IW3MService {
Future connectSelectedWallet({bool inBrowser = false}) async {
_checkInitialized();
+ final selectedWalletRedirect = explorerService.instance?.getWalletRedirect(
+ selectedWallet,
+ );
if (selectedWalletRedirect == null) {
throw W3MServiceException(
'You didn\'t select a wallet or walletInfo argument is null',
);
}
- if (_connectingWallet) {
- return;
- }
+ if (_connectingWallet) return;
_connectingWallet = true;
var pType = platformUtils.instance.getPlatformType();
@@ -447,14 +446,13 @@ class W3MService with ChangeNotifier implements IW3MService {
try {
await buildConnectionUri();
await urlUtils.instance.openRedirect(
- selectedWalletRedirect!,
+ selectedWalletRedirect,
wcURI: wcUri!,
pType: pType,
);
} on LaunchUrlException catch (e) {
W3MLoggerUtil.logger.e(
- '[$runtimeType] error launching wallet. '
- '${selectedWalletRedirect?.toString()}',
+ '[$runtimeType] error launching wallet $selectedWalletRedirect',
);
if (e.message.toLowerCase() != 'app not installed') {
toastUtils.instance.show(
@@ -513,7 +511,7 @@ class W3MService with ChangeNotifier implements IW3MService {
try {
_currentSession = await connectResponse!.session.future;
_setSessionValues(_currentSession!);
- await explorerService.instance!.storeConnectedWalletData(_selectedWallet);
+ await explorerService.instance!.storeConnectedWallet(_selectedWallet);
} on TimeoutException {
W3MLoggerUtil.logger
.i('[$runtimeType] Rebuilding session, ending future');
@@ -531,17 +529,21 @@ class W3MService with ChangeNotifier implements IW3MService {
Future launchConnectedWallet() async {
_checkInitialized();
- final sessionRedirect = await sessionWalletRedirect();
- if (sessionRedirect == null) {
+ final walletInfo = explorerService.instance!.getConnectedWallet();
+ if (walletInfo == null) {
+ // if walletInfo is null could mean that either
+ // 1. There's no wallet connected (shouldn't happen)
+ // 2. Wallet is connected on another device through qr code
return;
}
- W3MLoggerUtil.logger.t(
- '[$runtimeType] Launching wallet: $sessionWalletRedirect, ${_currentSession?.peer.metadata}',
- );
+ final redirect = explorerService.instance!.getWalletRedirect(walletInfo);
+ if (redirect == null) {
+ return;
+ }
return await urlUtils.instance.openRedirect(
- sessionRedirect,
+ redirect,
pType: platformUtils.instance.getPlatformType(),
);
}
@@ -808,6 +810,7 @@ class W3MService with ChangeNotifier implements IW3MService {
}
void _cleanSession() {
+ explorerService.instance!.deleteConnectedWallet();
_currentSelectedChain = null;
_isConnected = false;
_address = null;
@@ -815,38 +818,6 @@ class W3MService with ChangeNotifier implements IW3MService {
_notify();
}
- @override
- WalletRedirect? get selectedWalletRedirect {
- final listing = _selectedWallet?.listing;
- if (listing == null) return null;
-
- return explorerService.instance?.getWalletRedirect(listing);
- }
-
- Future sessionWalletRedirect() async {
- final metadata = _currentSession?.peer.metadata;
- final sessionRedirect = metadata?.redirect;
- if (sessionRedirect == null) {
- final walletString = storageService.instance.getString(
- StringConstants.walletData,
- );
- if ((walletString ?? '').isNotEmpty) {
- final walletInfo = W3MWalletInfo.fromJson(jsonDecode(walletString!));
- return explorerService.instance!.getWalletRedirect(walletInfo.listing);
- }
-
- return await explorerService.instance?.tryWalletRedirectByName(
- metadata?.name,
- );
- }
-
- return WalletRedirect(
- mobile: sessionRedirect.native,
- desktop: sessionRedirect.native,
- web: sessionRedirect.universal,
- );
- }
-
void _checkInitialized() {
if (_status != W3MServiceStatus.initialized &&
_status != W3MServiceStatus.initializing) {
diff --git a/lib/version.dart b/lib/version.dart
index 6e622a8f..71eaabf7 100644
--- a/lib/version.dart
+++ b/lib/version.dart
@@ -1,2 +1,2 @@
// Generated code. Do not modify.
-const packageVersion = '3.0.20';
+const packageVersion = '3.0.21';
diff --git a/pubspec.yaml b/pubspec.yaml
index 867e528a..2752f06a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: web3modal_flutter
description: "WalletConnect Web3Modal: Simple, intuitive wallet login. With this drop-in UI SDK, enable any wallet's users to seamlessly log in to your app and enjoy a unified experience"
-version: 3.0.20
+version: 3.0.21
repository: https://github.com/WalletConnect/Web3ModalFlutter
environment:
diff --git a/test/mock_classes.mocks.dart b/test/mock_classes.mocks.dart
index 5311b364..1539645d 100644
--- a/test/mock_classes.mocks.dart
+++ b/test/mock_classes.mocks.dart
@@ -4,9 +4,9 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i15;
-import 'dart:convert' as _i28;
-import 'dart:typed_data' as _i29;
-import 'dart:ui' as _i19;
+import 'dart:convert' as _i27;
+import 'dart:typed_data' as _i28;
+import 'dart:ui' as _i17;
import 'package:event/event.dart' as _i3;
import 'package:flutter/foundation.dart' as _i2;
@@ -14,46 +14,44 @@ import 'package:flutter/material.dart' as _i12;
import 'package:http/http.dart' as _i10;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i14;
-import 'package:url_launcher/url_launcher.dart' as _i21;
+import 'package:url_launcher/url_launcher.dart' as _i19;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/i_message_tracker.dart'
as _i8;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/json_rpc_2/src/peer.dart'
- as _i27;
-import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart'
as _i26;
+import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart'
+ as _i25;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/i_websocket_handler.dart'
as _i9;
import 'package:walletconnect_flutter_v2/apis/core/store/i_generic_store.dart'
as _i5;
import 'package:walletconnect_flutter_v2/apis/core/store/i_store.dart' as _i7;
import 'package:walletconnect_flutter_v2/apis/sign_api/i_sessions.dart' as _i6;
-import 'package:web3modal_flutter/models/grid_item.dart' as _i31;
+import 'package:web3modal_flutter/models/grid_item.dart' as _i30;
import 'package:web3modal_flutter/services/blockchain_api_service/blockchain_api_utils.dart'
- as _i32;
+ as _i31;
import 'package:web3modal_flutter/services/blockchain_api_service/blockchain_identity.dart'
as _i11;
import 'package:web3modal_flutter/services/explorer_service/explorer_service.dart'
as _i13;
-import 'package:web3modal_flutter/services/explorer_service/models/api_response.dart'
- as _i17;
import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart'
- as _i16;
+ as _i20;
import 'package:web3modal_flutter/services/ledger_service/ledger_service.dart'
- as _i33;
+ as _i32;
import 'package:web3modal_flutter/services/network_service/network_service.dart'
- as _i30;
+ as _i29;
import 'package:web3modal_flutter/services/storage_service/storage_service.dart'
- as _i34;
+ as _i33;
import 'package:web3modal_flutter/services/w3m_service/i_w3m_service.dart'
- as _i18;
-import 'package:web3modal_flutter/utils/platform/i_platform_utils.dart' as _i22;
-import 'package:web3modal_flutter/utils/platform/platform_utils.dart' as _i23;
-import 'package:web3modal_flutter/utils/toast/toast_message.dart' as _i25;
-import 'package:web3modal_flutter/utils/toast/toast_utils.dart' as _i24;
-import 'package:web3modal_flutter/utils/url/url_utils.dart' as _i20;
+ as _i16;
+import 'package:web3modal_flutter/utils/platform/i_platform_utils.dart' as _i21;
+import 'package:web3modal_flutter/utils/platform/platform_utils.dart' as _i22;
+import 'package:web3modal_flutter/utils/toast/toast_message.dart' as _i24;
+import 'package:web3modal_flutter/utils/toast/toast_utils.dart' as _i23;
+import 'package:web3modal_flutter/utils/url/url_utils.dart' as _i18;
import 'package:web3modal_flutter/web3modal_flutter.dart' as _i4;
import 'package:web3modal_flutter/widgets/widget_stack/widget_stack.dart'
- as _i35;
+ as _i34;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@@ -411,16 +409,25 @@ class MockExplorerService extends _i1.Mock implements _i13.ExplorerService {
returnValueForMissingStub: _i15.Future.value(),
) as _i15.Future);
@override
- _i15.Future storeConnectedWalletData(_i4.W3MWalletInfo? walletInfo) =>
+ _i15.Future storeConnectedWallet(_i4.W3MWalletInfo? walletInfo) =>
(super.noSuchMethod(
Invocation.method(
- #storeConnectedWalletData,
+ #storeConnectedWallet,
[walletInfo],
),
returnValue: _i15.Future.value(),
returnValueForMissingStub: _i15.Future.value(),
) as _i15.Future);
@override
+ _i15.Future deleteConnectedWallet() => (super.noSuchMethod(
+ Invocation.method(
+ #deleteConnectedWallet,
+ [],
+ ),
+ returnValue: _i15.Future.value(),
+ returnValueForMissingStub: _i15.Future.value(),
+ ) as _i15.Future);
+ @override
void search({String? query}) => super.noSuchMethod(
Invocation.method(
#search,
@@ -457,21 +464,6 @@ class MockExplorerService extends _i1.Mock implements _i13.ExplorerService {
),
),
) as String);
- @override
- _i16.WalletRedirect? getWalletRedirect(_i17.Listing? listing) =>
- (super.noSuchMethod(Invocation.method(
- #getWalletRedirect,
- [listing],
- )) as _i16.WalletRedirect?);
- @override
- _i15.Future<_i16.WalletRedirect?> tryWalletRedirectByName(String? name) =>
- (super.noSuchMethod(
- Invocation.method(
- #tryWalletRedirectByName,
- [name],
- ),
- returnValue: _i15.Future<_i16.WalletRedirect?>.value(),
- ) as _i15.Future<_i16.WalletRedirect?>);
}
/// A class which mocks [W3MService].
@@ -500,19 +492,19 @@ class MockW3MService extends _i1.Mock implements _i4.W3MService {
),
) as _i3.Event<_i3.EventArgs>);
@override
- _i3.Event<_i18.WalletErrorEvent> get onWalletConnectionError =>
+ _i3.Event<_i16.WalletErrorEvent> get onWalletConnectionError =>
(super.noSuchMethod(
Invocation.getter(#onWalletConnectionError),
- returnValue: _FakeEvent_1<_i18.WalletErrorEvent>(
+ returnValue: _FakeEvent_1<_i16.WalletErrorEvent>(
this,
Invocation.getter(#onWalletConnectionError),
),
- ) as _i3.Event<_i18.WalletErrorEvent>);
+ ) as _i3.Event<_i16.WalletErrorEvent>);
@override
- _i18.W3MServiceStatus get status => (super.noSuchMethod(
+ _i16.W3MServiceStatus get status => (super.noSuchMethod(
Invocation.getter(#status),
- returnValue: _i18.W3MServiceStatus.idle,
- ) as _i18.W3MServiceStatus);
+ returnValue: _i16.W3MServiceStatus.idle,
+ ) as _i16.W3MServiceStatus);
@override
bool get hasNamespaces => (super.noSuchMethod(
Invocation.getter(#hasNamespaces),
@@ -677,16 +669,7 @@ class MockW3MService extends _i1.Mock implements _i4.W3MService {
returnValueForMissingStub: null,
);
@override
- _i15.Future<_i16.WalletRedirect?> sessionWalletRedirect() =>
- (super.noSuchMethod(
- Invocation.method(
- #sessionWalletRedirect,
- [],
- ),
- returnValue: _i15.Future<_i16.WalletRedirect?>.value(),
- ) as _i15.Future<_i16.WalletRedirect?>);
- @override
- void addListener(_i19.VoidCallback? listener) => super.noSuchMethod(
+ void addListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@@ -694,7 +677,7 @@ class MockW3MService extends _i1.Mock implements _i4.W3MService {
returnValueForMissingStub: null,
);
@override
- void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod(
+ void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
@@ -714,7 +697,7 @@ class MockW3MService extends _i1.Mock implements _i4.W3MService {
/// A class which mocks [UrlUtils].
///
/// See the documentation for Mockito's code generation for more information.
-class MockUrlUtils extends _i1.Mock implements _i20.UrlUtils {
+class MockUrlUtils extends _i1.Mock implements _i18.UrlUtils {
MockUrlUtils() {
_i1.throwOnMissingStub(this);
}
@@ -727,17 +710,17 @@ class MockUrlUtils extends _i1.Mock implements _i20.UrlUtils {
@override
_i15.Future Function(
Uri, {
- _i21.LaunchMode? mode,
+ _i19.LaunchMode? mode,
}) get launchUrlFunc => (super.noSuchMethod(
Invocation.getter(#launchUrlFunc),
returnValue: (
Uri url, {
- _i21.LaunchMode? mode,
+ _i19.LaunchMode? mode,
}) =>
_i15.Future.value(false),
) as _i15.Future Function(
Uri, {
- _i21.LaunchMode? mode,
+ _i19.LaunchMode? mode,
}));
@override
_i15.Future Function(Uri) get canLaunchUrlFunc => (super.noSuchMethod(
@@ -755,7 +738,7 @@ class MockUrlUtils extends _i1.Mock implements _i20.UrlUtils {
@override
_i15.Future launchUrl(
Uri? url, {
- _i21.LaunchMode? mode,
+ _i19.LaunchMode? mode,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -767,9 +750,9 @@ class MockUrlUtils extends _i1.Mock implements _i20.UrlUtils {
) as _i15.Future);
@override
_i15.Future openRedirect(
- _i16.WalletRedirect? redirect, {
+ _i20.WalletRedirect? redirect, {
String? wcURI,
- _i22.PlatformType? pType,
+ _i21.PlatformType? pType,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -788,27 +771,27 @@ class MockUrlUtils extends _i1.Mock implements _i20.UrlUtils {
/// A class which mocks [PlatformUtils].
///
/// See the documentation for Mockito's code generation for more information.
-class MockPlatformUtils extends _i1.Mock implements _i23.PlatformUtils {
+class MockPlatformUtils extends _i1.Mock implements _i22.PlatformUtils {
MockPlatformUtils() {
_i1.throwOnMissingStub(this);
}
@override
- _i22.PlatformExact getPlatformExact() => (super.noSuchMethod(
+ _i21.PlatformExact getPlatformExact() => (super.noSuchMethod(
Invocation.method(
#getPlatformExact,
[],
),
- returnValue: _i22.PlatformExact.iOS,
- ) as _i22.PlatformExact);
+ returnValue: _i21.PlatformExact.iOS,
+ ) as _i21.PlatformExact);
@override
- _i22.PlatformType getPlatformType() => (super.noSuchMethod(
+ _i21.PlatformType getPlatformType() => (super.noSuchMethod(
Invocation.method(
#getPlatformType,
[],
),
- returnValue: _i22.PlatformType.mobile,
- ) as _i22.PlatformType);
+ returnValue: _i21.PlatformType.mobile,
+ ) as _i21.PlatformType);
@override
bool canDetectInstalledApps() => (super.noSuchMethod(
Invocation.method(
@@ -846,18 +829,18 @@ class MockPlatformUtils extends _i1.Mock implements _i23.PlatformUtils {
/// A class which mocks [ToastUtils].
///
/// See the documentation for Mockito's code generation for more information.
-class MockToastUtils extends _i1.Mock implements _i24.ToastUtils {
+class MockToastUtils extends _i1.Mock implements _i23.ToastUtils {
MockToastUtils() {
_i1.throwOnMissingStub(this);
}
@override
- _i15.Stream<_i25.ToastMessage?> get toasts => (super.noSuchMethod(
+ _i15.Stream<_i24.ToastMessage?> get toasts => (super.noSuchMethod(
Invocation.getter(#toasts),
- returnValue: _i15.Stream<_i25.ToastMessage?>.empty(),
- ) as _i15.Stream<_i25.ToastMessage?>);
+ returnValue: _i15.Stream<_i24.ToastMessage?>.empty(),
+ ) as _i15.Stream<_i24.ToastMessage?>);
@override
- void show(_i25.ToastMessage? message) => super.noSuchMethod(
+ void show(_i24.ToastMessage? message) => super.noSuchMethod(
Invocation.method(
#show,
[message],
@@ -1497,7 +1480,7 @@ class MockSessions extends _i1.Mock implements _i4.Sessions {
/// A class which mocks [RelayClient].
///
/// See the documentation for Mockito's code generation for more information.
-class MockRelayClient extends _i1.Mock implements _i26.RelayClient {
+class MockRelayClient extends _i1.Mock implements _i25.RelayClient {
MockRelayClient() {
_i1.throwOnMissingStub(this);
}
@@ -1570,7 +1553,7 @@ class MockRelayClient extends _i1.Mock implements _i26.RelayClient {
),
) as _i3.Event<_i3.EventArgs>);
@override
- set jsonRPC(_i27.Peer? _jsonRPC) => super.noSuchMethod(
+ set jsonRPC(_i26.Peer? _jsonRPC) => super.noSuchMethod(
Invocation.setter(
#jsonRPC,
_jsonRPC,
@@ -1802,7 +1785,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
Uri? url, {
Map? headers,
Object? body,
- _i28.Encoding? encoding,
+ _i27.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -1832,7 +1815,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
Uri? url, {
Map? headers,
Object? body,
- _i28.Encoding? encoding,
+ _i27.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -1862,7 +1845,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
Uri? url, {
Map? headers,
Object? body,
- _i28.Encoding? encoding,
+ _i27.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -1892,7 +1875,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
Uri? url, {
Map? headers,
Object? body,
- _i28.Encoding? encoding,
+ _i27.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -1938,7 +1921,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
)),
) as _i15.Future);
@override
- _i15.Future<_i29.Uint8List> readBytes(
+ _i15.Future<_i28.Uint8List> readBytes(
Uri? url, {
Map? headers,
}) =>
@@ -1948,8 +1931,8 @@ class MockClient extends _i1.Mock implements _i10.Client {
[url],
{#headers: headers},
),
- returnValue: _i15.Future<_i29.Uint8List>.value(_i29.Uint8List(0)),
- ) as _i15.Future<_i29.Uint8List>);
+ returnValue: _i15.Future<_i28.Uint8List>.value(_i28.Uint8List(0)),
+ ) as _i15.Future<_i28.Uint8List>);
@override
_i15.Future<_i10.StreamedResponse> send(_i10.BaseRequest? request) =>
(super.noSuchMethod(
@@ -1979,7 +1962,7 @@ class MockClient extends _i1.Mock implements _i10.Client {
/// A class which mocks [NetworkService].
///
/// See the documentation for Mockito's code generation for more information.
-class MockNetworkService extends _i1.Mock implements _i30.NetworkService {
+class MockNetworkService extends _i1.Mock implements _i29.NetworkService {
MockNetworkService() {
_i1.throwOnMissingStub(this);
}
@@ -2001,14 +1984,14 @@ class MockNetworkService extends _i1.Mock implements _i30.NetworkService {
returnValueForMissingStub: null,
);
@override
- List<_i31.GridItem<_i4.W3MChainInfo>> get itemListComplete =>
+ List<_i30.GridItem<_i4.W3MChainInfo>> get itemListComplete =>
(super.noSuchMethod(
Invocation.getter(#itemListComplete),
- returnValue: <_i31.GridItem<_i4.W3MChainInfo>>[],
- ) as List<_i31.GridItem<_i4.W3MChainInfo>>);
+ returnValue: <_i30.GridItem<_i4.W3MChainInfo>>[],
+ ) as List<_i30.GridItem<_i4.W3MChainInfo>>);
@override
set itemListComplete(
- List<_i31.GridItem<_i4.W3MChainInfo>>? _itemListComplete) =>
+ List<_i30.GridItem<_i4.W3MChainInfo>>? _itemListComplete) =>
super.noSuchMethod(
Invocation.setter(
#itemListComplete,
@@ -2017,18 +2000,18 @@ class MockNetworkService extends _i1.Mock implements _i30.NetworkService {
returnValueForMissingStub: null,
);
@override
- _i2.ValueNotifier>> get itemList =>
+ _i2.ValueNotifier>> get itemList =>
(super.noSuchMethod(
Invocation.getter(#itemList),
returnValue:
- _FakeValueNotifier_0>>(
+ _FakeValueNotifier_0>>(
this,
Invocation.getter(#itemList),
),
- ) as _i2.ValueNotifier>>);
+ ) as _i2.ValueNotifier>>);
@override
set itemList(
- _i2.ValueNotifier>>?
+ _i2.ValueNotifier>>?
_itemList) =>
super.noSuchMethod(
Invocation.setter(
@@ -2061,7 +2044,7 @@ class MockNetworkService extends _i1.Mock implements _i30.NetworkService {
///
/// See the documentation for Mockito's code generation for more information.
class MockBlockchainApiUtils extends _i1.Mock
- implements _i32.BlockchainApiUtils {
+ implements _i31.BlockchainApiUtils {
MockBlockchainApiUtils() {
_i1.throwOnMissingStub(this);
}
@@ -2112,7 +2095,7 @@ class MockBlockchainApiUtils extends _i1.Mock
/// A class which mocks [LedgerService].
///
/// See the documentation for Mockito's code generation for more information.
-class MockLedgerService extends _i1.Mock implements _i33.LedgerService {
+class MockLedgerService extends _i1.Mock implements _i32.LedgerService {
MockLedgerService() {
_i1.throwOnMissingStub(this);
}
@@ -2185,7 +2168,7 @@ class MockLedgerService extends _i1.Mock implements _i33.LedgerService {
/// A class which mocks [StorageService].
///
/// See the documentation for Mockito's code generation for more information.
-class MockStorageService extends _i1.Mock implements _i34.StorageService {
+class MockStorageService extends _i1.Mock implements _i33.StorageService {
MockStorageService() {
_i1.throwOnMissingStub(this);
}
@@ -2224,12 +2207,20 @@ class MockStorageService extends _i1.Mock implements _i34.StorageService {
),
returnValue: _i15.Future.value(false),
) as _i15.Future);
+ @override
+ _i15.Future clearKey(String? key) => (super.noSuchMethod(
+ Invocation.method(
+ #clearKey,
+ [key],
+ ),
+ returnValue: _i15.Future.value(false),
+ ) as _i15.Future);
}
/// A class which mocks [WidgetStack].
///
/// See the documentation for Mockito's code generation for more information.
-class MockWidgetStack extends _i1.Mock implements _i35.WidgetStack {
+class MockWidgetStack extends _i1.Mock implements _i34.WidgetStack {
MockWidgetStack() {
_i1.throwOnMissingStub(this);
}
@@ -2323,7 +2314,7 @@ class MockWidgetStack extends _i1.Mock implements _i35.WidgetStack {
returnValueForMissingStub: null,
);
@override
- void addListener(_i19.VoidCallback? listener) => super.noSuchMethod(
+ void addListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@@ -2331,7 +2322,7 @@ class MockWidgetStack extends _i1.Mock implements _i35.WidgetStack {
returnValueForMissingStub: null,
);
@override
- void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod(
+ void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
From 3b693cc222be37d1bf7c37a6490c05756bf1724d Mon Sep 17 00:00:00 2001
From: Alfreedom <00tango.bromine@icloud.com>
Date: Wed, 10 Jan 2024 16:44:51 +0100
Subject: [PATCH 2/5] Pull changes from stable branch, fix conflicts and bugs
---
analysis_options.yaml | 2 +
example/ios/Runner.xcodeproj/project.pbxproj | 4 +-
example/ios/Runner/Info.plist | 1 -
example/lib/home_page.dart | 19 +-
example/lib/utils/crypto/eip155.dart | 6 +-
example/pubspec.lock | 4 +-
lib/pages/connect_wallet_page.dart | 2 +-
.../coinbase_service/coinbase_service.dart | 67 +-
.../coinbase_service/i_coinbase_service.dart | 20 +-
.../explorer_service/explorer_service.dart | 166 ++--
.../explorer_service/i_explorer_service.dart | 9 +-
.../explorer_service/models/redirect.dart | 3 +-
.../storage_service/storage_service.dart | 8 +-
lib/services/w3m_service/i_w3m_service.dart | 65 +-
.../w3m_service/models/w3m_session.dart | 5 -
lib/services/w3m_service/w3m_service.dart | 200 ++---
lib/utils/url/i_url_utils.dart | 2 +-
lib/utils/url/url_utils.dart | 92 +-
.../lists/list_items/coinbase_list_item.dart | 48 --
pubspec.lock | 4 +-
pubspec.yaml | 2 +-
test/mock_classes.mocks.dart | 801 ++++++++----------
22 files changed, 693 insertions(+), 837 deletions(-)
delete mode 100644 lib/widgets/lists/list_items/coinbase_list_item.dart
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 6e9ba49d..b677fc6a 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -34,6 +34,8 @@ analyzer:
exclude:
- '**.freezed.dart'
- '**.g.dart'
+ - '**/*.freezed.dart'
+ - '**/*.g.dart'
- '**/generated_plugin_registrant.dart'
errors:
invalid_annotation_target: ignore
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 9a50adb9..3249f0ef 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -483,7 +483,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
- "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = AlfredoDevelopmentProfile;
+ "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = FlutterDevelopmentProfile2;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
@@ -668,7 +668,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.web3modal.flutterExample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
- "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = AlfredoDevelopmentProfile;
+ "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = FlutterDevelopmentProfile2;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index 16f52d65..a148e6a4 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -77,7 +77,6 @@
oasys-wallet
coinstats
ledgerlive
- zerion
safe
okex
trust
diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart
index cd591f91..baaf0e9a 100644
--- a/example/lib/home_page.dart
+++ b/example/lib/home_page.dart
@@ -46,17 +46,20 @@ class _MyHomePageState extends State {
),
),
// excludedWalletIds: {
- // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
+ // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase Wallet
// },
// includedWalletIds: {
- // 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96',
- // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
- // '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369',
- // },
- // featuredWalletIds: {
- // 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96',
- // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
+ // 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // Metamask
+ // '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', // Rainbow
+ // 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase Wallet
+ // 'be49f0a78d6ea1beed3804c3a6b62ea71f568d58d9df8097f3d61c7c9baf273d', // Uniswap
// },
+ featuredWalletIds: {
+ '19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927', // Ledger Live
+ '4457c130df49fb3cb1f8b99574b97b35208bd3d0d13b8d25d2b5884ed2cad13a', // Shapeshift
+ 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', // Coinbase Wallet
+ '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662', // Bitget
+ },
);
await _w3mService.init();
diff --git a/example/lib/utils/crypto/eip155.dart b/example/lib/utils/crypto/eip155.dart
index b2758647..a2908c53 100644
--- a/example/lib/utils/crypto/eip155.dart
+++ b/example/lib/utils/crypto/eip155.dart
@@ -190,9 +190,11 @@ class EIP155 {
params: {
"type": "ERC20",
"options": {
- "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
- "symbol": "USDT",
+ "address": "0xcf664087a5bb0237a0bad6742852ec6c8d69a27a",
+ "symbol": "WONE",
"decimals": 18,
+ "image":
+ "https://s2.coinmarketcap.com/static/img/coins/64x64/11696.png"
}
},
),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 9fe829c9..a333e6ce 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -953,10 +953,10 @@ packages:
dependency: transitive
description:
name: url_launcher
- sha256: e9aa5ea75c84cf46b3db4eea212523591211c3cf2e13099ee4ec147f54201c86
+ sha256: d25bb0ca00432a5e1ee40e69c36c85863addf7cc45e433769d61bed3fe81fd96
url: "https://pub.dev"
source: hosted
- version: "6.2.2"
+ version: "6.2.3"
url_launcher_android:
dependency: transitive
description:
diff --git a/lib/pages/connect_wallet_page.dart b/lib/pages/connect_wallet_page.dart
index f8ad5253..2fef5655 100644
--- a/lib/pages/connect_wallet_page.dart
+++ b/lib/pages/connect_wallet_page.dart
@@ -95,7 +95,7 @@ class _ConnectWalletPageState extends State
kNavbarHeight -
(kPadding16 * 2);
//
- final walletRedirect = explorerService.instance?.getWalletRedirect(
+ final walletRedirect = explorerService.instance.getWalletRedirect(
_service!.selectedWallet,
);
final webOnlyWallet = walletRedirect?.webOnly == true;
diff --git a/lib/services/coinbase_service/coinbase_service.dart b/lib/services/coinbase_service/coinbase_service.dart
index 2938ccdf..b1dae4a4 100644
--- a/lib/services/coinbase_service/coinbase_service.dart
+++ b/lib/services/coinbase_service/coinbase_service.dart
@@ -17,6 +17,10 @@ import 'package:coinbase_wallet_sdk/request.dart';
import 'models/coinbase_data.dart';
class CoinbaseService implements ICoinbaseService {
+ static const coinbaseWalletId =
+ 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa';
+ static const coinbaseSchema = 'cbwallet://wsegue';
+
@override
Event onCoinbaseConnect = Event();
@@ -33,7 +37,10 @@ class CoinbaseService implements ICoinbaseService {
@protected
@override
- Future cbInit({required PairingMetadata metadata}) async {
+ Future cbInit({
+ required PairingMetadata metadata,
+ W3MWalletInfo? cbWallet,
+ }) async {
// Configure SDK for each platform
final universal = metadata.redirect?.universal ?? metadata.url;
final nativeLink = metadata.redirect?.native ?? '';
@@ -41,7 +48,7 @@ class CoinbaseService implements ICoinbaseService {
try {
final config = Configuration(
ios: IOSConfiguration(
- host: Uri.parse('cbwallet://wsegue'),
+ host: Uri.parse(cbWallet?.listing.mobileLink ?? coinbaseSchema),
callback: Uri.parse(nativeLink),
),
android: AndroidConfiguration(domain: Uri.parse(universal)),
@@ -51,37 +58,36 @@ class CoinbaseService implements ICoinbaseService {
// Silent error
}
} else {
- throw W3MCoinbaseException('PairingMetadata error');
+ throw W3MCoinbaseException('Initialization error');
}
}
@protected
@override
Future cbGetAccount() async {
+ await _checkInstalled();
try {
- final result = (await CoinbaseWalletSDK.shared.initiateHandshake([
+ final results = await CoinbaseWalletSDK.shared.initiateHandshake([
const RequestAccounts(),
- ]))
- .first;
+ ]);
+ final result = results.first;
if (result.error != null) {
final errorCode = result.error?.code;
final errorMessage = result.error!.message;
onCoinbaseError.broadcast(CoinbaseErrorEvent(errorMessage));
- throw CoinbaseRPCError(errorCode, errorMessage);
+ throw W3MCoinbaseException('$errorMessage ($errorCode)');
}
+
final data = CoinbaseData.fromJson(result.account!.toJson());
onCoinbaseConnect.broadcast(CoinbaseConnectEvent(data));
+ return;
} on PlatformException catch (e, s) {
- final message = (e.message ?? '').toLowerCase();
- final error0 = message.contains('error 0');
- final denied = message.contains('user denied');
- if (error0 || denied) {
- throw CoinbaseRPCError(0, 'User denied handshake');
- }
- throw W3MCoinbaseException(e, s);
+ final errorMessage = (e.message ?? '').toLowerCase();
+ onCoinbaseError.broadcast(CoinbaseErrorEvent(errorMessage));
+ throw W3MCoinbaseException(errorMessage, e, s);
} catch (e, s) {
- onCoinbaseError.broadcast(CoinbaseErrorEvent(e.toString()));
- throw W3MCoinbaseException(e, s);
+ onCoinbaseError.broadcast(CoinbaseErrorEvent('Initial handshake error'));
+ throw W3MCoinbaseException('Initial handshake error', e, s);
}
}
@@ -90,6 +96,7 @@ class CoinbaseService implements ICoinbaseService {
String? chainId,
required SessionRequestParams request,
}) async {
+ await _checkInstalled();
try {
final req = Request(actions: [request.toCoinbaseRequest(chainId)]);
final result = (await CoinbaseWalletSDK.shared.makeRequest(req)).first;
@@ -97,7 +104,7 @@ class CoinbaseService implements ICoinbaseService {
final errorCode = result.error?.code;
final errorMessage = result.error!.message;
onCoinbaseError.broadcast(CoinbaseErrorEvent(errorMessage));
- throw CoinbaseRPCError(errorCode, errorMessage);
+ throw W3MCoinbaseException('$errorMessage ($errorCode)');
}
switch (req.actions.first.method) {
case 'wallet_switchEthereumChain':
@@ -116,10 +123,12 @@ class CoinbaseService implements ICoinbaseService {
break;
}
return result.value;
- } on W3MCoinbaseException {
- rethrow;
} catch (e, s) {
- throw W3MCoinbaseException(e, s);
+ if (e is W3MCoinbaseException) {
+ rethrow;
+ }
+ onCoinbaseError.broadcast(CoinbaseErrorEvent('Request error'));
+ throw W3MCoinbaseException('Request error', e, s);
}
}
@@ -128,7 +137,7 @@ class CoinbaseService implements ICoinbaseService {
try {
return await CoinbaseWalletSDK.shared.isAppInstalled();
} catch (e, s) {
- throw W3MCoinbaseException(e, s);
+ throw W3MCoinbaseException('Check is installed error', e, s);
}
}
@@ -137,7 +146,7 @@ class CoinbaseService implements ICoinbaseService {
try {
return await CoinbaseWalletSDK.shared.isConnected();
} catch (e, s) {
- throw W3MCoinbaseException(e, s);
+ throw W3MCoinbaseException('Check is connected error', e, s);
}
}
@@ -146,8 +155,16 @@ class CoinbaseService implements ICoinbaseService {
try {
return CoinbaseWalletSDK.shared.resetSession();
} catch (e, s) {
- throw W3MCoinbaseException(e, s);
+ throw W3MCoinbaseException('Reset session error', e, s);
+ }
+ }
+
+ Future _checkInstalled() async {
+ final installed = await cbIsInstalled();
+ if (!installed) {
+ throw W3MCoinbaseException('App not installed');
}
+ return true;
}
}
@@ -209,8 +226,8 @@ extension on SessionRequestParams {
iconUrls: iconUrls,
blockExplorerUrls: explorerUrls,
);
- } catch (_, s) {
- throw W3MCoinbaseException('Unrecognized chainId $chainId', s);
+ } catch (e, s) {
+ throw W3MCoinbaseException('Unrecognized chainId $chainId', e, s);
}
case 'wallet_watchAsset':
return WatchAsset(params: params);
diff --git a/lib/services/coinbase_service/i_coinbase_service.dart b/lib/services/coinbase_service/i_coinbase_service.dart
index c7fbf951..9675e827 100644
--- a/lib/services/coinbase_service/i_coinbase_service.dart
+++ b/lib/services/coinbase_service/i_coinbase_service.dart
@@ -2,20 +2,14 @@ import 'package:web3modal_flutter/services/coinbase_service/models/coinbase_even
import 'package:web3modal_flutter/web3modal_flutter.dart';
class W3MCoinbaseException implements Exception {
- final dynamic message;
+ final String message;
+ final dynamic error;
final dynamic stackTrace;
- W3MCoinbaseException(this.message, [this.stackTrace]) : super();
-}
-
-class CoinbaseRPCError {
- int? code;
- String? message;
- CoinbaseRPCError(
- this.code,
- this.message,
- );
-
- Map toJson() => {'code': code, 'message': message};
+ W3MCoinbaseException(
+ this.message, [
+ this.error,
+ this.stackTrace,
+ ]) : super();
}
abstract class ICoinbaseService {
diff --git a/lib/services/explorer_service/explorer_service.dart b/lib/services/explorer_service/explorer_service.dart
index 0f94395e..fd0d0691 100644
--- a/lib/services/explorer_service/explorer_service.dart
+++ b/lib/services/explorer_service/explorer_service.dart
@@ -5,7 +5,6 @@ import 'dart:math';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
-import 'package:web3modal_flutter/services/coinbase_service/coinbase_service.dart';
import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart';
import 'package:web3modal_flutter/utils/debouncer.dart';
import 'package:web3modal_flutter/utils/url/url_utils_singleton.dart';
@@ -20,7 +19,7 @@ import 'package:web3modal_flutter/web3modal_flutter.dart';
const int _defaultEntriesCount = 48;
-class ExplorerService with CoinbaseService implements IExplorerService {
+class ExplorerService implements IExplorerService {
static const _apiUrl = 'https://api.web3modal.com';
final http.Client _client;
@@ -54,6 +53,10 @@ class ExplorerService with CoinbaseService implements IExplorerService {
@override
Set? featuredWalletIds;
+ // String? get _featuredWalletsParam {
+ // final featuredIds = (featuredWalletIds ?? {});
+ // return featuredIds.isNotEmpty ? featuredIds.join(',') : null;
+ // }
@override
Set? includedWalletIds;
@@ -84,22 +87,6 @@ class ExplorerService with CoinbaseService implements IExplorerService {
}) : _referer = referer,
_client = http.Client();
- @override
- bool get includeCoinbaseWallet {
- final cbId = _coinbaseWallet.listing.id;
- final included = (includedWalletIds ?? {});
- final excluded = (excludedWalletIds ?? {});
-
- if (included.isNotEmpty) {
- return included.contains(cbId);
- }
- if (excluded.isNotEmpty) {
- return !excluded.contains(cbId);
- }
-
- return true;
- }
-
@override
Future init() async {
if (initialized.value) {
@@ -124,27 +111,14 @@ class ExplorerService with CoinbaseService implements IExplorerService {
totalListings.value = 0;
final allListings = await Future.wait([
_fetchInstalledListings(),
+ // _fetchFeaturedListings(),
_fetchOtherListings(),
]);
- final countInstalled = allListings.first.length;
-
- _listings = [...allListings.first, ...allListings.last];
-
- // Include Coinbase Wallet if needed
- if (includeCoinbaseWallet) {
- final cbWallet = _coinbaseWallet.copyWith(
- installed: await cbIsInstalled(),
- );
- int i = max(countInstalled, 3);
- if (cbWallet.installed) {
- i = 3;
- }
- final j = min(i, _listings.length);
- _listings.insert(j, cbWallet);
- }
-
- _listings = _listings.sortByRecommended(featuredWalletIds);
+ _listings = [
+ ...allListings[0].sortByRecommended(featuredWalletIds),
+ ...allListings[1].sortByRecommended(featuredWalletIds),
+ ];
listings.value = _listings;
if (_listings.length < _defaultEntriesCount) {
@@ -158,6 +132,7 @@ class ExplorerService with CoinbaseService implements IExplorerService {
W3MWalletInfo? walletInfo;
final walletString = storageService.instance.getString(
StringConstants.connectedWalletData,
+ defaultValue: '',
);
if (walletString!.isNotEmpty) {
walletInfo = W3MWalletInfo.fromJson(jsonDecode(walletString));
@@ -165,7 +140,11 @@ class ExplorerService with CoinbaseService implements IExplorerService {
walletInfo = null;
}
}
- await _updateRecentWalletId(walletInfo);
+
+ final walletId = storageService.instance.getString(
+ StringConstants.recentWalletId,
+ );
+ await _updateRecentWalletId(walletInfo, walletId: walletId);
}
@override
@@ -221,11 +200,28 @@ class ExplorerService with CoinbaseService implements IExplorerService {
page: 1,
entries: _installedWalletIds.length,
include: _installedWalletIds.join(','),
+ platform: _getPlatformType(),
);
// this query gives me a count of installedWalletsParam.length
return (await _fetchListings(params: params)).setInstalledFlag();
}
+ // Future> _fetchFeaturedListings() async {
+ // // ..removeAll(_installedWalletIds)
+ // final entries = (_featuredWalletsParam ?? '').split(',').length;
+ // if (entries == 0) {
+ // return [];
+ // }
+ // final params = RequestParams(
+ // page: 1,
+ // entries: entries,
+ // include: _featuredWalletsParam,
+ // platform: _getPlatformType(),
+ // );
+ // debugPrint('[$runtimeType] _featuredWalletsParam');
+ // return await _fetchListings(params: params);
+ // }
+
Future> _fetchOtherListings() async {
_requestParams = RequestParams(
page: 1,
@@ -270,7 +266,17 @@ class ExplorerService with CoinbaseService implements IExplorerService {
StringConstants.connectedWalletData,
walletDataString,
);
- await _updateRecentWalletId(walletInfo);
+ await storeRecentWalletId(walletInfo.listing.id);
+ await _updateRecentWalletId(walletInfo, walletId: walletInfo.listing.id);
+ }
+
+ @override
+ Future storeRecentWalletId(String? walletId) async {
+ if (walletId == null) return;
+ await storageService.instance.setString(
+ StringConstants.recentWalletId,
+ walletId,
+ );
}
@override
@@ -293,21 +299,18 @@ class ExplorerService with CoinbaseService implements IExplorerService {
return null;
}
- @override
- Future deleteConnectedWallet() async {
- await storageService.instance.clearKey(StringConstants.connectedWalletData);
- }
-
Future _updateRecentWalletId(
W3MWalletInfo? walletInfo, {
String? walletId,
}) async {
final recentId = walletInfo?.listing.id ?? walletId ?? '';
// Set the recent
- await storageService.instance.setString(
- StringConstants.recentWalletId,
- recentId,
- );
+ if (recentId.isNotEmpty) {
+ await storageService.instance.setString(
+ StringConstants.recentWalletId,
+ recentId,
+ );
+ }
final currentListings = List.from(
_listings.map((e) => e.copyWith(recent: false)).toList(),
);
@@ -321,7 +324,8 @@ class ExplorerService with CoinbaseService implements IExplorerService {
}
_listings = currentListings;
listings.value = _listings;
- W3MLoggerUtil.logger.t('[$runtimeType] updateRecentPosition($recentId)');
+ W3MLoggerUtil.logger.t(
+ '[$runtimeType] _updateRecentWalletId $walletId ${walletInfo?.toJson()}');
}
@override
@@ -363,6 +367,24 @@ class ExplorerService with CoinbaseService implements IExplorerService {
_debouncer.run(() => isSearching.value = false);
}
+ @override
+ Future getCoinbaseWalletObject() async {
+ final results = await _fetchListings(
+ params: RequestParams(
+ page: 1,
+ entries: 1,
+ search: 'coinbase wallet',
+ platform: _getPlatformType(),
+ ),
+ updateCount: false,
+ );
+
+ if (results.isNotEmpty) {
+ return results.first;
+ }
+ return null;
+ }
+
@override
String getWalletImageUrl(String imageId) =>
'$_apiUrl/getWalletImage/$imageId';
@@ -424,26 +446,18 @@ extension on List {
extension on List {
List sortByRecommended(Set? featuredWalletIds) {
- List sortedByRecommended = [];
- Set recommendedIds = featuredWalletIds ?? {};
- List listToSort = this;
-
- if (recommendedIds.isNotEmpty) {
- for (var recommendedId in featuredWalletIds!) {
- final rw = listToSort.firstWhereOrNull(
- (element) => element.listing.id == recommendedId,
- );
- if (rw != null) {
- sortedByRecommended.add(rw);
- listToSort.removeWhere(
- (element) => element.listing.id == recommendedId,
- );
- }
+ Map sortedMap = {};
+ final auxList = List.from(this);
+
+ for (var id in featuredWalletIds ?? {}) {
+ final featured = auxList.firstWhereOrNull((e) => e.listing.id == id);
+ if (featured != null) {
+ auxList.removeWhere((e) => e.listing.id == id);
+ sortedMap[id] = featured;
}
- sortedByRecommended.addAll(listToSort);
- return sortedByRecommended;
}
- return listToSort;
+
+ return [...sortedMap.values, ...auxList];
}
List setInstalledFlag() {
@@ -463,23 +477,3 @@ extension on List {
return installedApps;
}
}
-
-final _coinbaseWallet = W3MWalletInfo(
- listing: Listing.fromJson({
- 'id': _coinbaseWalletNativeData.id,
- 'name': 'Coinbase Wallet',
- 'homepage': 'https://www.coinbase.com/wallet/',
- 'image_id': 'a5ebc364-8f91-4200-fcc6-be81310a0000',
- 'order': 40,
- 'mobile_link': _coinbaseWalletNativeData.schema,
- 'app_store': 'https://apps.apple.com/app/apple-store/id1278383455',
- 'play_store': 'https://play.google.com/store/apps/details?id=org.toshi',
- }),
- installed: false,
- recent: false,
-);
-
-final _coinbaseWalletNativeData = NativeAppData(
- id: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
- schema: 'cbwallet://wsegue',
-);
diff --git a/lib/services/explorer_service/i_explorer_service.dart b/lib/services/explorer_service/i_explorer_service.dart
index 5624a95a..5c869d8a 100644
--- a/lib/services/explorer_service/i_explorer_service.dart
+++ b/lib/services/explorer_service/i_explorer_service.dart
@@ -18,8 +18,6 @@ abstract class IExplorerService {
/// If includedWalletIds is set only wallets from this list are going to be shown
Set? includedWalletIds;
- bool get includeCoinbaseWallet;
-
/// If excludedWalletIds is set wallets from this list are going to be excluded
Set? excludedWalletIds;
@@ -41,12 +39,11 @@ abstract class IExplorerService {
/// update the recently used position to the top list
Future storeConnectedWallet(W3MWalletInfo? walletInfo);
+ Future storeRecentWalletId(String? walletId);
+
/// Get connected wallet data from local storage
W3MWalletInfo? getConnectedWallet();
- /// Removes connected wallet data from local storage
- Future deleteConnectedWallet();
-
/// Gets the WalletRedirect object from a wallet info data
WalletRedirect? getWalletRedirect(W3MWalletInfo? walletInfo);
@@ -55,4 +52,6 @@ abstract class IExplorerService {
/// Given an imageId it return the chain icon from our services
String getAssetImageUrl(String imageId);
+
+ Future getCoinbaseWalletObject();
}
diff --git a/lib/services/explorer_service/models/redirect.dart b/lib/services/explorer_service/models/redirect.dart
index c844d98b..96b9cf0a 100644
--- a/lib/services/explorer_service/models/redirect.dart
+++ b/lib/services/explorer_service/models/redirect.dart
@@ -18,5 +18,6 @@ class WalletRedirect {
Uri? get desktopUri => desktop != null ? Uri.parse(desktop!) : null;
@override
- String toString() => 'mobile: $mobile, desktop: $desktop, web: $web';
+ String toString() =>
+ 'mobile: $mobile (mobileOnly: $mobileOnly), desktop: $desktop (desktopOnly: $desktopOnly), web: $web (webOnly: $webOnly)';
}
diff --git a/lib/services/storage_service/storage_service.dart b/lib/services/storage_service/storage_service.dart
index f028ad1b..527886a6 100644
--- a/lib/services/storage_service/storage_service.dart
+++ b/lib/services/storage_service/storage_service.dart
@@ -1,4 +1,3 @@
-import 'package:web3modal_flutter/constants/string_constants.dart';
import 'package:web3modal_flutter/services/storage_service/i_storage_service.dart';
import 'package:web3modal_flutter/web3modal_flutter.dart';
@@ -22,12 +21,7 @@ class StorageService implements IStorageService {
@override
Future clearAll() async {
- final walletData = getString(StringConstants.walletData, defaultValue: '');
- final result = await _prefs!.clear();
- if (walletData!.isNotEmpty) {
- await setString(StringConstants.walletData, walletData);
- }
- return result;
+ return await _prefs!.clear();
}
@override
diff --git a/lib/services/w3m_service/i_w3m_service.dart b/lib/services/w3m_service/i_w3m_service.dart
index 6746babb..5b3195f1 100644
--- a/lib/services/w3m_service/i_w3m_service.dart
+++ b/lib/services/w3m_service/i_w3m_service.dart
@@ -1,6 +1,7 @@
-import 'package:event/event.dart';
import 'package:flutter/material.dart';
+
import 'package:web3modal_flutter/web3modal_flutter.dart';
+import 'package:web3modal_flutter/services/w3m_service/models/w3m_session.dart';
enum W3MServiceStatus {
idle,
@@ -29,10 +30,6 @@ abstract class IW3MService with ChangeNotifier {
/// Whether or not this object has been initialized.
W3MServiceStatus get status;
- /// If the [web3App] fails to initialize and throws an exception, this will contain the caught exception.
- /// Otherwise, it will be null.
- dynamic get initError;
-
bool get hasNamespaces;
/// The object that manages sessions, authentication, events, and requests for WalletConnect.
@@ -49,35 +46,21 @@ abstract class IW3MService with ChangeNotifier {
String? get wcUri;
/// The current session's data.
- SessionData? get session;
-
- /// The address of the currently connected account.
- String? get address;
-
- /// Returns the url of the token of the currently selected chain.
- /// Pass this into a [Image.network] and it will load the token image.
- String? get tokenImageUrl;
+ W3MSession? get session;
/// The url to the account's avatar image.
/// Pass this into a [Image.network] and it will load the avatar image.
String? get avatarUrl;
- /// The currently selected chain.
- W3MChainInfo? get selectedChain;
-
/// Returns the balance of the currently connected wallet on the selected chain.
double? get chainBalance;
+ /// The currently selected chain.
+ W3MChainInfo? get selectedChain;
+
/// The currently selected wallet.
W3MWalletInfo? get selectedWallet;
- /// Sets the [selectedChain] and gets the [chainBalance].
- /// If the wallet is already connected, it will request the chain to be changed and will update the session with the new chain.
- /// If [chainInfo] is null this will disconnect the wallet.
- Future selectChain(W3MChainInfo? chainInfo, {bool switchChain = false});
-
- void launchBlockExplorer();
-
/// Sets up the explorer and the web3App if they already been initialized.
Future init();
@@ -92,6 +75,14 @@ abstract class IW3MService with ChangeNotifier {
/// Sets the [selectedWallet] to be connected
void selectWallet(W3MWalletInfo walletInfo);
+ /// Sets the [selectedChain] and gets the [chainBalance].
+ /// If the wallet is already connected, it will request the chain to be changed and will update the session with the new chain.
+ /// If [chainInfo] is null this will disconnect the wallet.
+ Future selectChain(W3MChainInfo? chainInfo, {bool switchChain = false});
+
+ /// Launch blockchain explorer for the current chain in external browser
+ void launchBlockExplorer();
+
/// Used to expire and delete any inactive pairing
Future expirePreviousInactivePairings();
@@ -104,27 +95,43 @@ abstract class IW3MService with ChangeNotifier {
/// Opens the native wallet [selectedWallet] after connected
Future launchConnectedWallet();
+ /// List of available chains to be added in connected wallet
List? getAvailableChains();
/// List of approved chains by connected wallet
List? getApprovedChains();
- /// Gets the name of the currently connected wallet.
- String getReferer();
+ /// List of approved methods by connected wallet
+ List? getApprovedMethods();
+
+ /// List of approved events by connected wallet
+ List? getApprovedEvents();
/// Disconnects the session and pairing, if any.
/// If there is no session, this does nothing.
Future disconnect({bool disconnectAllSessions = true});
+ /// Make a request
+ Future request({
+ required String topic,
+ required String chainId,
+ String? switchToChainId,
+ required SessionRequestParams request,
+ });
+
/// Closes the modal.
void closeModal();
@override
void dispose();
- /// Subscribe to listen to pairing expirations
- final Event onPairingExpire = Event();
+ /* EVENTS DECLARATIONS */
- /// When users rejects connection or an error occurs this will event
- final Event onWalletConnectionError = Event();
+ abstract final Event onSessionConnectEvent;
+ abstract final Event onSessionDeleteEvent;
+ abstract final Event onSessionExpireEvent;
+ abstract final Event onSessionUpdateEvent;
+ abstract final Event onSessionEventEvent;
+ abstract final Event onPairingExpire;
+ abstract final Event onWalletConnectionError;
}
diff --git a/lib/services/w3m_service/models/w3m_session.dart b/lib/services/w3m_service/models/w3m_session.dart
index 0c13869d..add3c0ac 100644
--- a/lib/services/w3m_service/models/w3m_session.dart
+++ b/lib/services/w3m_service/models/w3m_session.dart
@@ -195,11 +195,6 @@ class W3MSession {
if (sessionService.noSession) {
return null;
}
- if (sessionService.isCoinbase) {
- return Redirect(native: 'cbwallet://wsegue');
- }
- // if (sessionService.isMagic) {
- //
return sessionData?.peer.metadata.redirect;
}
diff --git a/lib/services/w3m_service/w3m_service.dart b/lib/services/w3m_service/w3m_service.dart
index 86c51ff1..db238b95 100644
--- a/lib/services/w3m_service/w3m_service.dart
+++ b/lib/services/w3m_service/w3m_service.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -89,8 +90,6 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
@override
final Event onWalletConnectionError = Event();
- bool _connectingWallet = false;
-
W3MService({
IWeb3App? web3App,
String? projectId,
@@ -161,8 +160,9 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
await storageService.instance.init();
await networkService.instance.init();
await explorerService.instance.init();
- if (explorerService.instance.includeCoinbaseWallet) {
- await cbInit(metadata: _web3App.metadata);
+ if (_initializeCoinbaseSDK) {
+ final cbWallet = await explorerService.instance.getCoinbaseWalletObject();
+ await cbInit(metadata: _web3App.metadata, cbWallet: cbWallet);
}
await expirePreviousInactivePairings();
@@ -196,7 +196,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
if (isCbConnected) {
await _storeSession(storedSession);
} else {
- _clearSession();
+ await _cleanSession();
}
}
}
@@ -411,7 +411,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
Future connectSelectedWallet({bool inBrowser = false}) async {
_checkInitialized();
- final selectedWalletRedirect = explorerService.instance?.getWalletRedirect(
+ final selectedWalletRedirect = explorerService.instance.getWalletRedirect(
selectedWallet,
);
if (selectedWalletRedirect == null) {
@@ -419,25 +419,23 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
'You didn\'t select a wallet or walletInfo argument is null',
);
}
-
- if (_connectingWallet) return;
- _connectingWallet = true;
-
var pType = platformUtils.instance.getPlatformType();
if (inBrowser) {
pType = PlatformType.web;
}
try {
- await buildConnectionUri();
- await urlUtils.instance.openRedirect(
- selectedWalletRedirect,
- wcURI: wcUri!,
- pType: pType,
- );
+ if (_selectedWallet!.isCoinbase) {
+ await cbGetAccount();
+ await explorerService.instance.storeConnectedWallet(_selectedWallet);
+ } else {
+ await buildConnectionUri();
+ await urlUtils.instance.openRedirect(
+ selectedWalletRedirect,
+ wcURI: wcUri!,
+ pType: pType,
+ );
+ }
} on LaunchUrlException catch (e) {
- W3MLoggerUtil.logger.e(
- '[$runtimeType] error launching wallet $selectedWalletRedirect',
- );
if (e.message.toLowerCase() != 'app not installed') {
toastUtils.instance.show(
ToastMessage(type: ToastType.error, text: e.message),
@@ -445,14 +443,18 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
}
onWalletConnectionError.broadcast(WalletErrorEvent('not installed'));
} catch (e, s) {
- if (_isUserRejectedError(e)) {
+ if (e is W3MCoinbaseException && e.message == 'App not installed') {
+ onWalletConnectionError.broadcast(WalletErrorEvent('not installed'));
+ } else if (_isUserRejectedError(e)) {
onWalletConnectionError.broadcast(WalletErrorEvent('rejected'));
} else {
- W3MLoggerUtil.logger.e('[$runtimeType] error launching wallet. $e, $s');
+ W3MLoggerUtil.logger.e(
+ '[$runtimeType] Error connecting wallet',
+ error: e,
+ stackTrace: s,
+ );
}
}
-
- _connectingWallet = false;
}
@override
@@ -476,37 +478,43 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
Future _awaitConnectionCallback(ConnectResponse connectResponse) async {
try {
- _currentSession = await connectResponse!.session.future;
- _setSessionValues(_currentSession!);
- await explorerService.instance!.storeConnectedWallet(_selectedWallet);
+ final response = await connectResponse.session.future;
+ await explorerService.instance.storeConnectedWallet(_selectedWallet);
+ W3MLoggerUtil.logger
+ .t('[$runtimeType] Connected with session ${response.toJson()}');
} on TimeoutException {
W3MLoggerUtil.logger
.i('[$runtimeType] Rebuilding session, ending future');
return;
- } on JsonRpcError catch (e) {
- W3MLoggerUtil.logger.e('[$runtimeType] Error connecting to wallet: $e');
+ } on JsonRpcError catch (e, s) {
if (_isUserRejectedError(e)) {
onWalletConnectionError.broadcast(WalletErrorEvent('rejected'));
+ } else {
+ W3MLoggerUtil.logger.e(
+ '[$runtimeType] Error connecting to wallet',
+ error: e,
+ stackTrace: s,
+ );
}
return await expirePreviousInactivePairings();
}
}
@override
- Future launchConnectedWallet() async {
+ Future launchConnectedWallet() async {
_checkInitialized();
- final walletInfo = explorerService.instance!.getConnectedWallet();
+ final walletInfo = explorerService.instance.getConnectedWallet();
if (walletInfo == null) {
// if walletInfo is null could mean that either
// 1. There's no wallet connected (shouldn't happen)
// 2. Wallet is connected on another device through qr code
- return;
+ return false;
}
- final redirect = explorerService.instance!.getWalletRedirect(walletInfo);
+ final redirect = explorerService.instance.getWalletRedirect(walletInfo);
if (redirect == null) {
- return;
+ return false;
}
return await urlUtils.instance.openRedirect(
@@ -538,7 +546,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
}
}
- return await _clearSession();
+ return await _cleanSession();
}
@override
@@ -580,65 +588,44 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
Future request({
required String topic,
required String chainId,
- String? switchToChainId,
required SessionRequestParams request,
- }) {
+ String? switchToChainId,
+ }) async {
if (_currentSession == null) {
throw W3MServiceException('Session is null');
}
try {
if (_currentSession!.sessionService.isCoinbase) {
- return cbRequest(
+ return await cbRequest(
chainId: switchToChainId ?? chainId.split(':').last,
request: request,
);
}
- return _web3App.request(
+ return await _web3App.request(
topic: topic,
chainId: chainId,
request: request,
);
} catch (e, s) {
- W3MLoggerUtil.logger.e('[$runtimeType] request: $e, $s');
- rethrow;
- }
- }
-
- @override
- WalletRedirect? get selectedWalletRedirect {
- final listing = _selectedWallet?.listing;
- if (listing == null) return null;
-
- return explorerService.instance.getWalletRedirect(listing);
- }
-
- Future sessionWalletRedirect() async {
- // final metadata = _currentSession?.peer.metadata;
- // final sessionRedirect = metadata?.redirect;
- final sessionRedirect = _currentSession?.getSessionRedirect();
- if (sessionRedirect == null) {
- final walletString = storageService.instance.getString(
- StringConstants.walletData,
- );
- if ((walletString ?? '').isNotEmpty) {
- final walletInfo = W3MWalletInfo.fromJson(jsonDecode(walletString!));
- return explorerService.instance.getWalletRedirect(walletInfo.listing);
- }
-
- final walletName = _currentSession?.connectedWalletName ?? '';
- if (walletName.isNotEmpty) {
- return await explorerService.instance.tryWalletRedirectByName(
- walletName,
+ if (_isUserRejectedError(e)) {
+ onWalletConnectionError.broadcast(WalletErrorEvent('rejected'));
+ if (request.method == 'wallet_switchEthereumChain' ||
+ request.method == 'wallet_addEthereumChain') {
+ rethrow;
+ }
+ return 'User rejected';
+ } else {
+ W3MLoggerUtil.logger.e(
+ '[$runtimeType] request error',
+ error: e,
+ stackTrace: s,
);
+ // TODO disconnect() if the error is due to no session on Coinbase Wallet.
+ // Coinbase Team must add this event for us.
+ // disconnect();
+ rethrow;
}
}
-
- final nativeLink = sessionRedirect!.native;
- return WalletRedirect(
- mobile: nativeLink,
- desktop: nativeLink,
- web: sessionRedirect.universal,
- );
}
@override
@@ -668,6 +655,21 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
void _notify() => notifyListeners();
+ bool get _initializeCoinbaseSDK {
+ final cbId = CoinbaseService.coinbaseWalletId;
+ final included = (explorerService.instance.includedWalletIds ?? {});
+ final excluded = (explorerService.instance.excludedWalletIds ?? {});
+
+ if (included.isNotEmpty) {
+ return included.contains(cbId);
+ }
+ if (excluded.isNotEmpty) {
+ return !excluded.contains(cbId);
+ }
+
+ return true;
+ }
+
void _setRequiredNamespaces(Map? requiredNSpaces) {
if (requiredNSpaces != null) {
// Set the required namespaces declared by the user on W3MService object
@@ -793,8 +795,8 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
final userDisapproved = stringError.contains('user disapproved');
return userRejected || userDisapproved;
}
- if (e is CoinbaseRPCError) {
- final stringError = e.toJson().toString().toLowerCase();
+ if (e is W3MCoinbaseException) {
+ final stringError = e.message.toLowerCase();
final userDenied = stringError.contains('user denied');
return userDenied;
}
@@ -820,12 +822,18 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService {
);
}
- void _cleanSession() {
- explorerService.instance!.deleteConnectedWallet();
+ Future _cleanSession() async {
+ if (_currentSession?.sessionService.isCoinbase == true) {
+ await cbResetSession();
+ }
+ final walletId = storageService.instance.getString(
+ StringConstants.recentWalletId,
+ );
+ await storageService.instance.clearAll();
+ await explorerService.instance.storeRecentWalletId(walletId);
_currentSelectedChain = null;
_isConnected = false;
_currentSession = null;
- await storageService.instance.clearAll();
_notify();
}
@@ -889,14 +897,13 @@ extension _W3MServiceExtension on W3MService {
@protected
void onCoinbaseConnectEvent(CoinbaseConnectEvent? args) async {
W3MLoggerUtil.logger
- .t('[$runtimeType] onCoinbaseConnect: ${args?.data?.toJson()}');
+ .t('[$runtimeType] onCoinbaseConnectEvent: ${args?.data?.toJson()}');
if (args != null) {
final eChainId = args.data?.chainId ?? _currentSelectedChain!.chainId;
final chainInfo =
W3MChainPresets.chains[eChainId] ?? W3MChainPresets.chains['1']!;
await selectChain(chainInfo);
await _storeSession(W3MSession(coinbaseData: args.data));
- _loadAccountData();
if (_isOpen) {
closeModal();
}
@@ -905,33 +912,36 @@ extension _W3MServiceExtension on W3MService {
@protected
void onCoinbaseErrorEvent(CoinbaseErrorEvent? args) async {
- W3MLoggerUtil.logger
- .e('[$runtimeType] onCoinbaseErrorEvent: ${args?.error}');
- final message = args?.error ?? 'Something wrong happened';
- onWalletConnectionError.broadcast(WalletErrorEvent(message));
+ final errorMessage = args?.error ?? 'Something went wrong';
+ if (!errorMessage.toLowerCase().contains('user denied')) {
+ W3MLoggerUtil.logger
+ .e('[$runtimeType] onCoinbaseErrorEvent: $errorMessage');
+ onWalletConnectionError.broadcast(WalletErrorEvent(errorMessage));
+ }
}
@protected
void onCoinbaseSessionUpdateEvent(CoinbaseSessionEvent? args) async {
W3MLoggerUtil.logger
- .t('[$runtimeType] onCoinbaseSessionEvent: ${args.toString()}');
+ .t('[$runtimeType] onCoinbaseSessionUpdateEvent: ${args.toString()}');
if (args != null) {
- final eChainId = args.chainId ?? _currentSelectedChain!.chainId;
- final eAddress = args.address ?? _currentSession!.address!;
try {
+ final eChainId = args.chainId ?? _currentSelectedChain!.chainId;
+ final eAddress = args.address ?? _currentSession!.address!;
final chainInfo =
W3MChainPresets.chains[eChainId] ?? W3MChainPresets.chains['1']!;
- await selectChain(chainInfo);
final cbData = CoinbaseData(
address: eAddress,
chainName: chainInfo.chainName,
chainId: int.parse(chainInfo.chainId),
);
await _storeSession(W3MSession(coinbaseData: cbData));
- _loadAccountData();
- } catch (e) {
- W3MLoggerUtil.logger
- .e('[$runtimeType] onCoinbaseChainChangedEvent: $e');
+ } catch (e, s) {
+ W3MLoggerUtil.logger.e(
+ '[$runtimeType] onCoinbaseChainChangedEvent',
+ error: e,
+ stackTrace: s,
+ );
}
}
}
@@ -978,7 +988,7 @@ extension _W3MServiceExtension on W3MService {
@protected
void onSessionDelete(SessionDelete? args) {
W3MLoggerUtil.logger.t('[$runtimeType] onSessionDelete: $args');
- _clearSession();
+ _cleanSession();
}
@protected
diff --git a/lib/utils/url/i_url_utils.dart b/lib/utils/url/i_url_utils.dart
index 2a43f8ce..e81ac9e8 100644
--- a/lib/utils/url/i_url_utils.dart
+++ b/lib/utils/url/i_url_utils.dart
@@ -9,7 +9,7 @@ abstract class IUrlUtils {
Future launchUrl(Uri url, {LaunchMode? mode});
- Future openRedirect(
+ Future openRedirect(
WalletRedirect redirect, {
String? wcURI,
PlatformType? pType,
diff --git a/lib/utils/url/url_utils.dart b/lib/utils/url/url_utils.dart
index 0a351d4c..24044c2a 100644
--- a/lib/utils/url/url_utils.dart
+++ b/lib/utils/url/url_utils.dart
@@ -1,4 +1,6 @@
import 'package:appcheck/appcheck.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart';
import 'package:web3modal_flutter/utils/core/core_utils_singleton.dart';
@@ -11,28 +13,35 @@ import 'package:web3modal_flutter/utils/w3m_logger.dart';
Future _launchUrl(Uri url, {LaunchMode? mode}) async {
try {
+ debugPrint('[url_utils] _launchUrl $url');
return await launchUrl(
url,
mode: mode ?? LaunchMode.platformDefault,
);
- } catch (e) {
+ } on PlatformException catch (e, s) {
W3MLoggerUtil.logger.e(
- 'Error launching URL: ${url.toString()}',
+ 'Error launching URL $url',
+ error: e,
+ stackTrace: s,
);
- W3MLoggerUtil.logger.e(e);
- throw LaunchUrlException(
- 'Error launching URL: ${url.toString()}',
+ throw LaunchUrlException('App not installed');
+ } catch (e, s) {
+ W3MLoggerUtil.logger.e(
+ 'Error launching URL $url',
+ error: e,
+ stackTrace: s,
);
+ throw LaunchUrlException('Error launching app');
}
}
-Future _androidLaunch(String uri) async {
+Future _androidAppCheck(String uri) async {
return await AppCheck.isAppEnabled(uri);
}
class UrlUtils extends IUrlUtils {
UrlUtils({
- this.androidAppCheck = _androidLaunch,
+ this.androidAppCheck = _androidAppCheck,
this.launchUrlFunc = _launchUrl,
this.canLaunchUrlFunc = canLaunchUrl,
});
@@ -77,47 +86,50 @@ class UrlUtils extends IUrlUtils {
}
@override
- Future openRedirect(
+ Future openRedirect(
WalletRedirect redirect, {
String? wcURI,
PlatformType? pType,
}) async {
+ Uri? uriToOpen;
try {
- Uri? uriToOpen;
- if ((redirect.mobileOnly || pType == PlatformType.mobile) &&
- redirect.mobile != null) {
- uriToOpen = wcURI != null
- ? coreUtils.instance.formatCustomSchemeUri(
- redirect.mobile,
- wcURI,
- )
- : redirect.mobileUri;
- }
- if ((redirect.webOnly || pType == PlatformType.web) &&
- redirect.web != null) {
- uriToOpen = wcURI != null
- ? coreUtils.instance.formatWebUrl(
- redirect.web,
- wcURI,
- )
- : redirect.webUri;
+ final isMobile = (redirect.mobileOnly || pType == PlatformType.mobile);
+ if (isMobile && redirect.mobile != null) {
+ final uri = wcURI ?? redirect.mobileUri?.toString();
+ uriToOpen = coreUtils.instance.formatCustomSchemeUri(
+ redirect.mobile,
+ uri!,
+ );
}
- if ((redirect.desktopOnly || pType == PlatformType.desktop) &&
- redirect.desktop != null) {
- uriToOpen = wcURI != null
- ? coreUtils.instance.formatCustomSchemeUri(
- redirect.desktop,
- wcURI,
- )
- : redirect.desktopUri;
+ //
+ final isWeb = (redirect.webOnly || pType == PlatformType.web);
+ if (isWeb && redirect.web != null) {
+ final uri = wcURI ?? redirect.webUri?.toString();
+ uriToOpen = coreUtils.instance.formatWebUrl(
+ redirect.web,
+ uri!,
+ );
}
- try {
- await launchUrlFunc(uriToOpen!, mode: LaunchMode.externalApplication);
- } catch (_) {
- throw LaunchUrlException('App not installed');
+ //
+ final isDesktop = (redirect.desktopOnly || pType == PlatformType.desktop);
+ if (isDesktop && redirect.desktop != null) {
+ final uri = wcURI ?? redirect.desktopUri?.toString();
+ uriToOpen = coreUtils.instance.formatCustomSchemeUri(
+ redirect.desktop,
+ uri!,
+ );
}
- } catch (e) {
- rethrow;
+ } catch (e, s) {
+ W3MLoggerUtil.logger.e(
+ 'Error opening redirect',
+ error: e,
+ stackTrace: s,
+ );
+ return false;
}
+ return await launchUrlFunc(
+ uriToOpen!,
+ mode: LaunchMode.externalApplication,
+ );
}
}
diff --git a/lib/widgets/lists/list_items/coinbase_list_item.dart b/lib/widgets/lists/list_items/coinbase_list_item.dart
deleted file mode 100644
index 9626301f..00000000
--- a/lib/widgets/lists/list_items/coinbase_list_item.dart
+++ /dev/null
@@ -1,48 +0,0 @@
-import 'package:flutter/material.dart';
-
-import 'package:web3modal_flutter/theme/w3m_theme.dart';
-import 'package:web3modal_flutter/widgets/avatars/w3m_wallet_avatar.dart';
-import 'package:web3modal_flutter/widgets/lists/list_items/base_list_item.dart';
-
-class CoinbaseListItem extends StatelessWidget {
- const CoinbaseListItem({
- super.key,
- this.title = 'Coinbase',
- this.trailing,
- this.onTap,
- });
- final String title;
- final Widget? trailing;
- final VoidCallback? onTap;
-
- @override
- Widget build(BuildContext context) {
- final themeData = Web3ModalTheme.getDataOf(context);
- final themeColors = Web3ModalTheme.colorsOf(context);
- final radiuses = Web3ModalTheme.radiusesOf(context);
- return BaseListItem(
- onTap: onTap,
- child: Row(
- children: [
- W3MListAvatar(
- borderRadius: radiuses.radius2XS,
- imageUrl:
- 'https://play-lh.googleusercontent.com/wrgUujbq5kbn4Wd4tzyhQnxOXkjiGqq39N4zBvCHmxpIiKcZw_Pb065KTWWlnoejsg=w240-h480',
- ),
- Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12.0),
- child: Text(
- title,
- style: themeData.textStyles.paragraph500.copyWith(
- color: themeColors.foreground100,
- ),
- ),
- ),
- ),
- trailing ?? const SizedBox.shrink(),
- ],
- ),
- );
- }
-}
diff --git a/pubspec.lock b/pubspec.lock
index 8c6d2628..c7df8554 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -937,10 +937,10 @@ packages:
dependency: "direct main"
description:
name: url_launcher
- sha256: e9aa5ea75c84cf46b3db4eea212523591211c3cf2e13099ee4ec147f54201c86
+ sha256: d25bb0ca00432a5e1ee40e69c36c85863addf7cc45e433769d61bed3fe81fd96
url: "https://pub.dev"
source: hosted
- version: "6.2.2"
+ version: "6.2.3"
url_launcher_android:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index dc6c1941..f6d7a689 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -21,7 +21,7 @@ dependencies:
json_annotation: ^4.8.1
qr_flutter_wc: ^0.0.3
shimmer: ^3.0.0
- url_launcher: ^6.2.2
+ url_launcher: ^6.2.3
walletconnect_flutter_v2: ^2.1.12
dev_dependencies:
diff --git a/test/mock_classes.mocks.dart b/test/mock_classes.mocks.dart
index 1f180c4f..6bf45f14 100644
--- a/test/mock_classes.mocks.dart
+++ b/test/mock_classes.mocks.dart
@@ -3,58 +3,56 @@
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
-import 'dart:async' as _i15;
-import 'dart:convert' as _i28;
-import 'dart:typed_data' as _i29;
-import 'dart:ui' as _i19;
+import 'dart:async' as _i14;
+import 'dart:convert' as _i27;
+import 'dart:typed_data' as _i28;
+import 'dart:ui' as _i17;
import 'package:flutter/foundation.dart' as _i2;
import 'package:flutter/material.dart' as _i11;
import 'package:http/http.dart' as _i9;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i13;
-import 'package:url_launcher/url_launcher.dart' as _i21;
+import 'package:url_launcher/url_launcher.dart' as _i19;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/i_message_tracker.dart'
as _i7;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/json_rpc_2/src/peer.dart'
- as _i27;
-import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart'
as _i26;
+import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart'
+ as _i25;
import 'package:walletconnect_flutter_v2/apis/core/relay_client/websocket/i_websocket_handler.dart'
as _i8;
import 'package:walletconnect_flutter_v2/apis/core/store/i_generic_store.dart'
as _i4;
import 'package:walletconnect_flutter_v2/apis/core/store/i_store.dart' as _i6;
import 'package:walletconnect_flutter_v2/apis/sign_api/i_sessions.dart' as _i5;
-import 'package:web3modal_flutter/models/grid_item.dart' as _i31;
+import 'package:web3modal_flutter/models/grid_item.dart' as _i30;
import 'package:web3modal_flutter/services/blockchain_api_service/blockchain_api_utils.dart'
- as _i32;
+ as _i31;
import 'package:web3modal_flutter/services/blockchain_api_service/blockchain_identity.dart'
as _i10;
import 'package:web3modal_flutter/services/coinbase_service/models/coinbase_events.dart'
- as _i14;
+ as _i16;
import 'package:web3modal_flutter/services/explorer_service/explorer_service.dart'
as _i12;
-import 'package:web3modal_flutter/services/explorer_service/models/api_response.dart'
- as _i17;
import 'package:web3modal_flutter/services/explorer_service/models/redirect.dart'
- as _i16;
+ as _i20;
import 'package:web3modal_flutter/services/ledger_service/ledger_service.dart'
- as _i33;
+ as _i32;
import 'package:web3modal_flutter/services/network_service/network_service.dart'
- as _i30;
+ as _i29;
import 'package:web3modal_flutter/services/storage_service/storage_service.dart'
- as _i34;
+ as _i33;
import 'package:web3modal_flutter/services/w3m_service/i_w3m_service.dart'
- as _i18;
-import 'package:web3modal_flutter/utils/platform/i_platform_utils.dart' as _i22;
-import 'package:web3modal_flutter/utils/platform/platform_utils.dart' as _i23;
-import 'package:web3modal_flutter/utils/toast/toast_message.dart' as _i25;
-import 'package:web3modal_flutter/utils/toast/toast_utils.dart' as _i24;
-import 'package:web3modal_flutter/utils/url/url_utils.dart' as _i20;
+ as _i15;
+import 'package:web3modal_flutter/utils/platform/i_platform_utils.dart' as _i21;
+import 'package:web3modal_flutter/utils/platform/platform_utils.dart' as _i22;
+import 'package:web3modal_flutter/utils/toast/toast_message.dart' as _i24;
+import 'package:web3modal_flutter/utils/toast/toast_utils.dart' as _i23;
+import 'package:web3modal_flutter/utils/url/url_utils.dart' as _i18;
import 'package:web3modal_flutter/web3modal_flutter.dart' as _i3;
import 'package:web3modal_flutter/widgets/widget_stack/widget_stack.dart'
- as _i35;
+ as _i34;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@@ -394,102 +392,43 @@ class MockExplorerService extends _i1.Mock implements _i12.ExplorerService {
returnValue: false,
) as bool);
@override
- bool get includeCoinbaseWallet => (super.noSuchMethod(
- Invocation.getter(#includeCoinbaseWallet),
- returnValue: false,
- ) as bool);
- @override
- _i3.Event<_i14.CoinbaseConnectEvent> get onCoinbaseConnect =>
- (super.noSuchMethod(
- Invocation.getter(#onCoinbaseConnect),
- returnValue: _FakeEvent_1<_i14.CoinbaseConnectEvent>(
- this,
- Invocation.getter(#onCoinbaseConnect),
- ),
- ) as _i3.Event<_i14.CoinbaseConnectEvent>);
- @override
- set onCoinbaseConnect(
- _i3.Event<_i14.CoinbaseConnectEvent>? _onCoinbaseConnect) =>
- super.noSuchMethod(
- Invocation.setter(
- #onCoinbaseConnect,
- _onCoinbaseConnect,
- ),
- returnValueForMissingStub: null,
- );
- @override
- _i3.Event<_i14.CoinbaseErrorEvent> get onCoinbaseError => (super.noSuchMethod(
- Invocation.getter(#onCoinbaseError),
- returnValue: _FakeEvent_1<_i14.CoinbaseErrorEvent>(
- this,
- Invocation.getter(#onCoinbaseError),
- ),
- ) as _i3.Event<_i14.CoinbaseErrorEvent>);
- @override
- set onCoinbaseError(_i3.Event<_i14.CoinbaseErrorEvent>? _onCoinbaseError) =>
- super.noSuchMethod(
- Invocation.setter(
- #onCoinbaseError,
- _onCoinbaseError,
- ),
- returnValueForMissingStub: null,
- );
- @override
- _i3.Event<_i14.CoinbaseSessionEvent> get onCoinbaseSessionUpdate =>
- (super.noSuchMethod(
- Invocation.getter(#onCoinbaseSessionUpdate),
- returnValue: _FakeEvent_1<_i14.CoinbaseSessionEvent>(
- this,
- Invocation.getter(#onCoinbaseSessionUpdate),
- ),
- ) as _i3.Event<_i14.CoinbaseSessionEvent>);
- @override
- set onCoinbaseSessionUpdate(
- _i3.Event<_i14.CoinbaseSessionEvent>? _onCoinbaseSessionUpdate) =>
- super.noSuchMethod(
- Invocation.setter(
- #onCoinbaseSessionUpdate,
- _onCoinbaseSessionUpdate,
- ),
- returnValueForMissingStub: null,
- );
- @override
- _i3.Event<_i14.CoinbaseResponseEvent> get onCoinbaseResponse =>
- (super.noSuchMethod(
- Invocation.getter(#onCoinbaseResponse),
- returnValue: _FakeEvent_1<_i14.CoinbaseResponseEvent>(
- this,
- Invocation.getter(#onCoinbaseResponse),
- ),
- ) as _i3.Event<_i14.CoinbaseResponseEvent>);
- @override
- _i15.Future init() => (super.noSuchMethod(
+ _i14.Future init() => (super.noSuchMethod(
Invocation.method(
#init,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future paginate() => (super.noSuchMethod(
+ _i14.Future paginate() => (super.noSuchMethod(
Invocation.method(
#paginate,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future storeConnectedWalletData(_i3.W3MWalletInfo? walletInfo) =>
+ _i14.Future storeConnectedWallet(_i3.W3MWalletInfo? walletInfo) =>
(super.noSuchMethod(
Invocation.method(
- #storeConnectedWalletData,
+ #storeConnectedWallet,
[walletInfo],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
+ @override
+ _i14.Future storeRecentWalletId(String? walletId) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #storeRecentWalletId,
+ [walletId],
+ ),
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
void search({String? query}) => super.noSuchMethod(
Invocation.method(
@@ -500,6 +439,15 @@ class MockExplorerService extends _i1.Mock implements _i12.ExplorerService {
returnValueForMissingStub: null,
);
@override
+ _i14.Future<_i3.W3MWalletInfo?> getCoinbaseWalletObject() =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #getCoinbaseWalletObject,
+ [],
+ ),
+ returnValue: _i14.Future<_i3.W3MWalletInfo?>.value(),
+ ) as _i14.Future<_i3.W3MWalletInfo?>);
+ @override
String getWalletImageUrl(String? imageId) => (super.noSuchMethod(
Invocation.method(
#getWalletImageUrl,
@@ -527,82 +475,6 @@ class MockExplorerService extends _i1.Mock implements _i12.ExplorerService {
),
),
) as String);
- @override
- _i16.WalletRedirect? getWalletRedirect(_i17.Listing? listing) =>
- (super.noSuchMethod(Invocation.method(
- #getWalletRedirect,
- [listing],
- )) as _i16.WalletRedirect?);
- @override
- _i15.Future<_i16.WalletRedirect?> tryWalletRedirectByName(String? name) =>
- (super.noSuchMethod(
- Invocation.method(
- #tryWalletRedirectByName,
- [name],
- ),
- returnValue: _i15.Future<_i16.WalletRedirect?>.value(),
- ) as _i15.Future<_i16.WalletRedirect?>);
- @override
- _i15.Future cbInit({required _i3.PairingMetadata? metadata}) =>
- (super.noSuchMethod(
- Invocation.method(
- #cbInit,
- [],
- {#metadata: metadata},
- ),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
- @override
- _i15.Future cbGetAccount() => (super.noSuchMethod(
- Invocation.method(
- #cbGetAccount,
- [],
- ),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
- @override
- _i15.Future cbRequest({
- String? chainId,
- required _i3.SessionRequestParams? request,
- }) =>
- (super.noSuchMethod(
- Invocation.method(
- #cbRequest,
- [],
- {
- #chainId: chainId,
- #request: request,
- },
- ),
- returnValue: _i15.Future.value(),
- ) as _i15.Future);
- @override
- _i15.Future cbIsInstalled() => (super.noSuchMethod(
- Invocation.method(
- #cbIsInstalled,
- [],
- ),
- returnValue: _i15.Future.value(false),
- ) as _i15.Future);
- @override
- _i15.Future cbIsConnected() => (super.noSuchMethod(
- Invocation.method(
- #cbIsConnected,
- [],
- ),
- returnValue: _i15.Future.value(false),
- ) as _i15.Future);
- @override
- _i15.Future cbResetSession() => (super.noSuchMethod(
- Invocation.method(
- #cbResetSession,
- [],
- ),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
}
/// A class which mocks [W3MService].
@@ -622,19 +494,19 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
),
) as _i3.Event<_i3.PairingEvent>);
@override
- _i3.Event<_i18.WalletErrorEvent> get onWalletConnectionError =>
+ _i3.Event<_i15.WalletErrorEvent> get onWalletConnectionError =>
(super.noSuchMethod(
Invocation.getter(#onWalletConnectionError),
- returnValue: _FakeEvent_1<_i18.WalletErrorEvent>(
+ returnValue: _FakeEvent_1<_i15.WalletErrorEvent>(
this,
Invocation.getter(#onWalletConnectionError),
),
- ) as _i3.Event<_i18.WalletErrorEvent>);
+ ) as _i3.Event<_i15.WalletErrorEvent>);
@override
- _i18.W3MServiceStatus get status => (super.noSuchMethod(
+ _i15.W3MServiceStatus get status => (super.noSuchMethod(
Invocation.getter(#status),
- returnValue: _i18.W3MServiceStatus.idle,
- ) as _i18.W3MServiceStatus);
+ returnValue: _i15.W3MServiceStatus.idle,
+ ) as _i15.W3MServiceStatus);
@override
bool get hasNamespaces => (super.noSuchMethod(
Invocation.getter(#hasNamespaces),
@@ -697,17 +569,17 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
returnValue: false,
) as bool);
@override
- _i3.Event<_i14.CoinbaseConnectEvent> get onCoinbaseConnect =>
+ _i3.Event<_i16.CoinbaseConnectEvent> get onCoinbaseConnect =>
(super.noSuchMethod(
Invocation.getter(#onCoinbaseConnect),
- returnValue: _FakeEvent_1<_i14.CoinbaseConnectEvent>(
+ returnValue: _FakeEvent_1<_i16.CoinbaseConnectEvent>(
this,
Invocation.getter(#onCoinbaseConnect),
),
- ) as _i3.Event<_i14.CoinbaseConnectEvent>);
+ ) as _i3.Event<_i16.CoinbaseConnectEvent>);
@override
set onCoinbaseConnect(
- _i3.Event<_i14.CoinbaseConnectEvent>? _onCoinbaseConnect) =>
+ _i3.Event<_i16.CoinbaseConnectEvent>? _onCoinbaseConnect) =>
super.noSuchMethod(
Invocation.setter(
#onCoinbaseConnect,
@@ -716,15 +588,15 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
returnValueForMissingStub: null,
);
@override
- _i3.Event<_i14.CoinbaseErrorEvent> get onCoinbaseError => (super.noSuchMethod(
+ _i3.Event<_i16.CoinbaseErrorEvent> get onCoinbaseError => (super.noSuchMethod(
Invocation.getter(#onCoinbaseError),
- returnValue: _FakeEvent_1<_i14.CoinbaseErrorEvent>(
+ returnValue: _FakeEvent_1<_i16.CoinbaseErrorEvent>(
this,
Invocation.getter(#onCoinbaseError),
),
- ) as _i3.Event<_i14.CoinbaseErrorEvent>);
+ ) as _i3.Event<_i16.CoinbaseErrorEvent>);
@override
- set onCoinbaseError(_i3.Event<_i14.CoinbaseErrorEvent>? _onCoinbaseError) =>
+ set onCoinbaseError(_i3.Event<_i16.CoinbaseErrorEvent>? _onCoinbaseError) =>
super.noSuchMethod(
Invocation.setter(
#onCoinbaseError,
@@ -733,17 +605,17 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
returnValueForMissingStub: null,
);
@override
- _i3.Event<_i14.CoinbaseSessionEvent> get onCoinbaseSessionUpdate =>
+ _i3.Event<_i16.CoinbaseSessionEvent> get onCoinbaseSessionUpdate =>
(super.noSuchMethod(
Invocation.getter(#onCoinbaseSessionUpdate),
- returnValue: _FakeEvent_1<_i14.CoinbaseSessionEvent>(
+ returnValue: _FakeEvent_1<_i16.CoinbaseSessionEvent>(
this,
Invocation.getter(#onCoinbaseSessionUpdate),
),
- ) as _i3.Event<_i14.CoinbaseSessionEvent>);
+ ) as _i3.Event<_i16.CoinbaseSessionEvent>);
@override
set onCoinbaseSessionUpdate(
- _i3.Event<_i14.CoinbaseSessionEvent>? _onCoinbaseSessionUpdate) =>
+ _i3.Event<_i16.CoinbaseSessionEvent>? _onCoinbaseSessionUpdate) =>
super.noSuchMethod(
Invocation.setter(
#onCoinbaseSessionUpdate,
@@ -752,25 +624,25 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
returnValueForMissingStub: null,
);
@override
- _i3.Event<_i14.CoinbaseResponseEvent> get onCoinbaseResponse =>
+ _i3.Event<_i16.CoinbaseResponseEvent> get onCoinbaseResponse =>
(super.noSuchMethod(
Invocation.getter(#onCoinbaseResponse),
- returnValue: _FakeEvent_1<_i14.CoinbaseResponseEvent>(
+ returnValue: _FakeEvent_1<_i16.CoinbaseResponseEvent>(
this,
Invocation.getter(#onCoinbaseResponse),
),
- ) as _i3.Event<_i14.CoinbaseResponseEvent>);
+ ) as _i3.Event<_i16.CoinbaseResponseEvent>);
@override
- _i15.Future init() => (super.noSuchMethod(
+ _i14.Future init() => (super.noSuchMethod(
Invocation.method(
#init,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future selectChain(
+ _i14.Future selectChain(
_i3.W3MChainInfo? chainInfo, {
bool? switchChain = false,
}) =>
@@ -780,11 +652,11 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
[chainInfo],
{#switchChain: switchChain},
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future openModal(
+ _i14.Future openModal(
_i11.BuildContext? context, [
_i11.Widget? startWidget,
]) =>
@@ -796,67 +668,66 @@ class MockW3MService extends _i1.Mock implements _i3.W3MService {
startWidget,
],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future expirePreviousInactivePairings() => (super.noSuchMethod(
+ _i14.Future expirePreviousInactivePairings() => (super.noSuchMethod(
Invocation.method(
#expirePreviousInactivePairings,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future connectSelectedWallet({bool? inBrowser = false}) =>
+ _i14.Future connectSelectedWallet({bool? inBrowser = false}) =>
(super.noSuchMethod(
Invocation.method(
#connectSelectedWallet,
[],
{#inBrowser: inBrowser},
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future buildConnectionUri() => (super.noSuchMethod(
+ _i14.Future buildConnectionUri() => (super.noSuchMethod(
Invocation.method(
#buildConnectionUri,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future.value(),
+ ) as _i14.Future);
@override
- _i15.Future launchConnectedWallet() => (super.noSuchMethod(
+ _i14.Future launchConnectedWallet() => (super.noSuchMethod(
Invocation.method(
#launchConnectedWallet,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(false),
+ ) as _i14.Future);
@override
- _i15.Future reconnectRelay() => (super.noSuchMethod(
+ _i14.Future reconnectRelay() => (super.noSuchMethod(
Invocation.method(
#reconnectRelay,
[],
),
- returnValue: _i15.Future.value(),
- returnValueForMissingStub: _i15.Future.value(),
- ) as _i15.Future);
+ returnValue: _i14.Future.value(),
+ returnValueForMissingStub: _i14.Future