Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onSessionUpdate call function created #39

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/wc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:wallet_connect/wc_session_store.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

typedef SessionRequest = void Function(int id, WCPeerMeta peerMeta);
typedef SessionUpdate = void Function(int id, int chainId);
typedef SocketError = void Function(dynamic message);
typedef SocketClose = void Function(int? code, String? reason);
typedef EthSign = void Function(int id, WCEthereumSignMessage message);
Expand All @@ -47,6 +48,7 @@ class WCClient {

WCClient({
this.onSessionRequest,
this.onSessionUpdate,
this.onFailure,
this.onDisconnect,
this.onEthSign,
Expand All @@ -57,6 +59,7 @@ class WCClient {
});

final SessionRequest? onSessionRequest;
final SessionUpdate? onSessionUpdate;
final SocketError? onFailure;
final SocketClose? onDisconnect;
final EthSign? onEthSign;
Expand Down Expand Up @@ -315,6 +318,7 @@ class WCClient {
case WCMethod.SESSION_UPDATE:
final param = WCSessionUpdate.fromJson(request.params!.first);
print('SESSION_UPDATE $param');
onSessionUpdate?.call(request.id, param.chainId!);
if (!param.approved) {
killSession();
}
Expand Down