Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Jul 4, 2024
1 parent a619862 commit c06defe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:fl_toast/fl_toast.dart';
import 'package:flutter/material.dart';
import 'package:walletconnect_flutter_dapp/utils/constants.dart';
import 'package:walletconnect_flutter_dapp/utils/crypto/siwe_service.dart';

import 'package:web3modal_flutter/web3modal_flutter.dart';

import 'package:walletconnect_flutter_dapp/utils/constants.dart';
import 'package:walletconnect_flutter_dapp/utils/crypto/siwe_service.dart';
import 'package:walletconnect_flutter_dapp/widgets/logger_widget.dart';
import 'package:walletconnect_flutter_dapp/widgets/session_widget.dart';
import 'package:walletconnect_flutter_dapp/utils/dart_defines.dart';
Expand Down
4 changes: 0 additions & 4 deletions lib/services/w3m_service/models/w3m_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class W3MSession {
CoinbaseData? coinbaseData,
MagicData? magicData,
SIWESession? siweSession,
List<Cacao>? cacaos,
}) : _sessionData = sessionData,
_coinbaseData = coinbaseData,
_magicData = magicData,
Expand All @@ -40,7 +39,6 @@ class W3MSession {
final coinbaseDataString = map['coinbaseData'];
final magicDataString = map['magicData'];
final siweSession = map['siweSession'];
final cacaos = map['cacaos'] as List?;
return W3MSession(
sessionData: sessionDataString != null
? SessionData.fromJson(sessionDataString)
Expand All @@ -52,7 +50,6 @@ class W3MSession {
magicDataString != null ? MagicData.fromJson(magicDataString) : null,
siweSession:
siweSession != null ? SIWESession.fromJson(siweSession) : null,
cacaos: cacaos?.map((c) => Cacao.fromJson(c)).toList(),
);
}

Expand All @@ -61,7 +58,6 @@ class W3MSession {
CoinbaseData? coinbaseData,
MagicData? magicData,
SIWESession? siweSession,
List<Cacao>? cacaos,
}) {
return W3MSession(
sessionData: sessionData ?? _sessionData,
Expand Down
9 changes: 3 additions & 6 deletions lib/services/w3m_service/w3m_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ extension _W3MServiceExtension on W3MService {
if (args != null) {
if (args.session != null) {
// IF 1-CA SUPPORTED WE SHOULD CALL SIWECONGIF METHODS HERE
final session = await _settleSession(args.session!, cacaos: args.auths);
final session = await _settleSession(args.session!);
final namespace = args.session!.namespaces[StringConstants.namespace]!;
final chains = namespace.chains!.map((c) => c.split(':').last).toList()
..sort();
Expand Down Expand Up @@ -1649,18 +1649,15 @@ extension _W3MServiceExtension on W3MService {
}

// HAS TO BE CALLED JUST ONCE ON CONNECTION
Future<W3MSession> _settleSession(
SessionData sessionData, {
List<Cacao>? cacaos,
}) async {
Future<W3MSession> _settleSession(SessionData sessionData) async {
if (_currentSelectedChain == null) {
final chains = NamespaceUtils.getChainIdsFromNamespaces(
namespaces: sessionData.namespaces,
)..sort((a, b) => a.compareTo(b));
final chainId = chains.first.split(':').last.toString();
_currentSelectedChain = W3MChainPresets.chains[chainId];
}
final session = W3MSession(sessionData: sessionData, cacaos: cacaos);
final session = W3MSession(sessionData: sessionData);
await _setSesionAndChainData(session);
if (_selectedWallet == null) {
analyticsService.instance.sendEvent(ConnectSuccessEvent(
Expand Down

0 comments on commit c06defe

Please sign in to comment.