diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea78..a24ee211 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,22 +17,19 @@ Steps to reproduce the behavior: 3. Scroll down to '....' 4. See error -**Expected behavior** -A clear and concise description of what you expected to happen. +**Meaningful logs** +Any error or information log that would help identify the issue + +**Reproducible code** +Minimum reproducible code of the issue **Screenshots** If applicable, add screenshots to help explain your problem. -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + - Web3Modal Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/CHANGELOG.md b/CHANGELOG.md index b3af0266..d03c45b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.2.3-alpha01 + +- One-Click Auth implementation + ## 3.2.2 - Network change improvements diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 9c768ec9..fb8d414f 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -44,25 +44,36 @@ class _MyHomePageState extends State { // See https://docs.walletconnect.com/web3modal/flutter/custom-chains W3MChainPresets.chains.addAll(W3MChainPresets.extraChains); W3MChainPresets.chains.addAll(W3MChainPresets.testChains); - // W3MChainPresets.chains.removeWhere((key, _) => key != '137'); + + final sortedChains = W3MChainPresets.chains.keys.toList() + ..sort((e1, e2) => e1.compareTo(e2)); + + final ocaRequestParams = OCARequestParams( + chains: sortedChains.map((e) => 'eip155:$e').toList(), + domain: 'web3modal.com', + nonce: AuthUtils.generateNonce(), + uri: 'https://web3modal.com/login', + statement: 'Welcome to Web3Modal for Flutter.', + methods: MethodsConstants.allMethods, + ); _w3mService = W3MService( projectId: DartDefines.projectId, logLevel: LogLevel.error, - metadata: const PairingMetadata( + metadata: PairingMetadata( name: StringConstants.w3mPageTitleV3, description: StringConstants.w3mPageTitleV3, - url: 'https://web3modal.com/', + url: 'https://${ocaRequestParams.domain}/', icons: [ 'https://docs.walletconnect.com/assets/images/web3modalLogo-2cee77e07851ba0a710b56d03d4d09dd.png' ], - redirect: Redirect( + redirect: const Redirect( native: 'web3modalflutter://', - universal: 'https://web3modal.com', ), ), - enableAnalytics: true, // OPTIONAL - null by default - enableEmail: true, // OPTIONAL - false by default + ocaRequestParams: ocaRequestParams, + // enableAnalytics: true, // OPTIONAL - null by default + // enableEmail: true, // OPTIONAL - false by default // requiredNamespaces: {}, // optionalNamespaces: {}, // excludedWalletIds: { diff --git a/example/pubspec.lock b/example/pubspec.lock index 7946a7b8..7230aed1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1105,10 +1105,10 @@ packages: dependency: transitive description: name: walletconnect_flutter_v2 - sha256: cc6fa6a537910a66258ee64bb510edbfc0dee01485ea1138651431087c94671b + sha256: "6bfd9e700f5fc712edf487e49842ba682a5e7ba0570f7299c9162e7dd7b5d549" url: "https://pub.dev" source: hosted - version: "2.2.3" + version: "2.3.0-alpha01" watcher: dependency: transitive description: @@ -1139,7 +1139,7 @@ packages: path: ".." relative: true source: path - version: "3.2.2" + version: "3.2.3-alpha01" web_socket_channel: dependency: transitive description: diff --git a/lib/pages/qr_code_page.dart b/lib/pages/qr_code_page.dart index 9aabf993..81be908a 100644 --- a/lib/pages/qr_code_page.dart +++ b/lib/pages/qr_code_page.dart @@ -51,8 +51,14 @@ class _QRCodePageState extends State { setState(() {}); } - void _onError(EventArgs? args) { - _showUserRejection(); + void _onError(ModalError? args) { + final event = args ?? ModalError('An error occurred'); + toastUtils.instance.show( + ToastMessage( + type: ToastType.error, + text: event.message, + ), + ); } @override @@ -144,8 +150,4 @@ class _QRCodePageState extends State { ToastMessage(type: ToastType.success, text: 'Link copied'), ); } - - void _showUserRejection() => toastUtils.instance.show( - ToastMessage(type: ToastType.error, text: 'User rejected'), - ); } diff --git a/lib/services/analytics_service/analytics_service.dart b/lib/services/analytics_service/analytics_service.dart index 55433a5b..027beb0a 100644 --- a/lib/services/analytics_service/analytics_service.dart +++ b/lib/services/analytics_service/analytics_service.dart @@ -45,9 +45,9 @@ class AnalyticsService implements IAnalyticsService { _endpoint = kDebugMode ? _debugApiEndpoint : await coreUtils.instance.getAnalyticsUrl(); - loggerService.instance.p('[$runtimeType] enabled: $_isEnabled'); + loggerService.instance.d('[$runtimeType] enabled: $_isEnabled'); } catch (e, s) { - loggerService.instance.p( + loggerService.instance.d( '[$runtimeType] init error', error: e, stackTrace: s, @@ -68,7 +68,7 @@ class AnalyticsService implements IAnalyticsService { final enabled = json['isAnalyticsEnabled'] as bool?; return enabled ?? false; } catch (e, s) { - loggerService.instance.p( + loggerService.instance.d( '[$runtimeType] fetch remote configuration error', error: e, stackTrace: s, @@ -101,9 +101,9 @@ class AnalyticsService implements IAnalyticsService { if (code == 200 || code == 202) { _eventsController.sink.add(analyticsEvent.toMap()); } - loggerService.instance.p('[$runtimeType] send event $code: $body'); + loggerService.instance.d('[$runtimeType] send event $code: $body'); } catch (e, s) { - loggerService.instance.p( + loggerService.instance.d( '[$runtimeType] send event error', error: e, stackTrace: s, diff --git a/lib/services/explorer_service/explorer_service.dart b/lib/services/explorer_service/explorer_service.dart index 410f2c33..0d0894eb 100644 --- a/lib/services/explorer_service/explorer_service.dart +++ b/lib/services/explorer_service/explorer_service.dart @@ -157,7 +157,7 @@ class ExplorerService implements IExplorerService { sampleWallets.add(sampleWallet); } } - loggerService.instance.p( + loggerService.instance.d( '[$runtimeType] sample wallets: ${sampleWallets.length}', ); return sampleWallets; @@ -399,7 +399,7 @@ class ExplorerService implements IExplorerService { final excludedIds = (excludedWalletIds ?? {}); final exclude = excludedIds.isNotEmpty ? excludedIds.join(',') : null; - loggerService.instance.p('[$runtimeType] search $query'); + loggerService.instance.d('[$runtimeType] search $query'); _currentSearchValue = query; final newListins = await _fetchListings( params: RequestParams( diff --git a/lib/services/logger_service/i_logger_service.dart b/lib/services/logger_service/i_logger_service.dart index b8f9544d..fa66f574 100644 --- a/lib/services/logger_service/i_logger_service.dart +++ b/lib/services/logger_service/i_logger_service.dart @@ -25,14 +25,6 @@ abstract class ILoggerService { StackTrace? stackTrace, }); - /// Log a message at level [Level.warning]. - void w( - dynamic message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }); - /// Log a message at level [Level.error]. void e( dynamic message, { @@ -41,31 +33,6 @@ abstract class ILoggerService { StackTrace? stackTrace, }); - /// Log a message at level [Level.fatal]. - void f( - dynamic message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }); - - /// Log a message with [level]. - void log( - Level level, - dynamic message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }); - - /// Log a message at level private. - void p( - dynamic message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }); - /// Closes the logger and releases all resources. Future close(); } diff --git a/lib/services/logger_service/logger_service.dart b/lib/services/logger_service/logger_service.dart index baa44529..21d65a41 100644 --- a/lib/services/logger_service/logger_service.dart +++ b/lib/services/logger_service/logger_service.dart @@ -6,13 +6,10 @@ import 'package:web3modal_flutter/web3modal_flutter.dart'; class LoggerService implements ILoggerService { late Logger _logger; - late String _projectId; LoggerService({ required LogLevel level, - required String projectId, - bool debugMode = true, + bool debugMode = kDebugMode, }) { - _projectId = projectId; _logger = Logger( level: level.toLevel(), printer: PrettyPrinter(methodCount: null), @@ -22,22 +19,7 @@ class LoggerService implements ILoggerService { } } - void _logListener(LogEvent event) { - debugPrint('${event.message}'); - } - - @override - void p( - message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }) { - // TODO [LoggerService] fix this - if (_projectId == 'cad4956f31a5e40a00b62865b030c6f8') { - _logger.i(message, time: time, error: error, stackTrace: stackTrace); - } - } + void _logListener(LogEvent event) => debugPrint('${event.message}'); @override void d( @@ -59,16 +41,6 @@ class LoggerService implements ILoggerService { _logger.e(message, time: time, error: error, stackTrace: stackTrace); } - @override - void f( - message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }) { - _logger.f(message, time: time, error: error, stackTrace: stackTrace); - } - @override void i( message, { @@ -79,18 +51,6 @@ class LoggerService implements ILoggerService { _logger.i(message, time: time, error: error, stackTrace: stackTrace); } - @override - void log( - Level level, - message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }) { - _logger.log(level, message, - time: time, error: error, stackTrace: stackTrace); - } - @override void t( message, { @@ -101,19 +61,11 @@ class LoggerService implements ILoggerService { _logger.t(message, time: time, error: error, stackTrace: stackTrace); } - @override - void w( - message, { - DateTime? time, - Object? error, - StackTrace? stackTrace, - }) { - _logger.w(message, time: time, error: error, stackTrace: stackTrace); - } - @override Future close() async { - Logger.removeLogListener(_logListener); + try { + Logger.removeLogListener(_logListener); + } catch (_) {} return await _logger.close(); } } diff --git a/lib/services/magic_service/magic_service.dart b/lib/services/magic_service/magic_service.dart index 6dbbb558..0729f1ac 100644 --- a/lib/services/magic_service/magic_service.dart +++ b/lib/services/magic_service/magic_service.dart @@ -143,14 +143,15 @@ class MagicService implements IMagicService { onWebResourceError: _onWebResourceError, onPageFinished: (String url) async { _onLoadCount++; + // If bundleId/packageName is whitelisted in cloud then for some reason it enters here twice + // Like as if secure-mobile.walletconnect.com is loaded twice + // If bundleId/packageName is NOT whitelisted in cloud then it enter just once. + // This is happening only on Android devices, on iOS only once execution is done no matter what. if (_onLoadCount < 2 && Platform.isAndroid) return; - await _runJavascript(_web3app.core.projectId); - Future.delayed(Duration(milliseconds: 200)).then((_) async { - try { - _initialized.complete(true); - } catch (e) { - loggerService.instance.e('[$runtimeType] CRASH! $e'); - } + await _runJavascript(); + Future.delayed(Duration(milliseconds: 600)).then((value) { + if (_initialized.isCompleted) return; + _initialized.complete(true); }); }, ), @@ -327,7 +328,7 @@ class MagicService implements IMagicService { void _onFrameMessage(JavaScriptMessage jsMessage) async { if (Platform.isAndroid) { - loggerService.instance.p('[$runtimeType] jsMessage ${jsMessage.message}'); + loggerService.instance.d('[$runtimeType] jsMessage ${jsMessage.message}'); } try { final frameMessage = jsMessage.toFrameMessage(); @@ -482,7 +483,7 @@ class MagicService implements IMagicService { _error(SignOutErrorEvent()); } } catch (e, s) { - loggerService.instance.p('[$runtimeType] $jsMessage', stackTrace: s); + loggerService.instance.d('[$runtimeType] $jsMessage', stackTrace: s); } } @@ -531,24 +532,24 @@ class MagicService implements IMagicService { onMagicError.broadcast(errorEvent); } - Future _runJavascript(String projectId) async { + Future _runJavascript() async { return await _webViewController.runJavaScript(''' const iframeFL = document.getElementById('frame-mobile-sdk') - + window.addEventListener('message', ({ data, origin }) => { - console.log('w3mMessage received <=== ' + JSON.stringify({data,origin})) + console.log('[MagicService] received <=== ' + JSON.stringify({data,origin})) window.w3mWebview.postMessage(JSON.stringify({data,origin})) }) const sendW3Message = async (message) => { - console.log('w3mMessage posted =====> ' + JSON.stringify(message)) + console.log('[MagicService] posted =====> ' + JSON.stringify(message)) iframeFL.contentWindow.postMessage(message, '*') } '''); } void _onDebugConsoleReceived(JavaScriptConsoleMessage message) { - loggerService.instance.p('[$runtimeType] JS Console ${message.message}'); + loggerService.instance.d('[$runtimeType] JS Console ${message.message}'); } void _onWebResourceError(WebResourceError error) { diff --git a/lib/services/w3m_service/events/w3m_events.dart b/lib/services/w3m_service/events/w3m_events.dart index 9956f2a5..07200ef4 100644 --- a/lib/services/w3m_service/events/w3m_events.dart +++ b/lib/services/w3m_service/events/w3m_events.dart @@ -50,5 +50,5 @@ class ErrorOpeningWallet extends ModalError { } class UserRejectedConnection extends ModalError { - UserRejectedConnection() : super('User rejected Wallet connection'); + UserRejectedConnection() : super('User rejected connection'); } diff --git a/lib/services/w3m_service/w3m_service.dart b/lib/services/w3m_service/w3m_service.dart index e8747a87..45e283c8 100644 --- a/lib/services/w3m_service/w3m_service.dart +++ b/lib/services/w3m_service/w3m_service.dart @@ -66,6 +66,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { Map _requiredNamespaces = {}; Map _optionalNamespaces = {}; + OCARequestParams? _ocaRequestParams; @override bool get hasNamespaces => @@ -112,6 +113,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { IWeb3App? web3App, String? projectId, PairingMetadata? metadata, + OCARequestParams? ocaRequestParams, Map? requiredNamespaces, Map? optionalNamespaces, Set? featuredWalletIds, @@ -140,10 +142,10 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { metadata: metadata!, ); _projectId = _web3App.core.projectId; + _ocaRequestParams = ocaRequestParams; loggerService.instance = LoggerService( level: logLevel, - projectId: _projectId, debugMode: kDebugMode, ); @@ -560,18 +562,6 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { name: walletName, platform: inBrowser ? AnalyticsPlatform.web : AnalyticsPlatform.mobile, ); - // if (walletRedirect?.mobileOnly == true) { - // event = SelectWalletEvent( - // name: walletName, - // platform: AnalyticsPlatform.mobile.name, - // ); - // } - // if (walletRedirect?.webOnly == true) { - // event = SelectWalletEvent( - // name: walletName, - // platform: AnalyticsPlatform.web.name, - // ); - // } analyticsService.instance.sendEvent(event); } @@ -657,53 +647,102 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { @override Future buildConnectionUri() async { if (!_isConnected) { - loggerService.instance.i( - '[$runtimeType] Connecting to WalletConnect, ' - 'required namespaces: $_requiredNamespaces, ' - 'optional namespaces: $_optionalNamespaces', - ); - - final connectResponse = await _web3App.connect( - requiredNamespaces: _requiredNamespaces, - optionalNamespaces: _optionalNamespaces, - ); - _wcUri = connectResponse.uri?.toString() ?? ''; - _notify(); - _awaitConnectionCallback(connectResponse); + if (_ocaRequestParams != null) { + // One-Click Auth + loggerService.instance.d( + '[$runtimeType] Sending One-Click Auth request to ' + '${_selectedWallet?.listing.name} with params ' + '${jsonEncode(_ocaRequestParams!.toJson())}', + ); + final authResponse = await _web3App.authenticate( + params: _ocaRequestParams!, + ); + _wcUri = authResponse.uri?.toString() ?? ''; + _notify(); + _awaitOCAuthCallback(authResponse); + } else { + // Regular Session Proposal + loggerService.instance.d( + '[$runtimeType] Sending Session Proposal to ' + '${_selectedWallet?.listing.name} with ' + 'required namespaces: ${jsonEncode(_requiredNamespaces)} and ' + 'optional namespaces: ${jsonEncode(_optionalNamespaces)}', + ); + final connectResponse = await _web3App.connect( + requiredNamespaces: _requiredNamespaces, + optionalNamespaces: _optionalNamespaces, + ); + _wcUri = connectResponse.uri?.toString() ?? ''; + _notify(); + _awaitConnectionCallback(connectResponse); + } } } - Future _awaitConnectionCallback(ConnectResponse connectResponse) async { + void _awaitConnectionCallback(ConnectResponse connectResponse) async { try { final response = await connectResponse.session.future; - await explorerService.instance.storeConnectedWallet(_selectedWallet); loggerService.instance.t( - '[$runtimeType] Connected with session ${response.toJson()}', + '[$runtimeType] Connected with session ${jsonEncode(response.toJson())}', ); } on TimeoutException { loggerService.instance.i( '[$runtimeType] Rebuilding session, ending future', ); return; - } on JsonRpcError catch (e, s) { - if (_isUserRejectedError(e)) { - loggerService.instance.i('[$runtimeType] User declined connection'); - onModalError.broadcast(UserRejectedConnection()); - analyticsService.instance.sendEvent(ConnectErrorEvent( - message: 'User declined connection', - )); - } else { - final message = e.message ?? 'Error connecting to wallet'; - loggerService.instance.e( - '[$runtimeType] $message', - error: e, - stackTrace: s, + } catch (e) { + await _connectionErrorHandler(e); + } + } + + Future _connectionErrorHandler(dynamic e) async { + if (_isUserRejectedError(e)) { + loggerService.instance.i('[$runtimeType] User declined connection'); + onModalError.broadcast(UserRejectedConnection()); + analyticsService.instance.sendEvent(ConnectErrorEvent( + message: 'User declined connection', + )); + } else if (e.toString().contains('wc_sessionAuthenticate')) { + // TODO + return; + } else { + final message = (e is JsonRpcError) + ? 'Error connecting to wallet' + : (e is WalletConnectError) + ? e.message + : 'Error connecting to wallet'; + onModalError.broadcast(ModalError(message)); + loggerService.instance.e('[$runtimeType] $message', error: e); + analyticsService.instance.sendEvent(ConnectErrorEvent( + message: message, + )); + } + return await expirePreviousInactivePairings(); + } + + void _awaitOCAuthCallback(OCARequestResponse authResponse) async { + try { + final response = await authResponse.completer.future; + if (response.session != null) { + loggerService.instance.t( + '[$runtimeType] Connected with session ${jsonEncode(response.toJson())}', ); - analyticsService.instance.sendEvent(ConnectErrorEvent( - message: message, - )); + _web3App.onSessionConnect.broadcast(SessionConnect(response.session!)); + } else { + if (response.jsonRpcError != null) { + throw response.jsonRpcError!; + } + if (response.error != null) { + throw response.error!; + } } - return await expirePreviousInactivePairings(); + } on TimeoutException { + loggerService.instance.i( + '[$runtimeType] Rebuilding session, ending future', + ); + return; + } catch (e) { + await _connectionErrorHandler(e); } } @@ -1302,7 +1341,7 @@ class W3MService with ChangeNotifier, CoinbaseService implements IW3MService { extension _W3MMagicExtension on W3MService { Future _onMagicLoginEvent(MagicLoginEvent? args) async { - _logger.p('[$runtimeType] _onMagicLoginEvent $args'); + _logger.d('[$runtimeType] _onMagicLoginEvent $args'); if (args != null) { final chainId = args.data?.chainId.toString(); // final chainId = _savedChainId(args.data?.chainId.toString()); @@ -1325,7 +1364,7 @@ extension _W3MMagicExtension on W3MService { } Future _onMagicSessionUpdateEvent(MagicSessionEvent? args) async { - _logger.p('[$runtimeType] _onMagicUpdateEvent: $args'); + _logger.d('[$runtimeType] _onMagicUpdateEvent: $args'); if (args != null) { try { final newEmail = args.email ?? _currentSession!.email; @@ -1341,7 +1380,7 @@ extension _W3MMagicExtension on W3MService { final session = _currentSession!.copyWith(magicData: newData); await _setSesionAndChainData(session); } catch (e, s) { - _logger.p( + _logger.d( '[$runtimeType] _onMagicUpdateEvent: $e', stackTrace: s, ); @@ -1350,7 +1389,7 @@ extension _W3MMagicExtension on W3MService { } Future _onMagicErrorEvent(MagicErrorEvent? args) async { - _logger.p('[$runtimeType] _onMagicErrorEvent ${args?.error}'); + _logger.d('[$runtimeType] _onMagicErrorEvent ${args?.error}'); final errorMessage = args?.error ?? 'Something went wrong'; if (!errorMessage.toLowerCase().contains('user denied')) { onModalError.broadcast(ModalError(errorMessage)); @@ -1359,7 +1398,7 @@ extension _W3MMagicExtension on W3MService { } void _onMagicRequest(MagicRequestEvent? args) { - _logger.p('[$runtimeType] _onMagicRequest ${args?.toString()}'); + _logger.d('[$runtimeType] _onMagicRequest ${args?.toString()}'); if (args?.result != null) { closeModal(); } @@ -1376,7 +1415,7 @@ extension _W3MMagicExtension on W3MService { extension _W3MCoinbaseExtension on W3MService { void _onCoinbaseConnectEvent(CoinbaseConnectEvent? args) async { - _logger.p('[$runtimeType] _onCoinbaseConnectEvent $args'); + _logger.d('[$runtimeType] _onCoinbaseConnectEvent $args'); if (args != null) { final chainId = _savedChainId(args.data?.chainId.toString()); final newChainId = chainId ?? '1'; @@ -1394,7 +1433,7 @@ extension _W3MCoinbaseExtension on W3MService { } void _onCoinbaseSessionUpdateEvent(CoinbaseSessionEvent? args) async { - _logger.p('[$runtimeType] _onCoinbaseSessionUpdateEvent $args'); + _logger.d('[$runtimeType] _onCoinbaseSessionUpdateEvent $args'); if (args != null) { try { final address = args.address ?? _currentSession!.address!; @@ -1409,7 +1448,7 @@ extension _W3MCoinbaseExtension on W3MService { final session = _currentSession!.copyWith(coinbaseData: newData); await _setSesionAndChainData(session); } catch (e, s) { - _logger.p( + _logger.d( '[$runtimeType] _onCoinbaseSessionUpdateEvent: $e', stackTrace: s, ); @@ -1418,7 +1457,7 @@ extension _W3MCoinbaseExtension on W3MService { } void _onCoinbaseErrorEvent(CoinbaseErrorEvent? args) async { - _logger.p('[$runtimeType] _onCoinbaseErrorEvent ${args?.error}'); + _logger.d('[$runtimeType] _onCoinbaseErrorEvent ${args?.error}'); final errorMessage = args?.error ?? 'Something went wrong'; if (!errorMessage.toLowerCase().contains('user denied')) { onModalError.broadcast(ModalError(errorMessage)); @@ -1431,10 +1470,10 @@ extension _W3MServiceExtension on W3MService { _logger.i('[$runtimeType] session connect $args'); if (args != null) { if (_currentSelectedChain == null) { - final chain = NamespaceUtils.getChainIdsFromNamespaces( + final chains = NamespaceUtils.getChainIdsFromNamespaces( namespaces: args.session.namespaces, - ).first; - final chainId = chain.split(':').last.toString(); + )..sort((a, b) => a.compareTo(b)); + final chainId = chains.first.split(':').last.toString(); _currentSelectedChain = W3MChainPresets.chains[chainId]; } final session = W3MSession(sessionData: args.session); @@ -1447,6 +1486,7 @@ extension _W3MServiceExtension on W3MService { storageService.instance.clearKey(StringConstants.recentWalletId); storageService.instance.clearKey(StringConstants.connectedWalletData); } else { + explorerService.instance.storeConnectedWallet(_selectedWallet); final walletName = _selectedWallet!.listing.name; analyticsService.instance.sendEvent(ConnectSuccessEvent( name: walletName, diff --git a/lib/utils/url/url_utils.dart b/lib/utils/url/url_utils.dart index 4ef4bf6e..b478dea8 100644 --- a/lib/utils/url/url_utils.dart +++ b/lib/utils/url/url_utils.dart @@ -64,9 +64,9 @@ class UrlUtils extends IUrlUtils { } } on FormatException catch (e) { if (id != null) { - loggerService.instance.p('[$runtimeType] $uri ($id): ${e.message}'); + loggerService.instance.d('[$runtimeType] $uri ($id): ${e.message}'); } else { - loggerService.instance.p('[$runtimeType] $uri: ${e.message}'); + loggerService.instance.d('[$runtimeType] $uri: ${e.message}'); } } catch (e) { rethrow; diff --git a/lib/version.dart b/lib/version.dart index cf4332e2..be5cd58b 100644 --- a/lib/version.dart +++ b/lib/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '3.2.2'; +const packageVersion = '3.2.3-alpha01'; diff --git a/pubspec.lock b/pubspec.lock index 326e3576..d2bbd640 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1081,10 +1081,10 @@ packages: dependency: "direct main" description: name: walletconnect_flutter_v2 - sha256: cc6fa6a537910a66258ee64bb510edbfc0dee01485ea1138651431087c94671b + sha256: "6bfd9e700f5fc712edf487e49842ba682a5e7ba0570f7299c9162e7dd7b5d549" url: "https://pub.dev" source: hosted - version: "2.2.3" + version: "2.3.0-alpha01" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d1a0da9d..76271480 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.2.2 +version: 3.2.3-alpha01 repository: https://github.com/WalletConnect/Web3ModalFlutter environment: @@ -25,7 +25,7 @@ dependencies: shimmer: ^3.0.0 url_launcher: ^6.2.5 uuid: ^4.3.3 - walletconnect_flutter_v2: ^2.2.3 + walletconnect_flutter_v2: 2.3.0-alpha01 webview_flutter: ^4.7.0 webview_flutter_android: ^3.16.0 webview_flutter_wkwebview: ^3.13.0 diff --git a/test/mock_classes.mocks.dart b/test/mock_classes.mocks.dart index 1b473d2e..d1f7e7ae 100644 --- a/test/mock_classes.mocks.dart +++ b/test/mock_classes.mocks.dart @@ -122,8 +122,9 @@ class _FakeISignEngine_4 extends _i1.SmartFake implements _i3.ISignEngine { ); } -class _FakeIAuthEngine_5 extends _i1.SmartFake implements _i3.IAuthEngine { - _FakeIAuthEngine_5( +class _FakeIGenericStore_5 extends _i1.SmartFake + implements _i4.IGenericStore { + _FakeIGenericStore_5( Object parent, Invocation parentInvocation, ) : super( @@ -132,9 +133,8 @@ class _FakeIAuthEngine_5 extends _i1.SmartFake implements _i3.IAuthEngine { ); } -class _FakeIGenericStore_6 extends _i1.SmartFake - implements _i4.IGenericStore { - _FakeIGenericStore_6( +class _FakeISessions_6 extends _i1.SmartFake implements _i5.ISessions { + _FakeISessions_6( Object parent, Invocation parentInvocation, ) : super( @@ -143,8 +143,8 @@ class _FakeIGenericStore_6 extends _i1.SmartFake ); } -class _FakeISessions_7 extends _i1.SmartFake implements _i5.ISessions { - _FakeISessions_7( +class _FakeIPairingStore_7 extends _i1.SmartFake implements _i3.IPairingStore { + _FakeIPairingStore_7( Object parent, Invocation parentInvocation, ) : super( @@ -153,8 +153,9 @@ class _FakeISessions_7 extends _i1.SmartFake implements _i5.ISessions { ); } -class _FakeIPairingStore_8 extends _i1.SmartFake implements _i3.IPairingStore { - _FakeIPairingStore_8( +class _FakeConnectResponse_8 extends _i1.SmartFake + implements _i3.ConnectResponse { + _FakeConnectResponse_8( Object parent, Invocation parentInvocation, ) : super( @@ -163,9 +164,9 @@ class _FakeIPairingStore_8 extends _i1.SmartFake implements _i3.IPairingStore { ); } -class _FakeConnectResponse_9 extends _i1.SmartFake - implements _i3.ConnectResponse { - _FakeConnectResponse_9( +class _FakeAuthRequestResponse_9 extends _i1.SmartFake + implements _i3.AuthRequestResponse { + _FakeAuthRequestResponse_9( Object parent, Invocation parentInvocation, ) : super( @@ -174,9 +175,9 @@ class _FakeConnectResponse_9 extends _i1.SmartFake ); } -class _FakeAuthRequestResponse_10 extends _i1.SmartFake - implements _i3.AuthRequestResponse { - _FakeAuthRequestResponse_10( +class _FakeOCARequestResponse_10 extends _i1.SmartFake + implements _i3.OCARequestResponse { + _FakeOCARequestResponse_10( Object parent, Invocation parentInvocation, ) : super( @@ -1211,22 +1212,6 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { returnValueForMissingStub: null, ); @override - _i3.IAuthEngine get authEngine => (super.noSuchMethod( - Invocation.getter(#authEngine), - returnValue: _FakeIAuthEngine_5( - this, - Invocation.getter(#authEngine), - ), - ) as _i3.IAuthEngine); - @override - set authEngine(_i3.IAuthEngine? _authEngine) => super.noSuchMethod( - Invocation.setter( - #authEngine, - _authEngine, - ), - returnValueForMissingStub: null, - ); - @override _i3.Event<_i3.SessionConnect> get onSessionConnect => (super.noSuchMethod( Invocation.getter(#onSessionConnect), returnValue: _FakeEvent_1<_i3.SessionConnect>( @@ -1294,7 +1279,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { @override _i4.IGenericStore<_i3.ProposalData> get proposals => (super.noSuchMethod( Invocation.getter(#proposals), - returnValue: _FakeIGenericStore_6<_i3.ProposalData>( + returnValue: _FakeIGenericStore_5<_i3.ProposalData>( this, Invocation.getter(#proposals), ), @@ -1302,7 +1287,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { @override _i5.ISessions get sessions => (super.noSuchMethod( Invocation.getter(#sessions), - returnValue: _FakeISessions_7( + returnValue: _FakeISessions_6( this, Invocation.getter(#sessions), ), @@ -1311,7 +1296,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { _i4.IGenericStore<_i3.SessionRequest> get pendingRequests => (super.noSuchMethod( Invocation.getter(#pendingRequests), - returnValue: _FakeIGenericStore_6<_i3.SessionRequest>( + returnValue: _FakeIGenericStore_5<_i3.SessionRequest>( this, Invocation.getter(#pendingRequests), ), @@ -1319,7 +1304,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { @override _i3.IPairingStore get pairings => (super.noSuchMethod( Invocation.getter(#pairings), - returnValue: _FakeIPairingStore_8( + returnValue: _FakeIPairingStore_7( this, Invocation.getter(#pairings), ), @@ -1333,9 +1318,17 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { ), ) as _i3.Event<_i3.AuthResponse>); @override + _i3.Event<_i3.OCAuthResponse> get onOCAuthResponse => (super.noSuchMethod( + Invocation.getter(#onOCAuthResponse), + returnValue: _FakeEvent_1<_i3.OCAuthResponse>( + this, + Invocation.getter(#onOCAuthResponse), + ), + ) as _i3.Event<_i3.OCAuthResponse>); + @override _i4.IGenericStore<_i3.AuthPublicKey> get authKeys => (super.noSuchMethod( Invocation.getter(#authKeys), - returnValue: _FakeIGenericStore_6<_i3.AuthPublicKey>( + returnValue: _FakeIGenericStore_5<_i3.AuthPublicKey>( this, Invocation.getter(#authKeys), ), @@ -1343,7 +1336,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { @override _i4.IGenericStore get pairingTopics => (super.noSuchMethod( Invocation.getter(#pairingTopics), - returnValue: _FakeIGenericStore_6( + returnValue: _FakeIGenericStore_5( this, Invocation.getter(#pairingTopics), ), @@ -1352,7 +1345,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { _i4.IGenericStore<_i3.StoredCacao> get completeRequests => (super.noSuchMethod( Invocation.getter(#completeRequests), - returnValue: _FakeIGenericStore_6<_i3.StoredCacao>( + returnValue: _FakeIGenericStore_5<_i3.StoredCacao>( this, Invocation.getter(#completeRequests), ), @@ -1395,7 +1388,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { }, ), returnValue: - _i14.Future<_i3.ConnectResponse>.value(_FakeConnectResponse_9( + _i14.Future<_i3.ConnectResponse>.value(_FakeConnectResponse_8( this, Invocation.method( #connect, @@ -1576,7 +1569,7 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { }, ), returnValue: _i14.Future<_i3.AuthRequestResponse>.value( - _FakeAuthRequestResponse_10( + _FakeAuthRequestResponse_9( this, Invocation.method( #requestAuth, @@ -1590,6 +1583,38 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { )), ) as _i14.Future<_i3.AuthRequestResponse>); @override + _i14.Future<_i3.OCARequestResponse> authenticate({ + required _i3.OCARequestParams? params, + String? pairingTopic, + List>? methods = const [ + [r'wc_sessionAuthenticate'] + ], + }) => + (super.noSuchMethod( + Invocation.method( + #authenticate, + [], + { + #params: params, + #pairingTopic: pairingTopic, + #methods: methods, + }, + ), + returnValue: _i14.Future<_i3.OCARequestResponse>.value( + _FakeOCARequestResponse_10( + this, + Invocation.method( + #authenticate, + [], + { + #params: params, + #pairingTopic: pairingTopic, + #methods: methods, + }, + ), + )), + ) as _i14.Future<_i3.OCARequestResponse>); + @override Map getCompletedRequestsForPairing( {required String? pairingTopic}) => (super.noSuchMethod( @@ -1601,6 +1626,22 @@ class MockWeb3App extends _i1.Mock implements _i3.Web3App { returnValue: {}, ) as Map); @override + _i14.Future validateSignedCacao({ + required _i3.Cacao? cacao, + required String? projectId, + }) => + (super.noSuchMethod( + Invocation.method( + #validateSignedCacao, + [], + { + #cacao: cacao, + #projectId: projectId, + }, + ), + returnValue: _i14.Future.value(false), + ) as _i14.Future); + @override String formatAuthMessage({ required String? iss, required _i3.CacaoRequestPayload? cacaoPayload, @@ -1944,7 +1985,7 @@ class MockRelayClient extends _i1.Mock implements _i25.RelayClient { @override _i4.IGenericStore get topicMap => (super.noSuchMethod( Invocation.getter(#topicMap), - returnValue: _FakeIGenericStore_6( + returnValue: _FakeIGenericStore_5( this, Invocation.getter(#topicMap), ),