submitAndWatchExtrinsic method
Future<StreamSubscription<ExtrinsicStatus> >
submitAndWatchExtrinsic(
- Uint8List extrinsic,
- dynamic onData()
Submits and subscribe to watch an extrinsic until unsubscribed.
Implementation
Future<StreamSubscription<ExtrinsicStatus>> submitAndWatchExtrinsic(
Uint8List extrinsic, Function(ExtrinsicStatus) onData) async {
final List<dynamic> params = ['0x${hex.encode(extrinsic)}'];
final subscription = await _provider
.subscribe('author_submitAndWatchExtrinsic', params,
onCancel: (subscription) async {
await _provider.send(
'author_unwatchExtrinsic',
[subscription],
);
});
return subscription.stream.map((response) {
return ExtrinsicStatus.fromJson(response.result);
}).listen(onData);
}