WalletConnectSession.fromUri constructor
WalletConnectSession.fromUri({})
Implementation
factory WalletConnectSession.fromUri({
required String uri,
required String clientId,
required PeerMeta clientMeta,
List<String>? accounts,
}) {
final protocolSeparator = uri.indexOf(':');
final topicSeparator = uri.indexOf('@', protocolSeparator);
final versionSeparator = uri.indexOf('?');
final protocol = uri.substring(0, protocolSeparator);
final handshakeTopic = uri.substring(protocolSeparator + 1, topicSeparator);
final version = uri.substring(topicSeparator + 1, versionSeparator);
final params = Uri.dataFromString(uri).queryParameters;
final bridge = params['bridge'] ??
(throw WalletConnectException('Missing bridge param in URI'));
final key = params['key'] ??
(throw WalletConnectException('Missing key param in URI'));
return WalletConnectSession(
protocol: protocol,
version: int.tryParse(version) ?? 1,
handshakeTopic: handshakeTopic,
bridge: Uri.decodeFull(bridge),
key: Uint8List.fromList(hex.decode(key)),
accounts: accounts ?? [],
clientId: clientId,
clientMeta: clientMeta,
);
}