encodeExtrinsics method

RawBlockExtrinsics encodeExtrinsics(
  1. DecodedBlockExtrinsics decodedBlockExtrinsics
)

Implementation

RawBlockExtrinsics encodeExtrinsics(
    DecodedBlockExtrinsics decodedBlockExtrinsics) {
  final blockNumber = decodedBlockExtrinsics.blockNumber;

  final VersionDescription? versionDescription =
      getVersionDescription(blockNumber);

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

  final List<String> encodedExtrinsicsHex =
      decodedBlockExtrinsics.extrinsics.map((extrinsic) {
    final output = HexOutput();
    ExtrinsicsCodec(chainInfo: versionDescription.chainInfo)
        .encodeTo(extrinsic, output);
    return output.toString();
  }).toList(growable: false);

  return RawBlockExtrinsics(
      blockNumber: blockNumber, extrinsics: encodedExtrinsicsHex);
}