decodeExtrinsics method

DecodedBlockExtrinsics decodeExtrinsics(
  1. RawBlockExtrinsics rawBlockExtrinsics
)

Implementation

DecodedBlockExtrinsics decodeExtrinsics(
    RawBlockExtrinsics rawBlockExtrinsics) {
  final blockNumber = rawBlockExtrinsics.blockNumber;

  final VersionDescription? versionDescription =
      getVersionDescription(blockNumber);

  // Check if this is not empty, throw Exception if it is.
  if (versionDescription == null) {
    throw BlockNotFoundException(blockNumber);
  }
  assertion(blockNumber >= versionDescription.blockNumber);

  final List<Map<String, dynamic>> extrinsics = <Map<String, dynamic>>[];

  for (var extrinsic in rawBlockExtrinsics.extrinsics) {
    final extrinsicInput = Input.fromHex(extrinsic);
    final value = ExtrinsicsCodec(chainInfo: versionDescription.chainInfo)
        .decode(extrinsicInput);

    // Check if the extrinsic is fully consumed
    extrinsicInput.assertEndOfDataReached(' At block: $blockNumber');
    extrinsics.add(value);
  }

  return DecodedBlockExtrinsics(
      blockNumber: blockNumber, extrinsics: extrinsics);
}