submitAndWatchExtrinsic method

Future<StreamSubscription<ExtrinsicStatus>> submitAndWatchExtrinsic(
  1. Uint8List extrinsic,
  2. dynamic onData(
    1. ExtrinsicStatus
    )
)

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);
}