Skip to content

Commit 055cb54

Browse files
committed
fixed tests and minor changes
1 parent 8985c42 commit 055cb54

14 files changed

Lines changed: 365 additions & 130 deletions

example/sign/lib/widgets/method_dialog.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ class MethodDialogState extends State<MethodDialog> {
4848
if (snapshot.hasData) {
4949
final String t = jsonEncode(snapshot.data);
5050
return InkWell(
51-
onTap: () async {
52-
await Clipboard.setData(
53-
ClipboardData(
54-
text: t,
55-
),
56-
);
57-
showPlatformToast(
58-
child: const Text(
59-
StringConstants.copiedToClipboard,
51+
onTap: () {
52+
Clipboard.setData(ClipboardData(text: t)).then(
53+
(_) => showPlatformToast(
54+
child: const Text(StringConstants.copiedToClipboard),
55+
context: context,
6056
),
61-
context: context,
6257
);
6358
},
6459
child: Text(
@@ -69,15 +64,12 @@ class MethodDialogState extends State<MethodDialog> {
6964
return InkWell(
7065
onTap: () async {
7166
await Clipboard.setData(
72-
ClipboardData(
73-
text: snapshot.data.toString(),
74-
),
75-
);
76-
showPlatformToast(
77-
child: const Text(
78-
StringConstants.copiedToClipboard,
67+
ClipboardData(text: snapshot.data.toString()),
68+
).then(
69+
(_) => showPlatformToast(
70+
child: const Text(StringConstants.copiedToClipboard),
71+
context: context,
7972
),
80-
context: context,
8173
);
8274
},
8375
child: Text(

generate_files.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
echo ' 🔄 Updating dependencies...'
4+
flutter pub get
5+
flutter pub run build_runner build --delete-conflicting-outputs
6+
7+
cd example/sign/
8+
9+
echo ' ⬇️ Getting dependencies...'
10+
flutter pub get
11+
flutter pub run build_runner build --delete-conflicting-outputs

lib/pages/qr_code_and_wallet_list_page.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import 'package:walletconnect_modal_flutter/widgets/walletconnect_modal_provider
1414

1515
class QRCodeAndWalletListPage extends StatelessWidget {
1616
const QRCodeAndWalletListPage()
17-
: super(
18-
key: WalletConnectModalConstants.qrCodeAndWalletListPageKey,
19-
);
17+
: super(key: WalletConnectModalConstants.qrCodeAndWalletListPageKey);
2018

2119
@override
2220
Widget build(BuildContext context) {

lib/pages/qr_code_page.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class QRCodePage extends StatelessWidget {
1818

1919
@override
2020
Widget build(BuildContext context) {
21-
final IWalletConnectModalService service =
22-
WalletConnectModalProvider.of(context).service;
21+
final service = WalletConnectModalProvider.of(context).service;
2322

2423
return WalletConnectModalNavBar(
2524
title: const WalletConnectModalNavbarTitle(

lib/pages/wallet_list_short_page.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import 'package:walletconnect_modal_flutter/widgets/walletconnect_modal_provider
1515

1616
class WalletListShortPage extends StatelessWidget {
1717
const WalletListShortPage()
18-
: super(
19-
key: WalletConnectModalConstants.walletListShortPageKey,
20-
);
18+
: super(key: WalletConnectModalConstants.walletListShortPageKey);
2119

2220
@override
2321
Widget build(BuildContext context) {

lib/services/utils/widget_stack/widget_stack.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WidgetStack extends IWidgetStack {
7171

7272
@override
7373
void addDefault() {
74-
final PlatformType pType = platformUtils.instance.getPlatformType();
74+
final pType = platformUtils.instance.getPlatformType();
7575

7676
// Choose the state based on platform
7777
if (pType == PlatformType.mobile) {

lib/services/walletconnect_modal/i_walletconnect_modal_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class IWalletConnectModalService implements ChangeNotifier {
3434
/// This is only available after the [open] function is called.
3535
String? get wcUri;
3636

37-
final Event<EventArgs> onPairingExpire = Event();
37+
final Event<EventArgs> onPairingExpireEvent = Event();
3838

3939
Future<void> clearPreviousInactivePairings();
4040

lib/services/walletconnect_modal/walletconnect_modal_service.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WalletConnectModalService extends ChangeNotifier
7171
Map<String, RequiredNamespace> get optionalNamespaces => _optionalNamespaces;
7272

7373
@override
74-
final Event<EventArgs> onPairingExpire = Event();
74+
final Event<EventArgs> onPairingExpireEvent = Event();
7575

7676
ConnectResponse? connectResponse;
7777
Future<SessionData>? get sessionFuture => connectResponse?.session.future;
@@ -139,14 +139,10 @@ class WalletConnectModalService extends ChangeNotifier
139139
_initError = null;
140140
try {
141141
await _web3App!.init();
142-
} catch (_) {}
143-
144-
try {
145142
await WalletConnectModalServices.init();
143+
await clearPreviousInactivePairings();
146144
} catch (_) {}
147145

148-
await clearPreviousInactivePairings();
149-
150146
if (_web3App!.sessions.getAll().isNotEmpty) {
151147
_isConnected = true;
152148
_session = _web3App!.sessions.getAll().first;
@@ -364,7 +360,7 @@ class WalletConnectModalService extends ChangeNotifier
364360

365361
void _onPairingExpire(PairingEvent? args) async {
366362
_web3App!.core.pairing.onPairingExpire.unsubscribe(_onPairingExpire);
367-
onPairingExpire.broadcast();
363+
onPairingExpireEvent.broadcast();
368364
}
369365

370366
bool _connectingWallet = false;

lib/widgets/qr_code_widget.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'dart:math';
33
import 'package:event/event.dart';
44
import 'package:flutter/material.dart';
55
import 'package:qr_flutter/qr_flutter.dart';
6-
import 'package:walletconnect_modal_flutter/models/walletconnect_modal_theme_data.dart';
76
import 'package:walletconnect_modal_flutter/services/utils/platform/platform_utils_singleton.dart';
87
import 'package:walletconnect_modal_flutter/services/walletconnect_modal/i_walletconnect_modal_service.dart';
98
import 'package:walletconnect_modal_flutter/widgets/walletconnect_modal_theme.dart';
@@ -31,8 +30,9 @@ class _QRCodeWidgetState extends State<QRCodeWidget> {
3130
super.initState();
3231
WidgetsBinding.instance.addPostFrameCallback((_) async {
3332
widget.service.addListener(_rebuild);
34-
widget.service.onPairingExpire.subscribe(_onPairingExpire);
33+
widget.service.onPairingExpireEvent.subscribe(_onPairingExpire);
3534
await widget.service.rebuildConnectionUri();
35+
_rebuild();
3636
});
3737
}
3838

@@ -42,7 +42,7 @@ class _QRCodeWidgetState extends State<QRCodeWidget> {
4242

4343
@override
4444
void dispose() {
45-
widget.service.onPairingExpire.unsubscribe(_onPairingExpire);
45+
widget.service.onPairingExpireEvent.unsubscribe(_onPairingExpire);
4646
widget.service.removeListener(_rebuild);
4747
widget.service.clearPreviousInactivePairings();
4848
super.dispose();
@@ -57,8 +57,7 @@ class _QRCodeWidgetState extends State<QRCodeWidget> {
5757

5858
@override
5959
Widget build(BuildContext context) {
60-
WalletConnectModalThemeData themeData =
61-
WalletConnectModalTheme.getData(context);
60+
final themeData = WalletConnectModalTheme.getData(context);
6261

6362
bool isLongBottomSheet = platformUtils.instance.isLongBottomSheet(
6463
MediaQuery.of(context).orientation,

test/mock_classes.dart

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:walletconnect_flutter_v2/apis/core/pairing/pairing_store.dart';
12
import 'package:walletconnect_flutter_v2/apis/core/relay_client/relay_client.dart';
23
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';
34
import 'package:walletconnect_modal_flutter/services/explorer/explorer_service.dart';
@@ -9,16 +10,21 @@ import 'package:walletconnect_modal_flutter/walletconnect_modal_flutter.dart';
910
import 'package:mockito/annotations.dart';
1011
import 'package:http/http.dart' as http;
1112

12-
@GenerateMocks([
13-
ExplorerService,
14-
WalletConnectModalService,
15-
UrlUtils,
16-
PlatformUtils,
17-
ToastUtils,
18-
Web3App,
19-
Sessions,
20-
RelayClient,
21-
StorageService,
22-
http.Client,
23-
])
13+
@GenerateMocks(
14+
[
15+
ExplorerService,
16+
WalletConnectModalService,
17+
UrlUtils,
18+
PlatformUtils,
19+
ToastUtils,
20+
Web3App,
21+
Sessions,
22+
RelayClient,
23+
StorageService,
24+
http.Client,
25+
],
26+
customMocks: [
27+
MockSpec<PairingStore>(onMissingStub: OnMissingStub.returnDefault),
28+
],
29+
)
2430
class Mocks {}

0 commit comments

Comments
 (0)