Skip to content

Commit

Permalink
Relay client init no longer fails on no internet
Browse files Browse the repository at this point in the history
  • Loading branch information
Sterling Long committed Aug 11, 2023
1 parent ae63ef4 commit 3b27b06
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.3

- Relay Client no longer throws errors on init

## 2.1.2

- No internet connection/invalid URL errors will no longer throw, but the relay's `onRelayClientError` will emit them.
Expand Down
16 changes: 6 additions & 10 deletions lib/apis/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,13 @@ class Core implements ICore {
Future<void> start() async {
await storage.init();
await crypto.init();
await relayClient.init();

try {
await relayClient.init();
} catch (e) {
// If the relay URL is the default, try both it and the backup (.org)
if (_relayUrl == WalletConnectConstants.DEFAULT_RELAY_URL) {
_relayUrl = WalletConnectConstants.FALLBACK_RELAY_URL;
try {
await relayClient.init();
} catch (_) {}
}
// If it didn't connect, and the relayUrl is the default, try the fallback
if (!relayClient.isConnected &&
_relayUrl == WalletConnectConstants.DEFAULT_RELAY_URL) {
_relayUrl = WalletConnectConstants.FALLBACK_RELAY_URL;
relayClient.connect();
}

await expirer.init();
Expand Down
1 change: 0 additions & 1 deletion lib/apis/core/relay_client/relay_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ class RelayClient implements IRelayClient {
e,
),
);
rethrow;
}
_connecting = false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/apis/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class WalletConnectConstants {
static const SDK_VERSION = '2.1.2';
static const SDK_VERSION = '2.1.3';

static const CORE_PROTOCOL = 'wc';
static const CORE_VERSION = 2;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: walletconnect_flutter_v2
description: WalletConnect v2 client made in dart for flutter.
version: 2.1.2
version: 2.1.3
repository: https://github.com/WalletConnect/WalletConnectFlutterV2

environment:
Expand Down
9 changes: 4 additions & 5 deletions test/core_api/relay_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ void main() {
});
await core.storage.init();
await core.crypto.init();
try {
await core.relayClient.init();
} on WalletConnectError catch (e) {
expect(e.message, 'No internet connection: test');
}
await core.relayClient.init();
// try {} on WalletConnectError catch (e) {
// expect(e.message, 'No internet connection: test');
// }

verify(mockWebSocketHandler.setup(
url: argThat(
Expand Down

0 comments on commit 3b27b06

Please sign in to comment.