WalletConnect V2 for Flutter
This lib came from the demand of our project Avacus
We used to try to make in pure Dart but it cost much time to build and test so we decide to make an wrapper to consume SDKs from WalletConnect team!
We make very detail in example so you can follow it.
Import and create instance
import 'package:wallet_connect_v2/wallet_connect_v2.dart';
final _client = WalletConnectV2();
Initiate WalletConnect SDK
_client.init(projectId: projectId, appMetadata: walletMetadata);
Listen needed events from our export
typedef OnConnectionStatus = Function(bool isConnected);
typedef OnSessionProposal = Function(SessionProposal proposal);
typedef OnSessionSettle = Function(Session session);
typedef OnSessionUpdate = Function(String topic);
typedef OnSessionDelete = Function(String topic);
typedef OnSessionRequest = Function(SessionRequest request);
typedef OnEventError = Function(String code, String message);
// example of listen to session proposal
_client.onSessionProposal = (proposal) {
// do approve and reject session here
}
Connect to listen event
_client.connect();
Disconnect
_client.disconnect();
Pair with DApps
_client.pair(uri: uri);
Approve session
_client.approveSession(approval: approval);
Reject session
_client.rejectSession(proposalId: proposal.id);
Disconnect session
_client.disconnectSession(topic: topic);
Update session
_client.updateSession(approval: updateApproval);
Approve request
_client.approveRequest(topic: topic, requestId: requestId, result: result);
Reject request
_client.rejectRequest(topic: topic, requestId: requestId);