Skip to content

Commit 6171c1d

Browse files
author
Sterling Long
committed
2.1.0
1 parent 1ba52c5 commit 6171c1d

11 files changed

Lines changed: 38 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.1.0
2+
3+
- Added `reconnectRelay` to the WalletConnectModalService to allow for manual reconnection to the relay
4+
- Updated tests to reflect new changes
5+
16
## 2.0.0
27

38
- Added setOptionalNamespaces to WalletConnectModalService

example/sign/lib/models/eth/ethereum_transaction.g.dart

Lines changed: 0 additions & 44 deletions
This file was deleted.

lib/constants/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
class WalletConnectModalConstants {
4-
static const WALLETCONNECT_MODAL_VERSION = '2.0.0';
4+
static const WALLETCONNECT_MODAL_VERSION = '2.1.0';
55

66
static const Key helpPageKey = Key('helpPageKey');
77
static const Key qrCodePageKey = Key('qrCodePageKey');

lib/services/walletconnect_modal/i_walletconnect_modal_service.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ abstract class IWalletConnectModalService implements ChangeNotifier {
4949
/// Closes the modal.
5050
void close();
5151

52+
/// Connects to the relay if not already connected.
53+
/// If the relay is already connected, this does nothing.
54+
Future<void> reconnectRelay();
55+
5256
/// Disconnects the session and pairing, if any.
5357
/// If there is no session, this does nothing.
5458
Future<void> disconnect();

lib/services/walletconnect_modal/walletconnect_modal_service.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ class WalletConnectModalService extends ChangeNotifier
247247
}
248248
}
249249

250+
@override
251+
Future<void> reconnectRelay() async {
252+
_checkInitialized();
253+
254+
await web3App!.core.relayClient.connect();
255+
}
256+
250257
@override
251258
Future<void> disconnect() async {
252259
_checkInitialized();

lib/widgets/walletconnect_modal_connect.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ class _WalletConnectModalConnectState extends State<WalletConnectModalConnect> {
199199
}
200200

201201
void _reconnect() {
202-
widget.service.web3App!.core.relayClient.connect(
203-
// relayUrl: WalletConnectConstants.DEFAULT_RELAY_URL,
204-
// relayUrl: 'https://test.walletconnect.org',
205-
);
202+
widget.service.reconnectRelay();
206203

207204
setState(() {
208205
_state = WalletConnectModalConnectButtonState.reconnecting;

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: walletconnect_modal_flutter
22
description: The WalletConnectModal for WalletConnect built using Flutter.
3-
version: 2.0.0
3+
version: 2.1.0
44
repository: https://github.com/WalletConnect/WalletConnectModalFlutter
55

66
environment:

test/mock_classes.mocks.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,15 @@ class MockWalletConnectModalService extends _i1.Mock
580580
returnValueForMissingStub: null,
581581
);
582582
@override
583+
_i4.Future<void> reconnectRelay() => (super.noSuchMethod(
584+
Invocation.method(
585+
#reconnectRelay,
586+
[],
587+
),
588+
returnValue: _i4.Future<void>.value(),
589+
returnValueForMissingStub: _i4.Future<void>.value(),
590+
) as _i4.Future<void>);
591+
@override
583592
_i4.Future<void> disconnect() => (super.noSuchMethod(
584593
Invocation.method(
585594
#disconnect,

test/walletconnect_modal_connect/walletconnect_modal_connect_ui_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void main() {
127127
when(service.initError).thenReturn(
128128
const WalletConnectError(code: -1, message: 'Network error'),
129129
);
130+
// when(service.reconnectRelay()).thenAnswer((_) async {});
130131

131132
final GlobalKey key = GlobalKey();
132133
// late BuildContext context;
@@ -166,7 +167,8 @@ void main() {
166167

167168
// Disabled button after tap
168169
await tester.tap(find.byKey(key));
169-
verifyNoMoreInteractions(service);
170+
await tester.pump();
171+
verify(service.reconnectRelay()).called(1);
170172
});
171173
});
172174
}

test/walletconnect_modal_service/walletconnect_modal_service_ui_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ void main() {
4747
when(web3App.onSessionDelete).thenReturn(
4848
Event<SessionDelete>(),
4949
);
50+
when(web3App.onSessionConnect).thenReturn(
51+
Event<SessionConnect>(),
52+
);
5053
when(web3App.init()).thenAnswer((_) async {});
5154
when(web3App.connect(
5255
requiredNamespaces: anyNamed('requiredNamespaces'),

0 commit comments

Comments
 (0)