subscribeStorage method
Future<StreamSubscription<StorageChangeSet> >
subscribeStorage()
Subscribes to storage changes for the provided keys
Implementation
Future<StreamSubscription<StorageChangeSet>> subscribeStorage(
List<Uint8List> storageKeys, Function(StorageChangeSet) onData) async {
final hexKeys = storageKeys.map((key) => '0x${hex.encode(key)}').toList();
final subscription = await _provider.subscribe(
'state_subscribeStorage', [hexKeys], onCancel: (subscription) async {
await _provider.send('state_unsubscribeStorage', [subscription]);
});
return subscription.stream
.map((response) => StorageChangeSet.fromJson(response.result))
.listen(onData);
}