diff --git a/example/dapp/pubspec.lock b/example/dapp/pubspec.lock index 03759f0..0bc4b4b 100644 --- a/example/dapp/pubspec.lock +++ b/example/dapp/pubspec.lock @@ -126,7 +126,7 @@ packages: name: cryptography url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.5" dio: dependency: transitive description: @@ -406,7 +406,7 @@ packages: path: "../.." relative: true source: path - version: "0.0.6" + version: "0.0.11" watcher: dependency: transitive description: diff --git a/example/mobile/pubspec.lock b/example/mobile/pubspec.lock index 1e680d8..c4374bc 100644 --- a/example/mobile/pubspec.lock +++ b/example/mobile/pubspec.lock @@ -140,7 +140,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -196,7 +196,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" file: dependency: transitive description: @@ -253,7 +253,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -288,7 +288,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -316,7 +316,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" plugin_platform_interface: dependency: transitive description: @@ -370,7 +370,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -412,7 +412,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -475,14 +475,14 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" walletconnect_dart: dependency: "direct main" description: path: "../.." relative: true source: path - version: "0.0.7" + version: "0.0.11" watcher: dependency: transitive description: @@ -512,5 +512,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.5.0" diff --git a/example/wallet/pubspec.lock b/example/wallet/pubspec.lock index faaa688..85d830d 100644 --- a/example/wallet/pubspec.lock +++ b/example/wallet/pubspec.lock @@ -406,7 +406,7 @@ packages: path: "../.." relative: true source: path - version: "0.0.7" + version: "0.0.11" watcher: dependency: transitive description: diff --git a/lib/src/walletconnect.dart b/lib/src/walletconnect.dart index 4edbebf..36fac9a 100644 --- a/lib/src/walletconnect.dart +++ b/lib/src/walletconnect.dart @@ -148,15 +148,11 @@ class WalletConnect { /// https://docs.walletconnect.com/client-api#register-event-subscription /// Supported events: connect, disconnect, session_request, session_update void on(String eventName, OnEvent callback) { - _eventBus - .on>() - .where((event) => event.name == eventName) - .listen((event) => callback(event.data)); + _eventBus.on>().where((event) => event.name == eventName).listen((event) => callback(event.data)); } /// Creates a new session calling [createSession] if it doesnt exists, or returns the instantiated one. - Future connect( - {int? chainId, OnDisplayUriCallback? onDisplayUri}) async { + Future connect({int? chainId, OnDisplayUriCallback? onDisplayUri}) async { if (connected) { onDisplayUri?.call(session.toUri()); return SessionStatus( @@ -244,6 +240,8 @@ class WalletConnect { await _sendResponse(response); session.connected = true; + session.chainId = chainId; + session.accounts = accounts; // Notify listeners _eventBus.fire(Event( @@ -378,20 +376,16 @@ class WalletConnect { Future killSession({String? sessionError}) async { final message = sessionError ?? 'Session disconnected'; - final request = JsonRpcRequest( - id: payloadId, - method: 'wc_sessionUpdate', - params: [ - { - 'approved': false, - 'chainId': null, - 'networkId': null, - 'accounts': null, - } - ], + final request = JsonRpcResponse( + id: session.handshakeId, + result: { + 'approved': false, + 'chainId': null, + 'networkId': null, + 'accounts': null, + }, ); - - unawaited(_sendRequest(request)); + await _sendResponse(request); await _handleSessionDisconnect(errorMessage: message, forceClose: true); } @@ -436,8 +430,7 @@ class WalletConnect { OnDisconnect? onDisconnect, }) { on('connect', (data) => onConnect?.call(data)); - on( - 'session_update', (data) => onSessionUpdate?.call(data)); + on('session_update', (data) => onSessionUpdate?.call(data)); on('disconnect', (data) => onDisconnect?.call()); }